|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openide.filesystems.FileSystem
Interface that provides basic information about a virtual filesystem in the IDE. Classes that implement it should follow JavaBean conventions because when a new instance of a file system class is inserted into the system, it should permit the user to modify it with standard Bean properties.
Implementing classes should also have associated subclasses of FileObject
.
Although the class is serializable, only the hidden state
and system name
are serialized, and the deserialized object is by default invalid
(and may be a distinct
object from a valid file system in the Repository). If you wish to safely deserialize a file
system, you should after deserialization try to replace it with a file system of the
same name
in the Repository.
Inner Class Summary | |
static interface |
FileSystem.AtomicAction
An action that it is to be called atomically with respect to file system event notification. |
static class |
FileSystem.Environment
Interface that allows filesystems to set up the Java environment for external execution and compilation. |
static interface |
FileSystem.Status
Allows a filesystem to annotate a group of files (typically comprising a data object) with additional markers. |
Field Summary | |
static String |
PROP_HIDDEN
Property name indicating whether file system is hidden. |
static String |
PROP_READ_ONLY
Property name giving read-only state. |
static String |
PROP_ROOT
Property name giving root folder of file system. |
static String |
PROP_SYSTEM_NAME
Property name giving internal system name of file system. |
static String |
PROP_VALID
Property name indicating validity of file system. |
Constructor Summary | |
FileSystem()
Default constructor. |
Method Summary | |
void |
addFileStatusListener(FileStatusListener listener)
Registers FileStatusListener to receive events. |
void |
addNotify()
Notifies this file system that it has been added to the repository. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Registers PropertyChangeListener to receive events. |
void |
addVetoableChangeListener(VetoableChangeListener listener)
Adds listener for the veto of property change. |
FileObject |
find(String aPackage,
String name,
String ext)
Finds file in the filesystem by name. |
abstract FileObject |
findResource(String name)
Finds file when its resource name is given. |
protected void |
fireFileStatusChanged(FileStatusEvent event)
Notifies all registered listeners about change of status of some files. |
protected void |
firePropertyChange(String name,
Object o,
Object n)
Fires property change event. |
protected void |
fireVetoableChange(String name,
Object o,
Object n)
Fires property vetoable event. |
abstract SystemAction[] |
getActions()
Returns an array of actions that can be invoked on any file in this file system. |
SystemAction[] |
getActions(Set foSet)
|
FileSystemCapability |
getCapability()
The object describing capabilities of this filesystem. |
abstract String |
getDisplayName()
Provides a name for the system that can be presented to the user. |
abstract FileObject |
getRoot()
Getter for root folder in the filesystem. |
FileSystem.Status |
getStatus()
Get a status object that can annotate a set of files by changing the names or icons associated with them. |
String |
getSystemName()
Internal (system) name of the file system. |
boolean |
isDefault()
Returns true if the filesystem is default one of the IDE. |
boolean |
isHidden()
Getter for the hidden property. |
protected boolean |
isPersistent()
Tests whether file system will survive reloading of system pool. |
abstract boolean |
isReadOnly()
Test if the filesystem is read-only or not. |
boolean |
isValid()
Test whether file system is valid. |
void |
prepareEnvironment(FileSystem.Environment env)
Allows filesystems to set up the environment for external execution and compilation. |
void |
removeFileStatusListener(FileStatusListener listener)
Removes FileStatusListener from the list of listeners. |
void |
removeNotify()
Notifies this file system that it has been removed from the repository. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes PropertyChangeListener from the list of listeners. |
void |
removeVetoableChangeListener(VetoableChangeListener listener)
Removes listener for the veto of property change. |
void |
runAtomicAction(FileSystem.AtomicAction run)
Executes atomic action. |
protected void |
setCapability(FileSystemCapability capability)
Allows subclasses to change a set of capabilities of the file system. |
void |
setHidden(boolean hide)
Set hidden state of the object. |
protected void |
setSystemName(String name)
Changes system name of the file system. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String PROP_VALID
public static final String PROP_HIDDEN
public static final String PROP_SYSTEM_NAME
public static final String PROP_ROOT
public static final String PROP_READ_ONLY
Constructor Detail |
public FileSystem()
Method Detail |
public final boolean isValid()
public final void setHidden(boolean hide)
hide
- true
if the file system should be hiddenpublic final boolean isHidden()
protected boolean isPersistent()
Repository
is reloading its content, it preserves this
file system in the pool.
This can be used when the pool contains system level and user level file systems. The system ones should be preserved when the user changes the content (for example when he is loading a new project).
The default implementation returns false
.
public abstract String getDisplayName()
This call should never be used to attempt to identify the file root
of the filesystem. On some systems it may happen to look the same but this is a
coincidence and may well change in the future. Either check whether
you are working with a LocalFileSystem
or similar implementation and use
LocalFileSystem.getRootDirectory()
; or better, try
FileUtil.toFile(org.openide.filesystems.FileObject)
which is designed to do this correctly.
public final String getSystemName()
A change of the system name should be interpreted as a change of the internal state of the file system. For example, if the root directory is moved to different location, one should rebuild representations for all files in the system.
This call should never be used to attempt to identify the file root
of the filesystem. On Unix systems it may happen to look the same but this is a
coincidence and may well change in the future. Either check whether
you are working with a LocalFileSystem
or similar implementation and use
LocalFileSystem.getRootDirectory()
; or better, try
FileUtil.toFile(org.openide.filesystems.FileObject)
which is designed to do this correctly.
protected final void setSystemName(String name) throws PropertyVetoException
Warning: this method is protected so that only subclasses can change the system name.
name
- new system namePropertyVetoException
- if the change is not allowed by a listenerpublic final boolean isDefault()
true
if the filesystem is default one of the IDE.Repository.getDefaultFileSystem()
public abstract boolean isReadOnly()
public abstract FileObject getRoot()
public FileObject find(String aPackage, String name, String ext)
The default implementation converts dots in the package name into slashes,
concatenates the strings, adds any extension prefixed by a dot and calls
the findResource
method.
Note: when both of name
and ext
are null
then name and
extension should be ignored and scan should look only for a package.
aPackage
- package name where each package component is separated by a dotname
- name of the file (without dots) or null
if
one wants to obtain a folder (package) and not a file in itext
- extension of the file (without leading dot) or null
if one needs
a package and not a filenull
if the file does not existpublic abstract FileObject findResource(String name)
ClassLoader.getResource(String)
method. So it may consist of "package1/package2/filename.ext".
If there is no package, it may consist only of "filename.ext".name
- resource namenull
if the file does not existpublic abstract SystemAction[] getActions()
Menu
,
Popup
,
and Toolbar
presenters.public SystemAction[] getActions(Set foSet)
public String toString()
toString
in class Object
public void prepareEnvironment(FileSystem.Environment env) throws EnvironmentNotSupportedException
FileSystem.Environment
interface.
The default implementation throws an exception to signal that it does not support external compilation or execution.
env
- the environment to setupEnvironmentNotSupportedException
- if external execution
and compilation cannot be supportedpublic FileSystem.Status getStatus()
The default implementation returns a status object making no modifications.
public final FileSystemCapability getCapability()
protected final void setCapability(FileSystemCapability capability)
capability
- the capability to usepublic final void runAtomicAction(FileSystem.AtomicAction run) throws IOException
Warning: the action should not take a significant amount of time, and should finish as soon as possible--otherwise all event notifications will be blocked.
Warning: do not be misled by the name of this method; it does not require the filesystem to treat the changes as an atomic block of commits in the database sense! That is, if an exception is thrown in the middle of the action, partial results will not be undone (in general this would be impossible to implement for all filesystems anyway).
run
- the action to runIOException
- if there is an IOException
thrown in the actions' run
methodpublic final void addFileStatusListener(FileStatusListener listener)
listener
- The listener to register.public final void removeFileStatusListener(FileStatusListener listener)
listener
- The listener to remove.protected final void fireFileStatusChanged(FileStatusEvent event)
e
- The event to be firedpublic final void addVetoableChangeListener(VetoableChangeListener listener)
listener
- the listenerpublic final void removeVetoableChangeListener(VetoableChangeListener listener)
listener
- the listenerprotected final void fireVetoableChange(String name, Object o, Object n) throws PropertyVetoException
name
- name of the propertyo
- old value of the propertyn
- new value of the propertyPropertyVetoException
- if an listener vetoed the changepublic final void addPropertyChangeListener(PropertyChangeListener listener)
listener
- The listener to register.public final void removePropertyChangeListener(PropertyChangeListener listener)
listener
- The listener to remove.protected final void firePropertyChange(String name, Object o, Object n)
name
- name of the propertyo
- old value of the propertyn
- new value of the propertypublic void addNotify()
Note that this method is advisory and serves as an optimization to avoid retaining resources for too long etc. Filesystems should maintain correct semantics regardless of whether and when this method is called.
public void removeNotify()
Note that this method is advisory and serves as an optimization to avoid retaining resources for too long etc. Filesystems should maintain correct semantics regardless of whether and when this method is called.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |