Creating actions
You can use the com.ibm.rational.common.test.editor.framework.extensions.ExtActionHandler
class to remove, move up, and move down menu buttons
About this task
NewModelElementAction
class as described
in the following conditions:Procedure
- For every model element displayed in the tree, the
com.ibm.rational.common.test.editor.framework.Test Editor
class expects to find an instance of thecom.ibm.rational.common.test.editor.framework.extensions.ExtActionHandler
class and somecom.ibm.rational.common.test.editor.framework.kernel.actions.NewModelElementAction
s registered incom.ibm.rational.common.test.editor.framework. TestEditorplug-in
’scom.ibm.rational.common.test.editor.framework.RptMenuManager
. - The
ActionHandler
s are declared in the plugin.xml file, while thecom.ibm.rational.common.test.editor.framework.kernel.actions.NewModelElementAction
class must be created and registered programmatically through the protocol plug-in class. Only one set of actions is needed for multiple editors, because this class is context sensitive. - The
ActionHandler
s of the selected elements are asked whether to enable the Remove, Move up and Move down buttons . Thecom.ibm.rational.common.test.editor.framework.extensions.ExtActionHandler
examines the selection, looks for the objects of the recognized types, and then returns a value of true or false. - To enable or disable Add and Insert buttons and menus, the
TestEditor
class passes the selection to each of the registeredcom.ibm.rational.common.test.editor.framework.kernel.actions.NewModelElementAction
instances. The action is expected to examine the selection, and enable or disable its state, based on whether this action can add its model object to the selected item. - The ID of each
com.ibm.rational.common.test.editor.framework.kernel.actions.NewModelElementAction
or the derived type must match the type of the model object that this action represents. The ID must have the same value as the one used in themodelObjectDescriptor
extension point. Thecom.ibm.rational.common.test.editor.framework.Test Editor
class uses this value to locate various providers for the specific model element. - There are two separate sets of actions maintained by the
com.ibm.rational.common.test.editor.framework.RptMenuManager
class, the Add and the Insert actions. While objects of the same type can be registered for both, the same instances of the same class cannot. This means that two instances of theAddObject
action must be created and registered. If the object cannot be inserted, the insert action is not required. The same is true for the add action. - If an action is selected, the action calls its correspondent
ActionHandler
to create a new model object. At this point, theActionHandler
class must create and initialize a new model object, including any required children. The action will add the new model object to the selected parent, but only if the selected parentContentProvider
returns a list of the children that haveEList
type, the native model list. For a composite list of children, for example theArrayList
assembled by provider, theActionHandler
is expected to add a new child to the parent. - The protocol writers must use the LoadTestNewModelElementAction class as the base class for creating actions. The class supports filtering by feature.