Class ActionsProvider


  • @OpenApi
    public final class ActionsProvider
    extends java.lang.Object
    The singleton class used for accessing actions in different parts (diagrams, browsers, main menu and etc.) of MagicDraw application.
    • Field Detail

      • mainToolbarActions

        private ActionsManager mainToolbarActions
        Actions for main toolbar.
      • mainMenuActions

        private ActionsManager mainMenuActions
        Actions for main menu.
      • mainShortcutsActions

        private ActionsManager mainShortcutsActions
        Actions for main shortcuts.
      • instance

        private static final ActionsProvider instance
        Single instance of this class.
      • creator

        private ActionsCreator creator
        Actions creator creates default actions.
      • managers

        private final java.util.Set<ActionsManager> managers
        Set of managers. MagicDraw will update state for all these actions.
      • registeredAvailableActions

        private final java.util.Map<java.lang.String,​NMAction> registeredAvailableActions
      • updatingActionsState

        private boolean updatingActionsState
        Indicates that actions update is still in progress.
    • Constructor Detail

      • ActionsProvider

        private ActionsProvider()
        Constructor
    • Method Detail

      • getInstance

        @OpenApi
        public static ActionsProvider getInstance()
        Returns single instance of this class.
        Returns:
        the instance of ActionsProvider.
      • getDiagramContextActions

        @OpenApi
        public ActionsManager getDiagramContextActions​(java.lang.String diagramType,
                                                       DiagramPresentationElement diagram,
                                                       PresentationElement[] selected,
                                                       @CheckForNull
                                                       PresentationElement requester)
        Returns context AM for given diagram type.
        Parameters:
        diagramType - diagram type
        diagram - the given diagram.
        selected - array of selected symbols.
        requester - symbol which requests actions, can be null if requester is diagram.
        Returns:
        manager with actions.
      • getTargetElementAMActions

        @OpenApi
        public ActionsManager getTargetElementAMActions​(java.lang.String diagramType,
                                                        PresentationElement requester,
                                                        java.lang.String pathActionID)
        Returns context AM for given diagram type.
        Parameters:
        diagramType - diagram type
        requester - symbol which requests actions, can be null if requester is diagram.
        pathActionID - path action id
        Returns:
        manager with actions.
      • getDiagramContextToolbarActions

        @OpenApi
        public ActionsManager getDiagramContextToolbarActions​(java.lang.String diagramType,
                                                              PresentationElement requester)
        Returns context AM for given diagram type.
        Parameters:
        diagramType - diagram type
        requester - symbol which requests actions, can be null if requester is diagram.
        Returns:
        manager with actions.
      • getDiagramToolbarConfiguration

        @OpenApi
        public DiagramToolbarConfiguration getDiagramToolbarConfiguration​(java.lang.String diagramType)
        Returns AM for diagram toolbar.
        Parameters:
        diagramType - diagram type
        Returns:
        DiagramToolbarConfiguration object for specified diagram type.
      • getDiagramCommandBarActions

        @OpenApi
        public ActionsManager getDiagramCommandBarActions​(@CheckForNull
                                                          java.lang.String diagramType)
        Returns actions of command bar for given diagram type.
        Parameters:
        diagramType - diagram type
        Returns:
        manager with actions.
      • getDiagramShortcutActions

        @OpenApi
        public ActionsManager getDiagramShortcutActions​(java.lang.String diagramType)
        Returns AM for given diagram type shortcuts.
        Parameters:
        diagramType - diagram type
        Returns:
        manager with actions.
      • getMainMenuActions

        @OpenApi
        public ActionsManager getMainMenuActions()
        Returns actions manager for main menu actions.
        Returns:
        manager with actions.
      • createMainMenuActions

        private static ActionsManager createMainMenuActions()
      • getMainToolbarActions

        @OpenApi
        public ActionsManager getMainToolbarActions()
        Returns manager with actions for main toolbar.
        Returns:
        manager with main toolbar actions.
      • createMainToolbarActions

        private static ActionsManager createMainToolbarActions()
      • getMainShortcutsActions

        @OpenApi
        public ActionsManager getMainShortcutsActions()
        Returns actions manager for main shortcuts.
        Returns:
        manager with actions.
      • createMainShortcutsActions

        private static ActionsManager createMainShortcutsActions()
      • getContainmentBrowserContextActions

        @OpenApi
        public static ActionsManager getContainmentBrowserContextActions​(BrowserTabTree tree)
        Returns context actions manager for containment browser.
        Parameters:
        tree - instance of tree.
        Returns:
        manager with actions.
      • getExtensionsBrowserContextActions

        @OpenApi
        public static ActionsManager getExtensionsBrowserContextActions​(BrowserTabTree tree)
        Returns context actions manager for containment browser.
        Parameters:
        tree - instance of tree.
        Returns:
        manager with actions.
      • getSearchBrowserContextActions

        @OpenApi
        public static ActionsManager getSearchBrowserContextActions​(BrowserTabTree tree)
        Returns context actions manager for search browser.
        Parameters:
        tree - instance of tree.
        Returns:
        manager with actions.
      • getDiagramsBrowserContextActions

        @OpenApi
        public static ActionsManager getDiagramsBrowserContextActions​(BrowserTabTree tree)
        Returns context actions manager for diagrams browser.
        Parameters:
        tree - instance of tree.
        Returns:
        manager with actions.
      • getInheritanceBrowserContextActions

        @OpenApi
        public static ActionsManager getInheritanceBrowserContextActions​(BrowserTabTree tree)
        Returns context actions manager for inheritance browser.
        Parameters:
        tree - instance of tree.
        Returns:
        manager with actions.
      • getContainmentBrowserShortcutsActions

        @OpenApi
        public ActionsManager getContainmentBrowserShortcutsActions()
        Returns actions manager for containment browser shortcuts.
        Returns:
        manager with actions.
      • getDiagramsBrowserShortcutsActions

        @OpenApi
        public ActionsManager getDiagramsBrowserShortcutsActions()
        Returns actions manager for diagrams browser shortcuts.
        Returns:
        manager with actions.
      • getInheritanceBrowserShortcutsActions

        @OpenApi
        public ActionsManager getInheritanceBrowserShortcutsActions()
        Returns shortcuts actions manager for inheritance browser.
        Returns:
        manager with actions.
      • getLockViewBrowserShortcutsActions

        @OpenApi
        public ActionsManager getLockViewBrowserShortcutsActions()
        Returns shortcuts actions manager for inheritance browser.
        Returns:
        manager with actions.
      • getExtensionsBrowserShortcutsActions

        @OpenApi
        public ActionsManager getExtensionsBrowserShortcutsActions()
        Returns shortcuts actions manager for inheritance browser.
        Returns:
        manager with actions.
      • getSearchBrowserShortcutsActions

        @OpenApi
        public ActionsManager getSearchBrowserShortcutsActions()
        Returns shortcuts actions manager for search browser.
        Returns:
        manager with actions.
      • getCreator

        @OpenApi
        public ActionsCreator getCreator()
        Returns instance of actions creator.
        Returns:
        the actions creator.
      • setActionsCreator

        private void setActionsCreator​(ActionsCreator creator)
        Sets Actions creator.
        Parameters:
        creator - actions creator.
      • createDiagramsActionsManager

        public DiagramsActionsManager createDiagramsActionsManager()
        Creates(or returns already created) action managers for all diagrams.
        Returns:
        the diagrams actions manager.
      • createGeneralActions

        public ActionsManager createGeneralActions()
        Creates the general actions
        Returns:
        the general actions
      • addManagerToUpdateList

        public void addManagerToUpdateList​(ActionsManager manager)
        Adds actions to managers list for updating the state.
        Parameters:
        manager - the given actions manager.
      • removeManagerFromUpdateList

        public void removeManagerFromUpdateList​(ActionsManager manager)
        Removes manager from updating actions state list.
        Parameters:
        manager - the given actions manager.
      • updateActionsState

        public void updateActionsState​(Project contextProject)
        Call updateState method for all registered actions without assigned group.
        Parameters:
        contextProject - context project
      • updateActionsState

        public static void updateActionsState​(ActionsManager manager,
                                              @CheckForNull
                                              Project contextProject)
        Call updateState method for given actions without assigned groups in manager.
        Parameters:
        manager - manager from which actions without assigned groups will be updated.
        contextProject - context project
      • checkNotActiveProject

        private static boolean checkNotActiveProject​(@CheckForNull
                                                     Project contextProject)
      • appendCategories

        private static void appendCategories​(ActionsManager destination,
                                             ActionsManager source,
                                             ActionsManager save,
                                             boolean oneCategory)
        Appends categories and actions from destination to source.
        Parameters:
        destination - destination manager.
        source - source manager.
        save - manager which contains actions to be saved.
        oneCategory - true when all actions should be append to first category in destination.
      • appendManagers

        public static void appendManagers()
        Appends general and diagrams actions manager with actions from configurator. This should be used before saving and loading actions shortcuts.
      • appendDiagramTypeManagers

        private static void appendDiagramTypeManagers​(java.lang.String diagramType,
                                                      java.util.Map<java.lang.String,​ActionsManager> managers)
      • getCreateDiagramDialogActions

        @OpenApi
        public ActionsManager getCreateDiagramDialogActions()
        Creates, configures and returns diagram creation actions to display in Create Diagram dialog (action in main menu and main toolbar)
        Returns:
        manager with diagram creation actions
      • resetCashedActions

        @Deprecated
        public void resetCashedActions()
        Deprecated.
        Resets already configured actions cache.
      • resetCachedActions

        public void resetCachedActions()
        Resets already configured actions cache.
      • registerAction

        @OpenApi
        public void registerAction​(NMAction action)
        Registers the action as available in application - other components (such as Perspectives) should know what actions are available.
        • Action id must be stable/constant,
        • It is not necessary to use the same action instance used when configuring appropriate menu/toolbar.
        Parameters:
        action - action to register.
        See Also:
        unregisterAction(com.nomagic.actions.NMAction)
      • getRegisteredAvailableActions

        public java.util.Collection<NMAction> getRegisteredAvailableActions()
        Returns:
        a collection of various registered actions. Used in User Modes.