public class DataFolder extends MultiDataObject implements DataObject.Container
Has special support for determining the sorting of the folder, or even explicit ordering of the children.
Modifier and Type | Class and Description |
---|---|
class |
DataFolder.FolderNode
Node for a folder.
|
static class |
DataFolder.Index
Support for index cookie for folder nodes.
|
static class |
DataFolder.SortMode
Type-safe enumeration of sort modes for data folders.
|
MultiDataObject.Entry
DataObject.Container, DataObject.Factory, DataObject.Registration, DataObject.Registrations, DataObject.Registry
Modifier and Type | Field and Description |
---|---|
static String |
PROP_CHILDREN
Name of property that holds children of this node.
|
static String |
PROP_ORDER
Name of property for order of children.
|
static String |
PROP_SORT_MODE
Name of property which decides sorting mode.
|
static String |
SET_SORTING
Name of set with sorting options.
|
PROP_COOKIE, PROP_FILES, PROP_HELP, PROP_MODIFIED, PROP_NAME, PROP_PRIMARY_FILE, PROP_TEMPLATE, PROP_VALID
Modifier | Constructor and Description |
---|---|
|
DataFolder(FileObject fo)
Deprecated.
This method should not be used in client code.
If you are searching for a
DataFolder for
a FileObject use DataFolder.findFolder(org.openide.filesystems.FileObject) factory method. |
protected |
DataFolder(FileObject fo,
DataLoader loader)
Deprecated.
Since 1.13 do not use this constructor, it is for backward compatibility only.
|
protected |
DataFolder(FileObject fo,
MultiFileLoader loader)
Create a data folder from a folder file object.
|
Modifier and Type | Method and Description |
---|---|
Enumeration<DataObject> |
children()
Get enumeration of children of this folder.
|
Enumeration<DataObject> |
children(boolean rec)
Enumerate all children of this folder.
|
static DataFolder |
create(DataFolder folder,
String name)
Helper method to find or create a folder of a given path.
|
Children |
createNodeChildren(DataFilter filter)
Support method to obtain a children object that
can be added to any
Node . |
protected Node |
createNodeDelegate()
Create node representative for this folder.
|
static DataObject.Container |
findContainer(FileObject fo)
Finds a DataObject.Container representing given folder.
|
static DataFolder |
findFolder(FileObject fo)
Create a folder for a specified file object.
|
DataObject[] |
getChildren()
Get the children of this folder.
|
HelpCtx |
getHelpCtx()
Get help context for this object.
|
Lookup |
getLookup()
Represents a context of the data object.
|
String |
getName()
Get the name of the data folder.
|
DataFolder.SortMode |
getSortMode()
Get the sort mode of the folder.
|
protected DataObject |
handleCopy(DataFolder f)
Copies primary and secondary files to new folder.
|
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 df)
Moves primary and secondary files to a new folder.
|
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 |
setOrder(DataObject[] arr)
Set the order of the children.
|
void |
setSortMode(DataFolder.SortMode mode)
Set the sort mode for the folder.
|
addSecondaryEntry, associateLookup, files, findSecondaryEntry, getCookie, getCookieSet, getMultiFileLoader, getPrimaryEntry, handleCopyRename, registerEditor, registerEntry, removeSecondaryEntry, secondaryEntries, setCookieSet, takePrimaryFileLock
addPropertyChangeListener, addVetoableChangeListener, copy, createFromTemplate, createFromTemplate, createFromTemplate, createShadow, delete, dispose, find, firePropertyChange, fireVetoableChange, getCookie, getFolder, getLoader, 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
public static final String PROP_CHILDREN
public static final String PROP_SORT_MODE
public static final String PROP_ORDER
public static final String SET_SORTING
@Deprecated public DataFolder(FileObject fo) throws DataObjectExistsException, IllegalArgumentException
DataFolder
for
a FileObject use DataFolder.findFolder(org.openide.filesystems.FileObject)
factory method.fo
- file folder to work onDataObjectExistsException
- if there is one alreadyIllegalArgumentException
- if fo
is not folderprotected DataFolder(FileObject fo, MultiFileLoader loader) throws DataObjectExistsException, IllegalArgumentException
fo
- file folder to work onloader
- data loader for this data objectDataObjectExistsException
- if there is one alreadyIllegalArgumentException
- if fo
is not folder@Deprecated protected DataFolder(FileObject fo, DataLoader loader) throws DataObjectExistsException, IllegalArgumentException
fo
- file folder to work onloader
- data loader for this data objectDataObjectExistsException
- if there is one alreadyIllegalArgumentException
- if fo
is not folderpublic static DataFolder create(DataFolder folder, String name) throws IOException
folder
- the folder to start inname
- a subfolder path (e.g. com/mycom/testfolder
)IOException
- if the I/O failspublic final void setSortMode(DataFolder.SortMode mode) throws IOException
mode
- an constant from DataFolder.SortMode
IOException
- if the mode cannot be setpublic final DataFolder.SortMode getSortMode()
public final void setOrder(DataObject[] arr) throws IOException
DataFolder.getChildren()
. If there are any other children, they
will be appended to the array.arr
- array of data objects (children of this
folder) to define the order; or null
if any particular ordering should
be cancelledIOException
- if the order cannot be setpublic 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 String getName()
This implementation uses the name and extension of the primary file.
getName
in class DataObject
public DataObject[] getChildren()
getChildren
in interface DataObject.Container
public Enumeration<DataObject> children()
DataObject
spublic Enumeration<DataObject> children(boolean rec)
rec
- whether to enumerate recursivelyDataObject
protected Node createNodeDelegate()
createNodeDelegate
in class MultiDataObject
DataNode
public Children createNodeChildren(DataFilter filter)
Node
. The provided filter can be
used to exclude some objects from the list.
Overriding this method is deprecated!
filter
- filter of data objectspublic 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
public static DataFolder findFolder(FileObject fo)
fo
- file objectIllegalArgumentException
- if the file object is not folder
or if its responsible loader prevents the data object from being
instantiated - e.g. DataObject.find(org.openide.filesystems.FileObject)
throws DataObjectNotFoundException
public static DataObject.Container findContainer(FileObject fo)
fo
- file object (must be folder)IllegalArgumentException
- if the file object is not folderprotected 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 void handleDelete() throws IOException
DataObject
handleDelete
in class MultiDataObject
IOException
- if an error occuresprotected FileObject handleRename(String name) throws IOException
DataObject
handleRename
in class MultiDataObject
name
- name to rename the object toIOException
- if an error occuresprotected FileObject handleMove(DataFolder df) throws IOException
MultiDataObject
handleMove
in class MultiDataObject
df
- the new folderIOException
- if there was a problem movingUserCancelException
- if the user cancelled the moveprotected DataObject handleCreateFromTemplate(DataFolder f, String name) throws IOException
DataObject
handleCreateFromTemplate
in class MultiDataObject
f
- 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 occuredprotected DataShadow handleCreateShadow(DataFolder f) throws IOException
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