Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

oracle.jdeveloper.uieditor.uicanvas
Class AbstractAssistant

java.lang.Object
  extended by oracle.jdeveloper.uieditor.uicanvas.AbstractAssistant
All Implemented Interfaces:
LayoutAssistant

public abstract class AbstractAssistant
extends java.lang.Object
implements LayoutAssistant

AbstractAssistant provides a base implementation for LayoutAssistant. Subclasses are expected to override the methods according to the behavior of the LayoutManager being modeled.

See Also:
LayoutAssistant

Field Summary
protected static IdeAction MOVE_TO_FIRST_ACTION
           
static javax.swing.JMenuItem MOVE_TO_FIRST_ITEM
           
protected static IdeAction MOVE_TO_LAST_ACTION
           
static javax.swing.JMenuItem MOVE_TO_LAST_ITEM
           
static javax.swing.JMenu ZORDER_MENU
           
 
Fields inherited from interface oracle.jdeveloper.uieditor.uicanvas.LayoutAssistant
TOOLBAR_ITEM, TOOLBAR_ITEM_COUNT
 
Constructor Summary
AbstractAssistant()
           
 
Method Summary
protected  int calcBestZ(CmtModelNode node, CmtModelNode toNode, java.awt.Point location, java.awt.Dimension size, java.awt.Rectangle zBounds)
          Determine the best position in the stacking order of toNode for node given a proposed location and size.
protected  boolean changeZ(CmtModelNode node, CmtModelNode toNode, int z)
          Move a node within its parent to a specific position in the stacking order.
 void cleanupRemovedComponent(CmtModelNode parent)
          A child of a container has been removed.
 void constrainAdd(CmtModelNode toNode, java.awt.Point mouseOrigin, java.awt.Point mousePos, java.awt.Point newPos, java.awt.Dimension newSize)
          Optionally modify size and position of an object being added to conform to the constraints imposed by the LayoutManager being represented.
 java.lang.String constrainMove(CmtModelNode node, CmtModelNode toNode, java.awt.Point mousePos, java.awt.Point mouseOffset, java.awt.Point newPos, java.awt.Dimension newSize)
          Optionally modify size and position of an object being moved to conform to the constraints imposed by the LayoutManager being represented.
 void drawGrid(java.awt.Container host, java.awt.Graphics g)
          Gives some special effects to the container based on the LayoutManager.
 javax.swing.JComponent[] getContextMenuItems(Context context)
          Get an array of JComponent for population onto a ContextMenu.
 javax.swing.JComponent getEffects(UICanvas canvas, java.awt.Container host)
          Get a JComponent whose rendering provides any special effects applicable during object creation, object resize or object move for the LayoutManager being represented.
 java.lang.String getInitializer()
          Get initialization string for use in declaration allocation, else null.
protected  java.lang.Object getKey(java.awt.Component comp)
          Get the sorting key associated with the given Component.
protected static java.util.ArrayList getSelectedSiblings(Context context)
          Convenience method for determining whether the selection of the given Context contains all siblings.
 boolean handleEvent(IdeAction action, Context context)
          Respond to the given user action within the given context.
 boolean hasInitializer()
          Determine whether or not this assistant generates an initialization string for use in the declaration allocation.
 void layoutChanged(CmtModelNode container)
          Layout has been switched.
protected  boolean lessThan(java.lang.Object o1, java.lang.Object o2)
          Determine whether one object is less than another for sorting purposes.
 void prepareAddComponent(CmtModelNode node, CmtModelNode toNode, java.awt.Point location, java.awt.Point offset, java.awt.Dimension size)
          Perform any preparation on a child component that will be added into to a container.
 java.lang.String prepareAddStatus(CmtModelNode node, CmtModelNode toNode, java.awt.Point location, java.awt.Dimension size)
          Return a string for display during the add process.
 void prepareChangeLayout(CmtModelNode parent)
          Perform changes on children of a container to best handle a layout type change.
 java.lang.String prepareMouseMoveStatus(CmtModelNode node, CmtModelNode toNode, java.awt.Point location)
          Return a string for display while the user is moving the mouse over a component.
 void prepareMoveComponent(CmtModelNode node, CmtModelNode toNode, java.awt.Point location, java.awt.Point offset)
          Child is being moved.
 void prepareResizeComponent(CmtModelNode node, SelectionEffects effects, SelectNib nib)
          Perform a requested resize on a child.
 java.lang.String prepareResizeStatus(CmtModelNode node, java.awt.Point location, java.awt.Dimension size)
          Return a string for display during the resize process.
 void prepareSelectComponent(CmtModelNode node, SelectionEffects effects)
          An immedate child node has been selected.
 void prepareSelectDescendant(CmtModelNode parent, CmtModelNode child, SelectionEffects effects)
          A descendant node has been selected.
protected  void raiseChildToView(CmtModelNode parent, CmtModelNode child)
          Raise the child within the parent as necessary such that it will be visible for selection.
protected static void removeBoundsSetting(CmtModelNode node)
          Convenience method for resetting the bounds probery of the given node.
 java.lang.String resizeAction(java.awt.Point location, SelectionEffects effects, SelectNib nib)
          Return a status message string that will be displayed while the user is dragging the nib.
protected  void sort(java.util.ArrayList array, java.util.ArrayList key)
          Sort the objects contained in array using the descriptions contained in key.
protected  java.util.ArrayList sortedNodes(CmtModelNode parent)
          Get a sorted list of a given parent's children.
 boolean update(IdeAction action, Context context)
          Update the enabled state of the given action within the given context.
 boolean usesReverseZOrder()
          Determine whether or not z-order is reversed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface oracle.jdeveloper.uieditor.uicanvas.LayoutAssistant
getConstraintsEditor, getConstraintsType, getPropertyEditor, getToolbarPrefix
 

Field Detail

ZORDER_MENU

public static javax.swing.JMenu ZORDER_MENU

MOVE_TO_FIRST_ITEM

public static javax.swing.JMenuItem MOVE_TO_FIRST_ITEM

MOVE_TO_LAST_ITEM

public static javax.swing.JMenuItem MOVE_TO_LAST_ITEM

MOVE_TO_FIRST_ACTION

protected static IdeAction MOVE_TO_FIRST_ACTION

MOVE_TO_LAST_ACTION

protected static IdeAction MOVE_TO_LAST_ACTION
Constructor Detail

AbstractAssistant

public AbstractAssistant()
Method Detail

hasInitializer

public boolean hasInitializer()
Description copied from interface: LayoutAssistant
Determine whether or not this assistant generates an initialization string for use in the declaration allocation. Implementations of this method should not display any UI. Default is false.

Specified by:
hasInitializer in interface LayoutAssistant

getInitializer

public java.lang.String getInitializer()
Description copied from interface: LayoutAssistant
Get initialization string for use in declaration allocation, else null. Implementing subclasses may display any necessary UI for gathering data before returning a value. A value of null will be interpreted to mean that the declaration should just use the default constructor without any initialization arguments. Default is null.

Specified by:
getInitializer in interface LayoutAssistant

prepareAddComponent

public void prepareAddComponent(CmtModelNode node,
                                CmtModelNode toNode,
                                java.awt.Point location,
                                java.awt.Point offset,
                                java.awt.Dimension size)
Perform any preparation on a child component that will be added into to a container. Typically this involves setting the node's constraint value. The new component has already been added to the container via container.add(component). After the constraint is set by this method and/or the add order of the components manipulated, it will be re-added with the supplied constraint.

Specified by:
prepareAddComponent in interface LayoutAssistant
Parameters:
node - the node being added.
toNode - CmtModelNode receiving the node.
location - the location in the parent.
offset - the mouse down position relative to the node.
size - the size of the component.

prepareMoveComponent

public void prepareMoveComponent(CmtModelNode node,
                                 CmtModelNode toNode,
                                 java.awt.Point location,
                                 java.awt.Point offset)
Child is being moved. Often implemented by calling prepareAddComponent

Specified by:
prepareMoveComponent in interface LayoutAssistant
Parameters:
node - the CmtModelNode that has moved.
toNode - CmtModelNode receiving the node.
location - the new location.
offset - the mouse down position relative to the node.

layoutChanged

public void layoutChanged(CmtModelNode container)
Layout has been switched. Chance for the old Container to clean up its mess. For instance; when switching from null layout, the NullLayoutAssistant uses this call to remove the Bounds property settings for each component in the Container.

Specified by:
layoutChanged in interface LayoutAssistant
Parameters:
container - teh CmtModelNode for the container that has changed.

prepareChangeLayout

public void prepareChangeLayout(CmtModelNode parent)
Perform changes on children of a container to best handle a layout type change. Should set the contraints for each Component in the container. The layout of the container has already been switched when this call is made.

Specified by:
prepareChangeLayout in interface LayoutAssistant
Parameters:
parent - the CmtModelNode for the container that has changed.

prepareResizeComponent

public void prepareResizeComponent(CmtModelNode node,
                                   SelectionEffects effects,
                                   SelectNib nib)
Perform a requested resize on a child. Sets a new constraint value for the node

Specified by:
prepareResizeComponent in interface LayoutAssistant
Parameters:
node - the CmtModelNode that is being resized.
effects - the SelectionEffects associated with the UIEditor upon which the SelectNib appears
nib - the SelectNib that is being manipulated.

prepareResizeStatus

public java.lang.String prepareResizeStatus(CmtModelNode node,
                                            java.awt.Point location,
                                            java.awt.Dimension size)
Return a string for display during the resize process.

Specified by:
prepareResizeStatus in interface LayoutAssistant
Parameters:
node - the node being resized.
location - new Point relative to parent's upper left corner.
size - the size of the new node.
Returns:
A status message.

resizeAction

public java.lang.String resizeAction(java.awt.Point location,
                                     SelectionEffects effects,
                                     SelectNib nib)
Return a status message string that will be displayed while the user is dragging the nib. Called once for each mouse dragged event processed during a resize operation

Specified by:
resizeAction in interface LayoutAssistant
Parameters:
location - new position of the SelectNib being manipulated.
effects - the SelectionEffects associated with the UICanvas upon which the SelectNib appears.
nib - the SelectNib being manipulated.
Returns:
String to display as a status message.

prepareSelectComponent

public void prepareSelectComponent(CmtModelNode node,
                                   SelectionEffects effects)
An immedate child node has been selected. Display selection nibs as desired and raise child to view as necessary via prepareSelectDescendant such that the child will be visible.

Specified by:
prepareSelectComponent in interface LayoutAssistant
Parameters:
node - the selected node.
effects - the SelectionEffects associated with the UICanvas upon which the selection has taken place.
See Also:
prepareSelectDescendant(oracle.jdeveloper.cmt.CmtModelNode, oracle.jdeveloper.cmt.CmtModelNode, oracle.jdeveloper.uieditor.uicanvas.SelectionEffects)

prepareSelectDescendant

public void prepareSelectDescendant(CmtModelNode parent,
                                    CmtModelNode child,
                                    SelectionEffects effects)
A descendant node has been selected. Recursively call up the hierarchy passing the parent as the child and its parent as the parent, then raise the original child within the original parent as necessary such that it will be visible for selection.

Specified by:
prepareSelectDescendant in interface LayoutAssistant
Parameters:
parent - the root of the selection path
child - the branch of the selection path stemming from parent
effects - the SelectionEffects associated with the UICanvas upon which the selection has taken place.

raiseChildToView

protected void raiseChildToView(CmtModelNode parent,
                                CmtModelNode child)
Raise the child within the parent as necessary such that it will be visible for selection. By default does nothing.

Parameters:
parent - the parent containing the child.
child - the child to raise.

prepareAddStatus

public java.lang.String prepareAddStatus(CmtModelNode node,
                                         CmtModelNode toNode,
                                         java.awt.Point location,
                                         java.awt.Dimension size)
Return a string for display during the add process.

Specified by:
prepareAddStatus in interface LayoutAssistant
Parameters:
node - the node about to be added.
toNode - the parent that the node will be added to.
location - new Point relative to parent's upper left corner.
size - the size of the new node.
Returns:
A status message.

prepareMouseMoveStatus

public java.lang.String prepareMouseMoveStatus(CmtModelNode node,
                                               CmtModelNode toNode,
                                               java.awt.Point location)
Return a string for display while the user is moving the mouse over a component. Typically used to identify the node and display the constraint for the component that would be selected if the user were to release the mouse.

Specified by:
prepareMouseMoveStatus in interface LayoutAssistant
Parameters:
node - the node that the mouse is over.
toNode - the parent of the node that the mouse is over.
location - Point relative to parent's upper left corner.
Returns:
A status message.

constrainMove

public java.lang.String constrainMove(CmtModelNode node,
                                      CmtModelNode toNode,
                                      java.awt.Point mousePos,
                                      java.awt.Point mouseOffset,
                                      java.awt.Point newPos,
                                      java.awt.Dimension newSize)
Optionally modify size and position of an object being moved to conform to the constraints imposed by the LayoutManager being represented. This method may be called from the UIEditor during a move operation such that it may provide dynamic feedback to the user depicting the expected bounds of the object throughout the operation.

Specified by:
constrainMove in interface LayoutAssistant
Parameters:
node - node being manipulated.
toNode - parent of node being manipulated.
mousePos - current mouse position relative to toNode.
mouseOffset - mouse position relative to node at beginning of move.
newPos - output parameter for receiving constrained drop location.
newSize - output parameter for receiving constrained drop size.
Returns:
a descriptive message describing the move.

constrainAdd

public void constrainAdd(CmtModelNode toNode,
                         java.awt.Point mouseOrigin,
                         java.awt.Point mousePos,
                         java.awt.Point newPos,
                         java.awt.Dimension newSize)
Optionally modify size and position of an object being added to conform to the constraints imposed by the LayoutManager being represented. This method may be called from the UIEditor during an add operation such that it may provide dynamic feedback to the user depicting the expected bounds of the object throughout the operation.

Specified by:
constrainAdd in interface LayoutAssistant
Parameters:
toNode - parent of node being added.
mouseOrigin - mouse position at start of move operation.
mousePos - current mouse position.
newPos - output parameter for receiving constrained add position.
newSize - output parameter for receiving constrained add size.

cleanupRemovedComponent

public void cleanupRemovedComponent(CmtModelNode parent)
A child of a container has been removed. This offers the LayoutAssistant the chance to clean up any data structures that it keeps for the container.

Specified by:
cleanupRemovedComponent in interface LayoutAssistant
Parameters:
parent - The node that had a child removed.

getEffects

public javax.swing.JComponent getEffects(UICanvas canvas,
                                         java.awt.Container host)
Get a JComponent whose rendering provides any special effects applicable during object creation, object resize or object move for the LayoutManager being represented. The effects object will be added to the UICanvas design surface between the glass pane and the content pane such that the effects will overlap the content. An example might be a simple transparent JPanel whose paint method renders equally spaced grid points in support of an XYLayout or Null layout.

Specified by:
getEffects in interface LayoutAssistant
Parameters:
canvas - UICanvas displaying the GUI
host - Container upon which an object is being added, resized or moved.
Returns:
a special effects object.

usesReverseZOrder

public boolean usesReverseZOrder()
Determine whether or not z-order is reversed. Normally, z-order is based on addition order in that the most recently added child is at the top of the z-order (i.e. would obscure any lower z-order sibling with whom it's bounds overlapped). However, some layouts reverse this in that the most recently added child is at the bottom of the z-order (i.e. would be obscured by any higher z-order siblings with whom it's bounds overlapped).

Specified by:
usesReverseZOrder in interface LayoutAssistant
Returns:
true if uses reverse z-order.

drawGrid

public void drawGrid(java.awt.Container host,
                     java.awt.Graphics g)
Gives some special effects to the container based on the LayoutManager. In case of a FormLayout manager which is based on rows and columns, this method will give the visual effects of rows and column by drawing gird. this is acheived by the paint mehtod of the host container.

Specified by:
drawGrid in interface LayoutAssistant
Parameters:
host - Container upon which the grid is being drawn.
g - Graphics object to draw the gird.

getContextMenuItems

public javax.swing.JComponent[] getContextMenuItems(Context context)
Get an array of JComponent for population onto a ContextMenu. Implementations are expected to return an array which may contain zero or more instances of JComponent. Implementations are expected to handle all associated listener registration on those items.

Specified by:
getContextMenuItems in interface LayoutAssistant
Parameters:
context - the current context.
Returns:
An array of JComponent that will be added to the ContextMenu on behalf of this LayoutAssistant.
See Also:
oracle.ide.ContextMenu

update

public boolean update(IdeAction action,
                      Context context)
Update the enabled state of the given action within the given context.

Specified by:
update in interface LayoutAssistant
Parameters:
action - action whose availability is to be updated.
context - the current context.
Returns:
true if the action was recognized and updated.

handleEvent

public boolean handleEvent(IdeAction action,
                           Context context)
Respond to the given user action within the given context.

Specified by:
handleEvent in interface LayoutAssistant
Parameters:
action - user action to be responded to.
context - context in which action was initiated.
Returns:
true if the action was recognized and handled.

getSelectedSiblings

protected static final java.util.ArrayList getSelectedSiblings(Context context)
Convenience method for determining whether the selection of the given Context contains all siblings. If all CmtModelNode in the selection that represent GUI items share a common parent, then those items will be returned, else an empty list will be returned. CmtModelNode for non Component objects are ignored.

Parameters:
context - selection to consider.
Returns:
a possibly empty list of CmtModelNode.

removeBoundsSetting

protected static final void removeBoundsSetting(CmtModelNode node)
Convenience method for resetting the bounds probery of the given node.

Parameters:
node - the CmtModelNode representing the Compnent whose bounds are to be reset.

calcBestZ

protected int calcBestZ(CmtModelNode node,
                        CmtModelNode toNode,
                        java.awt.Point location,
                        java.awt.Dimension size,
                        java.awt.Rectangle zBounds)
Determine the best position in the stacking order of toNode for node given a proposed location and size.

Parameters:
node - the node whose stacking position is desired.
toNode - the container in which node is to reside.
location - the location of node.
size - the size of node.
zBounds -
Returns:
the stacking position for node in toNode.

changeZ

protected boolean changeZ(CmtModelNode node,
                          CmtModelNode toNode,
                          int z)
Move a node within its parent to a specific position in the stacking order. Called by prepareAddComponent with z being determined by calcBestZ

Parameters:
node - the node to move.
toNode - the container in which node resides.
z - the new position in the stacking order.
Returns:
true if any change was made.

getKey

protected java.lang.Object getKey(java.awt.Component comp)
Get the sorting key associated with the given Component. Called by sortedNodes. Default implementation returns a Point representing the physical center of the Component relative to its parent Container.

Parameters:
comp - the Component for which a sorting key is desired.
Returns:
a sorting key associated with comp.
See Also:
sortedNodes(oracle.jdeveloper.cmt.CmtModelNode)

lessThan

protected boolean lessThan(java.lang.Object o1,
                           java.lang.Object o2)
Determine whether one object is less than another for sorting purposes. Called by sort. Default implementation assumes Point objects and returns true when o1 is less than o2 on the y-axis, or when o1 is equal to o2 on the y-axis but is less than o2 on the x-axis. Returns false otherwise.

Parameters:
o1 - first object to compare.
o2 - second object to compare.
Returns:
true if o1 is less than o2 for sorting purposes.
See Also:
sort(java.util.ArrayList, java.util.ArrayList)

sort

protected void sort(java.util.ArrayList array,
                    java.util.ArrayList key)
Sort the objects contained in array using the descriptions contained in key. Called by sortedNodes and employs lessThan for making sorting decisions.

Parameters:
array - the collection of objects to sort.
key - the sorting criteria of each object in array.
See Also:
sortedNodes(oracle.jdeveloper.cmt.CmtModelNode), lessThan(java.lang.Object, java.lang.Object)

sortedNodes

protected java.util.ArrayList sortedNodes(CmtModelNode parent)
Get a sorted list of a given parent's children. The sorting criteria is based upon the result of getKey called for each underlying Component which are collected in a list and forwarded on to sort along with the CmtModelNode instances for those children.

Parameters:
parent - the parent whose children are to be sorted.
Returns:
a list of sorted CmtModelNode.
See Also:
getKey(java.awt.Component), sort(java.util.ArrayList, java.util.ArrayList)

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-04

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