Class Browser


  • @OpenApi
    public class Browser
    extends java.lang.Object
    The MagicDraw application UI part with trees, documentation, zoom and search panels. The primary purpose of this class is to manages predefined Trees and Panels in MagicDraw application Browser.

    It has five trees:

    • containment
    • diagrams
    • inheritance
    • extensions
    • search results

    Also it has two panels:

    • documentation
    • zoom control

    Sample of accessing Swing JTree of containment tree:

    getContainmentTree().getTree()
    • Field Detail

      • BROWSER_COMPONENTS

        private static final java.util.List<WindowComponentInfo> BROWSER_COMPONENTS
      • overviewPanel

        private com.nomagic.magicdraw.ui.diagramoverview.DiagramOverviewPanel overviewPanel
      • documentationPanel

        private com.nomagic.magicdraw.ui.browser.BrowserDocumentationPanel documentationPanel
      • propertiesPanel

        private com.nomagic.magicdraw.properties.qproperties.ui.QPropertiesPanel propertiesPanel
      • rememberedTrees

        private final java.util.Deque<BrowserTabTree> rememberedTrees
      • treeActivationHistory

        private final java.util.List<BrowserTabTree> treeActivationHistory
      • treeStateManager

        private final com.nomagic.awt.TreeStateManager treeStateManager
      • nodeMap

        private final com.nomagic.magicdraw.ui.browser.BrowserNodeMap nodeMap
      • initialized

        private java.lang.Boolean initialized
      • project

        private volatile Project project
      • logBrowserUpdates

        private final boolean logBrowserUpdates
      • registeredFocusListeners

        private final java.util.Map<BrowserTabTree,​java.awt.event.FocusListener> registeredFocusListeners
      • treeStateRestored

        private boolean treeStateRestored
        Indicates if tree expand state is restored or not. True is restored, false not restored yet.
      • treeStateRestoreCounter

        private final java.util.concurrent.atomic.AtomicInteger treeStateRestoreCounter
    • Constructor Detail

      • Browser

        public Browser()
    • Method Detail

      • isInitialized

        public boolean isInitialized()
      • initBrowser

        public void initBrowser​(Project project)
      • initBrowserInternal

        private void initBrowserInternal​(Project project,
                                         @CheckForNull
                                         java.lang.Runnable runnable)
      • reCreateBrowser

        public void reCreateBrowser​(Project project)
      • getProject

        public Project getProject()
      • loadTrees

        public void loadTrees()
        Loads persistent trees specified in project options
      • addPanel

        @OpenApi
        public void addPanel​(ExtendedPanel panel)
        Adds a new browser panel.Should be called during browser initialization only.
        Parameters:
        panel - panel
        See Also:
        Browser.BrowserInitializer
      • addPanel

        @OpenApi
        public void addPanel​(ExtendedPanel panel,
                             int index)
        Adds a new browser panel.Should be called during browser initialization only.
        Parameters:
        panel - panel
        index - index
        See Also:
        Browser.BrowserInitializer
      • removePanel

        @OpenApi
        public void removePanel​(ExtendedPanel panel)
        Removes browser panel. Should be called during browser initialization only.
        Parameters:
        panel - panel
        See Also:
        Browser.BrowserInitializer
      • addTree

        @OpenApi
        public BrowserTabTree addTree​(BrowserTabTree tree,
                                      boolean drag,
                                      boolean drop)
        Adds and does setup a new tree to the browser. Should be called during browser initialization only.
        Parameters:
        tree - a new tree
        drag - tree should be a drag operation source
        drop - tree should be a drop operation source
        Returns:
        added tree
        See Also:
        Browser.BrowserInitializer
      • addTree

        @OpenApi
        public BrowserTabTree addTree​(@Nonnull
                                      BrowserTabTree tree,
                                      boolean drag,
                                      boolean drop,
                                      int index)
        Adds and does setup a new tree to the browser. Should be called during browser initialization only.
        Parameters:
        tree - a new tree
        drag - tree should be a drag operation source
        drop - tree should be a drop operation source
        index - the position of new tree among other trees
        Returns:
        added tree
        See Also:
        Browser.BrowserInitializer
      • removeTree

        @OpenApi
        public void removeTree​(BrowserTabTree tree)
        Removes a tree from the browser.Should be called during browser initialization only.
        Parameters:
        tree - a new tree
        See Also:
        Browser.BrowserInitializer
      • removeTree

        @OpenApi
        public void removeTree​(BrowserTabTree tree,
                               boolean saveLayout)
        Removes a tree from the browser.Should be called during browser initialization only.
        Parameters:
        tree - a new tree
        saveLayout - save information about existing trees into project options
        See Also:
        Browser.BrowserInitializer
      • removeComponent

        private static void removeComponent​(java.awt.Component component)
      • removeComponentInfo

        public void removeComponentInfo​(WindowComponentInfo info)
        Remove information about registered component
        Parameters:
        info - component info
      • addComponentInfo

        private static void addComponentInfo​(WindowComponentInfo info,
                                             int index)
        Add information about registered component
        Parameters:
        info - component info
      • setActiveTree

        public void setActiveTree​(BrowserTabTree activeTree)
        Sets active tree. Does not select this tree in TabbedPane, just changes the reference to active tree in code.
        Parameters:
        activeTree - a new active tree for this browser.
      • getActiveTree

        @CheckForNull
        @OpenApi
        public BrowserTabTree getActiveTree()
        Returns reference to the active tree.
        Returns:
        active tree.
      • initTrees

        public void initTrees​(java.lang.String group,
                              boolean activateTree)
      • initTrees

        public void initTrees()
      • initTrees

        public void initTrees​(boolean activateTree)
      • initTrees

        public void initTrees​(java.util.List<BrowserTabTree> trees,
                              boolean activateTree)
        Init the browser. Init all browser trees.
        Parameters:
        trees - trees to init
        activateTree - activate tree
      • activateVisibleTrees

        public void activateVisibleTrees()
        Activate all visible on screen trees.
      • doActivateVisibleTrees

        private static void doActivateVisibleTrees​(java.util.Collection<BrowserTabTree> trees,
                                                   @CheckForNull
                                                   BrowserTabTree doNotActivate)
      • sortAllTrees

        public void sortAllTrees()
        Sorts the nodes in all trees.
      • updateSortAlwaysFlag

        public void updateSortAlwaysFlag()
        Updates the sort always flag in trees' models. If sort flag is true, sorts the trees.
      • reInitTrees

        public void reInitTrees()
        ReInit browser trees
      • updateBrowser

        public void updateBrowser​(boolean updateOnlyDirty,
                                  java.lang.String group)
        Updates the nodes in all trees. Updates documentation panel also.
        Parameters:
        updateOnlyDirty - true if only dirty nodes will be updated. on false all nodes will be updated
        group - trees group
      • updateBrowser

        public void updateBrowser​(boolean updateOnlyDirty)
      • getSelectedNode

        @CheckForNull
        private Node getSelectedNode()
        Returns:
        active tree selected node
      • updateBrowser

        private void updateBrowser​(boolean updateOnlyDirty,
                                   java.util.Collection<BrowserTabTree> trees)
      • updateBrowserOnEDT

        private void updateBrowserOnEDT​(boolean updateOnlyDirty,
                                        java.util.Collection<BrowserTabTree> trees)
      • decorateBrowser

        public void decorateBrowser()
        changes browser's trees decoration
      • getDocPanel

        public com.nomagic.magicdraw.ui.browser.BrowserDocumentationPanel getDocPanel()
        Returns documentation panel.
        Returns:
        documentation panel.
      • getOverviewPanel

        public com.nomagic.magicdraw.ui.diagramoverview.DiagramOverviewPanel getOverviewPanel()
        Returns zoom panel.
        Returns:
        zoom panel.
      • getQPanel

        public com.nomagic.magicdraw.properties.qproperties.ui.QPropertiesPanel getQPanel()
      • getInheritanceTree

        @OpenApi
        @CheckForNull
        public InheritanceTree getInheritanceTree()
        Returns inheritance tree if it exists, otherwise null
        Returns:
        inheritance tree.
      • getLockViewTree

        @CheckForNull
        @OpenApi
        public LockViewTree getLockViewTree()
        Returns Lock view tree.
        Returns:
        lock view tree.
      • getLastActiveTree

        @CheckForNull
        public BrowserTabTree getLastActiveTree​(java.lang.String group)
      • getContainmentTree

        @OpenApi
        public ContainmentTree getContainmentTree()
        Returns containment tree.
        Returns:
        containment tree.
      • getDiagramsTree

        @OpenApi
        public DiagramsTree getDiagramsTree()
        Returns diagrams tree.
        Returns:
        diagrams tree.
      • getExtensionsTree

        @OpenApi
        @CheckForNull
        public ExtensionsTree getExtensionsTree()
        Returns extensions tree.
        Returns:
        extensions tree.
      • getExtensionsTree

        @OpenApi
        @CheckForNull
        public ExtensionsTree getExtensionsTree​(boolean addIfNotExists)
        Returns extensions tree.
        Parameters:
        addIfNotExists - add tree if not exists and it is allowed to have extension tree
        Returns:
        extensions tree.
      • getSearchResultsTree

        @OpenApi
        public SearchResultsTree getSearchResultsTree()
        Returns last active or newly added search results tree.
        Returns:
        search results tree.
      • getSearchResultsTree

        @CheckForNull
        @OpenApi
        public SearchResultsTree getSearchResultsTree​(boolean addIfNotExists)
        Returns last active or newly added search results tree.
        Parameters:
        addIfNotExists - add search result tree if it does not exist
        Returns:
        search results tree.
      • addSearchResultsTree

        @CheckForNull
        public SearchResultsTree addSearchResultsTree()
        Adds new browser tab tree for search results
        Returns:
        search results tree
      • getNodeMap

        public com.nomagic.magicdraw.ui.browser.BrowserNodeMap getNodeMap()
      • rememberState

        public void rememberState()
        Remembers all expanded nodes in all trees. Later these expanded nodes can be restored with method restoreExpandedNodes().
        See Also:
        restoreState(), TreeStateManager
      • restoreState

        public void restoreState()
        Restores all expanded nodes in all trees. Method rememberExpandedNodes must be called first.
        See Also:
        rememberState(), TreeStateManager
      • isTreeExpandStateRestored

        protected boolean isTreeExpandStateRestored()
        True if expand state is restored, else false.
        Returns:
        true if expand state is restored, else false.
      • getTrees

        @OpenApi
        public java.util.List<BrowserTabTree> getTrees()
        Returns:
        a list of browser trees
      • getTrees

        public java.util.List<BrowserTabTree> getTrees​(java.lang.String group)
      • getSearchResultTrees

        public java.util.List<SearchResultsTree> getSearchResultTrees()
      • getPanels

        @OpenApi
        public java.util.List<ExtendedPanel> getPanels()
        Returns:
        a list of browser panels.
      • dispose

        public void dispose()
      • getAllComponentInfo

        public static WindowComponentInfo[] getAllComponentInfo()
        Used in JIDE to create actions for these components
        Returns:
        info about all windows components related to browser
      • getTreeActivationHistory

        public java.util.List<BrowserTabTree> getTreeActivationHistory()
      • getTreeActivationHistory

        public java.util.List<BrowserTabTree> getTreeActivationHistory​(java.lang.String group)
      • removeTreeFromBrowser

        public void removeTreeFromBrowser​(BrowserTabTree tree,
                                          boolean saveLayout)
        Remove given tree and also close a window of tree if any
        Parameters:
        tree - tree
        saveLayout - save information about trees layout
      • removePanelFromBrowser

        private void removePanelFromBrowser​(ExtendedPanel panel)
      • getPersistentTreesStringRepresentation

        private java.util.List<java.lang.String> getPersistentTreesStringRepresentation()
      • saveTreesLayout

        public void saveTreesLayout()
        Save information about trees layout into project options
      • getRemovableTrees

        private java.util.List<BrowserTabTree> getRemovableTrees()
      • removeAllRemovableTrees

        public void removeAllRemovableTrees()
        Removes all removable trees.
      • removeAllRemovablePanels

        public void removeAllRemovablePanels()
        Removes all removable panels. Removables panels are of type BrowserPanelInfo and have field showByDefault set to true.
      • isRemovablePanel

        private static boolean isRemovablePanel​(ExtendedPanel panel)
      • getBrowserTreeForElement

        @CheckForNull
        public BrowserTabTree getBrowserTreeForElement​(com.nomagic.magicdraw.ui.browser.TreeRoot treeRoot,
                                                       java.lang.String group)
      • getBrowserTreeForNode

        @CheckForNull
        public BrowserTabTree getBrowserTreeForNode​(Node node)
      • getBrowserTreeForNode

        @CheckForNull
        public BrowserTabTree getBrowserTreeForNode​(Node node,
                                                    java.lang.String group)
      • isExtensionTreeAllowed

        public boolean isExtensionTreeAllowed()
        Returns:
        true if Extensions tree can be created in a browser
      • addBrowserInitializer

        @OpenApi
        public static void addBrowserInitializer​(Browser.BrowserInitializer initializer)
        Add new new browser initializer.
        Parameters:
        initializer - initializer
      • removeBrowserInitializer

        @OpenApi
        public static void removeBrowserInitializer​(Browser.BrowserInitializer initializer)
        Remove browser initializer.
        Parameters:
        initializer - initializer