IBM Rational Performance Tester SDK

com.ibm.rational.common.test.editor.framework.extensions
Class ExtActionHandler

java.lang.Object
  extended by com.ibm.rational.common.test.editor.framework.extensions.ExtActionHandler
All Implemented Interfaces:
com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler, com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandlerExtension, com.ibm.rational.common.test.editor.framework.kernel.interfaces.IGlobalActionsHandler, com.ibm.rational.common.test.editor.framework.kernel.interfaces.IResetable, com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler, com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITreeSectionActions, IExecutableExtension

public abstract class ExtActionHandler
extends Object
implements com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler, com.ibm.rational.common.test.editor.framework.kernel.interfaces.IResetable, com.ibm.rational.common.test.editor.framework.kernel.interfaces.IGlobalActionsHandler, com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandlerExtension


Field Summary
 String m_mode
           
static short MOVE_HINT_CAN_PASTE
           
static short MOVE_HINT_MOVING_DOWN
           
static short MOVE_HINT_MOVING_NOOP
           
static short MOVE_HINT_MOVING_UP
           
static short REPARENTING_MODE_MOVING
           
static short REPARENTING_MODE_NORMAL
           
 
Fields inherited from interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITreeSectionActions
ACTION_ADD, ACTION_INSERT, ACTION_MOVE_DOWN, ACTION_MOVE_UP, ACTION_REMOVE
 
Constructor Summary
ExtActionHandler()
           
 
Method Summary
protected  String _T(String t)
           
protected  boolean askToMove(String propAsk, String propMove, String key)
           
 boolean canMoveDown(CBActionElement element)
           
 boolean canMoveUp(CBActionElement element)
           
 boolean canRemove(IStructuredSelection ssel)
           
 boolean doCopy(Control focusControl, com.ibm.rational.common.test.editor.framework.ccp.provisional.CopyOperation op)
          Default implementation does not do anything and returns false.
 boolean doCopy(Control focusControl, ISelection selection)
           
 boolean doCut(Control focusControl, com.ibm.rational.common.test.editor.framework.ccp.provisional.CutOperation op)
          Default implementation does not do anything and returns false.
 boolean doCut(Control focusControl, ISelection selection)
           
 boolean doDelete(Control focusControl, ISelection selection)
          Default implementation does not do anything and returns false.
 boolean doMoveDown(IStructuredSelection ssel)
           
 boolean doMoveUp(IStructuredSelection ssel)
           
 boolean doPaste(Control focusControl, com.ibm.rational.common.test.editor.framework.ccp.provisional.OperationDescriptor descriptor)
          This implementation does nothing.
 boolean doPaste(Control focusControl, String text)
           
 boolean doRemove(List ssel)
          This implementation removes selected elements, from their parents' children lists and prompts to relocate deleted element's children.
 boolean doSelectAll(Control focusControl)
           
 boolean doSelectAll(Control focusControl, Clipboard clipboard)
          Default implenetation returns false.
 void flushCachedData()
           
 short getChildValidationMode()
           
 String getMode()
           
 short getMovingHint()
           
 IStructuredSelection getSelection()
           
 TestEditor getTestEditor()
           
 boolean isAddMode()
           
 boolean isCopyEnabled(Control focusControl, ISelection selection)
          By default, copy is enabled and this method returns true.
 boolean isCutEnabled(Control focusControl, ISelection selection)
          Cut is enabled if selecion can be removed from the test.
 boolean isDeleteEnabled(Control focusControl, ISelection selection)
          This method is called by TestRemoveAction.
 boolean isEqualType(String otherType)
           
 boolean isInsertMode()
           
 boolean isPasteEnabled(Control focusControl, com.ibm.rational.common.test.editor.framework.ccp.provisional.OperationDescriptor descriptor)
          This implementation verifies that each and every one of pasted objects is a valid child of the currently selected object, and that the currently selected object is valid parent for every and each of the pasted elements.
 boolean isPasteEnabled(Control focusControl, String text)
           
 boolean isSelectAllEnabled(Control focusControl)
           
 boolean isStatic(CBActionElement element)
           
 boolean isValidChild(String type)
           
 boolean isValidParent2(CBActionElement element)
          For backward compatibility this implementation always returns true
 boolean moveChildren(CBActionElement fromParent, CBActionElement toParent, IStructuredSelection ssel, int position)
           
protected  boolean promptToKeepChildren(CBActionElement parent, int position, CBActionElement removeObject, List children1, List children2)
           
protected  void relocateChildren(CBActionElement newParent, List sourceList, int position)
          Relocate the selection list into a new parent container.
protected  void relocateChildren(List targetList, List sourceList, int position)
          Deprecated. Use relocateChildren(CBActionElement newParent, List sourceList, int position)
 void relocateChildren2(CBActionElement newParent, List sourceList, int position)
           
 short setChildValidationMode(short mode)
           
 void setInitializationData(IConfigurationElement config, String propertyName, Object data)
           
 void setMode(String mode)
           
 void setMovingHint(short movingHint)
           
 void setSelection(IStructuredSelection structuredSelection)
           
 void setTestEditor(TestEditor testEditor)
           
 List sortTreeSelection(List selectedElements, CBActionElement parent)
          Sorts an array of elements obtained from MainSection.TreeView.
 Object[] sortTreeSelection(Object[] selectedElements, List list)
          Sorts an array of elements obtained from MainSection.TreeView.
protected  boolean validateReparenting(CBActionElement toParent, CBActionElement fromParent, int position, List elements1, List elements2)
           
 boolean validateReparentingForMove(CBActionElement toParent, CBActionElement fromParent, int position, List elements1, List elements2)
          This method is called by TestMoveDownAction and TestMoveUpAction when a decision needs to be made if selected elements can be moved inside given parent.
protected  boolean warning(PluginHelper ph, String key, CBActionElement toParent, CBActionElement fromParent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler
createNew, isValidParent
 

Field Detail

m_mode

public String m_mode

MOVE_HINT_MOVING_NOOP

public static final short MOVE_HINT_MOVING_NOOP
See Also:
Constant Field Values

MOVE_HINT_MOVING_DOWN

public static final short MOVE_HINT_MOVING_DOWN
See Also:
Constant Field Values

MOVE_HINT_MOVING_UP

public static final short MOVE_HINT_MOVING_UP
See Also:
Constant Field Values

MOVE_HINT_CAN_PASTE

public static final short MOVE_HINT_CAN_PASTE
See Also:
Constant Field Values

REPARENTING_MODE_NORMAL

public static final short REPARENTING_MODE_NORMAL
See Also:
Constant Field Values

REPARENTING_MODE_MOVING

public static final short REPARENTING_MODE_MOVING
See Also:
Constant Field Values
Constructor Detail

ExtActionHandler

public ExtActionHandler()
Method Detail

setInitializationData

public void setInitializationData(IConfigurationElement config,
                                  String propertyName,
                                  Object data)
                           throws CoreException
Specified by:
setInitializationData in interface IExecutableExtension
Throws:
CoreException

doMoveDown

public boolean doMoveDown(IStructuredSelection ssel)
Specified by:
doMoveDown in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler

doMoveUp

public boolean doMoveUp(IStructuredSelection ssel)
Specified by:
doMoveUp in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler

getTestEditor

public TestEditor getTestEditor()
Returns:
Returns the testEditor.

setTestEditor

public void setTestEditor(TestEditor testEditor)
Parameters:
testEditor - The testEditor to set.

doRemove

public boolean doRemove(List ssel)
This implementation removes selected elements, from their parents' children lists and prompts to relocate deleted element's children.

If this behavior is undesired, or if the content provider of the parent of the deleted element does not return its children in EMF Elist, and the model element is removable, then youmust override this method.
If the children list is not an EMF EList, then @see com.ibm.rational.common.test.editor.framework.extensions.ICoreObjectContainerActionHandler: when the IActionHandler associated to the parent is also a ICoreObjectContainerActionHandler, then doRemove is called to actually remove this element from the parent children list in the extension's model.

Delete only those elements in the selection, which type equals to the type of your action handler.

Specified by:
doRemove in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler
Parameters:
ssel - List. List of selected model elements to be deleted.
Returns:
boolean. true if at least one element was deleted by this handler, false otherwise.
See Also:
IActionHandler.doRemove(java.util.List)

relocateChildren

protected void relocateChildren(List targetList,
                                List sourceList,
                                int position)
Deprecated. Use relocateChildren(CBActionElement newParent, List sourceList, int position)

Parameters:
targetList -
sourceList -
position -

relocateChildren

protected void relocateChildren(CBActionElement newParent,
                                List sourceList,
                                int position)
Relocate the selection list into a new parent container. It iterates through the sourceList of model elements and moves them under the newParent, one at a time, from begining to the end of the list. Each element is placed at the supplied position within the newParent. A position of -1 is interpreted as the end of the list of newParent's children.

Parameters:
newParent - - the CBActionElement that will be the new parent
sourceList - - the list of elemens being relocated
position - - the position within the newParen where the list is being moved

relocateChildren2

public void relocateChildren2(CBActionElement newParent,
                              List sourceList,
                              int position)

canMoveDown

public boolean canMoveDown(CBActionElement element)
Specified by:
canMoveDown in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler
See Also:
IActionHandler.canMoveDown(CBActionElement)

canMoveUp

public boolean canMoveUp(CBActionElement element)
Specified by:
canMoveUp in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler
See Also:
IActionHandler.canMoveUp(CBActionElement)

canRemove

public boolean canRemove(IStructuredSelection ssel)
Specified by:
canRemove in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler

flushCachedData

public void flushCachedData()
Specified by:
flushCachedData in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IResetable

setSelection

public void setSelection(IStructuredSelection structuredSelection)
Parameters:
structuredSelection -

getSelection

public IStructuredSelection getSelection()
Returns:
Returns the selection.

sortTreeSelection

public Object[] sortTreeSelection(Object[] selectedElements,
                                  List list)
Sorts an array of elements obtained from MainSection.TreeView. The sort order is the same as the order obtained from the parent's children list.

Parameters:
selectedElements -
list -
Returns:
Object[]

sortTreeSelection

public List sortTreeSelection(List selectedElements,
                              CBActionElement parent)
Sorts an array of elements obtained from MainSection.TreeView. The sort order is the same as the order obtained from the parent's children list.

Parameters:
selectedElements - List
parent - CBActionElement
Returns:
List

askToMove

protected boolean askToMove(String propAsk,
                            String propMove,
                            String key)
Parameters:
propAsk -
propMove -
key -
Returns:
boolean

promptToKeepChildren

protected boolean promptToKeepChildren(CBActionElement parent,
                                       int position,
                                       CBActionElement removeObject,
                                       List children1,
                                       List children2)
Parameters:
parent - Parent of an object being removed.
position - position (zero-based index) of the removeObject in its parent's children list.
removeObject - object being deleted
children1 - List of children to reparent
children2 - (optional) Second list of children to reparent, or null.
Returns:
boolean
   if( removeObject instanceof CBBlock )
   {
       CBBlock asBlock = (CBBlock)removeObject;
       return asBlock.isControlBlock();
   }
   return false;
 

getMode

public String getMode()
Returns:
Returns the mode.

setMode

public void setMode(String mode)
Parameters:
mode - The mode to set.

isAddMode

public boolean isAddMode()

isInsertMode

public boolean isInsertMode()

validateReparenting

protected boolean validateReparenting(CBActionElement toParent,
                                      CBActionElement fromParent,
                                      int position,
                                      List elements1,
                                      List elements2)

validateReparentingForMove

public boolean validateReparentingForMove(CBActionElement toParent,
                                          CBActionElement fromParent,
                                          int position,
                                          List elements1,
                                          List elements2)
This method is called by TestMoveDownAction and TestMoveUpAction when a decision needs to be made if selected elements can be moved inside given parent. Subclasses may override to provide more specialized behavior.

This implementation simply calls ActionHandlerUtil.validateReparenting(getTestEditor(), toParent, fromParent, position, elements1, elements2, REPARENTING_MODE_MOVING )

Parameters:
toParent - CBActionElement target parent
fromParent - CBActionElement original parent
position - int Proposed position in the target parent list of children
elements1 - First set of moving elements
elements2 - Second set of moving elements, or null
Returns:
boolean.

warning

protected boolean warning(PluginHelper ph,
                          String key,
                          CBActionElement toParent,
                          CBActionElement fromParent)

moveChildren

public boolean moveChildren(CBActionElement fromParent,
                            CBActionElement toParent,
                            IStructuredSelection ssel,
                            int position)

isValidChild

public boolean isValidChild(String type)

_T

protected String _T(String t)

isEqualType

public final boolean isEqualType(String otherType)

doCopy

public boolean doCopy(Control focusControl,
                      com.ibm.rational.common.test.editor.framework.ccp.provisional.CopyOperation op)
Default implementation does not do anything and returns false.

Specified by:
doCopy in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IGlobalActionsHandler

doCut

public boolean doCut(Control focusControl,
                     com.ibm.rational.common.test.editor.framework.ccp.provisional.CutOperation op)
Default implementation does not do anything and returns false.

Specified by:
doCut in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IGlobalActionsHandler

doDelete

public boolean doDelete(Control focusControl,
                        ISelection selection)
Default implementation does not do anything and returns false.

Specified by:
doDelete in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler

doPaste

public boolean doPaste(Control focusControl,
                       com.ibm.rational.common.test.editor.framework.ccp.provisional.OperationDescriptor descriptor)
This implementation does nothing. Client should override if they support pasting.

Typical usage (for inserting pasted elements before or after the selected one):


 List newElements = CutCopyPasteUtil.cloneSelection( descriptor, getTestEditor());
 this.relocateChildren(targetList, newElements, position );
 

Specified by:
doPaste in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IGlobalActionsHandler
Returns:
boolean. This implementation always returns false to allow for default processing.

doSelectAll

public boolean doSelectAll(Control focusControl,
                           Clipboard clipboard)
Default implenetation returns false.

Specified by:
doSelectAll in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler

isCopyEnabled

public boolean isCopyEnabled(Control focusControl,
                             ISelection selection)
By default, copy is enabled and this method returns true.

Specified by:
isCopyEnabled in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler
Returns:
true id copy operation should be enabed, or false if not.

isCutEnabled

public boolean isCutEnabled(Control focusControl,
                            ISelection selection)
Cut is enabled if selecion can be removed from the test. So this implementation calls ExtActionHandler.canRemove(IStructuredSelection) method. Cleints can override to provide customized behavior.

Specified by:
isCutEnabled in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler

isDeleteEnabled

public boolean isDeleteEnabled(Control focusControl,
                               ISelection selection)
This method is called by TestRemoveAction. This implementation calls ExtActionHandler.canRemove(IStructuredSelection)

Specified by:
isDeleteEnabled in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler

isPasteEnabled

public boolean isPasteEnabled(Control focusControl,
                              com.ibm.rational.common.test.editor.framework.ccp.provisional.OperationDescriptor descriptor)
This implementation verifies that each and every one of pasted objects is a valid child of the currently selected object, and that the currently selected object is valid parent for every and each of the pasted elements.

 for( int i = 0; i < pasteElements.length; ++i ){
    CBActionElement pasteObject = (CBActionElement)pasteElements[i];
    ExtActionHandler childHandler = getTestEditor().getProviders( pasteObject ).getActionHandler();
    if( this.isValidChild( pasteObject.getType()) == false || childHandler.isValidParent( parentElement ) == false )
    {
        return false;
    }
 }
 
This should only care about its own ability to paste. It should not attempt to do parent's work.

Specified by:
isPasteEnabled in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IGlobalActionsHandler
See Also:
com.ibm.rational.common.test.editor.framework.kernel.interfaces.IGlobalActionsHandler#isPasteEnabled(org.eclipse.swt.widgets.Control, com.ibm.rational.common.test.editor.framework.ccp.CcpOperation.OperationDescriptor)

isSelectAllEnabled

public boolean isSelectAllEnabled(Control focusControl)
Specified by:
isSelectAllEnabled in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler

doCopy

public boolean doCopy(Control focusControl,
                      ISelection selection)
Specified by:
doCopy in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler

doCut

public boolean doCut(Control focusControl,
                     ISelection selection)
Specified by:
doCut in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler

doPaste

public boolean doPaste(Control focusControl,
                       String text)
Specified by:
doPaste in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler

doSelectAll

public boolean doSelectAll(Control focusControl)
Specified by:
doSelectAll in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler

isPasteEnabled

public boolean isPasteEnabled(Control focusControl,
                              String text)
Specified by:
isPasteEnabled in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler
See Also:
com.ibm.rational.common.test.editor.framework.kernel.interfaces.ITextGlobalActionHandler#isPasteEnabled(org.eclipse.swt.widgets.Control)

isValidParent2

public boolean isValidParent2(CBActionElement element)
For backward compatibility this implementation always returns true


getMovingHint

public short getMovingHint()

setMovingHint

public void setMovingHint(short movingHint)

setChildValidationMode

public short setChildValidationMode(short mode)

getChildValidationMode

public short getChildValidationMode()

isStatic

public boolean isStatic(CBActionElement element)
Specified by:
isStatic in interface com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandlerExtension

IBM Rational Performance Tester SDK

© Copyright IBM Corp. 2012. All rights reserved.