Package com.nomagic.magicdraw.ui.browser
Class Browser
- java.lang.Object
-
- com.nomagic.magicdraw.ui.browser.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
- documentation
- zoom control
Sample of accessing Swing JTree of containment tree:
getContainmentTree().getTree()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Browser.BrowserInitializer
Browser initializer is an extension point for browser creation.static interface
com.nomagic.magicdraw.ui.browser.Browser.BrowserTabTreeFactory
Browser tree factory for creating a tree in a lazy mode (on demand, not during browser initialization)(package private) static class
com.nomagic.magicdraw.ui.browser.Browser.BrowserUpdatable
Updatable for browser.private class
com.nomagic.magicdraw.ui.browser.Browser.MyFocusListener
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<WindowComponentInfo>
BROWSER_COMPONENTS
private com.nomagic.magicdraw.ui.browser.BrowserDocumentationPanel
documentationPanel
private java.lang.Boolean
initialized
(package private) static java.util.List<Browser.BrowserInitializer>
INITIALIZERS
private boolean
logBrowserUpdates
private com.nomagic.magicdraw.ui.browser.BrowserNodeMap
nodeMap
private com.nomagic.magicdraw.ui.diagramoverview.DiagramOverviewPanel
overviewPanel
private java.util.List<ExtendedPanel>
panels
private Project
project
private com.nomagic.magicdraw.properties.qproperties.ui.QPropertiesPanel
propertiesPanel
private java.util.Map<BrowserTabTree,java.awt.event.FocusListener>
registeredFocusListeners
private java.util.Deque<BrowserTabTree>
rememberedTrees
private java.util.List<BrowserTabTree>
treeActivationHistory
private java.util.List<BrowserTabTree>
trees
private com.nomagic.awt.TreeStateManager
treeStateManager
private java.util.concurrent.atomic.AtomicInteger
treeStateRestoreCounter
private boolean
treeStateRestored
Indicates if tree expand state is restored or not.
-
Constructor Summary
Constructors Constructor Description Browser()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateVisibleTrees()
Activate all visible on screen trees.static void
addBrowserInitializer(Browser.BrowserInitializer initializer)
Add new new browser initializer.private static void
addComponentInfo(WindowComponentInfo info, int index)
Add information about registered componentvoid
addPanel(ExtendedPanel panel)
Adds a new browser panel.Should be called during browser initialization only.void
addPanel(ExtendedPanel panel, int index)
Adds a new browser panel.Should be called during browser initialization only.SearchResultsTree
addSearchResultsTree()
Adds new browser tab tree for search resultsBrowserTabTree
addTree(BrowserTabTree tree, boolean drag, boolean drop)
Adds and does setup a new tree to the browser.BrowserTabTree
addTree(BrowserTabTree tree, boolean drag, boolean drop, int index)
Adds and does setup a new tree to the browser.void
decorateBrowser()
changes browser's trees decorationvoid
dispose()
private static void
doActivateVisibleTrees(java.util.Collection<BrowserTabTree> trees, BrowserTabTree doNotActivate)
BrowserTabTree
getActiveTree()
Returns reference to the active tree.static WindowComponentInfo[]
getAllComponentInfo()
Used in JIDE to create actions for these componentsBrowserTabTree
getBrowserTreeForElement(com.nomagic.magicdraw.ui.browser.TreeRoot treeRoot, java.lang.String group)
BrowserTabTree
getBrowserTreeForNode(Node node)
BrowserTabTree
getBrowserTreeForNode(Node node, java.lang.String group)
ContainmentTree
getContainmentTree()
Returns containment tree.DiagramsTree
getDiagramsTree()
Returns diagrams tree.com.nomagic.magicdraw.ui.browser.BrowserDocumentationPanel
getDocPanel()
Returns documentation panel.ExtensionsTree
getExtensionsTree()
Returns extensions tree.ExtensionsTree
getExtensionsTree(boolean addIfNotExists)
Returns extensions tree.InheritanceTree
getInheritanceTree()
Returns inheritance tree if it exists, otherwise nullBrowserTabTree
getLastActiveTree(java.lang.String group)
LockViewTree
getLockViewTree()
Returns Lock view tree.com.nomagic.magicdraw.ui.browser.BrowserNodeMap
getNodeMap()
com.nomagic.magicdraw.ui.diagramoverview.DiagramOverviewPanel
getOverviewPanel()
Returns zoom panel.java.util.List<ExtendedPanel>
getPanels()
private java.util.List<java.lang.String>
getPersistentTreesStringRepresentation()
Project
getProject()
com.nomagic.magicdraw.properties.qproperties.ui.QPropertiesPanel
getQPanel()
private java.util.List<BrowserTabTree>
getRemovableTrees()
SearchResultsTree
getSearchResultsTree()
Returns last active or newly added search results tree.SearchResultsTree
getSearchResultsTree(boolean addIfNotExists)
Returns last active or newly added search results tree.java.util.List<SearchResultsTree>
getSearchResultTrees()
private Node
getSelectedNode()
java.util.List<BrowserTabTree>
getTreeActivationHistory()
java.util.List<BrowserTabTree>
getTreeActivationHistory(java.lang.String group)
java.util.List<BrowserTabTree>
getTrees()
java.util.List<BrowserTabTree>
getTrees(java.lang.String group)
void
initBrowser(Project project)
private void
initBrowserInternal(Project project, java.lang.Runnable runnable)
void
initTrees()
void
initTrees(boolean activateTree)
void
initTrees(java.lang.String group, boolean activateTree)
void
initTrees(java.util.List<BrowserTabTree> trees, boolean activateTree)
Init the browser.boolean
isExtensionTreeAllowed()
boolean
isInitialized()
private static boolean
isRemovablePanel(ExtendedPanel panel)
protected boolean
isTreeExpandStateRestored()
True if expand state is restored, else false.void
loadTrees()
Loads persistent trees specified in project optionsvoid
reCreateBrowser(Project project)
void
reInitTrees()
ReInit browser treesvoid
rememberState()
Remembers all expanded nodes in all trees.void
removeAllRemovablePanels()
Removes all removable panels.void
removeAllRemovableTrees()
Removes all removable trees.static void
removeBrowserInitializer(Browser.BrowserInitializer initializer)
Remove browser initializer.private static void
removeComponent(java.awt.Component component)
void
removeComponentInfo(WindowComponentInfo info)
Remove information about registered componentvoid
removePanel(ExtendedPanel panel)
Removes browser panel.private void
removePanelFromBrowser(ExtendedPanel panel)
void
removeTree(BrowserTabTree tree)
Removes a tree from the browser.Should be called during browser initialization only.void
removeTree(BrowserTabTree tree, boolean saveLayout)
Removes a tree from the browser.Should be called during browser initialization only.void
removeTreeFromBrowser(BrowserTabTree tree, boolean saveLayout)
Remove given tree and also close a window of tree if anyvoid
restoreState()
Restores all expanded nodes in all trees.void
saveTreesLayout()
Save information about trees layout into project optionsvoid
setActiveTree(BrowserTabTree activeTree)
Sets active tree.void
sortAllTrees()
Sorts the nodes in all trees.void
updateBrowser(boolean updateOnlyDirty)
void
updateBrowser(boolean updateOnlyDirty, java.lang.String group)
Updates the nodes in all trees.private void
updateBrowser(boolean updateOnlyDirty, java.util.Collection<BrowserTabTree> trees)
private void
updateBrowserOnEDT(boolean updateOnlyDirty, java.util.Collection<BrowserTabTree> trees)
void
updateSortAlwaysFlag()
Updates the sort always flag in trees' models.
-
-
-
Field Detail
-
BROWSER_COMPONENTS
private static final java.util.List<WindowComponentInfo> BROWSER_COMPONENTS
-
INITIALIZERS
static java.util.List<Browser.BrowserInitializer> INITIALIZERS
-
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
-
trees
private final java.util.List<BrowserTabTree> trees
-
rememberedTrees
private final java.util.Deque<BrowserTabTree> rememberedTrees
-
treeActivationHistory
private final java.util.List<BrowserTabTree> treeActivationHistory
-
panels
private final java.util.List<ExtendedPanel> panels
-
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
-
-
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
- panelindex
- 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 treedrag
- tree should be a drag operation sourcedrop
- 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 treedrag
- tree should be a drag operation sourcedrop
- tree should be a drop operation sourceindex
- 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 treesaveLayout
- 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 initactivateTree
- 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 updatedgroup
- 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
- treesaveLayout
- 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
-
-