Class MainFrame

  • All Implemented Interfaces:
    com.jidesoft.action.DockableBarDockableHolder, com.jidesoft.action.DockableBarHolder, com.jidesoft.docking.DockableHolder, ActionsGroups, EnvironmentOptions.EnvironmentChangeListener, com.nomagic.ui.CursorOwner, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    @OpenApi
    public final class MainFrame
    extends com.jidesoft.action.DefaultDockableBarDockableHolder
    implements java.beans.PropertyChangeListener, com.nomagic.ui.CursorOwner, ActionsGroups, EnvironmentOptions.EnvironmentChangeListener
    The MainFrame class represents main window of the MagicDraw application. Also it has a set of inner classes- event listeners to handle all menu and toolbar events.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  com.nomagic.magicdraw.ui.MainFrame.DefaultStatusLine  
      private static class  com.nomagic.magicdraw.ui.MainFrame.MainFrameDockableBarChangeListener  
      private static class  com.nomagic.magicdraw.ui.MainFrame.MainMenuExpertModeCustomizer  
      private static class  com.nomagic.magicdraw.ui.MainFrame.MainWindowAdapter
      The MainWindowAdapter class represents window events handler for MainFrame window.
      • Nested classes/interfaces inherited from class javax.swing.JFrame

        javax.swing.JFrame.AccessibleJFrame
      • Nested classes/interfaces inherited from class java.awt.Frame

        java.awt.Frame.AccessibleAWTFrame
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • 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
      MainFrame​(com.nomagic.magicdraw.core.Application.MainFrameController controller)
      Constructs MainFrame window, adds menu and popup buttons toolbar to it.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      private void addCloseProjectButton​(com.jidesoft.action.CommandBar menuBar)  
      void addRecentWindow​(DiagramWindow window)
      Adds diagram window name to the recent window list.
      static void addStateListener​(java.beans.PropertyChangeListener listener)
      Adds listener for listening changes of recent windows, projects or files.
      private static void checkAndShowWarningFor​(java.lang.String id, PropertyManager propertyManager)  
      private static void closeOpenedMenu()  
      void createCommandBar()
      Deprecated.
      private void createMenu()
      Creates new instance of JMenu of the MainFrame.
      void createMenuAndToolbars()
      Create (or recreate) all menu and toolbars.
      private void createProgressBar()  
      java.lang.Runnable createStartupActivity()
      Creates startup activity for setting APPLICATION_STARTED flag.
      private void createToolbar()  
      java.awt.Frame getActiveFrame()  
      Browser getBrowser()
      Returns model browser.
      CookieSet getCookieSet()  
      java.awt.Cursor getCurrentCursor()  
      javax.swing.JMenuBar getMainMenuBar()
      Returns main menu bar.
      com.nomagic.magicdraw.ui.ProgressBar getProgressBar()  
      java.lang.String getProjectTitle​(Project project)
      Returns project title suitable for application title bar
      ProjectWindowsManager getProjectWindowsManager()
      Returns ProjectWindowsManager.
      java.awt.Cursor getSpecificCursor()  
      com.nomagic.awt.StatusLine getStatusLine()  
      com.nomagic.magicdraw.ui.toolbar.ToolbarsManager getToolbarsManager()  
      com.nomagic.magicdraw.ui.UIInstaller getUIInstaller()  
      private static java.awt.Rectangle getVisibleBounds​(java.awt.Rectangle preferredBounds)
      Returns visible bounds of the frame.
      java.util.function.Consumer<java.awt.Window> getWindowFullScreenCustomizer()  
      com.nomagic.magicdraw.ui.WindowsManagerImpl getWindowsManager()  
      void init()
      Creates GUI elements in MainFrame: menu and toolbar, browser and desktop.
      static boolean isLFUpdateRequired​(java.lang.String lf, java.lang.String themeID, int jideStyle)  
      static boolean isSilentMode()
      Returns, flag, which shows if MF is working in silent mode.
      private static boolean isVisibleBounds​(java.awt.Rectangle r)
      Returns whether the specified rectangle is fully visible on screen or not
      void propertyChange​(java.beans.PropertyChangeEvent evt)
      Handles Property changing event, fired by PropertyChangeSupport
      private static boolean rememberBrowserStateForProjects​(boolean done)  
      private void removeRecentWindow​(DiagramWindow window)
      Removes window from list.
      private void restoreBoundsHack()
      fix for: https://jira.nomagic.com/browse/MDUML-67827, https://jira.nomagic.com/browse/MDUML-87461
      void setActiveFrame​(java.awt.Frame activeFrame)  
      void setBounds​(java.awt.Rectangle r)  
      boolean setLF​(java.lang.String lf, java.lang.String theme, int jideStyle, boolean explicitlyUpdateUI)  
      void setRecentWindowsList​(java.util.Collection<DiagramWindow> windows)
      Sets the list of the recent windows.
      static void setSilentMode​(boolean silentMode)
      Set flag, which shows if MF is working in silent mode.
      void setSpecificCursor​(java.awt.Cursor c)  
      void setStatusLine​(com.nomagic.awt.StatusLine statusLine)  
      void setUIInstaller​(com.nomagic.magicdraw.ui.UIInstaller installer)  
      void setVisible​(boolean visible)  
      void setWindowFullScreenCustomizer​(java.util.function.Consumer<java.awt.Window> windowFullScreenCustomizer)  
      void sSetLF​(java.lang.String lf, java.lang.String themeID, int jideStyle, boolean explicitlyUpdateUI)
      Set look and feel without handling errors
      private static void updateByEnvironmentOptions()
      Update environment by current environment options.
      void updateByEnvironmentProperties​(java.util.List<Property> properties)
      Update environment by given properties.
      private static void updateExistingSearchResultsTree​(Project project)  
      private void updateFrameUI()
      Updates all elements ui
      void updateRecentProject​(Project prj)
      Updates project label in projects choice.
      void updateTitle​(Project project)  
      • Methods inherited from class com.jidesoft.action.DefaultDockableBarDockableHolder

        createContentContainer, createDockableBarManager, dispose, getDockableBarManager, getJMenuBar, getLayoutPersistence, initFrame
      • Methods inherited from class com.jidesoft.docking.DefaultDockableHolder

        createDockingManager, getDockingManager, isAutoDispose, isContentPaneCheckingEnabled, setAutoDispose, setContentPaneCheckingEnabled
      • Methods inherited from class javax.swing.JFrame

        addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Frame

        addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, show, toBack, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, 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.jidesoft.docking.DockableHolder

        getDockingManager
      • Methods inherited from interface java.awt.MenuContainer

        getFont, postEvent
    • Field Detail

      • MAIN_TOOLBAR_EXPERT

        public static final java.lang.String MAIN_TOOLBAR_EXPERT
        See Also:
        Constant Field Values
      • MAIN_TOOLBAR_STANDARD

        public static final java.lang.String MAIN_TOOLBAR_STANDARD
        See Also:
        Constant Field Values
      • RECENT_PROJECT_NAME_CHANGE

        public static final java.lang.String RECENT_PROJECT_NAME_CHANGE
        See Also:
        Constant Field Values
      • cookieSet

        private final CookieSet cookieSet
      • progressBar

        private com.nomagic.magicdraw.ui.ProgressBar progressBar
      • mainMenuBar

        private com.jidesoft.action.CommandBar mainMenuBar
      • statusLine

        private com.nomagic.awt.StatusLine statusLine
      • uiInstaller

        private com.nomagic.magicdraw.ui.UIInstaller uiInstaller
      • recentWindows

        private final java.util.List<DiagramWindow> recentWindows
      • support

        private static final com.nomagic.utils.ExtendedPropertyChangeSupport support
        Support for listeners of changing recent files.
      • silentMode

        private static boolean silentMode
        Flag, which shows if MF is working in silent mode.
      • windowsManager

        private com.nomagic.magicdraw.ui.WindowsManagerImpl windowsManager
      • activeFrame

        @CheckForNull
        private java.awt.Frame activeFrame
      • toolbarsManager

        private com.nomagic.magicdraw.ui.toolbar.ToolbarsManager toolbarsManager
      • mainFrameController

        private final com.nomagic.magicdraw.core.Application.MainFrameController mainFrameController
      • dockableBarChangeListener

        private com.nomagic.magicdraw.ui.DockableBarChangeListener dockableBarChangeListener
      • ignoreVisibilityChange

        private boolean ignoreVisibilityChange
      • windowFullScreenCustomizer

        private java.util.function.Consumer<java.awt.Window> windowFullScreenCustomizer
      • mStartupActivity

        private final java.lang.Runnable mStartupActivity
        Runnable for checking if MD is started first time if it is started first time notification will be showed about news and note worthy.
    • Constructor Detail

      • MainFrame

        public MainFrame​(com.nomagic.magicdraw.core.Application.MainFrameController controller)
        Constructs MainFrame window, adds menu and popup buttons toolbar to it. Also this method sets event listeners for each menu item and toolbar button.
        Parameters:
        controller - controller
    • Method Detail

      • setBounds

        public void setBounds​(java.awt.Rectangle r)
        Overrides:
        setBounds in class java.awt.Window
      • getVisibleBounds

        private static java.awt.Rectangle getVisibleBounds​(java.awt.Rectangle preferredBounds)
        Returns visible bounds of the frame. If the preferred bounds are visible then return the preferred bounds. If the preferred bounds are not fully visible then returns bounds of the default display.
        Parameters:
        preferredBounds - preferred bounds.
        Returns:
        visible bounds.
      • isVisibleBounds

        private static boolean isVisibleBounds​(java.awt.Rectangle r)
        Returns whether the specified rectangle is fully visible on screen or not
        Parameters:
        r - a rectangle.
        Returns:
        true if the specified rectangle is fully visible.
      • createMenu

        private void createMenu()
        Creates new instance of JMenu of the MainFrame. The created menu is not set as menu of the frame.
      • addCloseProjectButton

        private void addCloseProjectButton​(com.jidesoft.action.CommandBar menuBar)
      • getMainMenuBar

        @OpenApi
        public javax.swing.JMenuBar getMainMenuBar()
        Returns main menu bar.
        Returns:
        main menu bar.
      • setActiveFrame

        public void setActiveFrame​(@CheckForNull
                                   java.awt.Frame activeFrame)
      • getActiveFrame

        public java.awt.Frame getActiveFrame()
      • init

        public void init()
        Creates GUI elements in MainFrame: menu and toolbar, browser and desktop. And adds action listeners to menu items and toolbar buttons
      • createCommandBar

        @Deprecated
        public void createCommandBar()
        Deprecated.
        use createMenuAndToolbars(). Some people use this api, because we had no way
      • createToolbar

        private void createToolbar()
      • createProgressBar

        private void createProgressBar()
      • getBrowser

        @CheckForNull
        @OpenApi
        public Browser getBrowser()
        Returns model browser.
        Returns:
        model browser.
      • checkAndShowWarningFor

        private static void checkAndShowWarningFor​(java.lang.String id,
                                                   PropertyManager propertyManager)
      • updateExistingSearchResultsTree

        private static void updateExistingSearchResultsTree​(Project project)
      • rememberBrowserStateForProjects

        private static boolean rememberBrowserStateForProjects​(boolean done)
      • updateByEnvironmentOptions

        private static void updateByEnvironmentOptions()
        Update environment by current environment options.
      • isSilentMode

        public static boolean isSilentMode()
        Returns, flag, which shows if MF is working in silent mode.
        Returns:
        flag, which shows if MF is working in silent mode.
      • setSilentMode

        public static void setSilentMode​(boolean silentMode)
        Set flag, which shows if MF is working in silent mode.

        Used by Forte Integration.

        Parameters:
        silentMode - flag, which shows if MF is working in silent mode.
      • getSpecificCursor

        public java.awt.Cursor getSpecificCursor()
        Specified by:
        getSpecificCursor in interface com.nomagic.ui.CursorOwner
      • getCurrentCursor

        public java.awt.Cursor getCurrentCursor()
        Specified by:
        getCurrentCursor in interface com.nomagic.ui.CursorOwner
      • setSpecificCursor

        public void setSpecificCursor​(java.awt.Cursor c)
        Specified by:
        setSpecificCursor in interface com.nomagic.ui.CursorOwner
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent evt)
        Handles Property changing event, fired by PropertyChangeSupport

        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Parameters:
        evt - PropertyChangeEvent, which has to be handled.

        See Also:
        PropertyChangeListener, PropertyChangeEvent, PropertyChangeListener, PropertyChangeSupport
      • closeOpenedMenu

        private static void closeOpenedMenu()
      • setLF

        public boolean setLF​(java.lang.String lf,
                             java.lang.String theme,
                             int jideStyle,
                             boolean explicitlyUpdateUI)
      • sSetLF

        public void sSetLF​(java.lang.String lf,
                           java.lang.String themeID,
                           int jideStyle,
                           boolean explicitlyUpdateUI)
                    throws java.lang.Throwable
        Set look and feel without handling errors
        Parameters:
        lf - lf name
        themeID - theme id
        jideStyle - jide style
        explicitlyUpdateUI - update ui flag
        Throws:
        java.lang.Throwable - exception
      • isLFUpdateRequired

        public static boolean isLFUpdateRequired​(java.lang.String lf,
                                                 java.lang.String themeID,
                                                 int jideStyle)
      • updateFrameUI

        private void updateFrameUI()
        Updates all elements ui
      • addRecentWindow

        public void addRecentWindow​(DiagramWindow window)
        Adds diagram window name to the recent window list.
        Parameters:
        window - the window to add.
      • removeRecentWindow

        private void removeRecentWindow​(DiagramWindow window)
        Removes window from list.
        Parameters:
        window - window to remove.
      • setRecentWindowsList

        public void setRecentWindowsList​(java.util.Collection<DiagramWindow> windows)
        Sets the list of the recent windows.
        Parameters:
        windows - the new list of the recent windows.
      • updateRecentProject

        public void updateRecentProject​(Project prj)
        Updates project label in projects choice.
        Parameters:
        prj - - project to update
      • getProjectWindowsManager

        @OpenApi
        public ProjectWindowsManager getProjectWindowsManager()
        Returns ProjectWindowsManager.
        Returns:
        project windows manager.
      • getWindowsManager

        public com.nomagic.magicdraw.ui.WindowsManagerImpl getWindowsManager()
      • addStateListener

        public static void addStateListener​(java.beans.PropertyChangeListener listener)
        Adds listener for listening changes of recent windows, projects or files.
        Parameters:
        listener - listener for listening changes of recent windows, projects or files.
      • updateTitle

        public void updateTitle​(@CheckForNull
                                Project project)
      • getProjectTitle

        public java.lang.String getProjectTitle​(Project project)
        Returns project title suitable for application title bar
        Parameters:
        project - project instance of Project
        Returns:
        project title suitable for application title bar
      • setStatusLine

        public void setStatusLine​(com.nomagic.awt.StatusLine statusLine)
      • getStatusLine

        public com.nomagic.awt.StatusLine getStatusLine()
      • getCookieSet

        public CookieSet getCookieSet()
      • getProgressBar

        public com.nomagic.magicdraw.ui.ProgressBar getProgressBar()
        Returns:
        Returns the progressBar.
      • getUIInstaller

        public com.nomagic.magicdraw.ui.UIInstaller getUIInstaller()
        Returns:
        Returns the uIInstaller.
      • setUIInstaller

        public void setUIInstaller​(com.nomagic.magicdraw.ui.UIInstaller installer)
        Parameters:
        installer - The uIInstaller to set.
      • setVisible

        public void setVisible​(boolean visible)
        Overrides:
        setVisible in class java.awt.Window
      • getToolbarsManager

        public com.nomagic.magicdraw.ui.toolbar.ToolbarsManager getToolbarsManager()
      • createStartupActivity

        public java.lang.Runnable createStartupActivity()
        Creates startup activity for setting APPLICATION_STARTED flag.
        Returns:
        runnable
      • getWindowFullScreenCustomizer

        public java.util.function.Consumer<java.awt.Window> getWindowFullScreenCustomizer()
      • setWindowFullScreenCustomizer

        public void setWindowFullScreenCustomizer​(java.util.function.Consumer<java.awt.Window> windowFullScreenCustomizer)
      • restoreBoundsHack

        private void restoreBoundsHack()
        fix for: https://jira.nomagic.com/browse/MDUML-67827, https://jira.nomagic.com/browse/MDUML-87461