Creating actions

You can use the class to remove, move up, and move down menu buttons

About this task

The editor or protocol extensions that are needed to manipulate the test, and the test add, remove, insert specific model elements, must use the NewModelElementAction class as described in the following conditions:


  1. For every model element displayed in the tree, the Editor class expects to find an instance of the class and some registered in TestEditorplug-in’s
  2. The ActionHandlers are declared in the plugin.xml file, while the 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.
  3. The ActionHandlers of the selected elements are asked whether to enable the Remove, Move up and Move down buttons . The examines the selection, looks for the objects of the recognized types, and then returns a value of true or false.
  4. To enable or disable Add and Insert buttons and menus, the TestEditor class passes the selection to each of the registered 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.
  5. The ID of each 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 the modelObjectDescriptor extension point. The Editor class uses this value to locate various providers for the specific model element.
  6. There are two separate sets of actions maintained by the 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 the AddObject 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.
  7. If an action is selected, the action calls its correspondent ActionHandler to create a new model object. At this point, the ActionHandler 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 parent ContentProvider returns a list of the children that have EList type, the native model list. For a composite list of children, for example the ArrayList assembled by provider, the ActionHandler is expected to add a new child to the parent.
  8. The protocol writers must use the LoadTestNewModelElementAction class as the base class for creating actions. The class supports filtering by feature.