|
org.openide.loaders 5.9.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openide.loaders.DataObject org.openide.loaders.MultiDataObject org.openide.loaders.InstanceDataObject
public class InstanceDataObject
A data object whose only purpose is to supply InstanceCookie
.
The instances are created by default instantiation; the name of the class
to instantiate is stored on disk, typically right in the file name.
This data object is generally used to configure menus and toolbars,
though it could be used in any situation requiring instances to be present in
a folder; for example, anything using FolderInstance
.
Typical instance classes are subclasses of SystemAction
to make
menu items or toolbar buttons; JSeparator
for a menu
separator; or JToolBar.Separator
for a toolbar
separator.
Use create(org.openide.loaders.DataFolder, java.lang.String, java.lang.String)
and remove(org.openide.loaders.DataFolder, java.lang.String, java.lang.String)
to make the objects.
Better yet, use an XML filesystem to install them declaratively.
Instance data object by default recognizes all files with .instance suffix. Such file can have associated optional file attributes:
Object
(e.g. created by
methodvalue at XML filesystem)
String
that is tokenized at ':', ',', ';' and
whitespace boundaries. Resulting tokens represent class names that created
instance is instanceof
. Utilizing it may improve performance.
Nested Class Summary |
---|
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 |
Nested classes/interfaces inherited from interface org.openide.cookies.InstanceCookie |
---|
InstanceCookie.Of |
Field Summary | |
---|---|
static String |
INSTANCE
File extension for instance data objects. |
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 | |
---|---|
InstanceDataObject(FileObject pf,
MultiFileLoader loader)
Create a new instance. |
Method Summary | |
---|---|
static InstanceDataObject |
create(DataFolder folder,
String name,
Class clazz)
Create a new InstanceDataObject in a given folder. |
static InstanceDataObject |
create(DataFolder folder,
String name,
Object instance,
ModuleInfo info)
Create a new InstanceDataObject containing settings
in a given folder. |
static InstanceDataObject |
create(DataFolder folder,
String name,
Object instance,
ModuleInfo info,
boolean create)
Create a new InstanceDataObject containing settings
in a given folder. |
static InstanceDataObject |
create(DataFolder folder,
String name,
String className)
Create a new InstanceDataObject in a given folder. |
protected Node |
createNodeDelegate()
Provides node that should represent this data object. |
protected void |
dispose()
Allows subclasses to discard the object. |
static InstanceDataObject |
find(DataFolder folder,
String name,
Class clazz)
Finds instance of specified name in a given folder. |
static InstanceDataObject |
find(DataFolder folder,
String name,
String className)
Finds instance of specified name in a given folder. |
Node.Cookie |
getCookie(Class clazz)
Look for a cookie in the current cookie set matching the requested class. |
HelpCtx |
getHelpCtx()
Get help context for this object. |
String |
getName()
Get the name of the data object. |
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 |
handleRename(String name)
Rename this object (implemented in subclasses). |
Class |
instanceClass()
|
Object |
instanceCreate()
|
String |
instanceName()
|
boolean |
instanceOf(Class type)
Query if this instance can create object of given type. |
static boolean |
remove(DataFolder folder,
String name,
Class clazz)
Remove an existing instance data object. |
static boolean |
remove(DataFolder folder,
String name,
String className)
Remove an existing instance data object. |
Methods inherited from class org.openide.loaders.MultiDataObject |
---|
addSecondaryEntry, files, findSecondaryEntry, getCookieSet, getMultiFileLoader, getPrimaryEntry, handleMove, isCopyAllowed, isDeleteAllowed, isMoveAllowed, isRenameAllowed, registerEntry, removeSecondaryEntry, secondaryEntries, setCookieSet, takePrimaryFileLock |
Methods inherited from class org.openide.loaders.DataObject |
---|
addPropertyChangeListener, addVetoableChangeListener, copy, createFromTemplate, createFromTemplate, createShadow, delete, find, firePropertyChange, fireVetoableChange, getCookie, getFolder, getLoader, 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 |
Field Detail |
---|
public static final String INSTANCE
Constructor Detail |
---|
public InstanceDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException
create(org.openide.loaders.DataFolder, java.lang.String, java.lang.String)
.
pf
- primary file object for this data objectloader
- the loader
DataObjectExistsException
- if it already existsMethod Detail |
---|
public static InstanceDataObject find(DataFolder folder, String name, String className)
folder
- the folder to create the instance data object inname
- the name to give to the object (can be null
if no special name besides the class name is needed)className
- the name of the class the new object should provide an instance of
public static InstanceDataObject find(DataFolder folder, String name, Class clazz)
folder
- the folder to create the instance data object inname
- the name to give to the object (can be null
if no special name besides the class name is needed)clazz
- the class to create instance for (see class header for details)
public static InstanceDataObject create(DataFolder folder, String name, String className) throws IOException
InstanceDataObject
in a given folder. If object with specified name already exists, it is returned.
You should specify the name if there is a chance another file of the same
instance class already exists in the folder; or just to provide a more
descriptive name, which will appear in the Explorer for example.
Note: use of XML layers to install instances is generally preferred.
folder
- the folder to create the instance data object inname
- the name to give to the object (can be null
if no special name besides the class name is needed)
but name cannot be emptyclassName
- the name of the class the new object should provide an instance of (see class header for details)
IOException
- if the file cannot be createdpublic static InstanceDataObject create(DataFolder folder, String name, Class clazz) throws IOException
InstanceDataObject
in a given folder. If object with specified name already exists, it is returned.
You should specify the name if there is a chance another file of the same
instance class already exists in the folder; or just to provide a more
descriptive name, which will appear in the Explorer for example.
Note: use of XML layers to install instances is generally preferred.
folder
- the folder to create the instance data object inname
- the name to give to the object (can be null
if no special name besides the class name is needed)clazz
- the class to create instance for (see class header for details)
IOException
- if the file cannot be createdpublic static InstanceDataObject create(DataFolder folder, String name, Object instance, ModuleInfo info) throws IOException
InstanceDataObject
containing settings
in a given folder. If object with specified name already exists, it is returned.
If the module info is null
then the origin module info
of an instance class is tried to find out.
Note: use of XML layers to install instances is generally preferred.
folder
- the folder to create the instance data object inname
- the name to give to the object (can be null
if no special name besides the class name is needed)
but name cannot be emptyinstance
- the serializable instanceinfo
- the module info describing the settings provenance (can be null
)
IOException
- if the file cannot be createdpublic static InstanceDataObject create(DataFolder folder, String name, Object instance, ModuleInfo info, boolean create) throws IOException
InstanceDataObject
containing settings
in a given folder.
If the module info is null
then the origin module info
of an instance class is tried to find out.
Note: use of XML layers to install instances is generally preferred.
folder
- the folder to create the instance data object inname
- the name to give to the object (can be null
if no special name besides the class name is needed)
but name cannot be emptyinstance
- the serializable instanceinfo
- the module info describing the settings provenance (can be null
)create
- true
- always create new file; false
- store to existing file if exist
IOException
- if the file cannot be createdpublic static boolean remove(DataFolder folder, String name, String className)
DataObject.delete()
;
this method lets you delete an instance you do not have an exact record
of the file name for, based on the same information used to create it.
Note: use of XML layers to install instances is generally preferred.
folder
- the folder to remove the file fromname
- the name of the instance (can be null
)className
- the name of class the object referred to (see class header for details)
true
if the instance was succesfully removed, false
if notpublic static boolean remove(DataFolder folder, String name, Class clazz)
DataObject.delete()
;
this method lets you delete an instance you do not have an exact record
of the file name for, based on the same information used to create it.
Note: use of XML layers to install instances is generally preferred.
folder
- the folder to remove the file fromname
- the name of the instance (can be null
)clazz
- the class the object referred to (see class header for details)
true
if the instance was succesfully removed, false
if notpublic HelpCtx getHelpCtx()
DataObject
getHelpCtx
in interface HelpCtx.Provider
getHelpCtx
in class MultiDataObject
protected Node createNodeDelegate()
MultiDataObject
createNodeDelegate
in class MultiDataObject
DataNode
public Node.Cookie getCookie(Class clazz)
MultiDataObject
getCookie
in class MultiDataObject
clazz
- the class to look for
null
if this class of cookie
is not supportedpublic String instanceName()
instanceName
in interface InstanceCookie
public Class instanceClass() throws IOException, ClassNotFoundException
instanceClass
in interface InstanceCookie
IOException
ClassNotFoundException
public boolean instanceOf(Class type)
instanceOf
in interface InstanceCookie.Of
type
- the type to create
public Object instanceCreate() throws IOException, ClassNotFoundException
instanceCreate
in interface InstanceCookie
IOException
ClassNotFoundException
public String getName()
DataObject
The default implementation uses the name of the primary file.
getName
in class DataObject
protected FileObject handleRename(String name) throws IOException
DataObject
handleRename
in class MultiDataObject
name
- name to rename the object to
IOException
- if an error occuresprotected DataObject handleCreateFromTemplate(DataFolder df, String name) throws IOException
DataObject
handleCreateFromTemplate
in class MultiDataObject
df
- 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 DataObject handleCopy(DataFolder df) throws IOException
MultiDataObject
handleCopy
in class MultiDataObject
df
- the new folder
IOException
- if there was a problem copyingprotected void dispose()
DataObject
The normal use of this method is to change the type of a data object. Because this would usually only be invoked from the original data object, it is protected.
dispose
in class DataObject
protected void handleDelete() throws IOException
DataObject
handleDelete
in class MultiDataObject
IOException
- if an error occures
|
org.openide.loaders 5.9.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |