public class NewModelElementAction extends BaseSelectionListenerAction implements ArmListener
Modifier and Type | Field and Description |
---|---|
static int |
ADD
constant indicating that this action adds, rather then inserts new
elements
|
protected List<com.ibm.rational.common.test.editor.framework.change.IAddChangeContext> |
parentContexts |
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT
Constructor and Description |
---|
NewModelElementAction()
Create an action for creating a specific model element type.
|
NewModelElementAction(String type)
Create an action for model element type
type . |
NewModelElementAction(String type,
boolean loadExtensions)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addChild(List<CBActionElement> children,
CBActionElement child)
Deprecated.
This method is no longer called.
|
protected com.ibm.rational.common.test.editor.framework.change.AddChangeResult |
addChildren(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context,
List<CBActionElement> children)
This implementation invokes the method
IContainerActionHandler#addChildren(IAddChangeContext, com.ibm.rational.common.test.editor.framework.kernel.interfaces.IAddedElementDescriptor)
on the action handler of the parent element. |
void |
cancelDropOperation()
Cancels any drop operation announced through
NewModelElementAction.startDropOperation(CBActionElement, ISelection) . |
protected void |
clearCache() |
protected com.ibm.rational.common.test.editor.framework.change.IEditorChange |
createAddChange() |
protected com.ibm.rational.common.test.editor.framework.change.IEditorChange |
createAddChange(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context) |
protected CBActionElement |
createChild(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context) |
protected List<CBActionElement> |
createChildren(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context)
This method may create one or more children for the specified parent.
|
protected CBActionElement |
createNewModelObject(CBActionElement parent)
Deprecated.
This method is not called any more.
|
protected CBActionElement |
createNewModelObject(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context)
Create a new instance of the model object.
|
protected CBActionElement |
doCreate(CBActionElement parent)
Deprecated.
This method is not called any more. It is replaced partially
by
NewModelElementAction.createChild(IAddChangeContext) and partially by
NewModelElementAction.addChildren(IAddChangeContext, List) .
NewModelElementAction.createNewModelObject(IAddChangeContext) may also be
a replacement candidates as some protocols used to mistakenly
override this method instead of
NewModelElementAction.createNewModelObject(CBActionElement) . |
int |
getInsertPoint() |
com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler |
getMyActionHandler() |
List<CBActionElement> |
getNewElements() |
TestEditor |
getTestEditor() |
protected void |
init()
Extracts text and image descriptor from
ExtLabelProvider>/code> |
boolean |
isRefreshEnabled() |
protected boolean |
isValidParent(Object object)
This method is called from
updateSelection and is used to
determine whether this action should be enabled or disabled. |
protected void |
refreshTest(CBActionElement parent,
CBActionElement child) |
protected void |
refreshTest(CBActionElement parent,
List<CBActionElement> children) |
void |
run()
Calls
doCreate method, and refreshes the Test in the tree. |
void |
setInsertPoint(int insertPoint)
Set dynamically by test editor framework as selection in the editor tree
changes.
|
void |
setRefreshEnabled(boolean refreshEnabled) |
void |
setTestEditor(TestEditor editor) |
void |
startDropOperation(CBActionElement target,
ISelection droppedElements)
Verifies if a specific drag and drop operation is allowed for the
specified argument.
|
boolean |
updateSelection(IStructuredSelection selection)
This method is called by editor framework when selection changes in the
editor's tree or when the editor become active.
|
void |
widgetArmed(ArmEvent e) |
getStructuredSelection, runWithEvent, selectionChanged, selectionChanged
convertAccelerator, convertAccelerator, findKeyCode, findKeyString, findModifier, findModifierString, getAccelerator, getActionDefinitionId, getDescription, getDisabledImageDescriptor, getHelpListener, getHoverImageDescriptor, getId, getImageDescriptor, getMenuCreator, getStyle, getText, getToolTipText, isChecked, isEnabled, isHandled, notifyResult, removeAcceleratorText, removeMnemonics, setAccelerator, setActionDefinitionId, setChecked, setDescription, setDisabledImageDescriptor, setEnabled, setHelpListener, setHoverImageDescriptor, setId, setImageDescriptor, setMenuCreator, setText, setToolTipText
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPropertyChangeListener, removePropertyChangeListener
public static final int ADD
protected final List<com.ibm.rational.common.test.editor.framework.change.IAddChangeContext> parentContexts
public NewModelElementAction()
public NewModelElementAction(String type)
type
.type
- String Type of a CBActionElement object that this action
produces.public NewModelElementAction(String type, boolean loadExtensions)
NewExtensibleModelElementAction
protected void init()
ExtLabelProvider>/code>
protected CBActionElement createNewModelObject(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context)
IActionHandler.createNew(IAddChangeContext)
method.context
- The context of the Add.protected final CBActionElement createNewModelObject(CBActionElement parent)
ExtActionHandler
for its type and calls
createnewObject
method.parent
- CBActionElement. Object that is typically selected in the
editor's tree.NewModelElementAction.createNewModelObject(IAddChangeContext)
public void startDropOperation(CBActionElement target, ISelection droppedElements)
NewModelElementAction.updateSelection(IStructuredSelection)
, and only if the action is
enabled after this call. When called, the enablement of the action must
be updated accordingly. Note: the attribute "contributeDrop" must be
explicitly set to true in plugin.xml to enable basic drag support;
otherwise this method will not be called.target
- The target element of the drop operation (i.e. the parent
element that should receive the dropped element). This
parameter always correspond to the selection that was passed
to NewModelElementAction.updateSelection(IStructuredSelection)
. If this
action is still enabled when this method returns, the
framework will always call either NewModelElementAction.run()
or
NewModelElementAction.cancelDropOperation()
.droppedElements
- The elements being dropped.public void cancelDropOperation()
NewModelElementAction.startDropOperation(CBActionElement, ISelection)
. Any retained
information about the drop operation must be released.public void run()
doCreate
method, and refreshes the Test in the tree.run
in interface IAction
run
in class Action
IAction.run()
protected com.ibm.rational.common.test.editor.framework.change.IEditorChange createAddChange()
protected com.ibm.rational.common.test.editor.framework.change.IEditorChange createAddChange(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context)
protected List<CBActionElement> createChildren(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context)
NewModelElementAction.createChild(IAddChangeContext)
.parent
- protected CBActionElement createChild(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context)
protected final CBActionElement doCreate(CBActionElement parent)
NewModelElementAction.createChild(IAddChangeContext)
and partially by
NewModelElementAction.addChildren(IAddChangeContext, List)
.
NewModelElementAction.createNewModelObject(IAddChangeContext)
may also be
a replacement candidates as some protocols used to mistakenly
override this method instead of
NewModelElementAction.createNewModelObject(CBActionElement)
.run{}
method. It does the
following: ExtContentProvider
for the parent and
obtains its list of children, createNewModelObject
to create new child object, instanceof
EMF EList)
ModelStateManager.setStatusNew(child, getTestEditor())
parent
- CBActionElement selected in the treeNewModelElementAction.createChild(IAddChangeContext)
,
NewModelElementAction.addChildren(IAddChangeContext, List)
protected final void addChild(List<CBActionElement> children, CBActionElement child)
instaceof
EList, the model change occures. Otherwise clients
need to make sure the new child objects is indeed added to a model.
This method is called by doCreate
only if the
children
obtained from parent's ExtContentProvider is of
(sub-)type of EMF EList
.
children
- List of childrenchild
- NewModelElementAction.addChildren(IAddChangeContext, List)
protected com.ibm.rational.common.test.editor.framework.change.AddChangeResult addChildren(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context, List<CBActionElement> children)
IContainerActionHandler#addChildren(IAddChangeContext, com.ibm.rational.common.test.editor.framework.kernel.interfaces.IAddedElementDescriptor)
on the action handler of the parent element. Override if insertion of
children in the parent list should be processed differently.parent
- The parent elementchild
- The child element to be added under the parent. This element
has been been created by this action's
NewModelElementAction.createNewModelObject(CBActionElement)
method.position
- The position, within the list of children of the parent.protected void refreshTest(CBActionElement parent, List<CBActionElement> children)
protected void refreshTest(CBActionElement parent, CBActionElement child)
public TestEditor getTestEditor()
public boolean isRefreshEnabled()
public void setRefreshEnabled(boolean refreshEnabled)
refreshEnabled
- The refreshEnabled to set.public boolean updateSelection(IStructuredSelection selection)
If isValidParent()
returns false
and extensions
are loaded, the list of contributions is checked to see whether the
parent/child relation was allowed declaretively.
protected void clearCache()
clearCache
in class BaseSelectionListenerAction
protected boolean isValidParent(Object object)
updateSelection
and is used to
determine whether this action should be enabled or disabled.
If client decides that the argument is one of the recognized types,
suitable to have a child object of the type handled by this action, this
method should return true
. If the parent's type is not
suitable or not recognized, the method should return false
.
If isValidParent()
returns false
and extensions
are loaded, the list of contributions is checked to see whether the
parent/child relation was allowed declaratively (by
updateSelection
method).
This implementation simply calls:
CBActionElement element = (CBActionElement) object; return getTestEditor().getProviders(element).getActionHandler().isValidParent(element);
object
- public void setTestEditor(TestEditor editor)
public int getInsertPoint()
public void setInsertPoint(int insertPoint)
Clients should not call this method.
insertPoint
- The insertPoint to set.public List<CBActionElement> getNewElements()
public com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler getMyActionHandler()
public void widgetArmed(ArmEvent e)
widgetArmed
in interface ArmListener
© Copyright IBM Corp. 2013. All rights reserved.