com.ibm.rational.common.test.editor.framework.kernel.actions

Class NewModelElementAction

    • Field Detail

      • ADD

        public static final int ADD
        constant indicating that this action adds, rather then inserts new elements
      • parentContexts

        protected final List<com.ibm.rational.common.test.editor.framework.change.IAddChangeContext> parentContexts
    • Constructor Detail

      • NewModelElementAction

        public NewModelElementAction()
        Create an action for creating a specific model element type. The type is derived from the declaring element in plugin.xml.
      • NewModelElementAction

        public NewModelElementAction(String type)
        Create an action for model element type type.
        Parameters:
        type - String Type of a CBActionElement object that this action produces.
      • NewModelElementAction

        public NewModelElementAction(String type,
                             boolean loadExtensions)
        Deprecated. 
        See Also:
        NewExtensibleModelElementAction
    • Method Detail

      • init

        protected void init()
        Extracts text and image descriptor from ExtLabelProvider>/code>
      • createNewModelObject

        protected CBActionElement createNewModelObject(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context)
        Create a new instance of the model object. This implementation calls the associated action handler's IActionHandler.createNew(IAddChangeContext) method.
        Parameters:
        context - The context of the Add.
        Returns:
        The newly created child object.
      • startDropOperation

        public void startDropOperation(CBActionElement target,
                              ISelection droppedElements)
        Verifies if a specific drag and drop operation is allowed for the specified argument. This method must be overridden if drop support is required. This operation is called only after 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.
        Parameters:
        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.
      • run

        public void run()
        Calls doCreate method, and refreshes the Test in the tree.
        Specified by:
        run in interface IAction
        Overrides:
        run in class Action
        See Also:
        IAction.run()
      • createAddChange

        protected com.ibm.rational.common.test.editor.framework.change.IEditorChange createAddChange()
      • createAddChange

        protected com.ibm.rational.common.test.editor.framework.change.IEditorChange createAddChange(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context)
      • createChildren

        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. By default, this method creates only one child by calling NewModelElementAction.createChild(IAddChangeContext).
        Parameters:
        parent -
        Returns:
      • createChild

        protected CBActionElement createChild(com.ibm.rational.common.test.editor.framework.change.IAddChangeContext context)
Parameters:
parent - CBActionElement selected in the tree
Returns:
CBActionElement new child object
See Also:
NewModelElementAction.createChild(IAddChangeContext), NewModelElementAction.addChildren(IAddChangeContext, List)
  • addChild

    protected final void addChild(List<CBActionElement> children,
                CBActionElement child)
    Deprecated. This method is no longer called.
    Adds or inserts a new children into a list of children. If the list if an 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.

    Parameters:
    children - List of children
    child -
    See Also:
    NewModelElementAction.addChildren(IAddChangeContext, List)
  • addChildren

    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. Override if insertion of children in the parent list should be processed differently.
    Parameters:
    parent - The parent element
    child - 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.
  • getTestEditor

    public TestEditor getTestEditor()
  • isRefreshEnabled

    public boolean isRefreshEnabled()
    Returns:
    Returns the refreshEnabled.
  • setRefreshEnabled

    public void setRefreshEnabled(boolean refreshEnabled)
    Parameters:
    refreshEnabled - The refreshEnabled to set.
  • isValidParent

    protected boolean isValidParent(Object object)
    This method is called from 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);
     
    Parameters:
    object -
    Returns:
    boolean
  • setTestEditor

    public void setTestEditor(TestEditor editor)
  • getInsertPoint

    public int getInsertPoint()
    Returns:
    Returns the insertPoint.
  • setInsertPoint

    public void setInsertPoint(int insertPoint)
    Set dynamically by test editor framework as selection in the editor tree changes. The insertion point is an index in the children list, where the new child will be inserted, if user selects Insert->newModelElementAction sequence.

    Clients should not call this method.

    Parameters:
    insertPoint - The insertPoint to set.
  • getNewElements

    public List<CBActionElement> getNewElements()
    Returns:
    Returns the newElements.
  • getMyActionHandler

    public com.ibm.rational.common.test.editor.framework.kernel.interfaces.IActionHandler getMyActionHandler()