org.openide.loaders 5.9.22

org.openide.loaders
Class DataFolder

java.lang.Object
  extended by org.openide.loaders.DataObject
      extended by org.openide.loaders.MultiDataObject
          extended by org.openide.loaders.DataFolder
All Implemented Interfaces:
Serializable, DataObject.Container, Node.Cookie, HelpCtx.Provider

public class DataFolder
extends MultiDataObject
implements Serializable, DataObject.Container

A folder containing data objects. Is actually itself a data object, whose primary (and only) file object is a file folder.

Has special support for determining the sorting of the folder, or even explicit ordering of the children.

See Also:
Serialized Form

Nested Class Summary
 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.
 
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.Registry
 
Field Summary
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.
 
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
  DataFolder(FileObject fo)
          Deprecated. This method should not be used in client code. If you are searching for a DataFolder for a FileObject use 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.
 
Method Summary
 Enumeration children()
          Get enumeration of children of this folder.
 Enumeration 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.
 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.
 
Methods inherited from class org.openide.loaders.MultiDataObject
addSecondaryEntry, files, findSecondaryEntry, getCookie, getCookieSet, getMultiFileLoader, getPrimaryEntry, registerEntry, removeSecondaryEntry, secondaryEntries, setCookieSet, takePrimaryFileLock
 
Methods inherited from class org.openide.loaders.DataObject
addPropertyChangeListener, addVetoableChangeListener, copy, 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
 
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
 

Field Detail

PROP_CHILDREN

public static final String PROP_CHILDREN
Name of property that holds children of this node.

See Also:
Constant Field Values

PROP_SORT_MODE

public static final String PROP_SORT_MODE
Name of property which decides sorting mode.

See Also:
Constant Field Values

PROP_ORDER

public static final String PROP_ORDER
Name of property for order of children.

See Also:
Constant Field Values

SET_SORTING

public static final String SET_SORTING
Name of set with sorting options.

See Also:
Constant Field Values
Constructor Detail

DataFolder

public DataFolder(FileObject fo)
           throws DataObjectExistsException,
                  IllegalArgumentException
Deprecated. This method should not be used in client code. If you are searching for a DataFolder for a FileObject use findFolder(org.openide.filesystems.FileObject) factory method.

Create a data folder from a folder file object.

Parameters:
fo - file folder to work on
Throws:
DataObjectExistsException - if there is one already
IllegalArgumentException - if fo is not folder

DataFolder

protected DataFolder(FileObject fo,
                     MultiFileLoader loader)
              throws DataObjectExistsException,
                     IllegalArgumentException
Create a data folder from a folder file object.

Parameters:
fo - file folder to work on
loader - data loader for this data object
Throws:
DataObjectExistsException - if there is one already
IllegalArgumentException - if fo is not folder

DataFolder

protected DataFolder(FileObject fo,
                     DataLoader loader)
              throws DataObjectExistsException,
                     IllegalArgumentException
Deprecated. Since 1.13 do not use this constructor, it is for backward compatibility only.

Create a data folder from a folder file object.

Parameters:
fo - file folder to work on
loader - data loader for this data object
Throws:
DataObjectExistsException - if there is one already
IllegalArgumentException - if fo is not folder
Method Detail

create

public static DataFolder create(DataFolder folder,
                                String name)
                         throws IOException
Helper method to find or create a folder of a given path. Tries to find such a subfolder, or creates it if it needs to.

Parameters:
folder - the folder to start in
name - a subfolder path (e.g. com/mycom/testfolder)
Returns:
a folder with the given name
Throws:
IOException - if the I/O fails

setSortMode

public final void setSortMode(DataFolder.SortMode mode)
                       throws IOException
Set the sort mode for the folder.

Parameters:
mode - an constant from DataFolder.SortMode
Throws:
IOException - if the mode cannot be set

getSortMode

public final DataFolder.SortMode getSortMode()
Get the sort mode of the folder.

Returns:
the sort mode

setOrder

public final void setOrder(DataObject[] arr)
                    throws IOException
Set the order of the children. The provided array defines the order of some children for the folder. Such children will be returned at the beginning of the array returned from getChildren(). If there are any other children, they will be appended to the array.

Parameters:
arr - array of data objects (children of this folder) to define the order; or null if any particular ordering should be cancelled
Throws:
IOException - if the order cannot be set

getName

public String getName()
Get the name of the data folder.

This implementation uses the name and extension of the primary file.

Overrides:
getName in class DataObject
Returns:
the name

getChildren

public DataObject[] getChildren()
Get the children of this folder.

Specified by:
getChildren in interface DataObject.Container
Returns:
array of children

children

public Enumeration children()
Get enumeration of children of this folder.

Returns:
enumeration of DataObjects

children

public Enumeration children(boolean rec)
Enumerate all children of this folder. If the children should be enumerated recursively, first all direct children are listed; then children of direct subfolders; and so on.

Parameters:
rec - whether to enumerate recursively
Returns:
enumeration of type DataObject

createNodeDelegate

protected Node createNodeDelegate()
Create node representative for this folder.

Overrides:
createNodeDelegate in class MultiDataObject
Returns:
the node representation
See Also:
DataNode

createNodeChildren

public Children createNodeChildren(DataFilter filter)
Support method to obtain a children object that can be added to any Node. The provided filter can be used to exclude some objects from the list.

Overriding this method is deprecated!

Parameters:
filter - filter of data objects
Returns:
children object representing content of this folder

isDeleteAllowed

public boolean isDeleteAllowed()
Description copied from class: DataObject
Test whether the object may be deleted.

Overrides:
isDeleteAllowed in class MultiDataObject
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 MultiDataObject
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 MultiDataObject
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 MultiDataObject
Returns:
true if it may

getHelpCtx

public HelpCtx getHelpCtx()
Description copied from class: DataObject
Get help context for this object.

Specified by:
getHelpCtx in interface HelpCtx.Provider
Overrides:
getHelpCtx in class MultiDataObject
Returns:
the help context

findFolder

public static DataFolder findFolder(FileObject fo)
Create a folder for a specified file object.

Parameters:
fo - file object
Returns:
folder for the file object
Throws:
IllegalArgumentException - if the file object is not folder

findContainer

public static DataObject.Container findContainer(FileObject fo)
Finds a DataObject.Container representing given folder.

Parameters:
fo - file object (must be folder)
Returns:
the container for the file object
Throws:
IllegalArgumentException - if the file object is not folder
Since:
1.11

handleCopy

protected DataObject handleCopy(DataFolder f)
                         throws IOException
Description copied from class: MultiDataObject
Copies primary and secondary files to new folder. May ask for user confirmation before overwriting.

Overrides:
handleCopy in class MultiDataObject
Parameters:
f - the new folder
Returns:
data object for the new primary
Throws:
IOException - if there was a problem copying

handleDelete

protected void handleDelete()
                     throws IOException
Description copied from class: DataObject
Delete this object (implemented by subclasses).

Overrides:
handleDelete in class MultiDataObject
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 MultiDataObject
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 df)
                         throws IOException
Description copied from class: MultiDataObject
Moves primary and secondary files to a new folder. May ask for user confirmation before overwriting.

Overrides:
handleMove in class MultiDataObject
Parameters:
df - the new folder
Returns:
the moved primary file object
Throws:
IOException - if there was a problem moving

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 MultiDataObject
Parameters:
f - 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

handleCreateShadow

protected DataShadow handleCreateShadow(DataFolder f)
                                 throws IOException
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
Parameters:
f - the folder to create a shortcut in
Returns:
the shadow
Throws:
IOException

org.openide.loaders 5.9.22

Built on July 11 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.