The Model Browser (Containment tree, Diagrams tree, etc.) is a based GUI part for displaying various model trees and panels
Browser browser = Application.getInstance().getMainFrame().getBrowser();
The browser has five trees by default (some of them are be default hidden):
- containment
- diagrams
- inheritance
- extensions
- search results
The browser has 3 panel by default
- documentation
- properties
- zoom
Last activated tree is marked as active:
BrowserTabTree activeTree = browser.getActiveTree();
Every tree is based on Swing JTree and all manipulations can be done by using the API provided by Swing:
JTree tree = activeTree.getTree();
Selected nodes are accessible in the following way:
Node[] nodes = activeTree.getSelectedNodes();
Node is derived from javax.swing.tree.DefaultMutableTreeNode.
Selecting/opening element in tree
In order to select some element in tree, you need
- Open(activate) a tree using com.nomagic.magicdraw.ui.browser.Browser#getContainmentTree;
- Call com.nomagic.magicdraw.ui.browser.Tree#openNode(com.nomagic.magicdraw.uml.BaseElement).