org.openide.loaders
Class DataShadow

java.lang.Object
  |
  +--org.openide.loaders.DataObject
        |
        +--org.openide.loaders.DataShadow
All Implemented Interfaces:
Node.Cookie, Serializable

public class DataShadow
extends DataObject

Default implementation of a shortcut to another data object.

See Also:
Serialized Form

Inner Class Summary
protected static class DataShadow.ShadowNode
          Node for a shadow object.
 
Inner classes inherited from class org.openide.loaders.DataObject
DataObject.Registry
 
Fields inherited from class org.openide.loaders.DataObject
PROP_COOKIE, PROP_FILES, PROP_HELP, PROP_MODIFIED, PROP_NAME, PROP_PRIMARY_FILE, PROP_TEMPLATE, PROP_VALID
 
Constructor Summary
protected DataShadow(FileObject fo, DataObject original, DataLoader loader)
          Constructs new data shadow for given primary file and referenced original.
 
Method Summary
static DataShadow create(DataFolder folder, DataObject original)
          Method that creates new data shadow in a folder.
static DataShadow create(DataFolder folder, String name, DataObject original)
          Method that creates new data shadow in a folder.
static DataShadow create(DataFolder folder, String name, DataObject original, String ext)
          Method that creates new data shadow in a folder.
protected  Node createNodeDelegate()
          Provides node that should represent this data object.
protected static DataObject deserialize(FileObject fileObject)
          Loads proper dataShadow from the file fileObject.
 Node.Cookie getCookie(Class c)
          Obtain a cookie from the data object.
 HelpCtx getHelpCtx()
          Get help context for this object.
 DataObject getOriginal()
          Return the original shadowed object.
protected  DataObject handleCopy(DataFolder f)
          Copy this object to a folder (implemented by subclasses).
protected  DataObject handleCreateFromTemplate(DataFolder f, 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  void handleDelete()
          Delete this object (implemented by subclasses).
protected  FileObject handleMove(DataFolder f)
          Move this object to another folder (implemented in subclasses).
protected  FileObject handleRename(String name)
          Rename this object (implemented in subclasses).
 boolean isCopyAllowed()
          Test whether the object may be copied.
 boolean isDeleteAllowed()
          Test whether the object may be deleted.
 boolean isMoveAllowed()
          Test whether the object may be moved.
 boolean isRenameAllowed()
          Test whether the object may be renamed.
 void refresh()
           
 
Methods inherited from class org.openide.loaders.DataObject
addPropertyChangeListener, addVetoableChangeListener, copy, createFromTemplate, createFromTemplate, createShadow, delete, dispose, files, find, firePropertyChange, fireVetoableChange, getFolder, getLoader, getName, getNodeDelegate, getPrimaryFile, getRegistry, isModified, isShadowAllowed, isTemplate, isValid, markFiles, move, removePropertyChangeListener, removeVetoableChangeListener, rename, setModified, setTemplate, setValid, takePrimaryFileLock, toString, writeReplace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataShadow

protected DataShadow(FileObject fo,
                     DataObject original,
                     DataLoader loader)
              throws DataObjectExistsException
Constructs new data shadow for given primary file and referenced original. Method to allow subclasses of data shadow.
Parameters:
fo - the primary file
original - original data object
loader - the loader that created the object
Method Detail

create

public static DataShadow create(DataFolder folder,
                                DataObject original)
                         throws IOException
Method that creates new data shadow in a folder. The name chosen is based on the name of the original object.
Parameters:
folder - target folder to create data in
original - orignal object that should be represented by the shadow

create

public static DataShadow create(DataFolder folder,
                                String name,
                                DataObject original)
                         throws IOException
Method that creates new data shadow in a folder. The default extension is used.
Parameters:
folder - target folder to create data in
name - name to give to the shadow
original - object that should be represented by the shadow

create

public static DataShadow create(DataFolder folder,
                                String name,
                                DataObject original,
                                String ext)
                         throws IOException
Method that creates new data shadow in a folder. All modifications are done atomicly using FileSystem.runAtomicAction(org.openide.filesystems.FileSystem.AtomicAction).
Parameters:
folder - target folder to create data in
name - name to give to the shadow
original - orignal object that should be represented by the shadow

deserialize

protected static DataObject deserialize(FileObject fileObject)
                                 throws IOException
Loads proper dataShadow from the file fileObject.
Parameters:
FileObject - fileObject The file to deserialize shadow from.
DataLoader - loader
Returns:
the original DataObject referenced by the shadow
Throws:
IOException - error during load

getOriginal

public DataObject getOriginal()
Return the original shadowed object.
Returns:
the data object

createNodeDelegate

protected Node createNodeDelegate()
Description copied from class: DataObject
Provides node that should represent this data object.

The default implementation creates an instance of DataNode.

This method is called only once per data object.

Overrides:
createNodeDelegate in class DataObject
Following copied from class: org.openide.loaders.DataObject
Returns:
the node delegate (without parent) for this data object

isDeleteAllowed

public boolean isDeleteAllowed()
Description copied from class: DataObject
Test whether the object may be deleted.
Overrides:
isDeleteAllowed in class DataObject
Following copied from class: org.openide.loaders.DataObject
Returns:
true if it may

isCopyAllowed

public boolean isCopyAllowed()
Description copied from class: DataObject
Test whether the object may be copied.
Overrides:
isCopyAllowed in class DataObject
Following copied from class: org.openide.loaders.DataObject
Returns:
true if it may

isMoveAllowed

public boolean isMoveAllowed()
Description copied from class: DataObject
Test whether the object may be moved.
Overrides:
isMoveAllowed in class DataObject
Following copied from class: org.openide.loaders.DataObject
Returns:
true if it may

isRenameAllowed

public boolean isRenameAllowed()
Description copied from class: DataObject
Test whether the object may be renamed.
Overrides:
isRenameAllowed in class DataObject
Following copied from class: org.openide.loaders.DataObject
Returns:
true if it may

getHelpCtx

public HelpCtx getHelpCtx()
Description copied from class: DataObject
Get help context for this object.
Overrides:
getHelpCtx in class DataObject
Following copied from class: org.openide.loaders.DataObject
Returns:
the help context

handleCopy

protected DataObject handleCopy(DataFolder f)
                         throws IOException
Description copied from class: DataObject
Copy this object to a folder (implemented by subclasses).
Overrides:
handleCopy in class DataObject
Following copied from class: org.openide.loaders.DataObject
Parameters:
f - target folder
Returns:
the new data object
Throws:
IOException - if an error occures

handleDelete

protected void handleDelete()
                     throws IOException
Description copied from class: DataObject
Delete this object (implemented by subclasses).
Overrides:
handleDelete in class DataObject
Following copied from class: org.openide.loaders.DataObject
Throws:
IOException - if an error occures

handleRename

protected FileObject handleRename(String name)
                           throws IOException
Description copied from class: DataObject
Rename this object (implemented in subclasses).
Overrides:
handleRename in class DataObject
Following copied from class: org.openide.loaders.DataObject
Parameters:
name - name to rename the object to
Returns:
new primary file of the object
Throws:
IOException - if an error occures

handleMove

protected FileObject handleMove(DataFolder f)
                         throws IOException
Description copied from class: DataObject
Move this object to another folder (implemented in subclasses).
Overrides:
handleMove in class DataObject
Following copied from class: org.openide.loaders.DataObject
Parameters:
df - target data folder
Returns:
new primary file of the object
Throws:
IOException - if an error occures

handleCreateShadow

protected DataShadow handleCreateShadow(DataFolder f)
                                 throws IOException
Description copied from class: DataObject
Creates shadow for this object in specified folder (overridable in subclasses).

The default implementation creates a reference data shadow and pastes it into the specified folder.

Overrides:
handleCreateShadow in class DataObject
Following copied from class: org.openide.loaders.DataObject
Parameters:
f - the folder to create a shortcut in
Returns:
the shadow

handleCreateFromTemplate

protected DataObject handleCreateFromTemplate(DataFolder f,
                                              String name)
                                       throws IOException
Description copied from class: DataObject
Create a new data object from template (implemented in subclasses). This method should copy the content of the template to the destination folder and assign a new name to the new object.
Overrides:
handleCreateFromTemplate in class DataObject
Following copied from class: org.openide.loaders.DataObject
Parameters:
df - data folder to create object in
name - name to give to the new object (or null if the name should be chosen according to the template)
Returns:
the new data object
Throws:
IOException - if an error occured

getCookie

public Node.Cookie getCookie(Class c)
Description copied from class: DataObject
Obtain a cookie from the data object. May be overridden by subclasses to extend the behaviour of data objects.

The default implementation tests if this object is of the requested class and if so, returns it.

Overrides:
getCookie in class DataObject
Following copied from class: org.openide.loaders.DataObject
Parameters:
c - class of requested cookie
Returns:
a cookie or null if such cookies are not supported

refresh

public void refresh()


Built on February 22 2001.  |  Portions Copyright 1997-2000 Sun Microsystems, Inc. All rights reserved.