Class DefaultBrowserAction

  • All Implemented Interfaces:
    BrowserAction, com.nomagic.magicdraw.actions.ShortcutSchemaAction, java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, java.util.EventListener, javax.swing.Action

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

      • DefaultBrowserAction

        @OpenApi
        public DefaultBrowserAction​(@CheckForNull
                                    java.lang.String actionID,
                                    java.lang.String actionName,
                                    @CheckForNull
                                    javax.swing.KeyStroke stroke,
                                    @CheckForNull
                                    java.lang.String group)
        Constructs new action.
        Parameters:
        actionID - the action ID.
        actionName - the action name.
        stroke - the action stroke.
        group - the action group.
    • Method Detail

      • 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 java.lang.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 java.lang.Object getSelectedObject()
        Returns:
        selected object in tree
      • getSelectedObjects

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

        public java.util.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 java.util.stream.Stream<java.lang.Object> getSelectedObjectsStream​(@CheckForNull
                                                                                         Tree tree)