|
org.netbeans.modules.looks/2 1.12 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.spi.looks.Look
org.netbeans.spi.looks.ProxyLook
public abstract class ProxyLook
This is base class for delegating to other looks. All methods are
enumerated by numeric constants and by overriding
delegateTo(long, org.netbeans.spi.looks.Look, java.lang.Object)
method subclasses can easily decide which methods and where to delegate.
It is not suggested to switch the looks that is being delegated to during different calls, because it can also result in calls to a look that has not have been attached by calling attachTo.
It is also not suggested to base the delegation on some changeable attribute of the representedObject. In such cases developer are encouraged to write new LookSelector and pass it as parameter into the constructor of the ProxyLook.
It is possible to change the represented object for a look
those are being delegated to (see method
delegateObject(java.lang.Object)
)
The default implementation of all methods share similar logic. If single value is returned from the method e.g. String or boolean all sublooks are consulted until one them returns diffrent value than null of false the value is returned from the ProxyLook (See Look for neutral values definition). If none of the sublooks returns non-neutral value then null or false is returned. In case of mutilvalued attributes e.g. Collections or Arrays the ProxyLook takes care of merging the values.
Field Summary |
---|
Fields inherited from class org.netbeans.spi.looks.Look |
---|
ALL_METHODS, CAN_COPY, CAN_CUT, CAN_DESTROY, CAN_RENAME, CLIPBOARD_COPY, CLIPBOARD_CUT, DESTROY, DRAG, GET_ACTIONS, GET_CHILD_OBJECTS, GET_CONTEXT_ACTIONS, GET_CUSTOMIZER, GET_DEFAULT_ACTION, GET_DISPLAY_NAME, GET_DROP_TYPE, GET_HELP_CTX, GET_ICON, GET_LOOKUP_ITEMS, GET_NAME, GET_NEW_TYPES, GET_OPENED_ICON, GET_PASTE_TYPES, GET_PROPERTY_SETS, GET_SHORT_DESCRIPTION, HAS_CUSTOMIZER, NO_METHODS, RENAME |
Constructor Summary | |
---|---|
ProxyLook(String name,
LookSelector content)
Creates new instance of look does no work. |
Method Summary | |
---|---|
boolean |
canCopy(Object representedObject,
Lookup env)
Tests whether the node permits the copy operation by consulting the set of sublooks. |
boolean |
canCut(Object representedObject,
Lookup env)
Tests whether the node permits the cut operation by consulting the set of sublooks. |
boolean |
canDestroy(Object representedObject,
Lookup env)
Tests whether the node permits the destroy operation by consulting the set of sublooks. |
boolean |
canRename(Object representedObject,
Lookup env)
Tests whether the node permits renaming by consulting the set of sublooks. |
Transferable |
clipboardCopy(Object representedObject,
Lookup env)
Gets the first transferable from any sublook which can provide the copy operation. |
Transferable |
clipboardCut(Object representedObject,
Lookup env)
Gets the first transferable from any sublook which can provide the cut operation. |
protected boolean |
delegateAll(long method,
Object representedObject)
Controls whether we delegate to all looks just the first one that returns a value. |
protected Object |
delegateObject(Object representedObject)
Permits changing the represented object when delegating to sublooks. |
protected boolean |
delegateTo(long method,
Look look,
Object representedObject)
A heart of this class - method which can decide where to delegate particular call. |
void |
destroy(Object representedObject,
Lookup env)
Calls the destroy method on all sublooks. |
Transferable |
drag(Object representedObject,
Lookup env)
Gets the first transferable from any sublook that can provide the drag operation. |
Action[] |
getActions(Object representedObject,
Lookup env)
Crates an array of actions for the node by consulting the set of sublooks. |
List |
getChildObjects(Object representedObject,
Lookup env)
Creates list of child objects of given object. |
Action[] |
getContextActions(Object representedObject,
Lookup env)
Crates an array of context actions for the node by consulting the set of sublooks. |
Component |
getCustomizer(Object representedObject,
Lookup env)
Gets the first customizer component provided by any sublook. |
Action |
getDefaultAction(Object representedObject,
Lookup env)
Gets the first default action provided by any sublook. |
String |
getDisplayName(Object representedObject,
Lookup env)
Gets the first display name provided by any sublook. |
PasteType |
getDropType(Object representedObject,
Transferable t,
int action,
int index,
Lookup env)
Gets the first PasteType from any sublook, which can provide the paste operation. |
HelpCtx |
getHelpCtx(Object representedObject,
Lookup env)
Gets the first help context provided by any sublook. |
Image |
getIcon(Object representedObject,
int type,
Lookup env)
Gets the first icon provided by any sublook. |
Collection |
getLookupItems(Object representedObject,
Lookup oldEnv)
Allowes for adding new object into the object's environement passed to other methods as the env parameter. |
String |
getName(Object representedObject,
Lookup env)
Gets the first name provided by any sublook. |
NewType[] |
getNewTypes(Object representedObject,
Lookup env)
Creates an array of NewTypes for given node consulting the set of sublooks. |
Image |
getOpenedIcon(Object representedObject,
int type,
Lookup env)
Gets the first icon for opened state provided by any sublook. |
PasteType[] |
getPasteTypes(Object representedObject,
Transferable t,
Lookup env)
Crates an array of allowed PasteTypes by consulting the set of sublooks. |
Node.PropertySet[] |
getPropertySets(Object representedObject,
Lookup env)
Creates and array of PropertySets by consulting sublooks. |
String |
getShortDescription(Object representedObject,
Lookup env)
Gets the first short description provided by any sublook. |
boolean |
hasCustomizer(Object representedObject,
Lookup env)
Determines if the node has customize element by consulting the set of sublooks. |
boolean |
isLeaf(Object representedObject,
Lookup env)
Determines if the object should be expandable by consulting the set of sublooks. |
void |
rename(Object representedObject,
String newName,
Lookup env)
Notifies all sublooks that the object was renamed. |
protected Object |
undelegateObject(Object delegate)
Performs reverse transformation from delegated object to original represented object. |
Methods inherited from class org.netbeans.spi.looks.Look |
---|
attachTo, detachFrom, fireChange, firePropertyChange, getDisplayName, getName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ProxyLook(String name, LookSelector content)
content
- LookSelector containing Looks the ProxyLook should
delegate to.Method Detail |
---|
protected boolean delegateTo(long method, Look look, Object representedObject)
The default implementation ignores all parameters and just returns true,
which means that by default all methods are delegated.
Subclasses might override this method with implementation that bases its
decision on different criteria.
method
- One of the constants defined here that identifies the method
we want to delegate tolook
- The look we want to delegate torepresentedObject
- The Look.NodeSubstitute of the node.
true
if method identified by the constant should be
delegated to given Look with given substitute.protected boolean delegateAll(long method, Object representedObject)
Useful for methods that return an array of objects. By default all sublooks are consulted and the result is a merge of all values returned by the sublooks. Overriding this method may disallow merging and force mutlivalued attributes of the node (e.g. properties, children, etc,) to behave like singlevalued attributes (e.g. name or icon). It means that the first sublook will "win" and will provide the values.
method
- One of the constants defined here that identifies the method
we want to delegate torepresentedObject
- Represented object the look should work with.
true
if the merge should happen false
otherwiseprotected Object delegateObject(Object representedObject)
The default implementation just returns the same object, but subclasses might use this method to change the represented object for the look they delegate to.
When overriding this object make sure you implement the
undelegateObject(java.lang.Object)
method correctly.
representedObject
- Represented object which should be translated
null
)protected Object undelegateObject(Object delegate)
The default implementation simply retruns the delegate.
This method has to be implemented correctly when the
delegateObject(java.lang.Object)
method is overridden.
delegate
- The delegate
public Collection getLookupItems(Object representedObject, Lookup oldEnv)
Look
getLookupItems
in class Look
representedObject
- Parameter is ignored.oldEnv
- Content of previous environement when called after a change
of environemnt or is empty.
null
public String getDisplayName(Object representedObject, Lookup env)
filtering method
.
getDisplayName
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
null
public String getName(Object representedObject, Lookup env)
filtering method
.
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
null
public void rename(Object representedObject, String newName, Lookup env) throws IOException
filtering method
.
representedObject
- Represented object the look should work with.newName
- New name of the object.env
- Environement for the represented object.
IOException
public String getShortDescription(Object representedObject, Lookup env)
filtering method
.
getShortDescription
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
null
public Image getIcon(Object representedObject, int type, Lookup env)
filtering method
.
representedObject
- Represented object the look should work with.type
- Icon type constant from BeanInfo
env
- Environement for the represented object.
null
public Image getOpenedIcon(Object representedObject, int type, Lookup env)
filtering method
.
getOpenedIcon
in class Look
representedObject
- Represented object the look should work with.type
- Icon type constant from BeanInfo
env
- Environement for the represented object.
null
public HelpCtx getHelpCtx(Object representedObject, Lookup env)
filtering method
.
getHelpCtx
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
null
public List getChildObjects(Object representedObject, Lookup env)
filtering method
.
getChildObjects
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
public boolean isLeaf(Object representedObject, Lookup env)
filtering method
.
Notice that filtering of this method is driven by the same constant as
by the getChildObjects(java.lang.Object, org.openide.util.Lookup)
getChildObjects( substitute )} method i.e.
GET_CHILD_OBJECTS
.
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
true
if at least one of the sublooks returns true
,
false
otherwise.public NewType[] getNewTypes(Object representedObject, Lookup env)
filtering method
.delegateAll(long, java.lang.Object)
method.
getNewTypes
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
public Action[] getActions(Object representedObject, Lookup env)
filtering method
.delegateAll(long, java.lang.Object)
method.
getActions
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
public Action[] getContextActions(Object representedObject, Lookup env)
filtering method
.delegateAll(long, java.lang.Object)
method.
getContextActions
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
public Action getDefaultAction(Object representedObject, Lookup env)
filtering method
.
getDefaultAction
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
null
public Node.PropertySet[] getPropertySets(Object representedObject, Lookup env)
filtering method
.delegateAll(long, java.lang.Object)
method.
getPropertySets
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
public Component getCustomizer(Object representedObject, Lookup env)
filtering method
.
getCustomizer
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
null
public boolean hasCustomizer(Object representedObject, Lookup env)
filtering method
.
hasCustomizer
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
true
if at least one of the sublooks returns true
,
false
otherwise.public boolean canRename(Object representedObject, Lookup env)
filtering method
.
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
true
if at least one of the sublooks returns true
,
false
otherwise.public boolean canDestroy(Object representedObject, Lookup env)
filtering method
.
canDestroy
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
true
if at least one of the sublooks returns true
,
false
otherwise.public boolean canCopy(Object representedObject, Lookup env)
filtering method
.
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
true
if at least one of the sublooks returns true
,
false
otherwise.public boolean canCut(Object representedObject, Lookup env)
filtering method
.
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
true
if at least one of the sublooks returns true
,
false
otherwise.public PasteType[] getPasteTypes(Object representedObject, Transferable t, Lookup env)
filtering method
.delegateAll(long, java.lang.Object)
method.
getPasteTypes
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.t
- The transferable
public PasteType getDropType(Object representedObject, Transferable t, int action, int index, Lookup env)
filtering method
.
getDropType
in class Look
representedObject
- Represented object the look should work with.t
- the transferableaction
- the drag'n'drop action to do DnDConstants.ACTION_MOVE, ACTION_COPY, ACTION_LINKindex
- index between children the drop occurred at or -1 if not specifiedenv
- Environement for the represented object.
null
Look.getDropType(T, java.awt.datatransfer.Transferable, int, int, org.openide.util.Lookup)
public Transferable clipboardCopy(Object representedObject, Lookup env) throws IOException
filtering method
.
clipboardCopy
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
null
IOException
- If any of the sublooks throws the exceptionpublic Transferable clipboardCut(Object representedObject, Lookup env) throws IOException
filtering method
.
clipboardCut
in class Look
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
null
IOException
- If any of the sublooks throws the exceptionpublic Transferable drag(Object representedObject, Lookup env) throws IOException
filtering method
.
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
null
IOException
- If any of the sublooks throws the exceptionpublic void destroy(Object representedObject, Lookup env) throws IOException
filtering method
.
representedObject
- Represented object the look should work with.env
- Environement for the represented object.
IOException
- If any of the sublooks throws the exception
|
org.netbeans.modules.looks/2 1.12 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |