Class DefaultBrowserAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- com.nomagic.actions.NMAction
-
- com.nomagic.magicdraw.actions.MDAction
-
- com.nomagic.magicdraw.ui.browser.actions.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
-
-
Field Summary
-
Fields inherited from class com.nomagic.actions.NMAction
ACTION_SHORTCUTS, BELONGS_TO_SEPARATE_GROUP_IN_UI, DO_NO_SHOW_ACTION_NAME_IN_UI, DO_NOT_REGISTER_ACTION_TO_COMPONENTS, GENERATED_ID_PREFIX, GROUP, ID, LARGE_ICON, MENU_SHORTCUT_MASK, TINY_ICON
-
-
Constructor Summary
Constructors Constructor Description DefaultBrowserAction(java.lang.String actionID, java.lang.String actionName, javax.swing.KeyStroke stroke, java.lang.String group)
Constructs new action.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Tree
getActiveTree()
BaseElement
getFirstElement()
Returns first selected element.BaseElement
getFirstElement(Tree tree)
Returns first selected element in a given tree.java.util.Collection<? extends BaseElement>
getSelectedBaseElements()
Collects selected base elements in treeprotected java.lang.Object
getSelectedObject()
static java.lang.Object
getSelectedObject(Tree tree)
Returns first selected object in a given tree.java.util.Collection<?>
getSelectedObjects()
Collect selected user objects in treestatic java.util.stream.Stream<java.lang.Object>
getSelectedObjectsStream(Tree tree)
Tree
getTree()
Return tree of this action.protected Tree
getTreeOrActiveTree()
void
setTree(Tree tree)
Set tree for this action.-
Methods inherited from class com.nomagic.magicdraw.actions.MDAction
actionPerformed, isUseShortcutSchema, updateState
-
Methods inherited from class com.nomagic.actions.NMAction
accept, addAction, addPropertyChangeListener, addShortcut, addShotcut, addWeakPropertyChangeListener, clone, compareTo, createMenuItem, equals, firePropertyChange, forEach, forEachIncludingSelf, getActions, getCommandKey, getDescription, getGroup, getIcon, getID, getLargeIcon, getLargeOrSmallIcon, getMenuShortcutMaskAsString, getMnemonicKey, getName, getPropertyChangeListeners, getShortcuts, getSmallIcon, getSmallOrLargeIcon, getTinyIcon, hashCode, hasMenuShortcutMask, isIDGenerated, removeAction, removeIf, removePropertyChangeListener, removeShortcut, removeWeakPropertyChangeListener, setActions, setDescription, setGroup, setIcon, setLargeIcon, setMnemonicKey, setName, setShortcuts, setSmallIcon, setTinyIcon, shallowClone, toString
-
Methods inherited from class javax.swing.AbstractAction
getKeys, getValue, isEnabled, putValue, setEnabled
-
-
-
-
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 interfaceBrowserAction
- 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:
- actions'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)
-
-