|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openide.loaders.DataObject
Object that represents one JavaBean in the tree of beans representing data systems.
Inner Class Summary | |
static interface |
DataObject.Container
Interface for objects that can contain other data objects. |
static class |
DataObject.Registry
Registry of modified data objects. |
Field Summary | |
static String |
PROP_COOKIE
Name of the property used during notification of changes in the set of cookies attached to this object. |
static String |
PROP_FILES
Name of files property. |
static String |
PROP_HELP
Name of the help context property. |
static String |
PROP_MODIFIED
Name of the modified property. |
static String |
PROP_NAME
Name of the name property. |
static String |
PROP_PRIMARY_FILE
Name of primary file property. |
static String |
PROP_TEMPLATE
Name of the template property. |
static String |
PROP_VALID
Name of valid property. |
Constructor Summary | |
DataObject(FileObject pf,
DataLoader loader)
Create new data object. |
Method Summary | |
void |
addPropertyChangeListener(PropertyChangeListener l)
|
void |
addVetoableChangeListener(VetoableChangeListener l)
|
DataObject |
copy(DataFolder f)
Copy this object to a folder. |
DataObject |
createFromTemplate(DataFolder f)
Create a new object from template (with a name depending on the template). |
DataObject |
createFromTemplate(DataFolder f,
String name)
Create a new object from template. |
protected Node |
createNodeDelegate()
Provides node that should represent this data object. |
DataShadow |
createShadow(DataFolder f)
Creates shadow for this object in specified folder. |
void |
delete()
Delete this object. |
protected void |
dispose()
Allows subclasses to discard the object. |
Set |
files()
Get all contained files. |
static DataObject |
find(FileObject fo)
Finds the data object for a specified file object. |
protected void |
firePropertyChange(String name,
Object oldValue,
Object newValue)
Fires property change notification to all listeners registered via addPropertyChangeListener(java.beans.PropertyChangeListener) . |
protected void |
fireVetoableChange(String name,
Object oldValue,
Object newValue)
Fires vetoable change notification. |
Node.Cookie |
getCookie(Class c)
Obtain a cookie from the data object. |
protected Node.Cookie |
getCookie(DataShadow shadow,
Class clazz)
When a request for a cookie is done on a DataShadow of this DataObject this methods gets called (by default) so the DataObject knows which DataShadow is asking and extract some information from the shadow itself. |
DataFolder |
getFolder()
Get the folder this data object is stored in. |
abstract HelpCtx |
getHelpCtx()
Get help context for this object. |
DataLoader |
getLoader()
Get the loader that created this data object. |
String |
getName()
Get the name of the data object. |
Node |
getNodeDelegate()
Get the node delegate. |
FileObject |
getPrimaryFile()
Get the primary file for this data object. |
static DataObject.Registry |
getRegistry()
Get the registry containing all modified objects. |
protected abstract DataObject |
handleCopy(DataFolder f)
Copy this object to a folder (implemented by subclasses). |
protected abstract DataObject |
handleCreateFromTemplate(DataFolder df,
String name)
Create a new data object from template (implemented in subclasses). |
protected DataShadow |
handleCreateShadow(DataFolder f)
Creates shadow for this object in specified folder (overridable in subclasses). |
protected abstract void |
handleDelete()
Delete this object (implemented by subclasses). |
protected abstract FileObject |
handleMove(DataFolder df)
Move this object to another folder (implemented in subclasses). |
protected abstract FileObject |
handleRename(String name)
Rename this object (implemented in subclasses). |
abstract boolean |
isCopyAllowed()
Test whether the object may be copied. |
abstract boolean |
isDeleteAllowed()
Test whether the object may be deleted. |
boolean |
isModified()
Test whether the object is modified. |
abstract boolean |
isMoveAllowed()
Test whether the object may be moved. |
abstract boolean |
isRenameAllowed()
Test whether the object may be renamed. |
boolean |
isShadowAllowed()
Test whether the object may create shadows. |
boolean |
isTemplate()
Get the template status of this data object. |
boolean |
isValid()
Test whether the data object is still valid and usable. |
protected void |
markFiles()
Mark all contained files as belonging to this loader. |
void |
move(DataFolder df)
Move this object to another folder. |
void |
removePropertyChangeListener(PropertyChangeListener l)
|
void |
removeVetoableChangeListener(VetoableChangeListener l)
|
void |
rename(String name)
Rename this object. |
void |
setModified(boolean modif)
Set whether the object is considered modified. |
void |
setTemplate(boolean newTempl)
Set the template status of this data object. |
void |
setValid(boolean valid)
Setter that allows to destroy this data object. |
protected FileLock |
takePrimaryFileLock()
Obtains lock for primary file. |
String |
toString()
|
Object |
writeReplace()
The Serialization replacement for this object stores the primary file instead. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String PROP_TEMPLATE
public static final String PROP_NAME
public static final String PROP_HELP
public static final String PROP_MODIFIED
public static final String PROP_COOKIE
public static final String PROP_VALID
public static final String PROP_PRIMARY_FILE
public static final String PROP_FILES
Constructor Detail |
public DataObject(FileObject pf, DataLoader loader) throws DataObjectExistsException
pf
- primary file object for this data objectloader
- loader that created the data objectDataObjectExistsException
- if there is already a data object
for this primary fileMethod Detail |
protected void dispose()
The normal use of this method is to change the type of a data object. Because this would usually only be invoked from the original data object, it is protected.
public void setValid(boolean valid) throws PropertyVetoException
valid
- should be falsePropertyVetoException
- if the invalidation has been vetoedpublic final boolean isValid()
The object can become invalid when it is deleted, its files are deleted, or
dispose()
is called.
When the validity of the object changes a property change event is fired, so anyone can listen and be notified when the object is deleted/disposed.
public final DataLoader getLoader()
protected final void markFiles() throws IOException
public Set files()
important flag
set appropriately.
The default implementation returns a set consisting only of the primary file.
FileObject
spublic final Node getNodeDelegate()
creates it
(if it does not
already exist) or
returns a previously created instance of it.protected Node createNodeDelegate()
The default implementation creates an instance of DataNode
.
This method is called only once per data object.
It is strongly recommended that the resulting node will, when asked for the cookie DataObject.class, return this same data object.
protected FileLock takePrimaryFileLock() throws IOException
IOException
- if taking the lock failspublic final void setTemplate(boolean newTempl) throws IOException
newTempl
- true
if the object should be a templateIOException
- if setting the template state failspublic final boolean isTemplate()
true
if it is a templatepublic abstract boolean isDeleteAllowed()
true
if it maypublic abstract boolean isCopyAllowed()
true
if it maypublic abstract boolean isMoveAllowed()
true
if it maypublic boolean isShadowAllowed()
The default implementation returns true
.
true
if it maypublic abstract boolean isRenameAllowed()
true
if it maypublic boolean isModified()
true
if it is modifiedpublic void setModified(boolean modif)
true
, the data object is added into a registry
of opened data objects.
If the new value is false
,
the data object is removed from the registry.public abstract HelpCtx getHelpCtx()
public final FileObject getPrimaryFile()
*.java
and *.class
files but the primary one is
always *.java
. Please note that two data objects are equivalent
if
they use the same primary file.
Warning: do not call Node.getHandle()
or DefaultHandle.createHandle(org.openide.nodes.Node)
in this method.
public static DataObject find(FileObject fo) throws DataObjectNotFoundException
fo
- file objectDataObjectNotFoundException
- if the file does not have a
data objectpublic static DataObject.Registry getRegistry()
public String getName()
The default implementation uses the name of the primary file.
public String toString()
toString
in class Object
public final DataFolder getFolder()
null
if the primary file
is the root
of its filesystempublic final DataObject copy(DataFolder f) throws IOException
An event is fired, and atomicity is implemented.
f
- the folder to copy the object toIOException
- if something went wrongprotected abstract DataObject handleCopy(DataFolder f) throws IOException
f
- target folderIOException
- if an error occurespublic final void delete() throws IOException
Events are fired and atomicity is implemented.
IOException
- if an error occuresprotected abstract void handleDelete() throws IOException
IOException
- if an error occurespublic final void rename(String name) throws IOException
Events are fired and atomicity is implemented.
name
- the new nameIOException
- if an error occursprotected abstract FileObject handleRename(String name) throws IOException
name
- name to rename the object toIOException
- if an error occurespublic final void move(DataFolder df) throws IOException
An event is fired and atomicity is implemented.
df
- folder to move object toIOException
- if an error occursprotected abstract FileObject handleMove(DataFolder df) throws IOException
df
- target data folderIOException
- if an error occuresprotected DataShadow handleCreateShadow(DataFolder f) throws IOException
The default implementation creates a reference data shadow and pastes it into the specified folder.
f
- the folder to create a shortcut inpublic final DataShadow createShadow(DataFolder f) throws IOException
An event is fired and atomicity is implemented.
f
- the folder to create shortcut inpublic final DataObject createFromTemplate(DataFolder f) throws IOException
f
- folder to create object inIOException
- if an error occuredcreateFromTemplate(DataFolder,String)
public final DataObject createFromTemplate(DataFolder f, String name) throws IOException
handleCreateFromTemplate(org.openide.loaders.DataFolder, java.lang.String)
.f
- folder to create object inname
- name of object that should be created, or null
if the
name should be same as that of the template (or otherwise mechanically generated)IOException
- if an error occuredprotected abstract DataObject handleCreateFromTemplate(DataFolder df, String name) throws IOException
df
- data folder to create object inname
- name to give to the new object (or null
if the name should be chosen according to the template)IOException
- if an error occuredpublic void addPropertyChangeListener(PropertyChangeListener l)
l
- the listenerpublic void removePropertyChangeListener(PropertyChangeListener l)
l
- the listenerprotected final void firePropertyChange(String name, Object oldValue, Object newValue)
addPropertyChangeListener(java.beans.PropertyChangeListener)
.name
- of propertyoldValue
- old valuenewValue
- new valuepublic void addVetoableChangeListener(VetoableChangeListener l)
l
- the listenerpublic void removeVetoableChangeListener(VetoableChangeListener l)
l
- the listenerprotected final void fireVetoableChange(String name, Object oldValue, Object newValue) throws PropertyVetoException
name
- of propertyoldValue
- old valuenewValue
- new valuePropertyVetoException
- if the change has been vetoedpublic Node.Cookie getCookie(Class c)
The default implementation tests if this object is of the requested class and if so, returns it.
c
- class of requested cookienull
if such cookies are not supportedprotected Node.Cookie getCookie(DataShadow shadow, Class clazz)
Subclasses can override this method with better logic, but the default
implementation just delegates to getCookie (Class)
.
clazz
- class to search forshadow
- the shadow for which is askingnull
public Object writeReplace()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |