Class DataShadow
java.lang.Object
org.openide.loaders.DataObject
org.openide.loaders.MultiDataObject
org.openide.loaders.DataShadow
- All Implemented Interfaces:
Serializable
,DataObject.Container
,org.openide.nodes.Node.Cookie
,org.openide.util.HelpCtx.Provider
,org.openide.util.Lookup.Provider
Default implementation of a shortcut to another data object.
Since 1.13 it extends MultiDataObject.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Node for a shadow object.Nested classes/interfaces inherited from class org.openide.loaders.MultiDataObject
MultiDataObject.Entry
Nested classes/interfaces inherited from class org.openide.loaders.DataObject
DataObject.Container, DataObject.Factory, DataObject.Registration, DataObject.Registrations, DataObject.Registry
-
Field Summary
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
Fields inherited from interface org.openide.loaders.DataObject.Container
PROP_CHILDREN
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DataShadow
(org.openide.filesystems.FileObject fo, DataObject original, DataLoader loader) Deprecated.Since 1.13 do not use this constructor, it is for backward compatibility onlyprotected
DataShadow
(org.openide.filesystems.FileObject fo, DataObject original, MultiFileLoader loader) Constructs new data shadow for given primary file and referenced original. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static DataShadow
create
(DataFolder folder, DataObject original) Method that creates new data shadow in a folder.protected org.openide.nodes.Node
Provides node that should represent this data object.protected static DataObject
deserialize
(org.openide.filesystems.FileObject fileObject) Tries to load the original file from a shadow.static org.openide.filesystems.FileObject
findOriginal
(org.openide.filesystems.FileObject fileObject) Tries to locate the original file from a shadow.Implementation of Container interface.<T extends org.openide.nodes.Node.Cookie>
TLook for a cookie in the current cookie set matching the requested class.org.openide.util.HelpCtx
Get help context for this object.org.openide.util.Lookup
Represents a context of the data object.Return the original shadowed object.protected DataObject
Copies primary and secondary files to new folder.protected DataShadow
Creates shadow for this object in specified folder (overridable in subclasses).protected org.openide.filesystems.FileObject
Moves primary and secondary files to a new folder.boolean
Test whether the object may be copied.boolean
Test whether the object may be deleted.boolean
Test whether the object may be moved.boolean
Test whether the object may be renamed.void
refresh()
Methods inherited from class org.openide.loaders.MultiDataObject
addSecondaryEntry, associateLookup, files, findSecondaryEntry, getCookieSet, getMultiFileLoader, getPrimaryEntry, handleCopyRename, handleCreateFromTemplate, handleDelete, handleRename, registerEditor, registerEntry, removeSecondaryEntry, secondaryEntries, setCookieSet, takePrimaryFileLock
Methods inherited from class org.openide.loaders.DataObject
addPropertyChangeListener, addVetoableChangeListener, copy, createFromTemplate, createFromTemplate, createFromTemplate, createShadow, delete, dispose, find, firePropertyChange, fireVetoableChange, getCookie, getFolder, getLoader, getName, getNodeDelegate, getPrimaryFile, getRegistry, isModified, isShadowAllowed, isTemplate, isValid, markFiles, move, removePropertyChangeListener, removeVetoableChangeListener, rename, setModified, setTemplate, setValid, toString, writeReplace
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.openide.loaders.DataObject.Container
addPropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
DataShadow
protected DataShadow(org.openide.filesystems.FileObject fo, DataObject original, MultiFileLoader 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 fileoriginal
- original data objectloader
- the loader that created the object- Throws:
DataObjectExistsException
-
DataShadow
@Deprecated protected DataShadow(org.openide.filesystems.FileObject fo, DataObject original, DataLoader loader) throws DataObjectExistsException Deprecated.Since 1.13 do not use this constructor, it is for backward compatibility onlyConstructs new data shadow for given primary file and referenced original. Method to allow subclasses of data shadow.- Parameters:
fo
- the primary fileoriginal
- original data objectloader
- the loader that created the object- Throws:
DataObjectExistsException
-
-
Method Details
-
create
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 inoriginal
- original object that should be represented by the shadow- Throws:
IOException
-
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 inname
- name to give to the shadoworiginal
- object that should be represented by the shadow- Throws:
IOException
-
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 atomically usingFileSystem.runAtomicAction(org.openide.filesystems.FileSystem.AtomicAction)
.- Parameters:
folder
- target folder to create data inname
- name to give to the shadoworiginal
- original object that should be represented by the shadow- Throws:
IOException
-
findOriginal
public static org.openide.filesystems.FileObject findOriginal(org.openide.filesystems.FileObject fileObject) throws IOException Tries to locate the original file from a shadow. Looks for file contents as well as the originalFile/originalFileSystem attributes. Attempts to discover locations for migrated files in configuration. Returnsnull
, if the target file could not be found (broken link)- Parameters:
fileObject
- a data shadow- Returns:
- the original
FileObject
referenced by the shadow - Throws:
IOException
- error during load- Since:
- 7.42
- See Also:
-
deserialize
protected static DataObject deserialize(org.openide.filesystems.FileObject fileObject) throws IOException Tries to load the original file from a shadow. Looks for file contents as well as the originalFile/originalFileSystem attributes. Attempts to discover locations for migrated files in configuration.- Parameters:
fileObject
- a data shadow- Returns:
- the original
DataObject
referenced by the shadow - Throws:
IOException
- error during load or broken link- See Also:
-
getOriginal
-
getChildren
Implementation of Container interface.- Specified by:
getChildren
in interfaceDataObject.Container
- Returns:
- array of one element, the original
-
createNodeDelegate
protected org.openide.nodes.Node createNodeDelegate()Description copied from class:MultiDataObject
Provides node that should represent this data object.- Overrides:
createNodeDelegate
in classMultiDataObject
- Returns:
- the node representation
- See Also:
-
isDeleteAllowed
public boolean isDeleteAllowed()Description copied from class:DataObject
Test whether the object may be deleted.- Overrides:
isDeleteAllowed
in classMultiDataObject
- Returns:
true
if it may
-
isCopyAllowed
public boolean isCopyAllowed()Description copied from class:DataObject
Test whether the object may be copied.- Overrides:
isCopyAllowed
in classMultiDataObject
- Returns:
true
if it may
-
isMoveAllowed
public boolean isMoveAllowed()Description copied from class:DataObject
Test whether the object may be moved.- Overrides:
isMoveAllowed
in classMultiDataObject
- Returns:
true
if it may
-
isRenameAllowed
public boolean isRenameAllowed()Description copied from class:DataObject
Test whether the object may be renamed.- Overrides:
isRenameAllowed
in classMultiDataObject
- Returns:
true
if it may
-
getHelpCtx
public org.openide.util.HelpCtx getHelpCtx()Description copied from class:DataObject
Get help context for this object.- Specified by:
getHelpCtx
in interfaceorg.openide.util.HelpCtx.Provider
- Overrides:
getHelpCtx
in classMultiDataObject
- Returns:
- the help context
-
handleCreateShadow
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 classDataObject
- Parameters:
f
- the folder to create a shortcut in- Returns:
- the shadow
- Throws:
IOException
-
getCookie
Description copied from class:MultiDataObject
Look for a cookie in the current cookie set matching the requested class.- Overrides:
getCookie
in classMultiDataObject
- Parameters:
c
- the class to look for- Returns:
- an instance of that class, or
null
if this class of cookie is not supported
-
getLookup
public org.openide.util.Lookup getLookup()Description copied from class:DataObject
Represents a context of the data object. This method is a more general replacement forDataObject.getCookie(java.lang.Class<T>)
and should preferably be used instead of the old method. The default implementation inside a data object returns thegetNodeDelegate().getLookup()
- which is the most compatible behaviour with previous versions. However this code has significant potential to deadlocks. That is why the preferred advice is to override the method to:class MyDataObject extends
MultiDataObject
{ public @Override Lookup getLookup() { return getCookieSet().getLookup(); } }Warning: the
DataObject.getCookie(java.lang.Class<T>)
method andDataObject.getLookup()
method are ment to be interchangable - e.g. if you override one of them be sure to override also the other and try as much as possible to keep the same content in each of them. The default implementation tries to do that as much as possible.- Specified by:
getLookup
in interfaceorg.openide.util.Lookup.Provider
- Overrides:
getLookup
in classMultiDataObject
- Returns:
- lookup representing this data object and its content
-
refresh
public void refresh() -
handleCopy
Description copied from class:MultiDataObject
Copies primary and secondary files to new folder. May ask for user confirmation before overwriting.- Overrides:
handleCopy
in classMultiDataObject
- Parameters:
f
- the new folder- Returns:
- data object for the new primary
- Throws:
IOException
- if there was a problem copying
-
handleMove
Description copied from class:MultiDataObject
Moves primary and secondary files to a new folder. May ask for user confirmation before overwriting.- Overrides:
handleMove
in classMultiDataObject
- Parameters:
f
- the new folder- Returns:
- the moved primary file object
- Throws:
IOException
- if there was a problem moving
-