| com.sun.rave.designtime.DesignContext
All known Subclasses: org.netbeans.modules.visualweb.insync.live.LiveUnit,
DesignContext | public interface DesignContext extends DisplayItem(Code) | | A DesignContext is a 'host' for DesignBean instances at design-time. The DesignContext
represents the 'source file' or 'persistence model' for a design-time session. A DesignContext
is the container (instance host) for a set of DesignBeans. For example, in a JSF application,
the DesignContext represents the logical backing file which is the combination of the 'Page1.jsp'
and the 'Page1.java' files. In a Swing application, the DesignContext represents the
'JFrame1.java' file.
IMPLEMENTED BY CREATOR - This interface is implemented by Creator for use by the
component (bean) author.
author: Joe Nuxoll version: 1.0 |
Method Summary | |
public void | addDesignContextListener(DesignContextListener listener) | public String | addResource(URL resource, boolean copy) Adds a resource reference to this DesignContext, and converts the external URL into a local
resource identifyer String. | public boolean | canCreateBean(String classname, DesignBean parent, Position position) Returns true if the specified type (classname) of JavaBean can be created as a
child of the specified parent DesignBean at the specified position. | public boolean | canMoveBean(DesignBean designBean, DesignBean newParent, Position position) Returns true if the specified DesignBean can be can be moved to be a child of
the specified parent DesignBean at the specified position. | public Transferable | copyBeans(DesignBean[] designBeans) Copies a set of DesignBean instances into a clipboard-like format. | public DesignBean | createBean(String classname, DesignBean parent, Position position) Creates an instance of a JavaBean of the specified type (classname), as a child of the
specified parent DesignBean at the specified position. | public boolean | createContextMethod(ContextMethod method) Creates a new method in the source code for this DesignContext. | public boolean | deleteBean(DesignBean designBean) Deletes a DesignBean object (and removes all persistence). | public DesignBean | getBeanByName(String instanceName) Returns a DesignBean (design-time proxy) to represent the JavaBean with the specified
instance name. | public DesignBean | getBeanForInstance(Object beanInstance) Returns a DesignBean (design-time proxy) to represent the specified JavaBean instance. | public DesignBean[] | getBeans() Returns an array of all the DesignBeans within the scope of this DesignContext. | public DesignBean[] | getBeansOfType(Class beanClass) Returns a DesignBean array (design-time proxies) representing the JavaBeans within the scope
of this DesignContext that are assignable from the specified class type. | public Object | getContextData(String key) Retrieves the value for a name-value pair of data on this DesignContext. | public ContextMethod | getContextMethod(String methodName, Class[] parameterTypes) Returns a
ContextMethod object describing the method with the specified name and
parameter types. | public ContextMethod[] | getContextMethods() Returns a set of
ContextMethod objects describing the methods declared on this
DesignContext (source file). | public DesignContextListener[] | getDesignContextListeners() | public DesignProject | getProject() Returns the project, which is the top-level container for all contexts. | public DesignBean | getRootContainer() Returns the root container DesignBean for this DesignContext. | public boolean | moveBean(DesignBean designBean, DesignBean newParent, Position position) Moves a DesignBean, to become a child of the specified parent DesignBean at the specified
position. | public DesignBean[] | pasteBeans(Transferable persistData, DesignBean newParent, Position position) Pastes a set of DesignBean instances (acquired via copyBeans) into the specified parent
DesignBean at the specified position. | public boolean | removeContextMethod(ContextMethod method) Removes an existing method from the source code for this DesignContext. | public void | removeDesignContextListener(DesignContextListener listener) | public URL | resolveResource(String localResource) Resolves a local resource identifyer String into a fully-qualified URL. | public void | setContextData(String key, Object data) Sets a name-value pair of data on this DesignContext. | public ContextMethod | updateContextMethod(ContextMethod method) Updates an existing method in the source code for this DesignContext. |
addDesignContextListener | public void addDesignContextListener(DesignContextListener listener)(Code) | | Adds a listener to this DesignContext
Parameters: listener - The desired listener to add |
addResource | public String addResource(URL resource, boolean copy) throws IOException(Code) | | Adds a resource reference to this DesignContext, and converts the external URL into a local
resource identifyer String. This may also copy (if specified) an external resource into the
project.
Parameters: resource - A URL pointing to the desired external resource Parameters: copy - true if the resource should be copied into the project,false if not throws: IOException - if the resource cannot be copied The resulting relative resource identifyer String. This will be a local relativeresource if the external resource was copied into the project. |
canCreateBean | public boolean canCreateBean(String classname, DesignBean parent, Position position)(Code) | | Returns true if the specified type (classname) of JavaBean can be created as a
child of the specified parent DesignBean at the specified position. This is a test call that
should be performed before calling the createBean method.
Parameters: classname - The fully qualified class name of the JavaBean to be created Parameters: parent - The DesignBean parent for the JavaBean to be created Parameters: position - The desired position for the JavaBean to be created true if a matching call to 'createBean' would succeed, orfalse if not See Also: DesignContext.createBean(StringDesignBeanPosition) |
canMoveBean | public boolean canMoveBean(DesignBean designBean, DesignBean newParent, Position position)(Code) | | Returns true if the specified DesignBean can be can be moved to be a child of
the specified parent DesignBean at the specified position. This is a test call that should
be performed before calling the moveBean method.
Parameters: designBean - The DesignBean to be moved Parameters: newParent - The new DesignBean parent for the DesignBean Parameters: position - The desired position for the DesignBean to be moved true if a matching call to 'moveBean' would succeed, orfalse if not See Also: moveBean(DesignBean, DesignBean, Position) |
copyBeans | public Transferable copyBeans(DesignBean[] designBeans)(Code) | | Copies a set of DesignBean instances into a clipboard-like format. This returns a
Transferable object that stores all the necessary data for the pasteBeans method.
Parameters: designBeans - An array of desired DesignBean instances the resulting Transferable object representing the copied beans See Also: pasteBeans(java.awt.datatransfer.Transferable, DesignBean, Position) |
createBean | public DesignBean createBean(String classname, DesignBean parent, Position position)(Code) | | Creates an instance of a JavaBean of the specified type (classname), as a child of the
specified parent DesignBean at the specified position. If successful, a DesignBean
representing the newly created bean is returned. Before this method is called, a test call
should be performed to the canCreateBean method.
Parameters: classname - The fully qualified class name of the JavaBean to be created Parameters: parent - The DesignBean parent for the JavaBean to be created Parameters: position - The desired position for the JavaBean to be created A DesignBean representing the JavaBean that was created, or null if the operationfailed See Also: DesignContext.canCreateBean(StringDesignBeanPosition) |
createContextMethod | public boolean createContextMethod(ContextMethod method) throws IllegalArgumentException(Code) | | Creates a new method in the source code for this DesignContext. The passed ContextMethod
must specify at least the designContext and name, and must
not describe a method that already exists in the DesignContext source. To update
an existing method, use the updateContextMethod() method. These methods are
separated to help prevent accidental method overwriting. The following table
details how the specified ContextMethod is used for this method:
designContext | REQUIRED. Must match the DesignContext that is
being called. This is essentially a safety precaution to help prevent accidental
method overwriting.
|
---|
name | REQUIRED. Defines the method name.
|
---|
modifiers | Defines the method modifiers. Use
java.lang.reflect.Modifier to define the modifier bits. If 0 is specified (no modifier bits), then
a public method is created.
|
---|
returnType | Defines the return type. If null is specified, the
created method will have a void return type.
|
---|
parameterTypes | Defines the parameter types. If null or an empty
array is specified, the created method will have no arguments.
|
---|
parameterNames | Defines the parameter names. If null or an empty
array is specified (or an array shorter than the parameterTypes array), default
argument names will be used.
|
---|
exceptionTypes | Defines the throws clause exception types. If null
is specified, the created method will have no throws clause.
|
---|
methodBodyText | Defines the method body Java source code. If null is
specified, the method will have an empty body. If the value is non-null, this must
represent valid (compilable) Java source code.
|
---|
commentText | Defines the comment text above the newly created method. If
null is specified, no comment text will be included.
|
---|
Parameters: method - A ContextMethod object representing the desired method. true if the method was created successfully, or false ifit was not. throws: IllegalArgumentException - If there was a syntax error in any of the ContextMethodsettings, or if the ContextMethod represents a method that already exists on thisDesignContext (updateContextMethod() must be used in this case to avoidaccidental method overwriting) |
deleteBean | public boolean deleteBean(DesignBean designBean)(Code) | | Deletes a DesignBean object (and removes all persistence). Returns true if the
delete was successful, false if not.
Parameters: designBean - The desired DesignBean to delete true if the delete operation was successful, false if not |
getBeanByName | public DesignBean getBeanByName(String instanceName)(Code) | | Returns a DesignBean (design-time proxy) to represent the JavaBean with the specified
instance name. This must be an instance that lives within the scope of this DesignContext,
or the method will return null.
Parameters: instanceName - The String instance name of the desired JavaBean A DesignBean (design-time proxy) representing the specified bean, or null if thespecified instance name does not represent a JavaBean within the scope of thisDesignContext |
getBeanForInstance | public DesignBean getBeanForInstance(Object beanInstance)(Code) | | Returns a DesignBean (design-time proxy) to represent the specified JavaBean instance. This
must be an instance that lives within the scope of this DesignContext, or the method will
return null.
Parameters: beanInstance - A live instance of a JavaBean A DesignBean (design-time proxy) representing the specified bean instance, or null ifthe specified Object does not represent a JavaBean within the scope of thisDesignContext |
getBeans | public DesignBean[] getBeans()(Code) | | Returns an array of all the DesignBeans within the scope of this DesignContext. This is a
flat list of instances, ignoring the containership hierarchy. To navigate the containership
hierarchy, use the getRootContainer() method.
An array of DesignBean representing the JavaBeans within the scope of thisDesignContext See Also: getRootContainer() |
getBeansOfType | public DesignBean[] getBeansOfType(Class beanClass)(Code) | | Returns a DesignBean array (design-time proxies) representing the JavaBeans within the scope
of this DesignContext that are assignable from the specified class type. This uses
Class.isAssignableFrom(...) to determine if a JavaBean satisfies the specified criteria, so
subtypes of the specified type will be included.
Parameters: beanClass - The desired class type An array of DesignBean representing the JavaBeans within the scope of thisDesignContext that are assignable from the specified class type See Also: Class.isAssignableFrom(Class) |
getContextData | public Object getContextData(String key)(Code) | | Retrieves the value for a name-value pair of data on this DesignContext. This name-value
pair is stored in the associated project file (as text) that contains this DesignContext, so
this data is retrievable in any IDE session once it has been set.
NOTE: The 'data' Object can be a simple String or a complex (non-String) Object. Either
way, it will be stored as text in the project file and will be associated with this
DesignContext. When the project file is written to disk, any complex (non-String) objects
will be converted to String using the 'toString()' method. If a component author wishes to
store a complex (non-String) object, they must be sure to override the 'toString()' method
on their object to serialize out enough information to be able to restore the object when a
subsequent call to 'getContextData' returns a String. Though a complex object was stored
via the 'setContextData' method, a component author *may* get back a String from
'getContextData' if the project has been saved and reopened since the previous call to
'setContextData'. It is the responsibility of the component author to reconstruct the
complex object from the String, and if desired, put it back into the context using the
'setContextData' method passing the newly constructed object in. This way, all subsequent
calls to 'getContextData' with that key will return the complex object instance - until the
project is closed and restored.
Parameters: key - The desired String key to retrieve the data object for The data object that is currently stored under this key - this may be a String oran Object, based on what was stored using 'setContextData'. NOTE: This will alwaysbe a String after the project file is read from disk, even if the stored object wasnot a String - it will have been converted using the 'toString()' method. See Also: DesignContext.setContextData(String,Object) See Also: Constants.ContextData |
getContextMethod | public ContextMethod getContextMethod(String methodName, Class[] parameterTypes)(Code) | | Returns a
ContextMethod object describing the method with the specified name and
parameter types. Returns null if no method exists on this DesignContext with
the specified name and parameter types.
Parameters: methodName - The method name of the desired context method Parameters: parameterTypes - The parameter types of the desired context method A ContextMethod object describing the requested method, or null if nomethod exists with the specified name and parameter types |
getContextMethods | public ContextMethod[] getContextMethods()(Code) | | Returns a set of
ContextMethod objects describing the methods declared on this
DesignContext (source file).
An array of ContextMethod objects, describing the methods declared on thisDesignContext (source file) |
getDesignContextListeners | public DesignContextListener[] getDesignContextListeners()(Code) | | Returns the array of current listeners to this DesignContext
An array of listeners currently listening to this DesignContext |
getProject | public DesignProject getProject()(Code) | | Returns the project, which is the top-level container for all contexts.
The DesignProject associated with this DesignContext |
getRootContainer | public DesignBean getRootContainer()(Code) | | Returns the root container DesignBean for this DesignContext. This is typically the "this"
component being designed. For example, this would be the view root in a JSF application.
The children of the root container are the items you see on the page. To get all of the
DesignBeans within the scope of this context (ignoring the containership hierarchy), use
the getBeans() method.
The root container DesignBean for this DesignContext See Also: getBeans() |
moveBean | public boolean moveBean(DesignBean designBean, DesignBean newParent, Position position)(Code) | | Moves a DesignBean, to become a child of the specified parent DesignBean at the specified
position. Returns true if successful, false if not. Before this
method is called, a test call should be performed to the canMoveBean method.
Parameters: designBean - The DesignBean to move Parameters: newParent - The new DesignBean parent for the DesignBean Parameters: position - The desired position for the DesignBean to be moved true if move was succeessful, or false if not See Also: canMoveBean(DesignBean, DesignBean, Position) |
pasteBeans | public DesignBean[] pasteBeans(Transferable persistData, DesignBean newParent, Position position)(Code) | | Pastes a set of DesignBean instances (acquired via copyBeans) into the specified parent
DesignBean at the specified position. This returns an array of DesignBean(s), representing
the newly pasted children.
Parameters: persistData - The Transferable object acquired via 'copyBeans' that contains the datarepresenting the DesignBean(s) to be pasted Parameters: newParent - The desired new parent DesignBean to paste the DesignBean(s) into Parameters: position - The desired new position for the pasted DesignBean(s) The newly created DesignBean instances See Also: copyBeans(DesignBean[]) |
removeContextMethod | public boolean removeContextMethod(ContextMethod method)(Code) | | Removes an existing method from the source code for this DesignContext. The passed
ContextMethod will be used to locate the desired method to remove using the designContext,
name, and parameterTypes. No other portions of the ContextMethod are used. The
following table details how the specified ContextMethod is used for this method:
designContext | REQUIRED. Must match the DesignContext that is
being called. This is essentially a safety precaution to help prevent accidental
method removal.
|
---|
name | REQUIRED. Specifies the desired method name.
|
---|
|
modifiers Ignored.
returnType | Ignored.
|
---|
parameterTypes | REQUIRED. Specifies the desired method's
parameter types (if it has any). If null or an empty array is
specified, the desired method is assumed to have zero arguments.
|
---|
parameterNames | Ignored.
|
---|
exceptionTypes | Ignored.
|
---|
methodBodyText | Ignored.
|
---|
commentText | Ignored.
|
---|
Parameters: method - A ContextMethod object defining the method to be removed true if the method was successfully removed exception: IllegalArgumentException - if the specified ContextMethod does not exist on thisDesignContext |
removeDesignContextListener | public void removeDesignContextListener(DesignContextListener listener)(Code) | | Removes a listener from this DesignContext
Parameters: listener - The desired listener to remove |
resolveResource | public URL resolveResource(String localResource)(Code) | | Resolves a local resource identifyer String into a fully-qualified URL.
Parameters: localResource - A local resource identifier string A fully-qualified URL |
setContextData | public void setContextData(String key, Object data)(Code) | | Sets a name-value pair of data on this DesignContext. This name-value pair will be stored
in the associated project file (as text) that contains this DesignContext, so this data is
retrievable in a future IDE session.
NOTE: The 'data' Object can be a simple String or a complex (non-String) Object. Either
way, it will be stored as text in the project file and will be associated with this
DesignContext. When the project file is written to disk, any complex (non-String) objects
will be converted to String using the 'toString()' method. If a component author wishes to
store a complex (non-String) object, they must be sure to override the 'toString()' method
on their object to serialize out enough information to be able to restore the object when a
subsequent call to 'getContextData' returns a String. Though a complex object was stored
via the 'setContextData' method, a component author *may* get back a String from
'getContextData' if the project has been saved and reopened since the previous call to
'setContextData'. It is the responsibility of the component author to reconstruct the
complex object from the String, and if desired, put it back into the context using the
'setContextData' method passing the newly constructed object in. This way, all subsequent
calls to 'getContextData' with that key will return the complex object instance - until the
project is closed and restored.
Parameters: key - The String key to store the data object under Parameters: data - The data object to store - this may be a String or any complex object, but itwill be stored as a string using the 'toString()' method when the project file iswritten to disk. See Also: getContextData(String) |
updateContextMethod | public ContextMethod updateContextMethod(ContextMethod method) throws IllegalArgumentException(Code) | | Updates an existing method in the source code for this DesignContext. The passed
ContextMethod will be used to locate the desired method to update using the designContext,
name, and parameterTypes. This method may only be used to update the modifiers, returnType,
parameterNames, exceptionTypes, methodBodyText, or commentText. Any other changes
actually constitute the creation of a new method, as they alter the method signature. To
create a new method, the createContextMethod() method should be used. These
operations are separated to help prevent accidental method overwriting. The following table
details how the specified ContextMethod is used for this method:
designContext | REQUIRED. Must match the DesignContext that is
being called. This is essentially a safety precaution to help prevent accidental
method overwriting.
|
---|
name | REQUIRED. Specifies the desired method name.
|
---|
modifiers | Defines the method modifiers. Use
java.lang.reflect.Modifier to define the modifier bits.
|
---|
returnType | Defines the method's return type. If null is specified,
the method is assumed to have a void return type.
|
---|
parameterTypes | REQUIRED. Specifies the desired method's
parameter types (if it has any). If null or an empty array is
specified, the desired method is assumed to have zero arguments.
|
---|
parameterNames | Defines the parameter names. If null or an empty
array is specified (or an array shorter than the parameterTypes array), default
argument names will be used.
|
---|
exceptionTypes | Defines the throws clause exception types. If null
is specified, the resulting method will have no throws clause.
|
---|
methodBodyText | Defines the method body Java source code. If null is
specified, the resulting method body will be empty. If the value is non-null, this
must represent valid (compilable) Java source code. Note that a method with a
non-void return type must return a value.
|
---|
commentText | Defines the comment text above the newly created method. If
null is specified, no comment text will be included.
|
---|
Parameters: method - The desired ContextMethod representing the method to be updated The resulting ContextMethod object (including any updates from the process) throws: IllegalArgumentException - If there was a syntax error in any of the ContextMethodsettings, or if the ContextMethod does not exist in this DesignContext. |
|
|