Class DiagramWindow

  • All Implemented Interfaces:
    com.nomagic.magicdraw.ui.Activatable, DiagramPresentationElementGetter, com.nomagic.ui.CursorOwner, HiDPIScalableComponent, java.awt.event.FocusListener, java.awt.event.WindowListener, java.beans.PropertyChangeListener, java.util.EventListener

    @OpenApi
    public class DiagramWindow
    extends java.lang.Object
    implements java.awt.event.WindowListener, java.beans.PropertyChangeListener, com.nomagic.ui.CursorOwner, java.awt.event.FocusListener, com.nomagic.magicdraw.ui.Activatable, HiDPIScalableComponent, DiagramPresentationElementGetter
    This class is base class for diagram specific windows.
    • Field Detail

      • CLASS_TYPE_SUFFIX

        public static final java.lang.String CLASS_TYPE_SUFFIX
        See Also:
        Constant Field Values
      • panel

        private com.nomagic.magicdraw.ui.DiagramWindowPanel panel
      • dropTarget

        @CheckForNull
        private com.nomagic.magicdraw.ui.DiagramWindow.DiagramWindowDropTarget dropTarget
      • container

        private com.nomagic.magicdraw.ui.DiagramFrame container
      • scaled

        private boolean scaled
    • Constructor Detail

      • DiagramWindow

        public DiagramWindow​(com.nomagic.magicdraw.ui.DiagramWindowPanel panel)
        Constructs window with specified panel.
        Parameters:
        panel - the panel to set.
    • Method Detail

      • updateIcon

        public void updateIcon()
        updates icon according to diagram type.
      • setImageIcon

        public void setImageIcon​(javax.swing.Icon i)
      • getImageIcon

        @CheckForNull
        public javax.swing.Icon getImageIcon()
      • getTitle

        public java.lang.String getTitle()
      • updateTitle

        public void updateTitle()
        Sets the title of the window. The title will be "diagram type - title)
      • propertyChange

        public void propertyChange​(java.beans.PropertyChangeEvent event)
        Changes the title after Diagram changed the name. Enables or disables the toolbar according to the diagram checkout state. Every DiagramWindow registers in the Diagram as PropertyChangeListener.
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
        Parameters:
        event - the propertyChangeEvent thrown from Diagram.
      • enabledDisabledToolbar

        public void enabledDisabledToolbar()
        Disable or enable the toolbar according to the checkout state of the diagram.
      • reLayoutToolbars

        private void reLayoutToolbars()
      • setVisible

        public void setVisible​(boolean visible)
      • getLocation

        @CheckForNull
        public java.awt.Point getLocation()
      • setLocation

        public void setLocation​(java.awt.Point l)
      • getFrame

        @CheckForNull
        public com.nomagic.magicdraw.ui.DiagramFrame getFrame()
      • setFrame

        public void setFrame​(com.nomagic.magicdraw.ui.DiagramFrame diagramFrame)
      • dropFrame

        public void dropFrame()
        rejects current frame without disposing it and disposes this window. This way current frame can be reused for another diagram window
      • updateFrame

        public void updateFrame()
        Updates frame to display diagram panel of this window
      • windowActivated

        public void windowActivated​(java.awt.event.WindowEvent e)
        handles window activation event
        Specified by:
        windowActivated in interface java.awt.event.WindowListener
        Parameters:
        e - Window event to handle
        See Also:
        WindowListener, WindowEvent
      • windowClosed

        public void windowClosed​(java.awt.event.WindowEvent e)
        handles event invoked after window closing
        Specified by:
        windowClosed in interface java.awt.event.WindowListener
        Parameters:
        e - Window event to handle
        See Also:
        WindowListener, WindowEvent
      • closeWindow

        public void closeWindow()
        Closes the window
      • needUnloadOnWindowClose

        private static boolean needUnloadOnWindowClose​(PresentationElement element)
      • isInEsiReadOnlyMode

        private static boolean isInEsiReadOnlyMode​(Project project)
      • windowClosing

        public void windowClosing​(java.awt.event.WindowEvent e)
        handles window closing event
        Specified by:
        windowClosing in interface java.awt.event.WindowListener
        Parameters:
        e - Window event to handle
        See Also:
        WindowListener, WindowEvent
      • windowDeactivated

        public void windowDeactivated​(java.awt.event.WindowEvent e)
        handles window deactivation event
        Specified by:
        windowDeactivated in interface java.awt.event.WindowListener
        Parameters:
        e - Window event to handle
        See Also:
        WindowListener, WindowEvent
      • windowDeiconified

        public void windowDeiconified​(java.awt.event.WindowEvent e)
        handles window iconified event
        Specified by:
        windowDeiconified in interface java.awt.event.WindowListener
        Parameters:
        e - Window event to handle
        See Also:
        WindowListener, WindowEvent
      • windowIconified

        public void windowIconified​(java.awt.event.WindowEvent e)
        handles window iconified event
        Specified by:
        windowIconified in interface java.awt.event.WindowListener
        Parameters:
        e - Window event to handle
        See Also:
        WindowListener, WindowEvent
      • windowOpened

        public void windowOpened​(java.awt.event.WindowEvent e)
        handles window opening event
        Specified by:
        windowOpened in interface java.awt.event.WindowListener
        Parameters:
        e - Window event to handle
        See Also:
        WindowListener, WindowEvent
      • toFront

        public void toFront()
      • requestFocus

        public void requestFocus()
      • setBounds

        public void setBounds​(java.awt.Rectangle r)
      • getBounds

        @CheckForNull
        public java.awt.Rectangle getBounds()
      • getClassType

        public java.lang.String getClassType()
        Gets the type of the class.
        Returns:
        the type of the class - a String
      • getDrawArea

        @CheckForNull
        public com.nomagic.magicdraw.ui.DrawArea getDrawArea()
        Get draw area of the window. This method returns the draw area panel from DiagramWindowPanel.
        Returns:
        current draw area
      • getPanel

        public com.nomagic.magicdraw.ui.DiagramWindowPanel getPanel()
        Returns the panel on which diagram is drawn.
        Returns:
        the diagram drawing panel.
      • getSpecificCursor

        public java.awt.Cursor getSpecificCursor()
        Returns cursor of the tree
        Specified by:
        getSpecificCursor in interface com.nomagic.ui.CursorOwner
      • setSpecificCursor

        public void setSpecificCursor​(java.awt.Cursor c)
        Sets cursor for documentation and tree
        Specified by:
        setSpecificCursor in interface com.nomagic.ui.CursorOwner
      • getCurrentCursor

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

        public void focusGained​(java.awt.event.FocusEvent e)
        When focus is gained, it must be reset to canvas. If window gained focus, use thread to delay some time before forwarding.
        Specified by:
        focusGained in interface java.awt.event.FocusListener
        Parameters:
        e - event to process
      • focusLost

        public void focusLost​(java.awt.event.FocusEvent e)
        When focus is lost, set focus flag of the window
        Specified by:
        focusLost in interface java.awt.event.FocusListener
        Parameters:
        e - event to process.
      • isVisible

        public boolean isVisible()
      • getLocationOnScreen

        @CheckForNull
        public java.awt.Point getLocationOnScreen()
      • dispose

        public void dispose()
      • registerDiagramListener

        private void registerDiagramListener()
      • unregisterDiagramListener

        private void unregisterDiagramListener()
      • createDiagramToolbars

        public static void createDiagramToolbars​(boolean createDiagramToolbar,
                                                 boolean createDiagramElementsToolbar)
      • createDiagramToolbars

        public static void createDiagramToolbars​(DiagramWindow diagramWindow,
                                                 boolean createDiagramToolbar,
                                                 boolean createDiagramElementsToolbar)
      • isEnableLoadOnActivation

        public boolean isEnableLoadOnActivation()
        Returns:
        true if diagram should load content on activation
      • setEnableLoadOnActivation

        public void setEnableLoadOnActivation​(boolean enableLoadOnActivation)
        Set load content on activation state
        Parameters:
        enableLoadOnActivation - true if diagram should load content on activation
      • activate

        public void activate()
        Activate window - load diagram content if needed.
        Specified by:
        activate in interface com.nomagic.magicdraw.ui.Activatable
      • storeDiagramViewState

        public void storeDiagramViewState()
        Remembers all view options/parameters upon close, so it's state could be restored when diagram is opened again.
      • restoreDiagramViewState

        public void restoreDiagramViewState()
        Restore window state from diagram view options
      • getProject

        @CheckForNull
        public Project getProject()
        Specified by:
        getProject in interface com.nomagic.magicdraw.ui.Activatable
      • executeWithLockedRepaint

        public static void executeWithLockedRepaint​(java.lang.Runnable run,
                                                    @CheckForNull
                                                    com.nomagic.magicdraw.ui.DiagramWindowPanel diagramWindowPanel)
        Executes given runnable while not repainting diagram window panel.
        Parameters:
        run - runnable to execute
        diagramWindowPanel - diagram window panel which must be repainted after this runnable completes
      • getCanvas

        @CheckForNull
        private com.nomagic.magicdraw.ui.DiagramCanvas getCanvas()
      • handleListener

        private void handleListener​(com.nomagic.magicdraw.ui.DiagramWindow.ListenerHandler listenerHandler,
                                    java.util.function.BiConsumer<DiagramPresentationElement,​java.beans.PropertyChangeListener> consumer)