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

ProxyLook (Looks) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.looks/2 1.12

org.netbeans.spi.looks
Class ProxyLook

java.lang.Object
  extended by org.netbeans.spi.looks.Look
      extended by org.netbeans.spi.looks.ProxyLook

public abstract class ProxyLook
extends Look

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

ProxyLook

public ProxyLook(String name,
                 LookSelector content)
Creates new instance of look does no work.

Parameters:
content - LookSelector containing Looks the ProxyLook should delegate to.
Method Detail

delegateTo

protected boolean delegateTo(long method,
                             Look look,
                             Object representedObject)
A heart of this class - method which can decide where to delegate particular call.

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.

Parameters:
method - One of the constants defined here that identifies the method we want to delegate to
look - The look we want to delegate to
representedObject - The Look.NodeSubstitute of the node.
Returns:
true if method identified by the constant should be delegated to given Look with given substitute.

delegateAll

protected boolean delegateAll(long method,
                              Object representedObject)
Controls whether we delegate to all looks just the first one that returns a value.

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.

Parameters:
method - One of the constants defined here that identifies the method we want to delegate to
representedObject - Represented object the look should work with.
Returns:
true if the merge should happen false otherwise

delegateObject

protected Object delegateObject(Object representedObject)
Permits changing the represented object when delegating to sublooks.

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.

Parameters:
representedObject - Represented object which should be translated
Returns:
The represented object for the sub-look (not null)

undelegateObject

protected Object undelegateObject(Object delegate)
Performs reverse transformation from delegated object to original represented object.

The default implementation simply retruns the delegate.

This method has to be implemented correctly when the delegateObject(java.lang.Object) method is overridden.

Parameters:
delegate - The delegate
Returns:
Original represented object

getLookupItems

public Collection getLookupItems(Object representedObject,
                                 Lookup oldEnv)
Description copied from class: Look
Allowes for adding new object into the object's environement passed to other methods as the env parameter.

Overrides:
getLookupItems in class Look
Parameters:
representedObject - Parameter is ignored.
oldEnv - Content of previous environement when called after a change of environemnt or is empty.
Returns:
null

getDisplayName

public String getDisplayName(Object representedObject,
                             Lookup env)
Gets the first display name provided by any sublook. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
getDisplayName in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
First display name returned by some of the sublooks or null

getName

public String getName(Object representedObject,
                      Lookup env)
Gets the first name provided by any sublook. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
getName in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
First name returned by some of the sublooks or null

rename

public void rename(Object representedObject,
                   String newName,
                   Lookup env)
            throws IOException
Notifies all sublooks that the object was renamed. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
rename in class Look
Parameters:
representedObject - Represented object the look should work with.
newName - New name of the object.
env - Environement for the represented object.
Throws:
IOException

getShortDescription

public String getShortDescription(Object representedObject,
                                  Lookup env)
Gets the first short description provided by any sublook. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
getShortDescription in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
First short description returned by some of the sublooks or null

getIcon

public Image getIcon(Object representedObject,
                     int type,
                     Lookup env)
Gets the first icon provided by any sublook. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
getIcon in class Look
Parameters:
representedObject - Represented object the look should work with.
type - Icon type constant from BeanInfo
env - Environement for the represented object.
Returns:
First icon returned by some of the sublooks or null

getOpenedIcon

public Image getOpenedIcon(Object representedObject,
                           int type,
                           Lookup env)
Gets the first icon for opened state provided by any sublook. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
getOpenedIcon in class Look
Parameters:
representedObject - Represented object the look should work with.
type - Icon type constant from BeanInfo
env - Environement for the represented object.
Returns:
First icon for opened state returned by some of the sublooks or null

getHelpCtx

public HelpCtx getHelpCtx(Object representedObject,
                          Lookup env)
Gets the first help context provided by any sublook. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
getHelpCtx in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
First help context returned by some of the sublooks or null

getChildObjects

public List getChildObjects(Object representedObject,
                            Lookup env)
Creates list of child objects of given object. Consults the sublooks to get the resulting list of child objects.
The set of consulted sublooks is determined by the selector associated with this look and the filtering method .
By default the resulting set is a merge of all values returned by sublooks. However the merging behavior can be modified by overriding the

Overrides:
getChildObjects in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
(Merged) list of the child objects

isLeaf

public boolean isLeaf(Object representedObject,
                      Lookup env)
Determines if the object should be expandable by consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the 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.

Overrides:
isLeaf in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
true if at least one of the sublooks returns true, false otherwise.

getNewTypes

public NewType[] getNewTypes(Object representedObject,
                             Lookup env)
Creates an array of NewTypes for given node consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the filtering method .
By default the resulting set is a merge of all values returned by sublooks. However the merging behavior can be modified by overriding the delegateAll(long, java.lang.Object) method.

Overrides:
getNewTypes in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
(Merged) array of the NewTypes

getActions

public Action[] getActions(Object representedObject,
                           Lookup env)
Crates an array of actions for the node by consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the filtering method .
By default the resulting set is a merge of all values returned by sublooks. However the merging behavior can be modified by overriding the delegateAll(long, java.lang.Object) method.

Overrides:
getActions in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
(Merged) array of actions

getContextActions

public Action[] getContextActions(Object representedObject,
                                  Lookup env)
Crates an array of context actions for the node by consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the filtering method .
By default the resulting set is a merge of all values returned by sublooks. However the merging behavior can be modified by overriding the delegateAll(long, java.lang.Object) method.

Overrides:
getContextActions in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
(Merged) array of context actions

getDefaultAction

public Action getDefaultAction(Object representedObject,
                               Lookup env)
Gets the first default action provided by any sublook. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
getDefaultAction in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
First default action returned by some of the sublooks or null

getPropertySets

public Node.PropertySet[] getPropertySets(Object representedObject,
                                          Lookup env)
Creates and array of PropertySets by consulting sublooks. The resulting array (if merging is enabled) contains all sets returned from the sublooks. If set with equal name is contained in array returned from more than one sublook, then the resulting array will contain one set of given name with all properties from the (sub)sets merged.
The set of consulted sublooks is determined by the selector associated with this look and the filtering method .
By default the resulting set is a merge of all values returned by sublooks. However the merging behavior can be modified by overriding the delegateAll(long, java.lang.Object) method.

Overrides:
getPropertySets in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
(Merged) array of PropertySets

getCustomizer

public Component getCustomizer(Object representedObject,
                               Lookup env)
Gets the first customizer component provided by any sublook. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
getCustomizer in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
First customizer component returned by some of the sublooks or null

hasCustomizer

public boolean hasCustomizer(Object representedObject,
                             Lookup env)
Determines if the node has customize element by consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
hasCustomizer in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
true if at least one of the sublooks returns true, false otherwise.

canRename

public boolean canRename(Object representedObject,
                         Lookup env)
Tests whether the node permits renaming by consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
canRename in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
true if at least one of the sublooks returns true, false otherwise.

canDestroy

public boolean canDestroy(Object representedObject,
                          Lookup env)
Tests whether the node permits the destroy operation by consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
canDestroy in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
true if at least one of the sublooks returns true, false otherwise.

canCopy

public boolean canCopy(Object representedObject,
                       Lookup env)
Tests whether the node permits the copy operation by consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
canCopy in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
true if at least one of the sublooks returns true, false otherwise.

canCut

public boolean canCut(Object representedObject,
                      Lookup env)
Tests whether the node permits the cut operation by consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
canCut in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
true if at least one of the sublooks returns true, false otherwise.

getPasteTypes

public PasteType[] getPasteTypes(Object representedObject,
                                 Transferable t,
                                 Lookup env)
Crates an array of allowed PasteTypes by consulting the set of sublooks. The set of consulted sublooks is determined by the selector associated with this look and the filtering method .
By default the resulting set is a merge of all values returned by sublooks. However the merging behavior can be modified by overriding the delegateAll(long, java.lang.Object) method.

Overrides:
getPasteTypes in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
t - The transferable
Returns:
(Merged) array of PasteTypes

getDropType

public 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. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
getDropType in class Look
Parameters:
representedObject - Represented object the look should work with.
t - the transferable
action - the drag'n'drop action to do DnDConstants.ACTION_MOVE, ACTION_COPY, ACTION_LINK
index - index between children the drop occurred at or -1 if not specified
env - Environement for the represented object.
Returns:
First PasteType returned by some of the sublooks or null
See Also:
Look.getDropType(T, java.awt.datatransfer.Transferable, int, int, org.openide.util.Lookup)

clipboardCopy

public Transferable clipboardCopy(Object representedObject,
                                  Lookup env)
                           throws IOException
Gets the first transferable from any sublook which can provide the copy operation. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
clipboardCopy in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
First transferable returned by some of the sublooks or null
Throws:
IOException - If any of the sublooks throws the exception

clipboardCut

public Transferable clipboardCut(Object representedObject,
                                 Lookup env)
                          throws IOException
Gets the first transferable from any sublook which can provide the cut operation. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
clipboardCut in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
First transferable returned by some of the sublooks or null
Throws:
IOException - If any of the sublooks throws the exception

drag

public Transferable drag(Object representedObject,
                         Lookup env)
                  throws IOException
Gets the first transferable from any sublook that can provide the drag operation. Set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
drag in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Returns:
First transferable returned by some of the sublooks or null
Throws:
IOException - If any of the sublooks throws the exception

destroy

public void destroy(Object representedObject,
                    Lookup env)
             throws IOException
Calls the destroy method on all sublooks. The set of sublooks is determined by the selector associated with this look and the filtering method .

Overrides:
destroy in class Look
Parameters:
representedObject - Represented object the look should work with.
env - Environement for the represented object.
Throws:
IOException - If any of the sublooks throws the exception

org.netbeans.modules.looks/2 1.12

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