org.openide.loaders
Class DataFolder

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

public class DataFolder
extends DataObject
implements Serializable

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

Inner 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.
 
Inner classes inherited from class org.openide.loaders.DataObject
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)
          Create a data folder from a folder file object.
protected DataFolder(FileObject fo, DataLoader 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 DataFolder findFolder(FileObject fo)
          Create a folder for a specified file object.
 DataObject[] getChildren()
          Get the children of this folder.
 Node.Cookie getCookie(Class cookie)
          Adds a compilation cookie.
 HelpCtx getHelpCtx()
          Get help context for this object.
 DataFolder.SortMode getSortMode()
          Get the sort mode of the folder.
protected  DataObject handleCopy(DataFolder f)
          Copy this object to a 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)
          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 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.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
 

Field Detail

PROP_CHILDREN

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

PROP_SORT_MODE

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

PROP_ORDER

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

SET_SORTING

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

DataFolder

public DataFolder(FileObject fo)
           throws DataObjectExistsException,
                  IllegalArgumentException
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,
                     DataLoader 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
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

getChildren

public DataObject[] getChildren()
Get the children of this folder.
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

getCookie

public Node.Cookie getCookie(Class cookie)
Adds a compilation cookie.
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

createNodeDelegate

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

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 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

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

handleCopy

protected DataObject handleCopy(DataFolder f)
                         throws IOException
Copy this object to a folder. The copy of the object is required to be deletable and movable.
Overrides:
handleCopy in class DataObject
Parameters:
f - the folder to copy object to
Returns:
the new object
Throws:
IOException - if something went wrong

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 df)
                         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

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

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


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