Package com.nomagic.magicdraw.ui
Class DiagramWindow
- java.lang.Object
-
- com.nomagic.magicdraw.ui.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
com.nomagic.magicdraw.ui.DiagramWindow.DiagramWindowDropTarget
private static class
com.nomagic.magicdraw.ui.DiagramWindow.DiagramWindowRepaintFilter
private static interface
com.nomagic.magicdraw.ui.DiagramWindow.ListenerHandler
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
CLASS_TYPE
static java.lang.String
CLASS_TYPE_SUFFIX
private com.nomagic.magicdraw.ui.DiagramFrame
container
private com.nomagic.magicdraw.ui.DiagramWindow.DiagramWindowDropTarget
dropTarget
static int
MAX_DIAGRAM_NAME
private com.nomagic.magicdraw.ui.DiagramWindowPanel
panel
private boolean
scaled
-
Constructor Summary
Constructors Constructor Description DiagramWindow(com.nomagic.magicdraw.ui.DiagramWindowPanel panel)
Constructs window with specified panel.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate()
Activate window - load diagram content if needed.void
closeWindow()
Closes the windowstatic void
createDiagramToolbars(boolean createDiagramToolbar, boolean createDiagramElementsToolbar)
static void
createDiagramToolbars(DiagramWindow diagramWindow, boolean createDiagramToolbar, boolean createDiagramElementsToolbar)
void
dispose()
void
dropFrame()
rejects current frame without disposing it and disposes this window.void
enabledDisabledToolbar()
Disable or enable the toolbar according to the checkout state of the diagram.static void
executeWithLockedRepaint(java.lang.Runnable run, com.nomagic.magicdraw.ui.DiagramWindowPanel diagramWindowPanel)
Executes given runnable while not repainting diagram window panel.void
focusGained(java.awt.event.FocusEvent e)
When focus is gained, it must be reset to canvas.void
focusLost(java.awt.event.FocusEvent e)
When focus is lost, set focus flag of the windowjava.awt.Rectangle
getBounds()
private com.nomagic.magicdraw.ui.DiagramCanvas
getCanvas()
java.lang.String
getClassType()
Gets the type of the class.java.awt.Cursor
getCurrentCursor()
DiagramPresentationElement
getDiagramPresentationElement()
Returns the diagram view of this window.com.nomagic.magicdraw.ui.DrawArea
getDrawArea()
Get draw area of the window.com.nomagic.magicdraw.ui.DiagramFrame
getFrame()
javax.swing.Icon
getImageIcon()
java.awt.Point
getLocation()
java.awt.Point
getLocationOnScreen()
com.nomagic.magicdraw.ui.DiagramWindowPanel
getPanel()
Returns the panel on which diagram is drawn.Project
getProject()
java.awt.Cursor
getSpecificCursor()
Returns cursor of the treejava.lang.String
getTitle()
private void
handleListener(com.nomagic.magicdraw.ui.DiagramWindow.ListenerHandler listenerHandler, java.util.function.BiConsumer<DiagramPresentationElement,java.beans.PropertyChangeListener> consumer)
boolean
isEnableLoadOnActivation()
boolean
isHiDPIScaled()
private static boolean
isInEsiReadOnlyMode(Project project)
boolean
isVisible()
private static boolean
needUnloadOnWindowClose(PresentationElement element)
void
propertyChange(java.beans.PropertyChangeEvent event)
Changes the title after Diagram changed the name.private void
registerDiagramListener()
private void
reLayoutToolbars()
void
requestFocus()
void
restoreDiagramViewState()
Restore window state from diagram view optionsvoid
scaleForHiDPI()
void
setBounds(java.awt.Rectangle r)
void
setDiagramView(DiagramPresentationElement view)
void
setEnableLoadOnActivation(boolean enableLoadOnActivation)
Set load content on activation statevoid
setFrame(com.nomagic.magicdraw.ui.DiagramFrame diagramFrame)
void
setHiDPIScaled(boolean scaled)
void
setImageIcon(javax.swing.Icon i)
void
setLocation(java.awt.Point l)
void
setSpecificCursor(java.awt.Cursor c)
Sets cursor for documentation and treevoid
setVisible(boolean visible)
void
storeDiagramViewState()
Remembers all view options/parameters upon close, so it's state could be restored when diagram is opened again.void
toFront()
private void
unregisterDiagramListener()
void
updateFrame()
Updates frame to display diagram panel of this windowvoid
updateIcon()
updates icon according to diagram type.void
updateTitle()
Sets the title of the window.void
windowActivated(java.awt.event.WindowEvent e)
handles window activation eventvoid
windowClosed(java.awt.event.WindowEvent e)
handles event invoked after window closingvoid
windowClosing(java.awt.event.WindowEvent e)
handles window closing eventvoid
windowDeactivated(java.awt.event.WindowEvent e)
handles window deactivation eventvoid
windowDeiconified(java.awt.event.WindowEvent e)
handles window iconified eventvoid
windowIconified(java.awt.event.WindowEvent e)
handles window iconified eventvoid
windowOpened(java.awt.event.WindowEvent e)
handles window opening event
-
-
-
Field Detail
-
MAX_DIAGRAM_NAME
public static final int MAX_DIAGRAM_NAME
- See Also:
- Constant Field Values
-
CLASS_TYPE
private static final java.lang.String CLASS_TYPE
- See Also:
- Constant Field Values
-
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
-
-
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 interfacejava.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()
-
setDiagramView
public void setDiagramView(@CheckForNull DiagramPresentationElement view)
-
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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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 interfacejava.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
-
getDiagramPresentationElement
@CheckForNull @OpenApi public DiagramPresentationElement getDiagramPresentationElement()
Returns the diagram view of this window. This method returns the diagram view from DiagramWindowPanel.- Specified by:
getDiagramPresentationElement
in interfaceDiagramPresentationElementGetter
- Returns:
- current diagram view.
-
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 interfacecom.nomagic.ui.CursorOwner
-
setSpecificCursor
public void setSpecificCursor(java.awt.Cursor c)
Sets cursor for documentation and tree- Specified by:
setSpecificCursor
in interfacecom.nomagic.ui.CursorOwner
-
getCurrentCursor
@CheckForNull public java.awt.Cursor getCurrentCursor()
- Specified by:
getCurrentCursor
in interfacecom.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 interfacejava.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 interfacejava.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 interfacecom.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 interfacecom.nomagic.magicdraw.ui.Activatable
-
isHiDPIScaled
public boolean isHiDPIScaled()
- Specified by:
isHiDPIScaled
in interfaceHiDPIScalableComponent
-
setHiDPIScaled
public void setHiDPIScaled(boolean scaled)
- Specified by:
setHiDPIScaled
in interfaceHiDPIScalableComponent
-
scaleForHiDPI
public void scaleForHiDPI()
- Specified by:
scaleForHiDPI
in interfaceHiDPIScalableComponent
-
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 executediagramWindowPanel
- 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)
-
-