Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


oracle.jdeveloper.controller
Class NodeActionDelegate

java.lang.Object
  extended by oracle.jdeveloper.controller.NodeActionDelegate

Direct Known Subclasses:
TextNodeActionDelegate, XmlSourceNodeActionDelegate

public abstract class NodeActionDelegate
extends java.lang.Object

An abstract delegate which implements a generic action for Nodes of a specific class.

By default, actions are performed on the node as a whole, so selections within a node (e.g., in the structure pane or in the code editor) are treated the same as explicit selection of the node in the navigator. In this case, the only methods that need to be overridden are doAction(oracle.ide.Context, oracle.ide.model.Element[], int[], oracle.ide.controller.IdeAction) and #undo. If additional state, beyond the node class, needs to be considered when determining whether the action should be enabled, #isEnabledNode should also be overridden.

To specifically perform actions on Element and/or text selections within a node, #isEnabledElements and #doElements and/or #isEnabledText and #doText should be overridden.

Delegates classes must have a public, no-argument constructor and are registered through the NodeActionController.addDelegate(java.lang.Class, java.lang.Class) method.

Both the do and the undo methods are invoked in a background thread and they should not use the command processor, or invoke methods that use the command processor. Some convenience subclasses are provided for commands which use text buffers, the Java model, or the XML model.

The Contexts passed to the delegate specifies the node being processed, the workspace and project which contains it, and the view copied from the context passed to the controller.

See Also:
NodeActionController, TextNodeActionDelegate, JavaSourceNodeActionDelegate, XmlSourceNodeActionDelegate

Constructor Summary
NodeActionDelegate()
           

 

Method Summary
abstract  int[] doAction(Context context, Element[] elements, int[] text, IdeAction action)
          Does the action on a Node.
 boolean isEnabled(IdeAction action, Context context, Element[] elements, int[] text)
          Gets whether an action is enabled for a Node selection.
abstract  void undoAction(Context context, Element[] elements, int[] text, IdeAction action)
          Undoes the action on a node.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

NodeActionDelegate

public NodeActionDelegate()

Method Detail

isEnabled

public boolean isEnabled(IdeAction action,
                         Context context,
                         Element[] elements,
                         int[] text)
Gets whether an action is enabled for a Node selection. As handled by the NodeActionController.update(oracle.ide.controller.IdeAction, oracle.ide.Context) method, the selection represents either the whole node, Elements within a node (e.g., in a structure pane), or a text range within a code editor. The context argument specifies the node and its containing project and workspace. The elements specifies elements selected within the node, or null if none. The text argument specifies the start (inclusive) and end (excluse) offset of the selection, or null if none. If this method returns false, the update method disables the action. If this method returns true, and isEnabled(oracle.ide.controller.IdeAction, oracle.ide.Context, oracle.ide.model.Element[], int[]) for any other nodes in the selection also returns true, the update method enables the action. The default NodeActionDelegate implementation returns true.

Because this method is invoked from the NodeActionController.update(oracle.ide.controller.IdeAction, oracle.ide.Context) method, it should avoid time-consuming computations.

Parameters:
action - The IDE action to be updated.
context - An IDE context specifying the node, project, and workspace.
elements - An array of Elements specifying the selected elements within the node, or null if none.
text - A two element int array specifying the start and end offsets of the selected text within the node, or null if none.
Returns:
true if the action should be enabled for the node.

doAction

public abstract int[] doAction(Context context,
                               Element[] elements,
                               int[] text,
                               IdeAction action)
                        throws java.lang.Exception
Does the action on a Node. This method is invoked on a background thread and should not, in general, invoke any Swing or UI methods.
Parameters:
context - An IDE context specifying the node, project, and workspace.
elements - An array of Elements specifying the selected elements within the node, or null if none.
text - A two element int array specifying the start and end offsets of the selected text within the node, or null if none.
action - The IDE action to do.
Returns:
a two-element int array specifying the start and end offsets of the text to select after the action is done, or null if none.
Throws:
java.lang.Exception

undoAction

public abstract void undoAction(Context context,
                                Element[] elements,
                                int[] text,
                                IdeAction action)
Undoes the action on a node.
Parameters:
context - An IDE context specifying the node, project, and workspace.
elements - An array of Elements specifying the selected elements within the node, or null if none.
text - A two element int array specifying the start and end offset
action - The IDE action to undo.

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


Copyright © 1997, 2012, Oracle. All rights reserved.