org.topbraidcomposer.core.io
Class TBCFileRegistry
java.lang.Object
org.topbraid.core.registry.impl.FileRegistry
org.topbraidcomposer.core.io.TBCFileRegistry
- All Implemented Interfaces:
- java.util.EventListener, org.eclipse.core.resources.IResourceChangeListener, IFileRegistry
public class TBCFileRegistry
- extends FileRegistry
- implements org.eclipse.core.resources.IResourceChangeListener
A singleton that monitors the workspace to find local versions
of remote namespaces. This is used to resolve imports, and otherwise
to determine whether a model with a certain URI is represented
by a local file in the workspace.
The main concept is that for each (imported) URI, there can be zero or
more matching local files. The FileRegistry listens to changes in the
Workspace and scans all files that have certain extensions ("owl" etc).
This inspection process loads the first few lines of the file to see
whether they contain a valid XML base declaration. If yes, the file will
be associated with this XML base as its URI.
The key services of this class for end users are getFiles() and
getURI(). These can be used to look up matching files for a
URI and vice versa.
The life cycle of the FileRegistry is controlled by the CorePlugin,
which invokes its init() and dispose() methods.
- Author:
- Holger Knublauch
|
Method Summary |
void |
dispose()
Disposes this FileRegistry. |
org.eclipse.core.resources.IFile |
getPreferredFile(java.net.URI uri)
Gets the first result of getFiles(uri), if one exists. |
protected void |
handleFileAdded(org.eclipse.core.resources.IFile file)
|
protected void |
handleFileChanged(org.eclipse.core.resources.IFile file)
|
protected void |
handleFileDeleted(org.eclipse.core.resources.IFile file)
|
void |
init()
Initializes the FileRegistry. |
boolean |
isReadOnlyFile(java.io.File file)
|
boolean |
isReadOnlyFile(org.eclipse.core.resources.IFile file)
|
void |
makePreferredFile(org.eclipse.core.resources.IFile file)
|
void |
register(org.eclipse.core.resources.IFile file,
java.net.URI uri)
|
void |
resourceChanged(org.eclipse.core.resources.IResourceChangeEvent event)
|
void |
setIgnoreMode(boolean ignore)
|
void |
setReadOnly(org.eclipse.core.resources.IFile file,
boolean value)
|
protected void |
unregister(org.eclipse.core.resources.IFile file)
|
void |
update(org.eclipse.core.resources.IFile file)
|
| Methods inherited from class org.topbraid.core.registry.impl.FileRegistry |
clearImportedURIs, compareFiles, dump, getBaseURI, getDependingFiles, getFiles, getImportedURIs, getImportingFiles, getModelFileExtensions, getSuitableFileName, inspectFile, inspectFileSafe, isModelFile, isModelFileExtension, listFiles, refresh, setBaseURI, setImportedURIs |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
READ_ONLY_PREFERENCE
public static final java.lang.String READ_ONLY_PREFERENCE
- See Also:
- Constant Field Values
TBCFileRegistry
public TBCFileRegistry()
dispose
public void dispose()
- Disposes this FileRegistry. This is called when the plugin is stopping.
getPreferredFile
public org.eclipse.core.resources.IFile getPreferredFile(java.net.URI uri)
- Gets the first result of
getFiles(uri), if one exists.
- Specified by:
getPreferredFile in interface IFileRegistry- Overrides:
getPreferredFile in class FileRegistry
- Parameters:
uri - the URI to get the preferred file for
- Returns:
- the preferred file or null if none could be found
- See Also:
FileRegistry.getFiles(URI)
handleFileAdded
protected void handleFileAdded(org.eclipse.core.resources.IFile file)
handleFileChanged
protected void handleFileChanged(org.eclipse.core.resources.IFile file)
handleFileDeleted
protected void handleFileDeleted(org.eclipse.core.resources.IFile file)
init
public void init()
- Initializes the FileRegistry. This will inspect all files in the
current Workspace. The method will also register this as a listener
on the Workspace to detect changes in files etc.
- Specified by:
init in interface IFileRegistry- Overrides:
init in class FileRegistry
isReadOnlyFile
public boolean isReadOnlyFile(java.io.File file)
isReadOnlyFile
public boolean isReadOnlyFile(org.eclipse.core.resources.IFile file)
makePreferredFile
public void makePreferredFile(org.eclipse.core.resources.IFile file)
register
public void register(org.eclipse.core.resources.IFile file,
java.net.URI uri)
- Specified by:
register in interface IFileRegistry- Overrides:
register in class FileRegistry
resourceChanged
public void resourceChanged(org.eclipse.core.resources.IResourceChangeEvent event)
- Specified by:
resourceChanged in interface org.eclipse.core.resources.IResourceChangeListener
setIgnoreMode
public void setIgnoreMode(boolean ignore)
setReadOnly
public void setReadOnly(org.eclipse.core.resources.IFile file,
boolean value)
unregister
protected void unregister(org.eclipse.core.resources.IFile file)
- Overrides:
unregister in class FileRegistry
update
public void update(org.eclipse.core.resources.IFile file)