Class Tree

  • All Implemented Interfaces:
    com.nomagic.awt.PopupOwner, com.nomagic.magicdraw.ui.Updatable, Cachable, java.awt.dnd.Autoscroll, java.awt.event.FocusListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible
    Direct Known Subclasses:
    BrowserTabTree

    @OpenApi
    public class Tree
    extends AbstractTree
    implements java.awt.dnd.Autoscroll, com.nomagic.awt.PopupOwner, com.nomagic.magicdraw.ui.Updatable, Cachable
    The tree used in MagicDraw browser.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  com.nomagic.magicdraw.ui.browser.Tree.BrowserTreeNodeEditor  
      private static class  com.nomagic.magicdraw.ui.browser.Tree.DirtyNodeComparator  
      private static class  com.nomagic.magicdraw.ui.browser.Tree.EnabledDeleteAction  
      private static interface  com.nomagic.magicdraw.ui.browser.Tree.Interruptible  
      private class  com.nomagic.magicdraw.ui.browser.Tree.TreeModelListener  
      private static class  com.nomagic.magicdraw.ui.browser.Tree.TreePatchForMac
      Patching two problems but related with multiple selection on Mac: Invoking popup for multi selection with traditional Mac style Ctrl+left mouse button (NOT right click) D&D multiple selection
      static interface  com.nomagic.magicdraw.ui.browser.Tree.TreeSelectionParticipant
      Interface to execute additional actions before tree selection listener updates actions
      • Nested classes/interfaces inherited from class javax.swing.JPanel

        javax.swing.JPanel.AccessibleJPanel
      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Constructor Summary

      Constructors 
      Constructor Description
      Tree()
      Constructs new tree.
      Tree​(boolean ignoreEnvironmentLock)
      Constructor.
      Tree​(com.nomagic.magicdraw.ui.browser.ChildrenOwner childrenOwner)  
      Tree​(javax.swing.JTree tree, com.nomagic.magicdraw.ui.browser.ChildrenOwner childrenOwner)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTreeSelectionParticipant​(com.nomagic.magicdraw.ui.browser.Tree.TreeSelectionParticipant participant)
      Adds tree selection participant
      private <A> boolean areDirtyNodesPresent​(boolean updateOnlyDirty, A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler)  
      void autoscroll​(java.awt.Point pt)
      Implementation of auto-scroll interface method auto-scroll(Point) Scrolls to specified point.
      protected void browserUpdateDelayed​(boolean updateOnlyDirty)
      Called if browser lazy and update vas delayed
      boolean canDelete​(Node[] node)
      Test if all nodes can be deleted
      void collectSelectedNodes​(com.nomagic.magicdraw.ui.browser.TreeModel treeModel, javax.swing.tree.TreePath parentPath, com.nomagic.magicdraw.ui.browser.TreeSelectionTracker selectionTracker)
      Collects selected nodes.
      private static com.nomagic.magicdraw.ui.browser.ChildrenOwner createChildrenOwner()  
      protected com.nomagic.magicdraw.ui.browser.NodeCreator createNodeCreator()  
      void decorateTree()  
      void delete​(Node[] node)  
      void delete​(Node[] nodes, boolean useSpecificDeletion, com.nomagic.magicdraw.commands.MacroCommand macroCommand)
      Deletes nodes
      void dispose()
      Removes all nodes recursively.
      void disposeNodes()
      Dispose nodes added into the tree.
      protected void doBeforeOpenNode()  
      private static void doSetBrowserForAction​(Tree tree, NMAction action, com.nomagic.magicdraw.ui.ElementSelectionProvider provider)  
      protected void doubleClick​(javax.swing.tree.DefaultMutableTreeNode node, java.awt.event.MouseEvent event)
      called on mouse double click on nod.
      void doubleClickAction​(Node node, java.awt.event.MouseEvent event)
      Edit action invoked if somebody did double click on some node
      void editAction​(Node node, java.awt.AWTEvent event)
      Edit action invoked if somebody pressed Enter on node
      void editPath​(javax.swing.tree.TreePath path)  
      protected ActionsManager getActions()
      Returns shortcuts action manager for this browser.
      java.awt.Insets getAutoscrollInsets()  
      java.awt.Component getDefaultFocusable()
      Request Focus for some component.
      Node getNode​(int row)
      Returns first selected node in the tree.
      Node getRootNode()
      Returns root node of the tree.
      Node getSelectedNode()
      Returns first selected node in the tree.
      Node[] getSelectedNodes()
      Returns all selected nodes in the tree.
      com.nomagic.magicdraw.ui.browser.TreeModel getTreeModel()  
      com.nomagic.magicdraw.ui.browser.TreeRoot getTreeRoot()  
      void init()  
      void init​(com.nomagic.magicdraw.ui.browser.TreeRoot treeRoot)  
      <A> void initAsync​(A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler)  
      <A> void initAsync​(com.nomagic.magicdraw.ui.browser.TreeRoot treeRoot, A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler)  
      private void initCellRendererEditor​(javax.swing.JTree tree)  
      protected boolean isShowOwner()  
      boolean isUpdateIfShowing()
      Returns if tree only updates when showing
      protected static <A> void maybeInvokeChainedCH​(A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler, java.lang.Throwable exc)  
      protected <A> void maybeInvokeChainedHandler​(A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler, com.nomagic.magicdraw.ui.browser.TreeModel browserModel, java.lang.Throwable exc)  
      protected static <A> void maybeInvokeChainedHandler​(A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler, java.lang.Throwable exc)  
      javax.swing.tree.TreePath openNode​(BaseElement object)
      Opens(expands) node for a give Element.
      javax.swing.tree.TreePath openNode​(BaseElement object, boolean requestFocus)
      Opens(expands) node for a give Element.
      javax.swing.tree.TreePath openNode​(BaseElement object, boolean select, boolean requestFocus)
      Opens(expands) node for a give Element.
      javax.swing.tree.TreePath openNode​(BaseElement object, boolean select, boolean appendSelection, boolean requestFocus)
      Opens(expands) node for a give Element.
      javax.swing.tree.TreePath openNode​(BaseElement object, boolean select, boolean appendSelection, boolean requestFocus, boolean scrollToVisible)
      Opens(expands) node for a give Element.
      javax.swing.tree.TreePath openNode​(BaseElement object, com.nomagic.magicdraw.ui.ElementSelection selection, boolean appendSelection)  
      javax.swing.tree.TreePath openNode​(BaseElement object, com.nomagic.magicdraw.ui.ElementSelection selection, boolean select, boolean appendSelection, boolean requestFocus, boolean scrollToVisible)  
      void openNode​(java.util.Collection<? extends BaseElement> elements)  
      <T extends BaseElement>
      void
      openNode​(java.util.Collection<T> elements, java.util.function.Consumer<T> failedConsumer)  
      private static <A> void privateMaybeInvokeChainedHandler​(A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler, java.lang.Throwable exc)  
      private void registerShortcutActions()
      Register all shortcut actions to the browser.
      void removeAction​(Node[] node)
      Edit action invoked if somebody pressed DELETE on node
      private void removeUIListener()
      Remove default swing listener which scrolls item to some prefix on key event.
      void reset()
      Cache managers invokes this method to free resources.
      protected static void setBrowserForActions​(Tree tree, ActionsManager manager, com.nomagic.magicdraw.ui.ElementSelectionProvider provider)  
      void setIgnoreLock​(boolean ignoreLock)  
      void setSelectedNodes​(Node[] nodes)
      Selects given nodes in the tree.
      void setUpdateIfShowing​(boolean updateIfShowing)
      Allows setting tree to update only if showing
      void showPopupMenu​(java.awt.event.MouseEvent evt)  
      protected void specificUpdateBrowser​(boolean updateOnlyDirty)  
      static Node[] toNodes​(javax.swing.tree.TreePath[] paths)
      Utility method for converting array of paths to array of nodes
      protected static Node[] toNodes​(javax.swing.tree.TreePath[] paths, boolean loadingDummyNodeDistinction)  
      static javax.swing.tree.TreePath[] toTreePaths​(Node[] nodes)
      Utility method for converting array of nodes to array of paths
      void update​(boolean deepUpdate)  
      private <A> void updateAllNodes​(A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler, ProgressStatus status)  
      boolean updateBrowser()
      Updates dirty nodes in tree with the newest data and shows it.
      boolean updateBrowser​(boolean updateOnlyDirty)
      Updates tree with the newest data and shows it.
      boolean updateBrowser​(boolean updateOnlyDirty, boolean updateNotShowing)
      Updates tree with the newest data and shows it.
      <A> void updateBrowserAsync​(boolean updateOnlyDirty, A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler, ProgressStatus status)  
      protected <A> boolean updateOnlyDirtyNodes​(A attachment, com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler, boolean updateAll)  
      void updateUI()  
      private static void waitForPreviousEvents()  
      protected boolean waitForPreviousEventsOnOpeningNode()  
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, paramString, setUI
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface com.nomagic.magicdraw.ui.Updatable

        afterAllUpdates, beforeAllUpdates
    • Field Detail

      • UPDATE_DIRTY_LIMIT

        private static final int UPDATE_DIRTY_LIMIT
        A limit of dirty nodes to update individually. If this limit is exceeded, whole browser is updated, because this is more efficient way.
        See Also:
        Constant Field Values
      • LOADING_DUMMY_NODE_DISTINCTION

        protected static final Node[] LOADING_DUMMY_NODE_DISTINCTION
      • EMPTY_NODES

        private static final Node[] EMPTY_NODES
      • LOG_SCALABILITY

        private static final org.apache.logging.log4j.Logger LOG_SCALABILITY
      • ignoreLock

        private volatile boolean ignoreLock
      • treePatchForMac

        private com.nomagic.magicdraw.ui.browser.Tree.TreePatchForMac treePatchForMac
      • treeUpdateTask

        @CheckForNull
        private com.nomagic.magicdraw.ui.browser.Tree.Interruptible treeUpdateTask
      • treeUpdateExecutor

        private final java.util.concurrent.Executor treeUpdateExecutor
      • treeSelectionParticipants

        private final java.util.Collection<com.nomagic.magicdraw.ui.browser.Tree.TreeSelectionParticipant> treeSelectionParticipants
      • componentShortcutsManager

        @CheckForNull
        private com.nomagic.actions.ComponentShortcutsManager componentShortcutsManager
      • delayedUpdateOnlyDirty

        private boolean delayedUpdateOnlyDirty
      • updateIfShowing

        private boolean updateIfShowing
      • canRemoveWaitCursor

        private static final java.util.concurrent.atomic.AtomicBoolean canRemoveWaitCursor
      • delayedRemoveWaitCursorTimer

        private static final javax.swing.Timer delayedRemoveWaitCursorTimer
      • nodeSelectionPaths

        private final java.util.List<javax.swing.tree.TreePath> nodeSelectionPaths
      • selectSelectedNodes

        private final java.lang.Runnable selectSelectedNodes
        For selecting paths. Selection should be done when treeNodesChanged event is fired.
    • Constructor Detail

      • Tree

        public Tree()
        Constructs new tree.
      • Tree

        public Tree​(com.nomagic.magicdraw.ui.browser.ChildrenOwner childrenOwner)
      • Tree

        public Tree​(boolean ignoreEnvironmentLock)
        Constructor.
        Parameters:
        ignoreEnvironmentLock - true if want to ignore environment lock.
        See Also:
        EnvironmentLockManager
      • Tree

        public Tree​(javax.swing.JTree tree,
                    com.nomagic.magicdraw.ui.browser.ChildrenOwner childrenOwner)
    • Method Detail

      • createChildrenOwner

        private static com.nomagic.magicdraw.ui.browser.ChildrenOwner createChildrenOwner()
      • createNodeCreator

        protected com.nomagic.magicdraw.ui.browser.NodeCreator createNodeCreator()
      • setIgnoreLock

        public void setIgnoreLock​(boolean ignoreLock)
      • doubleClick

        protected void doubleClick​(javax.swing.tree.DefaultMutableTreeNode node,
                                   java.awt.event.MouseEvent event)
        Description copied from class: AbstractTree
        called on mouse double click on nod.
        Parameters:
        node - node on which double click was called.
        event - double click event
      • doubleClickAction

        public void doubleClickAction​(Node node,
                                      java.awt.event.MouseEvent event)
        Edit action invoked if somebody did double click on some node
        Parameters:
        node - node
        event - event
      • editAction

        public void editAction​(Node node,
                               java.awt.AWTEvent event)
        Edit action invoked if somebody pressed Enter on node
        Parameters:
        node - node
        event - action event
      • removeAction

        public void removeAction​(Node[] node)
        Edit action invoked if somebody pressed DELETE on node
        Parameters:
        node - node
      • isShowOwner

        protected boolean isShowOwner()
      • updateUI

        public void updateUI()
        Overrides:
        updateUI in class javax.swing.JPanel
      • removeUIListener

        private void removeUIListener()
        Remove default swing listener which scrolls item to some prefix on key event.
      • update

        public void update​(boolean deepUpdate)
        Specified by:
        update in interface com.nomagic.magicdraw.ui.Updatable
      • registerShortcutActions

        private void registerShortcutActions()
        Register all shortcut actions to the browser.
      • addTreeSelectionParticipant

        public void addTreeSelectionParticipant​(com.nomagic.magicdraw.ui.browser.Tree.TreeSelectionParticipant participant)
        Adds tree selection participant
        Parameters:
        participant - tree selection participant to execute additional methods before and after selection
      • init

        public void init()
      • getTreeRoot

        public com.nomagic.magicdraw.ui.browser.TreeRoot getTreeRoot()
      • init

        public void init​(com.nomagic.magicdraw.ui.browser.TreeRoot treeRoot)
      • initAsync

        public <A> void initAsync​(@CheckForNull
                                  A attachment,
                                  com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler)
        Type Parameters:
        A - The type of the object attached to the completion handler
        Parameters:
        attachment - the object for completion handler attached to this operation
        handler - the handler to consume completion of this operation, see initAsync(TreeRoot, Object, com.nomagic.magicdraw.utils.concurrent.CompletionHandler)
      • initAsync

        public <A> void initAsync​(com.nomagic.magicdraw.ui.browser.TreeRoot treeRoot,
                                  @CheckForNull
                                  A attachment,
                                  @CheckForNull
                                  com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler)
        Parameters:
        treeRoot - root
        attachment - the object for completion handler attached to this operation
        handler - the handler to consume completion of this operation or null. The handler is always invoked on EventQueue dispatch thread
      • maybeInvokeChainedHandler

        protected static <A> void maybeInvokeChainedHandler​(@CheckForNull
                                                            A attachment,
                                                            @CheckForNull
                                                            com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler,
                                                            @CheckForNull
                                                            java.lang.Throwable exc)
      • privateMaybeInvokeChainedHandler

        private static <A> void privateMaybeInvokeChainedHandler​(@CheckForNull
                                                                 A attachment,
                                                                 com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler,
                                                                 @CheckForNull
                                                                 java.lang.Throwable exc)
      • maybeInvokeChainedCH

        protected static <A> void maybeInvokeChainedCH​(@CheckForNull
                                                       A attachment,
                                                       @CheckForNull
                                                       com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler,
                                                       @CheckForNull
                                                       java.lang.Throwable exc)
      • updateBrowser

        public final boolean updateBrowser()
        Updates dirty nodes in tree with the newest data and shows it. The current thread will be blocked until tree update is complete, but the event dispatcher is going to continue to process events.
        Returns:
        true if update was performed
      • delete

        public void delete​(Node[] node)
      • delete

        public void delete​(Node[] nodes,
                           boolean useSpecificDeletion,
                           @CheckForNull
                           com.nomagic.magicdraw.commands.MacroCommand macroCommand)
        Deletes nodes
        Parameters:
        nodes - nodes which will be deleted
        useSpecificDeletion - if true deletes nodes with specific remove command
        macroCommand - to add delete commands
      • canDelete

        public boolean canDelete​(Node[] node)
        Test if all nodes can be deleted
        Parameters:
        node - array to check
        Returns:
        true if all elements can be deleted
      • updateBrowser

        public final boolean updateBrowser​(boolean updateOnlyDirty)
        Updates tree with the newest data and shows it. The current thread will be blocked until tree update is complete, but the event dispatcher is going to continue to process events.
        Parameters:
        updateOnlyDirty - - if true updates only dirty expanded nodes, otherwise - updates all expanded tree nodes
        Returns:
        true if update was performed
      • updateBrowser

        public final boolean updateBrowser​(boolean updateOnlyDirty,
                                           boolean updateNotShowing)
        Updates tree with the newest data and shows it. The current thread will be blocked until tree update is complete, but the event dispatcher is going to continue to process events.
        Parameters:
        updateOnlyDirty - if true updates only dirty expanded nodes, otherwise - updates all expanded tree nodes.
        updateNotShowing - forces update even if component is not showing.
        Returns:
        true if update was performed
      • browserUpdateDelayed

        protected void browserUpdateDelayed​(boolean updateOnlyDirty)
        Called if browser lazy and update vas delayed
        Parameters:
        updateOnlyDirty - if true updates only dirty expanded nodes, otherwise - updates all expanded tree nodes
      • specificUpdateBrowser

        protected void specificUpdateBrowser​(boolean updateOnlyDirty)
      • updateBrowserAsync

        public <A> void updateBrowserAsync​(boolean updateOnlyDirty,
                                           @CheckForNull
                                           A attachment,
                                           com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler,
                                           ProgressStatus status)
      • areDirtyNodesPresent

        private <A> boolean areDirtyNodesPresent​(boolean updateOnlyDirty,
                                                 @CheckForNull
                                                 A attachment,
                                                 @CheckForNull
                                                 com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler)
      • updateAllNodes

        private <A> void updateAllNodes​(@CheckForNull
                                        A attachment,
                                        com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler,
                                        ProgressStatus status)
      • updateOnlyDirtyNodes

        protected <A> boolean updateOnlyDirtyNodes​(@CheckForNull
                                                   A attachment,
                                                   com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler,
                                                   boolean updateAll)
      • maybeInvokeChainedHandler

        protected <A> void maybeInvokeChainedHandler​(@CheckForNull
                                                     A attachment,
                                                     com.nomagic.magicdraw.utils.concurrent.CompletionHandler<?,​? super A> handler,
                                                     com.nomagic.magicdraw.ui.browser.TreeModel browserModel,
                                                     @CheckForNull
                                                     java.lang.Throwable exc)
      • getSelectedNode

        @CheckForNull
        @OpenApi
        public Node getSelectedNode()
        Returns first selected node in the tree.
        Returns:
        first selected node.
      • getNode

        @CheckForNull
        @OpenApi
        public Node getNode​(int row)
        Returns first selected node in the tree.
        Returns:
        first selected node.
      • getSelectedNodes

        @OpenApi
        public Node[] getSelectedNodes()
        Returns all selected nodes in the tree.
        Returns:
        all selected nodes in the tree.
      • toNodes

        public static Node[] toNodes​(@CheckForNull
                                     javax.swing.tree.TreePath[] paths)
        Utility method for converting array of paths to array of nodes
        Parameters:
        paths - tree paths
        Returns:
        nodes
      • toNodes

        protected static Node[] toNodes​(@CheckForNull
                                        javax.swing.tree.TreePath[] paths,
                                        boolean loadingDummyNodeDistinction)
      • setSelectedNodes

        public void setSelectedNodes​(Node[] nodes)
        Selects given nodes in the tree. Deselects everything if nodes are null.
        Parameters:
        nodes - nodes
      • toTreePaths

        @CheckForNull
        public static javax.swing.tree.TreePath[] toTreePaths​(Node[] nodes)
        Utility method for converting array of nodes to array of paths
        Parameters:
        nodes - nodes
        Returns:
        tree paths
      • openNode

        @CheckForNull
        @OpenApi
        public final javax.swing.tree.TreePath openNode​(BaseElement object)
        Opens(expands) node for a give Element.
        Parameters:
        object - the element to expand in the tree
        Returns:
        path of opened node
      • openNode

        @CheckForNull
        @OpenApi
        public final javax.swing.tree.TreePath openNode​(BaseElement object,
                                                        boolean requestFocus)
        Opens(expands) node for a give Element. May request focus for a tree.
        Parameters:
        object - the element to expand in the tree
        requestFocus - request focus for a tree.
        Returns:
        path of opened node
      • openNode

        @CheckForNull
        @OpenApi
        public final javax.swing.tree.TreePath openNode​(@CheckForNull
                                                        BaseElement object,
                                                        boolean select,
                                                        boolean appendSelection,
                                                        boolean requestFocus)
        Opens(expands) node for a give Element. May request focus for a tree.
        Parameters:
        object - the element to expand in the tree
        select - select node.
        appendSelection - append to old selection or clear old selection
        requestFocus - request focus for a tree.
        Returns:
        path of opened node
      • openNode

        @CheckForNull
        @OpenApi
        public final javax.swing.tree.TreePath openNode​(BaseElement object,
                                                        boolean select,
                                                        boolean requestFocus)
        Opens(expands) node for a give Element. May request focus for a tree.
        Parameters:
        object - the element to expand in the tree
        select - select node.
        requestFocus - request focus for a tree.
        Returns:
        path of opened node
      • openNode

        @CheckForNull
        @OpenApi
        public final javax.swing.tree.TreePath openNode​(@CheckForNull
                                                        BaseElement object,
                                                        boolean select,
                                                        boolean appendSelection,
                                                        boolean requestFocus,
                                                        boolean scrollToVisible)
        Opens(expands) node for a give Element. May request focus for a tree.
        Parameters:
        object - the element to expand in the tree.
        select - select node.
        appendSelection - append to old selection or clear old selection
        requestFocus - request focus for a tree.
        scrollToVisible - do we need to scroll to visible?
        Returns:
        path of opened node.
      • openNode

        @CheckForNull
        public final javax.swing.tree.TreePath openNode​(@CheckForNull
                                                        BaseElement object,
                                                        @CheckForNull
                                                        com.nomagic.magicdraw.ui.ElementSelection selection,
                                                        boolean appendSelection)
      • openNode

        @CheckForNull
        public final javax.swing.tree.TreePath openNode​(@CheckForNull
                                                        BaseElement object,
                                                        @CheckForNull
                                                        com.nomagic.magicdraw.ui.ElementSelection selection,
                                                        boolean select,
                                                        boolean appendSelection,
                                                        boolean requestFocus,
                                                        boolean scrollToVisible)
      • waitForPreviousEventsOnOpeningNode

        protected boolean waitForPreviousEventsOnOpeningNode()
      • doBeforeOpenNode

        protected void doBeforeOpenNode()
      • openNode

        public void openNode​(java.util.Collection<? extends BaseElement> elements)
      • openNode

        public <T extends BaseElement> void openNode​(java.util.Collection<T> elements,
                                                     java.util.function.Consumer<T> failedConsumer)
      • waitForPreviousEvents

        private static void waitForPreviousEvents()
      • getAutoscrollInsets

        public java.awt.Insets getAutoscrollInsets()
        Specified by:
        getAutoscrollInsets in interface java.awt.dnd.Autoscroll
      • getActions

        protected ActionsManager getActions()
        Returns shortcuts action manager for this browser.
        Returns:
        ActionsManager with actions to register in this browser as KeyListeners
      • setBrowserForActions

        protected static void setBrowserForActions​(@CheckForNull
                                                   Tree tree,
                                                   ActionsManager manager,
                                                   @CheckForNull
                                                   com.nomagic.magicdraw.ui.ElementSelectionProvider provider)
      • doSetBrowserForAction

        private static void doSetBrowserForAction​(@CheckForNull
                                                  Tree tree,
                                                  NMAction action,
                                                  @CheckForNull
                                                  com.nomagic.magicdraw.ui.ElementSelectionProvider provider)
      • showPopupMenu

        public void showPopupMenu​(java.awt.event.MouseEvent evt)
        Specified by:
        showPopupMenu in interface com.nomagic.awt.PopupOwner
      • decorateTree

        public void decorateTree()
      • getDefaultFocusable

        public java.awt.Component getDefaultFocusable()
        Description copied from class: ExtendedPanel
        Request Focus for some component. Here it is empty.
      • editPath

        public void editPath​(javax.swing.tree.TreePath path)
      • autoscroll

        public void autoscroll​(java.awt.Point pt)
        Implementation of auto-scroll interface method auto-scroll(Point) Scrolls to specified point.
        Specified by:
        autoscroll in interface java.awt.dnd.Autoscroll
        Parameters:
        pt - - Point
      • getRootNode

        @OpenApi
        public Node getRootNode()
        Returns root node of the tree.
        Overrides:
        getRootNode in class AbstractTree
        Returns:
        root node.
      • dispose

        public void dispose()
        Removes all nodes recursively.
      • disposeNodes

        public void disposeNodes()
        Dispose nodes added into the tree.
      • getTreeModel

        public com.nomagic.magicdraw.ui.browser.TreeModel getTreeModel()
      • collectSelectedNodes

        public void collectSelectedNodes​(com.nomagic.magicdraw.ui.browser.TreeModel treeModel,
                                         javax.swing.tree.TreePath parentPath,
                                         com.nomagic.magicdraw.ui.browser.TreeSelectionTracker selectionTracker)
        Collects selected nodes.

        During event dispatching node state can change from Node <-> LoadingDummyNode If node was selected it must be selected when node state is changed. On treeStructureChanged event all selected tree paths are collected, on treeNodesChanged event they are selected.

        Parameters:
        treeModel - model
        parentPath - parent path
        selectionTracker - selection tracker
      • reset

        public void reset()
        Description copied from interface: Cachable
        Cache managers invokes this method to free resources. Usually this method must drop references to external objects in order to enable garbage collection of them.
        Specified by:
        reset in interface Cachable
      • initCellRendererEditor

        private void initCellRendererEditor​(javax.swing.JTree tree)
      • isUpdateIfShowing

        public boolean isUpdateIfShowing()
        Returns if tree only updates when showing
        Returns:
        true if tree only updates when showing
      • setUpdateIfShowing

        public void setUpdateIfShowing​(boolean updateIfShowing)
        Allows setting tree to update only if showing
        Parameters:
        updateIfShowing - true if tree should only update when showing