站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

MultiDataObject (NetBeans Loaders API) - NetBeans API Javadoc 5.0.0

 

org.openide.loaders
Class MultiDataObject

java.lang.Object
  extended byorg.openide.loaders.DataObject
      extended byorg.openide.loaders.MultiDataObject
All Implemented Interfaces:
HelpCtx.Provider, Node.Cookie, Serializable
Direct Known Subclasses:
DataFolder, DataShadow, InstanceDataObject, XMLDataObject

public class MultiDataObject
extends DataObject

Provides support for handling of data objects with multiple files. One file is represented by one MultiDataObject.Entry. Each handler has one primary entry and zero or more secondary entries.

See Also:
Serialized Form

Nested Class Summary
 class MultiDataObject.Entry
          Represents one file in a group data object.
 
Nested classes inherited from class org.openide.loaders.DataObject
DataObject.Container, 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
 
Constructor Summary
MultiDataObject(FileObject fo, MultiFileLoader loader)
          Create a MultiFileObject.
 
Method Summary
protected  void addSecondaryEntry(MultiDataObject.Entry fe)
          Add a new secondary entry to the list.
protected  Node createNodeDelegate()
          Provides node that should represent this data object.
 Set files()
          Get all contained files.
 MultiDataObject.Entry findSecondaryEntry(FileObject fo)
          For a given file, find the associated secondary entry.
 Node.Cookie getCookie(Class type)
          Look for a cookie in the current cookie set matching the requested class.
protected  CookieSet getCookieSet()
          Get the set of cookies.
 HelpCtx getHelpCtx()
          Get help context for this object.
 MultiFileLoader getMultiFileLoader()
          Getter for the multi file loader that created this object.
 MultiDataObject.Entry getPrimaryEntry()
          Get the primary entry.
protected  DataObject handleCopy(DataFolder df)
          Copies primary and secondary files to new folder.
protected  DataObject handleCreateFromTemplate(DataFolder df, String name)
          Create a new data object from template (implemented 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.
protected  MultiDataObject.Entry registerEntry(FileObject fo)
          Tests whether this file is between entries and if not, creates a secondary entry for it and adds it into set of secondary entries.
protected  void removeSecondaryEntry(MultiDataObject.Entry fe)
          Remove a secondary entry from the list.
 Set secondaryEntries()
          Get secondary entries.
protected  void setCookieSet(CookieSet s)
          Deprecated. just use getCookieSet().add(...) instead
protected  FileLock takePrimaryFileLock()
          Obtains lock for primary file.
 
Methods inherited from class org.openide.loaders.DataObject
addPropertyChangeListener, addVetoableChangeListener, copy, createFromTemplate, createFromTemplate, createShadow, delete, dispose, find, firePropertyChange, fireVetoableChange, getCookie, getFolder, getLoader, getName, getNodeDelegate, getPrimaryFile, getRegistry, handleCreateShadow, 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
 

Constructor Detail

MultiDataObject

public MultiDataObject(FileObject fo,
                       MultiFileLoader loader)
                throws DataObjectExistsException
Create a MultiFileObject.

Parameters:
fo - the primary file object
loader - loader of this data object
See Also:
DataObject.DataObject(org.openide.filesystems.FileObject,org.openide.loaders.DataLoader)
Method Detail

getMultiFileLoader

public final MultiFileLoader getMultiFileLoader()
Getter for the multi file loader that created this object.

Returns:
the multi loader for the object

files

public Set files()
Description copied from class: DataObject
Get all contained files. These file objects should ideally have had the important flag set appropriately.

The default implementation returns a set consisting only of the primary file.

Overrides:
files in class DataObject
Returns:
set of FileObjects

isDeleteAllowed

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

Specified by:
isDeleteAllowed in class DataObject
Returns:
true if it may

isCopyAllowed

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

Specified by:
isCopyAllowed in class DataObject
Returns:
true if it may

isMoveAllowed

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

Specified by:
isMoveAllowed in class DataObject
Returns:
true if it may

isRenameAllowed

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

Specified by:
isRenameAllowed in class DataObject
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
Specified by:
getHelpCtx in class DataObject
Returns:
the help context

createNodeDelegate

protected Node createNodeDelegate()
Provides node that should represent this data object.

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

addSecondaryEntry

protected final void addSecondaryEntry(MultiDataObject.Entry fe)
Add a new secondary entry to the list.

Parameters:
fe - the entry to add

removeSecondaryEntry

protected final void removeSecondaryEntry(MultiDataObject.Entry fe)
Remove a secondary entry from the list.

Parameters:
fe - the entry to remove

registerEntry

protected final MultiDataObject.Entry registerEntry(FileObject fo)
Tests whether this file is between entries and if not, creates a secondary entry for it and adds it into set of secondary entries.

This method should be used in constructor of MultiDataObject to register all the important files, that could belong to this data object. As example, our XMLDataObject, tries to locate its xmlinfo file and then do register it

Parameters:
fo - the file to register (can be null, then the action is ignored)
Returns:
the entry associated to this file object (returns primary entry if the fo is null)

getPrimaryEntry

public final MultiDataObject.Entry getPrimaryEntry()
Get the primary entry.

Returns:
the entry

secondaryEntries

public final Set secondaryEntries()
Get secondary entries.

Returns:
immutable set of MultiDataObject.Entrys

findSecondaryEntry

public final MultiDataObject.Entry findSecondaryEntry(FileObject fo)
For a given file, find the associated secondary entry.

Parameters:
fo - file object
Returns:
the entry associated with the file object, or null if there is no such entry

takePrimaryFileLock

protected FileLock takePrimaryFileLock()
                                throws IOException
Description copied from class: DataObject
Obtains lock for primary file.

Overrides:
takePrimaryFileLock in class DataObject
Returns:
the lock
Throws:
IOException - if taking the lock fails

handleCopy

protected DataObject handleCopy(DataFolder df)
                         throws IOException
Copies primary and secondary files to new folder. May ask for user confirmation before overwriting.

Specified by:
handleCopy in class DataObject
Parameters:
df - the new folder
Returns:
data object for the new primary
Throws:
IOException - if there was a problem copying
UserCancelException - if the user cancelled the copy

handleDelete

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

Specified by:
handleDelete in class 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).

Specified by:
handleRename in class 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
Moves primary and secondary files to a new folder. May ask for user confirmation before overwriting.

Specified by:
handleMove in class DataObject
Parameters:
df - the new folder
Returns:
the moved primary file object
Throws:
IOException - if there was a problem moving
UserCancelException - if the user cancelled the move

handleCreateFromTemplate

protected DataObject handleCreateFromTemplate(DataFolder df,
                                              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.

Specified by:
handleCreateFromTemplate in class 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

setCookieSet

protected final void setCookieSet(CookieSet s)
Deprecated. just use getCookieSet().add(...) instead

Set the set of cookies. To the provided cookie set a listener is attached, and any change to the set is propagated by firing a change on DataObject.PROP_COOKIE.

Parameters:
s - the cookie set to use

getCookieSet

protected final CookieSet getCookieSet()
Get the set of cookies. If the set had been previously set by setCookieSet(org.openide.nodes.CookieSet), that set is returned. Otherwise an empty set is returned.

Returns:
the cookie set (never null)

getCookie

public Node.Cookie getCookie(Class type)
Look for a cookie in the current cookie set matching the requested class.

Overrides:
getCookie in class DataObject
Parameters:
type - the class to look for
Returns:
an instance of that class, or null if this class of cookie is not supported

 

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