org.netbeans.spi.viewmodel/2 1.32.1

org.netbeans.spi.viewmodel
Class Models.CompoundModel

java.lang.Object
  extended by org.netbeans.spi.viewmodel.Models.CompoundModel
All Implemented Interfaces:
CheckNodeModel, DnDNodeModel, ExtendedNodeModel, Model, NodeActionsProvider, NodeModel, ReorderableTreeModel, TableModel, TableRendererModel, TreeExpansionModel, TreeModel
Enclosing class:
Models

public static final class Models.CompoundModel
extends Object
implements ReorderableTreeModel, ExtendedNodeModel, CheckNodeModel, DnDNodeModel, NodeActionsProvider, TableModel, TreeExpansionModel, TableRendererModel

This model encapsulates all currently supported models.

See Also:
Models.createCompoundModel(java.util.List)

Field Summary
 
Fields inherited from interface org.netbeans.spi.viewmodel.TreeModel
ROOT
 
Method Summary
 void addModelListener(ModelListener l)
          Registers given listener.
 Executor asynchronous(AsynchronousModelFilter.CALL asynchCall, Object node)
           
 boolean canCopy(Object node)
          Test whether this node permits copying.
 boolean canCut(Object node)
          Test whether this node permits cutting.
 boolean canEditCell(Object node, String columnID)
          Test whether this renderer can edit the given cell.
 boolean canRename(Object node)
          Test whether this node permits renaming.
 boolean canRenderCell(Object node, String columnID)
          Test whether this renderer can render the given cell.
 boolean canReorder(Object parent)
          Provide if this model implementation can reorder children nodes.
 Transferable clipboardCopy(Object node)
          Called when a node is to be copied to the clipboard.
 Transferable clipboardCut(Object node)
          Called when a node is to be cut to the clipboard.
 Transferable drag(Object node)
          Initiate a drag operation.
 Action[] getActions(Object node)
          Returns set of actions for given node.
 int getAllowedDragActions()
          Action constants from DnDConstants.
 int getAllowedDropActions(Transferable t)
          Action constants from DnDConstants.
 TableCellEditor getCellEditor(Object node, String columnID)
          Get the editor of the given cell
 TableCellRenderer getCellRenderer(Object node, String columnID)
          Get the renderer of the given cell
 Object[] getChildren(Object parent, int from, int to)
          Returns children for given parent on given indexes.
 int getChildrenCount(Object node)
          Returns number of children for given node.
 ColumnModel[] getColumns()
          Returns sorted array of ColumnModels.
 String getDisplayName(Object node)
          Returns display name for given node.
 PasteType getDropType(Object node, Transferable t, int action, int index)
          Determines if there is a paste operation that can be performed on provided transferable when drop is done.
 String getHelpId()
          Get a help ID for this model.
 String getIconBase(Object node)
          Returns icon for given node.
 String getIconBaseWithExtension(Object node)
          Returns icon resource with extension for given node.
 PasteType[] getPasteTypes(Object node, Transferable t)
          Determine which paste operations are allowed when a given transferable is in the clipboard.
 Object getRoot()
          Returns the root node of the tree or null, if the tree is empty.
 String getShortDescription(Object node)
          Returns tooltip for given node.
 Object getValueAt(Object node, String columnID)
          Returns value to be displayed in column columnID and row identified by node.
 boolean isCheckable(Object node)
          Tell the renderer to display the check-box.
 boolean isCheckEnabled(Object node)
          Provide the enabled state of the check-box.
 boolean isExpanded(Object node)
          Defines default state (collapsed, expanded) of given node.
 boolean isLeaf(Object node)
          Returns true if node is leaf.
 boolean isReadOnly(Object node, String columnID)
          Returns true if value displayed in column columnID and row node is read only.
 Boolean isSelected(Object node)
          Provide the selected state of the check-box.
 void nodeCollapsed(Object node)
          Called when given node is collapsed.
 void nodeExpanded(Object node)
          Called when given node is expanded.
 void performDefaultAction(Object node)
          Performs default action for given node.
 void removeModelListener(ModelListener l)
          Unregisters given listener.
 void reorder(Object parent, int[] perm)
          Reorder children nodes with a given permutation.
 void setName(Object node, String name)
          Sets a new name for given node.
 void setSelected(Object node, Boolean selected)
          Called by the renderer when the check-box gets selected/unselected
 void setValueAt(Object node, String columnID, Object value)
          Changes a value displayed in column columnID and row node.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getHelpId

public String getHelpId()
Get a help ID for this model.

Returns:
The help ID defined for the properties sheets, or null.
Since:
1.7

getRoot

public Object getRoot()
Returns the root node of the tree or null, if the tree is empty.

Specified by:
getRoot in interface TreeModel
Returns:
the root node of the tree or null

getChildren

public Object[] getChildren(Object parent,
                            int from,
                            int to)
                     throws UnknownTypeException
Returns children for given parent on given indexes.

Specified by:
getChildren in interface TreeModel
Parameters:
parent - a parent of returned nodes
from - a start index
to - a end index
Returns:
children for given parent on given indexes
Throws:
UnknownTypeException - if this TreeModel implementation is not able to resolve dchildren for given node type
See Also:
TreeModel.getChildrenCount(java.lang.Object)

getChildrenCount

public int getChildrenCount(Object node)
                     throws UnknownTypeException
Returns number of children for given node.

Specified by:
getChildrenCount in interface TreeModel
Parameters:
node - the parent node
Returns:
true if node is leaf
Throws:
UnknownTypeException - if this TreeModel implementation is not able to resolve children for given node type
See Also:
TreeModel.getChildren(java.lang.Object, int, int)

isLeaf

public boolean isLeaf(Object node)
               throws UnknownTypeException
Returns true if node is leaf.

Specified by:
isLeaf in interface TreeModel
Returns:
true if node is leaf
Throws:
UnknownTypeException - if this TreeModel implementation is not able to resolve dchildren for given node type

canReorder

public boolean canReorder(Object parent)
                   throws UnknownTypeException
Description copied from interface: ReorderableTreeModel
Provide if this model implementation can reorder children nodes.

Specified by:
canReorder in interface ReorderableTreeModel
Parameters:
parent - The parent node of children that are test for reorder
Returns:
true if this model can handle reordering of children, false otherwise
Throws:
UnknownTypeException - if this model implementation is not able to decide the reorder capability for given node type

reorder

public void reorder(Object parent,
                    int[] perm)
             throws UnknownTypeException
Description copied from interface: ReorderableTreeModel
Reorder children nodes with a given permutation.

Specified by:
reorder in interface ReorderableTreeModel
Parameters:
parent - The parent node of children that are being reordered
perm - permutation with the length of current child nodes. The permutation lists the new positions of the original nodes, that is, for nodes [A,B,C,D] and permutation [0,3,1,2], the final order would be [A,C,D,B].
Throws:
UnknownTypeException - if this model implementation is not able to perform the reorder for given node type

getDisplayName

public String getDisplayName(Object node)
                      throws UnknownTypeException
Returns display name for given node.

Specified by:
getDisplayName in interface NodeModel
Returns:
display name for given node
Throws:
UnknownTypeException - if this NodeModel implementation is not able to resolve display name for given node type

getShortDescription

public String getShortDescription(Object node)
                           throws UnknownTypeException
Returns tooltip for given node.

Specified by:
getShortDescription in interface NodeModel
Returns:
tooltip for given node
Throws:
UnknownTypeException - if this NodeModel implementation is not able to resolve tooltip for given node type

getIconBase

public String getIconBase(Object node)
                   throws UnknownTypeException
Returns icon for given node.

Specified by:
getIconBase in interface NodeModel
Returns:
icon for given node
Throws:
UnknownTypeException - if this NodeModel implementation is not able to resolve icon for given node type

performDefaultAction

public void performDefaultAction(Object node)
                          throws UnknownTypeException
Performs default action for given node.

Specified by:
performDefaultAction in interface NodeActionsProvider
Throws:
UnknownTypeException - if this NodeActionsProvider implementation is not able to resolve actions for given node type

getActions

public Action[] getActions(Object node)
                    throws UnknownTypeException
Returns set of actions for given node.

Specified by:
getActions in interface NodeActionsProvider
Returns:
display name for given node
Throws:
UnknownTypeException - if this NodeActionsProvider implementation is not able to resolve actions for given node type

getColumns

public ColumnModel[] getColumns()
Returns sorted array of ColumnModels.

Returns:
sorted array of ColumnModels

getValueAt

public Object getValueAt(Object node,
                         String columnID)
                  throws UnknownTypeException
Description copied from interface: TableModel
Returns value to be displayed in column columnID and row identified by node. Column ID is defined in by ColumnModel.getID(), and rows are defined by values returned from TreeModel.getChildren(java.lang.Object, int, int).

Specified by:
getValueAt in interface TableModel
Parameters:
node - a object returned from TreeModel.getChildren(java.lang.Object, int, int) for this row
columnID - a id of column defined by ColumnModel.getID()
Returns:
value of variable representing given position in tree table.
Throws:
UnknownTypeException - if there is no TableModel defined for given parameter type

isReadOnly

public boolean isReadOnly(Object node,
                          String columnID)
                   throws UnknownTypeException
Description copied from interface: TableModel
Returns true if value displayed in column columnID and row node is read only. Column ID is defined in by ColumnModel.getID(), and rows are defined by values returned from TreeModel.getChildren(java.lang.Object, int, int).

Specified by:
isReadOnly in interface TableModel
Parameters:
node - a object returned from TreeModel.getChildren(java.lang.Object, int, int) for this row
columnID - a id of column defined by ColumnModel.getID()
Returns:
true if variable on given position is read only
Throws:
UnknownTypeException - if there is no TableModel defined for given parameter type

setValueAt

public void setValueAt(Object node,
                       String columnID,
                       Object value)
                throws UnknownTypeException
Description copied from interface: TableModel
Changes a value displayed in column columnID and row node. Column ID is defined in by ColumnModel.getID(), and rows are defined by values returned from TreeModel.getChildren(java.lang.Object, int, int).

Specified by:
setValueAt in interface TableModel
Parameters:
node - a object returned from TreeModel.getChildren(java.lang.Object, int, int) for this row
columnID - a id of column defined by ColumnModel.getID()
value - a new value of variable on given position
Throws:
UnknownTypeException - if there is no TableModel defined for given parameter type

isExpanded

public boolean isExpanded(Object node)
                   throws UnknownTypeException
Defines default state (collapsed, expanded) of given node.

Specified by:
isExpanded in interface TreeExpansionModel
Parameters:
node - a node
Returns:
default state (collapsed, expanded) of given node
Throws:
UnknownTypeException

nodeExpanded

public void nodeExpanded(Object node)
Called when given node is expanded.

Specified by:
nodeExpanded in interface TreeExpansionModel
Parameters:
node - a expanded node

nodeCollapsed

public void nodeCollapsed(Object node)
Called when given node is collapsed.

Specified by:
nodeCollapsed in interface TreeExpansionModel
Parameters:
node - a collapsed node

addModelListener

public void addModelListener(ModelListener l)
Registers given listener.

Specified by:
addModelListener in interface NodeModel
Specified by:
addModelListener in interface TableModel
Specified by:
addModelListener in interface TableRendererModel
Specified by:
addModelListener in interface TreeModel
Parameters:
l - the listener to add

removeModelListener

public void removeModelListener(ModelListener l)
Unregisters given listener.

Specified by:
removeModelListener in interface NodeModel
Specified by:
removeModelListener in interface TableModel
Specified by:
removeModelListener in interface TableRendererModel
Specified by:
removeModelListener in interface TreeModel
Parameters:
l - the listener to remove

toString

public String toString()
Overrides:
toString in class Object

canRename

public boolean canRename(Object node)
                  throws UnknownTypeException
Description copied from interface: ExtendedNodeModel
Test whether this node permits renaming.

Specified by:
canRename in interface ExtendedNodeModel
Returns:
true if so
Throws:
UnknownTypeException

canCopy

public boolean canCopy(Object node)
                throws UnknownTypeException
Description copied from interface: ExtendedNodeModel
Test whether this node permits copying.

Specified by:
canCopy in interface ExtendedNodeModel
Returns:
true if so
Throws:
UnknownTypeException

canCut

public boolean canCut(Object node)
               throws UnknownTypeException
Description copied from interface: ExtendedNodeModel
Test whether this node permits cutting.

Specified by:
canCut in interface ExtendedNodeModel
Returns:
true if so
Throws:
UnknownTypeException

clipboardCopy

public Transferable clipboardCopy(Object node)
                           throws IOException,
                                  UnknownTypeException
Description copied from interface: ExtendedNodeModel
Called when a node is to be copied to the clipboard.

Specified by:
clipboardCopy in interface ExtendedNodeModel
Parameters:
node - The node object
Returns:
the transferable object representing the content of the clipboard
Throws:
IOException - when the copy cannot be performed
UnknownTypeException

clipboardCut

public Transferable clipboardCut(Object node)
                          throws IOException,
                                 UnknownTypeException
Description copied from interface: ExtendedNodeModel
Called when a node is to be cut to the clipboard.

Specified by:
clipboardCut in interface ExtendedNodeModel
Parameters:
node - The node object
Returns:
the transferable object representing the content of the clipboard
Throws:
IOException - when the cut cannot be performed
UnknownTypeException

getAllowedDragActions

public int getAllowedDragActions()
Description copied from interface: DnDNodeModel
Action constants from DnDConstants. No actions are allowed by default.

Specified by:
getAllowedDragActions in interface DnDNodeModel
Returns:
int representing set of actions which are allowed when dragging from asociated component.

getAllowedDropActions

public int getAllowedDropActions(Transferable t)
Description copied from interface: DnDNodeModel
Action constants from DnDConstants. No actions are allowed by default.

Specified by:
getAllowedDropActions in interface DnDNodeModel
Parameters:
t - The transferable for which the allowed drop actions are requested, or null to get actions for the creation of DropTarget for the view.
Returns:
int representing set of actions which are allowed when dropping the transferable into the asociated component.

drag

public Transferable drag(Object node)
                  throws IOException,
                         UnknownTypeException
Description copied from interface: DnDNodeModel
Initiate a drag operation.

Specified by:
drag in interface DnDNodeModel
Parameters:
node - The node to drag
Returns:
transferable to represent this node during a drag
Throws:
IOException - when the drag cannot be performed
UnknownTypeException - if this model implementation is not able to perform drag for given node type

getPasteTypes

public PasteType[] getPasteTypes(Object node,
                                 Transferable t)
                          throws UnknownTypeException
Description copied from interface: ExtendedNodeModel
Determine which paste operations are allowed when a given transferable is in the clipboard. For example, a node representing a Java package will permit classes to be pasted into it.

Specified by:
getPasteTypes in interface ExtendedNodeModel
Parameters:
node - The node object
t - the transferable in the clipboard
Returns:
array of operations that are allowed
Throws:
UnknownTypeException

getDropType

public PasteType getDropType(Object node,
                             Transferable t,
                             int action,
                             int index)
                      throws UnknownTypeException
Description copied from interface: DnDNodeModel
Determines if there is a paste operation that can be performed on provided transferable when drop is done.

Specified by:
getDropType in interface DnDNodeModel
Parameters:
node - The node where to drop
t - the transferable to drop
action - the Drag and Drop action from DnDConstants
index - index between children the drop occured at or -1 if not specified
Returns:
null if the transferable cannot be accepted
Throws:
UnknownTypeException - if this model implementation is not able to perform drop for given node type

setName

public void setName(Object node,
                    String name)
             throws UnknownTypeException
Description copied from interface: ExtendedNodeModel
Sets a new name for given node.

Specified by:
setName in interface ExtendedNodeModel
Parameters:
node - The object to set the new name to.
name - The new name for the given node
Throws:
UnknownTypeException

getIconBaseWithExtension

public String getIconBaseWithExtension(Object node)
                                throws UnknownTypeException
Description copied from interface: ExtendedNodeModel
Returns icon resource with extension for given node. This is the preferred way of icon specification over org.netbeans.spi.viewmodel.NodeModel.getIconBase

Specified by:
getIconBaseWithExtension in interface ExtendedNodeModel
Parameters:
node - The node object
Returns:
The base resouce name with extension (no initial slash)
Throws:
UnknownTypeException - if this NodeModel implementation is not able to resolve icon for given node type

isCheckable

public boolean isCheckable(Object node)
                    throws UnknownTypeException
Description copied from interface: CheckNodeModel
Tell the renderer to display the check-box.

Specified by:
isCheckable in interface CheckNodeModel
Parameters:
node - the tree node object
Returns:
true if the check-box should be displayed, false otherwise.
Throws:
UnknownTypeException

isCheckEnabled

public boolean isCheckEnabled(Object node)
                       throws UnknownTypeException
Description copied from interface: CheckNodeModel
Provide the enabled state of the check-box.

Specified by:
isCheckEnabled in interface CheckNodeModel
Parameters:
node - the tree node object
Returns:
true if the check-box should be enabled, false otherwise.
Throws:
UnknownTypeException

isSelected

public Boolean isSelected(Object node)
                   throws UnknownTypeException
Description copied from interface: CheckNodeModel
Provide the selected state of the check-box.

Specified by:
isSelected in interface CheckNodeModel
Parameters:
node - the tree node object
Returns:
true if the check-box should be selected, false if it should be unselected and null if the state is unknown.
Throws:
UnknownTypeException

setSelected

public void setSelected(Object node,
                        Boolean selected)
                 throws UnknownTypeException
Description copied from interface: CheckNodeModel
Called by the renderer when the check-box gets selected/unselected

Specified by:
setSelected in interface CheckNodeModel
Parameters:
node - the tree node object
selected - true if the check-box was selected, false if the check-box was unselected.
Throws:
UnknownTypeException

asynchronous

public Executor asynchronous(AsynchronousModelFilter.CALL asynchCall,
                             Object node)
                      throws UnknownTypeException
Throws:
UnknownTypeException

canRenderCell

public boolean canRenderCell(Object node,
                             String columnID)
                      throws UnknownTypeException
Description copied from interface: TableRendererModel
Test whether this renderer can render the given cell.

Specified by:
canRenderCell in interface TableRendererModel
Parameters:
node - Tree node representing the row
columnID - The column name
Returns:
true if the implementation can render the given cell, false otherwise
Throws:
UnknownTypeException - If the implementation can not decide whether to render the given cell.

getCellRenderer

public TableCellRenderer getCellRenderer(Object node,
                                         String columnID)
                                  throws UnknownTypeException
Description copied from interface: TableRendererModel
Get the renderer of the given cell

Specified by:
getCellRenderer in interface TableRendererModel
Parameters:
node - Tree node representing the row
columnID - The column name
Returns:
The cell renderer
Throws:
UnknownTypeException - If the implementation can not render the given cell.

canEditCell

public boolean canEditCell(Object node,
                           String columnID)
                    throws UnknownTypeException
Description copied from interface: TableRendererModel
Test whether this renderer can edit the given cell.

Specified by:
canEditCell in interface TableRendererModel
Parameters:
node - Tree node representing the row
columnID - The column name
Returns:
true if the implementation can edit the given cell, false otherwise
Throws:
UnknownTypeException - If the implementation can not decide whether to edit the given cell.

getCellEditor

public TableCellEditor getCellEditor(Object node,
                                     String columnID)
                              throws UnknownTypeException
Description copied from interface: TableRendererModel
Get the editor of the given cell

Specified by:
getCellEditor in interface TableRendererModel
Parameters:
node - Tree node representing the row
columnID - The column name
Returns:
The cell editor
Throws:
UnknownTypeException - If the implementation can not edit the given cell.

org.netbeans.spi.viewmodel/2 1.32.1

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.