public class DataShadow extends MultiDataObject implements DataObject.Container
Modifier and Type | Class and Description |
---|---|
protected static class |
DataShadow.ShadowNode
Node for a shadow object.
|
MultiDataObject.Entry
DataObject.Container, DataObject.Factory, DataObject.Registration, DataObject.Registrations, DataObject.Registry
PROP_COOKIE, PROP_FILES, PROP_HELP, PROP_MODIFIED, PROP_NAME, PROP_PRIMARY_FILE, PROP_TEMPLATE, PROP_VALID
PROP_CHILDREN
Modifier | Constructor and Description |
---|---|
protected |
DataShadow(FileObject fo,
DataObject original,
DataLoader loader)
Deprecated.
Since 1.13 do not use this constructor, it is for backward compatibility only
|
protected |
DataShadow(FileObject fo,
DataObject original,
MultiFileLoader loader)
Constructs new data shadow for given primary file and referenced original.
|
Modifier and Type | Method and Description |
---|---|
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)
Tries to load the original file from a shadow.
|
static FileObject |
findOriginal(FileObject fileObject)
Tries to locate the original file from a shadow.
|
DataObject[] |
getChildren()
Implementation of Container interface.
|
<T extends Node.Cookie> |
getCookie(Class<T> c)
Look for a cookie in the current cookie set matching the requested class.
|
HelpCtx |
getHelpCtx()
Get help context for this object.
|
Lookup |
getLookup()
Represents a context of the data object.
|
DataObject |
getOriginal()
Return the original shadowed object.
|
protected DataObject |
handleCopy(DataFolder f)
Copies primary and secondary files to new folder.
|
protected DataShadow |
handleCreateShadow(DataFolder f)
Creates shadow for this object in specified folder (overridable in subclasses).
|
protected FileObject |
handleMove(DataFolder f)
Moves primary and secondary files to a new folder.
|
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() |
addSecondaryEntry, associateLookup, files, findSecondaryEntry, getCookieSet, getMultiFileLoader, getPrimaryEntry, handleCopyRename, handleCreateFromTemplate, handleDelete, handleRename, registerEditor, registerEntry, removeSecondaryEntry, secondaryEntries, setCookieSet, takePrimaryFileLock
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, removePropertyChangeListener
protected DataShadow(FileObject fo, DataObject original, MultiFileLoader loader) throws DataObjectExistsException
fo
- the primary fileoriginal
- original data objectloader
- the loader that created the objectDataObjectExistsException
@Deprecated protected DataShadow(FileObject fo, DataObject original, DataLoader loader) throws DataObjectExistsException
fo
- the primary fileoriginal
- original data objectloader
- the loader that created the objectDataObjectExistsException
public static DataShadow create(DataFolder folder, DataObject original) throws IOException
folder
- target folder to create data inoriginal
- original object that should be represented by the shadowIOException
public static DataShadow create(DataFolder folder, String name, DataObject original) throws IOException
folder
- target folder to create data inname
- name to give to the shadoworiginal
- object that should be represented by the shadowIOException
public static DataShadow create(DataFolder folder, String name, DataObject original, String ext) throws IOException
FileSystem.runAtomicAction(org.openide.filesystems.FileSystem.AtomicAction)
.folder
- target folder to create data inname
- name to give to the shadoworiginal
- original object that should be represented by the shadowIOException
public static FileObject findOriginal(FileObject fileObject) throws IOException
null
, if the target file could not be found (broken link)fileObject
- a data shadowFileObject
referenced by the shadowIOException
- error during loadUtilities.translate(java.lang.String)
protected static DataObject deserialize(FileObject fileObject) throws IOException
fileObject
- a data shadowDataObject
referenced by the shadowIOException
- error during load or broken linkUtilities.translate(java.lang.String)
public DataObject getOriginal()
public DataObject[] getChildren()
getChildren
in interface DataObject.Container
protected Node createNodeDelegate()
MultiDataObject
createNodeDelegate
in class MultiDataObject
DataNode
public boolean isDeleteAllowed()
DataObject
isDeleteAllowed
in class MultiDataObject
true
if it maypublic boolean isCopyAllowed()
DataObject
isCopyAllowed
in class MultiDataObject
true
if it maypublic boolean isMoveAllowed()
DataObject
isMoveAllowed
in class MultiDataObject
true
if it maypublic boolean isRenameAllowed()
DataObject
isRenameAllowed
in class MultiDataObject
true
if it maypublic HelpCtx getHelpCtx()
DataObject
getHelpCtx
in interface HelpCtx.Provider
getHelpCtx
in class MultiDataObject
protected DataShadow handleCreateShadow(DataFolder f) throws IOException
DataObject
The default implementation creates a reference data shadow and pastes it into the specified folder.
handleCreateShadow
in class DataObject
f
- the folder to create a shortcut inIOException
public <T extends Node.Cookie> T getCookie(Class<T> c)
MultiDataObject
getCookie
in class MultiDataObject
c
- the class to look fornull
if this class of cookie
is not supportedpublic Lookup getLookup()
DataObject
DataObject.getCookie(java.lang.Class<T>)
and should preferably
be used instead of the old method. The default implementation
inside a data object
returns the getNodeDelegate().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 and DataObject.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.
getLookup
in interface Lookup.Provider
getLookup
in class MultiDataObject
public void refresh()
protected DataObject handleCopy(DataFolder f) throws IOException
MultiDataObject
handleCopy
in class MultiDataObject
f
- the new folderIOException
- if there was a problem copyingUserCancelException
- if the user cancelled the copyprotected FileObject handleMove(DataFolder f) throws IOException
MultiDataObject
handleMove
in class MultiDataObject
f
- the new folderIOException
- if there was a problem movingUserCancelException
- if the user cancelled the move