Class DefaultBrowserAction

All Implemented Interfaces:
BrowserAction, com.nomagic.magicdraw.actions.ShortcutSchemaAction, ActionListener, Serializable, Cloneable, Comparable, EventListener, Action

@OpenApiAll public class DefaultBrowserAction extends MDAction implements BrowserAction
The default implementation of BrowserAction and simple MDAction
See Also:
  • Constructor Details

    • DefaultBrowserAction

      @OpenApi public DefaultBrowserAction(@CheckForNull String actionID, String actionName, @CheckForNull KeyStroke stroke, @CheckForNull String group)
      Constructs new action.
      Parameters:
      actionID - the action ID
      actionName - the action name
      stroke - the action stroke
      group - the action group
    • DefaultBrowserAction

      @OpenApi public DefaultBrowserAction(@CheckForNull String actionID, @CheckForNull String actionName, @CheckForNull KeyStroke stroke, @CheckForNull String group, boolean useShortcutSchema)
      Constructs new action.
      Parameters:
      actionID - the action ID
      actionName - the action name
      stroke - the action stroke
      group - the action group
      useShortcutSchema - use shortcut schema
  • Method Details

    • setTree

      public void setTree(@CheckForNull Tree tree)
      Set tree for this action.
      Specified by:
      setTree in interface BrowserAction
      Parameters:
      tree - the browser for this action
    • getTree

      @CheckForNull public Tree getTree()
      Return tree of this action. MagicDraw framework guarantee that tree will set if this method is called from updateState() or actionPerformed(ActionEvent) methods.
      Returns:
      browser of this action
    • getTreeOrActiveTree

      @CheckForNull protected Tree getTreeOrActiveTree()
      Returns:
      action's tree or active tree in browser of action's tree is null
    • getActiveTree

      @CheckForNull public static Tree getActiveTree()
    • getSelectedObject

      @CheckForNull public static Object getSelectedObject(@CheckForNull Tree tree)
      Returns first selected object in a given tree.
      Parameters:
      tree - given tree
      Returns:
      first selected object
    • getFirstElement

      @CheckForNull public BaseElement getFirstElement(@CheckForNull Tree tree)
      Returns first selected element in a given tree.
      Parameters:
      tree - given tree
      Returns:
      first selected element
    • getFirstElement

      @CheckForNull public BaseElement getFirstElement()
      Returns first selected element.
      Returns:
      first selected element
    • getSelectedObject

      @CheckForNull protected Object getSelectedObject()
      Returns:
      selected object in tree
    • getSelectedObjects

      public Collection<?> getSelectedObjects()
      Collect selected user objects in tree
      Returns:
      collection of selected objects. Empty collection is nothing is selected
    • getSelectedBaseElements

      public Collection<? extends BaseElement> getSelectedBaseElements()
      Collects selected base elements in tree
      Returns:
      collection of selected base elements. Empty collection is nothing is selected
    • getSelectedObjectsStream

      public static Stream<Object> getSelectedObjectsStream(@CheckForNull Tree tree)