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

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

org.netbeans.modules.looks/2 1.12

org.netbeans.spi.looks
Class Look<T>

java.lang.Object
  extended by org.netbeans.spi.looks.Look<T>
Direct Known Subclasses:
DefaultLook, ProxyLook

public abstract class Look<T>
extends Object

Base class for all Looks. All methods in the class provide neutral behavior (i.e. do nothing, rerurn null or false).
Extending this class in order to implement a Look requires overriding all methods which should provide some functionality. You may also consider subclassing the adaptor class DefaultLook class, which provides basic implementations for finding Icons and Actions.

Most methods take a Lookup as parameter. This lookup represents environement associated with given represented object. This environement usually contains data from the getLookupItems(T, org.openide.util.Lookup) method. However if more looks cooperate on the same represented object it should contain union of items provided by all cooperating looks.

See Also:
DefaultLook

Field Summary
static long ALL_METHODS
          Mask for enabling (unmasking) all methods
static long CAN_COPY
          Mask for the method canCopy(T, org.openide.util.Lookup).
static long CAN_CUT
          Mask for the method canCut(T, org.openide.util.Lookup).
static long CAN_DESTROY
          Mask for the method canDestroy(T, org.openide.util.Lookup).
static long CAN_RENAME
          Mask for the method canRename(T, org.openide.util.Lookup).
static long CLIPBOARD_COPY
          Mask for the method clipboardCopy(T, org.openide.util.Lookup).
static long CLIPBOARD_CUT
          Mask for the method clipboardCut(T, org.openide.util.Lookup).
static long DESTROY
          Mask for the method destroy(T, org.openide.util.Lookup).
static long DRAG
          Mask for the method drag(T, org.openide.util.Lookup).
static long GET_ACTIONS
          Mask for the method getActions(T, org.openide.util.Lookup).
static long GET_CHILD_OBJECTS
          Mask for the method getChildObjects(T, org.openide.util.Lookup).
static long GET_CONTEXT_ACTIONS
          Mask for the method getContextActions(T, org.openide.util.Lookup).
static long GET_CUSTOMIZER
          Mask for the method getCustomizer(T, org.openide.util.Lookup).
static long GET_DEFAULT_ACTION
          Mask for the method getDefaultAction(T, org.openide.util.Lookup).
static long GET_DISPLAY_NAME
          Mask for the method getDisplayName().
static long GET_DROP_TYPE
          Mask for the method getDropType(T, java.awt.datatransfer.Transferable, int, int, org.openide.util.Lookup).
static long GET_HELP_CTX
          Mask for the method getHelpCtx(T, org.openide.util.Lookup).
static long GET_ICON
          Mask for the method getIcon(T, int, org.openide.util.Lookup).
static long GET_LOOKUP_ITEMS
          Mask for firing Cookie events and providing lookup items
static long GET_NAME
          Mask for the method getName().
static long GET_NEW_TYPES
          Mask for the method getNewTypes(T, org.openide.util.Lookup).
static long GET_OPENED_ICON
          Mask for the method getOpenedIcon(T, int, org.openide.util.Lookup).
static long GET_PASTE_TYPES
          Mask for the method getPasteTypes(T, java.awt.datatransfer.Transferable, org.openide.util.Lookup).
static long GET_PROPERTY_SETS
          Mask for the method getPropertySets(T, org.openide.util.Lookup).
static long GET_SHORT_DESCRIPTION
          Mask for the method getShortDescription(T, org.openide.util.Lookup).
static long HAS_CUSTOMIZER
          Mask for the method hasCustomizer(T, org.openide.util.Lookup).
static long NO_METHODS
          Mask for disabling (masking) all methods
static long RENAME
          Mask for the method rename(T, java.lang.String, org.openide.util.Lookup).
 
Constructor Summary
protected Look(String name)
          Creates new instance of look does no work.
 
Method Summary
protected  void attachTo(T representedObject)
          Overriding this method permits registering listeners on represented objects.
 boolean canCopy(T representedObject, Lookup env)
          Test whether this object permits copying.
 boolean canCut(T representedObject, Lookup env)
          Test whether this object permits cutting.
 boolean canDestroy(T representedObject, Lookup env)
          Test whether this object can be deleted.
 boolean canRename(T representedObject, Lookup env)
          Test whether this object can be renamed.
 Transferable clipboardCopy(T representedObject, Lookup env)
          Called when a object is to be copied to the clipboard.
 Transferable clipboardCut(T representedObject, Lookup env)
          Called when the object is to be cut to the clipboard.
 void destroy(T representedObject, Lookup env)
          Called when object was destroyed.
protected  void detachFrom(T representedObject)
          This method is called when listening on represeted object is no longer needed.
 Transferable drag(T representedObject, Lookup env)
          Called when a drag is started with this object.
protected  void fireChange(T representedObject, long mask)
          Notifies all listeners attached to the representedObject that result(s) of some method(s) changed.
protected  void firePropertyChange(T representedObject, String propertyName)
          Notifies all listeners attached to the representedObject that a property in the PropertySets changed it's value.
 Action[] getActions(T representedObject, Lookup env)
          Get the set of actions associated with the object.
 List<?> getChildObjects(T representedObject, Lookup env)
          Gets objects which are children of the represented object in the hierarchy represented by this Look.
 Action[] getContextActions(T representedObject, Lookup env)
          Get a special set of actions for situations when this object is displayed as a context.
 Component getCustomizer(T representedObject, Lookup env)
          Get the customizer for represented object if available.
 Action getDefaultAction(T representedObject, Lookup env)
          Get the default action for this object.
 String getDisplayName()
          The human presentable name of the look.
 String getDisplayName(T representedObject, Lookup env)
          Gets localized name of the object.
 PasteType getDropType(T representedObject, Transferable t, int action, int index, Lookup env)
          Determine if there is a paste operation that can be performed on provided transferable.
 HelpCtx getHelpCtx(T representedObject, Lookup env)
          Get context help associated with this object.
 Image getIcon(T representedObject, int type, Lookup env)
          Find an icon for this object (in the closed state).
 Collection getLookupItems(T representedObject, Lookup oldEnv)
          Allowes for adding new object into the object's environement passed to other methods as the env parameter.
 String getName()
          Returns name of the look.
 String getName(T representedObject, Lookup env)
          Gets the programmatic name of the object.
 NewType[] getNewTypes(T representedObject, Lookup env)
          Get the new types that user can create from given object.
 Image getOpenedIcon(T representedObject, int type, Lookup env)
          Find an icon for this object (in the open state).
 PasteType[] getPasteTypes(T representedObject, Transferable t, Lookup env)
          Determine which paste operations are allowed when a given transferable is in the clipboard.
 Node.PropertySet[] getPropertySets(T representedObject, Lookup env)
          Get the list of property sets for object.
 String getShortDescription(T representedObject, Lookup env)
          Gets short description for given object.
 boolean hasCustomizer(T representedObject, Lookup env)
          Check whether the customizer for the represented object is available.
 boolean isLeaf(T representedObject, Lookup env)
          Decides whether given object should be a leaf.
 void rename(T representedObject, String newName, Lookup env)
          This method is called when the user renames the object.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL_METHODS

public static final long ALL_METHODS
Mask for enabling (unmasking) all methods

See Also:
Constant Field Values

NO_METHODS

public static final long NO_METHODS
Mask for disabling (masking) all methods

See Also:
Constant Field Values

DESTROY

public static final long DESTROY
Mask for the method destroy(T, org.openide.util.Lookup).

See Also:
Constant Field Values

RENAME

public static final long RENAME
Mask for the method rename(T, java.lang.String, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_LOOKUP_ITEMS

public static final long GET_LOOKUP_ITEMS
Mask for firing Cookie events and providing lookup items

See Also:
Constant Field Values

GET_DISPLAY_NAME

public static final long GET_DISPLAY_NAME
Mask for the method getDisplayName().

See Also:
Constant Field Values

GET_NAME

public static final long GET_NAME
Mask for the method getName().

See Also:
Constant Field Values

GET_SHORT_DESCRIPTION

public static final long GET_SHORT_DESCRIPTION
Mask for the method getShortDescription(T, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_ICON

public static final long GET_ICON
Mask for the method getIcon(T, int, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_OPENED_ICON

public static final long GET_OPENED_ICON
Mask for the method getOpenedIcon(T, int, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_HELP_CTX

public static final long GET_HELP_CTX
Mask for the method getHelpCtx(T, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_CHILD_OBJECTS

public static final long GET_CHILD_OBJECTS
Mask for the method getChildObjects(T, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_NEW_TYPES

public static final long GET_NEW_TYPES
Mask for the method getNewTypes(T, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_ACTIONS

public static final long GET_ACTIONS
Mask for the method getActions(T, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_CONTEXT_ACTIONS

public static final long GET_CONTEXT_ACTIONS
Mask for the method getContextActions(T, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_DEFAULT_ACTION

public static final long GET_DEFAULT_ACTION
Mask for the method getDefaultAction(T, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_PROPERTY_SETS

public static final long GET_PROPERTY_SETS
Mask for the method getPropertySets(T, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_CUSTOMIZER

public static final long GET_CUSTOMIZER
Mask for the method getCustomizer(T, org.openide.util.Lookup).

See Also:
Constant Field Values

CAN_RENAME

public static final long CAN_RENAME
Mask for the method canRename(T, org.openide.util.Lookup).

See Also:
Constant Field Values

CAN_DESTROY

public static final long CAN_DESTROY
Mask for the method canDestroy(T, org.openide.util.Lookup).

See Also:
Constant Field Values

CAN_COPY

public static final long CAN_COPY
Mask for the method canCopy(T, org.openide.util.Lookup).

See Also:
Constant Field Values

CAN_CUT

public static final long CAN_CUT
Mask for the method canCut(T, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_PASTE_TYPES

public static final long GET_PASTE_TYPES
Mask for the method getPasteTypes(T, java.awt.datatransfer.Transferable, org.openide.util.Lookup).

See Also:
Constant Field Values

GET_DROP_TYPE

public static final long GET_DROP_TYPE
Mask for the method getDropType(T, java.awt.datatransfer.Transferable, int, int, org.openide.util.Lookup).

See Also:
Constant Field Values

CLIPBOARD_COPY

public static final long CLIPBOARD_COPY
Mask for the method clipboardCopy(T, org.openide.util.Lookup).

See Also:
Constant Field Values

CLIPBOARD_CUT

public static final long CLIPBOARD_CUT
Mask for the method clipboardCut(T, org.openide.util.Lookup).

See Also:
Constant Field Values

DRAG

public static final long DRAG
Mask for the method drag(T, org.openide.util.Lookup).

See Also:
Constant Field Values

HAS_CUSTOMIZER

public static final long HAS_CUSTOMIZER
Mask for the method hasCustomizer(T, org.openide.util.Lookup).

See Also:
Constant Field Values
Constructor Detail

Look

protected Look(String name)
Creates new instance of look does no work.

Parameters:
name - the name to assign to the look.
Method Detail

getName

public final String getName()
Returns name of the look. This name should identify the look.

Returns:
Name of the look.

getDisplayName

public String getDisplayName()
The human presentable name of the look. Default implementation calls getName();

Returns:
human presentable name

toString

public String toString()
Overrides:
toString in class Object

attachTo

protected void attachTo(T representedObject)
Overriding this method permits registering listeners on represented objects.

If given instance is used in many places (e.g. multiple views are using the look for representing the given object or when the look is used as a sublook in multiple composite looks) attachTo will only be called once per represented object.

Implementors may not wait for any other threads at it may be potentially called from internal lock.

Parameters:
representedObject - Represented object the look should work with.
Throws:
ClassCastException - When the represented object is unacceptable for the look due to wrong class
IllegalArgumentException - When the represented object is unacceptable for other reason than class cast.

detachFrom

protected void detachFrom(T representedObject)
This method is called when listening on represeted object is no longer needed. Make sure to deregister all listeners registered in attachTo(T) method.
If given instance is used in many places (e.g. more views are using the look for representing given object or when the look is used as a sublook in more composite look) the detachFrom method will only be called once per reprsented object.

Implementors may not wait for any other threads at it may be potentially called from internal lock.

Parameters:
representedObject - Represented object to detach from.

getLookupItems

public Collection getLookupItems(T representedObject,
                                 Lookup oldEnv)
Allowes for adding new object into the object's environement passed to other methods as the env parameter.

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

getName

public String getName(T representedObject,
                      Lookup env)
Gets the programmatic name of the object. This name shouldn't be localized.
Notice that the env parameter may be empty in some cases (e.g. when call to this methods is performed during serialization)

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
Programmatic name of the object.

getDisplayName

public String getDisplayName(T representedObject,
                             Lookup env)
Gets localized name of the object.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
Localized name of the object.

rename

public void rename(T representedObject,
                   String newName,
                   Lookup env)
            throws IOException
This method is called when the user renames the object.

Parameters:
representedObject - Represented object to be renamed.
newName - The new name set by the user.
env - Environment for the represented object.
Throws:
IOException

getShortDescription

public String getShortDescription(T representedObject,
                                  Lookup env)
Gets short description for given object. The short description is usually visualized as a tooltip, but may have another forms as well.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
A localized short description of the object.

getIcon

public Image getIcon(T representedObject,
                     int type,
                     Lookup env)
Find an icon for this object (in the closed state).

Parameters:
representedObject - Represented object the look should work with.
type - Constant from BeanInfo
env - Environment for the represented object.
Returns:
Icon to use to represent the object in the closed state.

getOpenedIcon

public Image getOpenedIcon(T representedObject,
                           int type,
                           Lookup env)
Find an icon for this object (in the open state). This icon is used when the object may have children and is expanded.

Parameters:
representedObject - Represented object the look should work with.
type - Constant from BeanInfo
env - Environment for the represented object.
Returns:
Icon to use to represent the object in the open state.

getHelpCtx

public HelpCtx getHelpCtx(T representedObject,
                          Lookup env)
Get context help associated with this object.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
The context help object (could be null or HelpCtx.DEFAULT_HELP)

getChildObjects

public List<?> getChildObjects(T representedObject,
                               Lookup env)
Gets objects which are children of the represented object in the hierarchy represented by this Look.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
List of objects which should be represented as node children of the node, can return null.

isLeaf

public boolean isLeaf(T representedObject,
                      Lookup env)
Decides whether given object should be a leaf. I.e. if the visual representation of the object should be expandable.

Notice : Implementation of this method must be consistent with implementation of getChildObjects(T, org.openide.util.Lookup). Notice that you can switch the form LEAF to nonLEAF node and vice versa by calling fireChange(T, long) with parameter GET_CHILD_OBJECTS, which in turn will call isLeaf(...) and eventually getChildObjects(...) where you can return new value.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
true if the object should be unexpandable false otherwise.

getNewTypes

public NewType[] getNewTypes(T representedObject,
                             Lookup env)
Get the new types that user can create from given object. For example, a a Java package will permit classes to be added.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
Array of new type operations that are allowed, can return null that is equivalent to empty array

getActions

public Action[] getActions(T representedObject,
                           Lookup env)
Get the set of actions associated with the object. This may be used for in constructing popup menus etc.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
Array of the Actions applicable to the node or null if actions in NodeOp.getDefaultActions() should be used.

getContextActions

public Action[] getContextActions(T representedObject,
                                  Lookup env)
Get a special set of actions for situations when this object is displayed as a context. (E.g. right clicking in the empty area of a tree)

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
Actions for a context.

getDefaultAction

public Action getDefaultAction(T representedObject,
                               Lookup env)
Get the default action for this object. This action can but need not be one from the list returned from getActions(T, org.openide.util.Lookup).

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
Default action, or null if there should be none.

getPropertySets

public Node.PropertySet[] getPropertySets(T representedObject,
                                          Lookup env)
Get the list of property sets for object. E.g. typically there may be one for normal Bean properties, one for expert properties, and one for hidden properties.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
Property sets for the object, can return null that is equivalent to empty array

hasCustomizer

public boolean hasCustomizer(T representedObject,
                             Lookup env)
Check whether the customizer for the represented object is available. If so, the method getCustomizer should return non-null value.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
true if the customizer is available, false otherwise

getCustomizer

public Component getCustomizer(T representedObject,
                               Lookup env)
Get the customizer for represented object if available.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
The component, or null if there is no customizer.

canRename

public boolean canRename(T representedObject,
                         Lookup env)
Test whether this object can be renamed. If true, rename(T, java.lang.String, org.openide.util.Lookup) will be called when the user changes the name of the node.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
true if the node object be renamed.

canDestroy

public boolean canDestroy(T representedObject,
                          Lookup env)
Test whether this object can be deleted.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
True if can be deleted.

canCopy

public boolean canCopy(T representedObject,
                       Lookup env)
Test whether this object permits copying.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
True if so.

canCut

public boolean canCut(T representedObject,
                      Lookup env)
Test whether this object permits cutting.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
True if so.

getPasteTypes

public PasteType[] getPasteTypes(T representedObject,
                                 Transferable t,
                                 Lookup env)
Determine which paste operations are allowed when a given transferable is in the clipboard. For example, a Java package will permit classes to be pasted into it.

Parameters:
representedObject - Represented object the look should work with.
t - The transferable in the clipboard.
env - Environment for the represented object.
Returns:
Array of operations that are allowed, can return null that is equivalent to empty array

getDropType

public PasteType getDropType(T representedObject,
                             Transferable t,
                             int action,
                             int index,
                             Lookup env)
Determine if there is a paste operation that can be performed on provided transferable. Used by drag'n'drop code to check whether the drop is possible.

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 occured at or -1 if not specified.
env - Environment for the represented object.
Returns:
Null if the transferable cannot be accepted or the paste type to execute when the drop occurs.

clipboardCopy

public Transferable clipboardCopy(T representedObject,
                                  Lookup env)
                           throws IOException
Called when a object is to be copied to the clipboard.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
The transferable object representing the content of the clipboard.
Throws:
IOException - When the copy cannot be performed.

clipboardCut

public Transferable clipboardCut(T representedObject,
                                 Lookup env)
                          throws IOException
Called when the object is to be cut to the clipboard.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
The transferable object representing the content of the clipboard.
Throws:
IOException - When the copy cannot be performed.

drag

public Transferable drag(T representedObject,
                         Lookup env)
                  throws IOException
Called when a drag is started with this object. The object can attach a transfer listener to ExTransferable and will be then notified about progress of the drag (accept/reject).

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Returns:
Transferable to represent this object during a drag.
Throws:
IOException - If a drag cannot be started.

destroy

public void destroy(T representedObject,
                    Lookup env)
             throws IOException
Called when object was destroyed.

Parameters:
representedObject - Represented object the look should work with.
env - Environment for the represented object.
Throws:
IOException - If reflecting the destroy action in underlying data fails for some reason.

fireChange

protected final void fireChange(T representedObject,
                                long mask)
Notifies all listeners attached to the representedObject that result(s) of some method(s) changed. The mask patameter contains bit mask of the methods.

Parameters:
representedObject - the object that has changed
mask - Bit mask of methods which's result changed. See Look for the constants

firePropertyChange

protected final void firePropertyChange(T representedObject,
                                        String propertyName)
Notifies all listeners attached to the representedObject that a property in the PropertySets changed it's value.

Parameters:
representedObject - the object that has changed
propertyName - Name of the property

org.netbeans.modules.looks/2 1.12

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