Class DiagramViewManager

java.lang.Object
de.cau.cs.kieler.klighd.ui.DiagramViewManager
All Implemented Interfaces:
org.eclipse.ui.IPartListener

public final class DiagramViewManager extends Object implements org.eclipse.ui.IPartListener
A singleton manager for creating, updating and closing diagram views. All methods in this class have to be called in the UI thread.
Author:
mri, chsch
  • Method Details

    • getInstance

      public static DiagramViewManager getInstance()
      Returns the singleton instance.
      Returns:
      the singleton instance
    • getDiagramWorkbenchPart

      public static IDiagramWorkbenchPart getDiagramWorkbenchPart(String id)
      Returns the IDiagramWorkbenchPart associated with the given identifier if available.
      Parameters:
      id - the diagram view identifier (can be null for the default view)
      Returns:
      the diagram view or null if no view with the given identifier exists
    • getView

      public static DiagramViewPart getView(String id)
      Returns the diagram view with the given identifier if available.
      Parameters:
      id - the diagram view identifier (can be null for the default view)
      Returns:
      the diagram view or null if no view with the given identifier exists
    • getEditor

      public static DiagramEditorPart getEditor(String id)
      Returns the diagram editor part with the given identifier if available.
      Parameters:
      id - the diagram view identifier (can be null for the default view)
      Returns:
      the diagram editor part or null if no view with the given identifier exists
    • updateView

      public static IDiagramWorkbenchPart updateView(String id)
      Updates the diagram view with the given identifier.

      The model has to be of the type of the old model, i.e. the view context associated with the identifier must support the model.
      Parameters:
      id - the diagram identifier (can be null for the default view)
      Returns:
      the view with the identifier or null on failure
    • updateView

      public static IDiagramWorkbenchPart updateView(String id, org.eclipse.elk.graph.properties.IPropertyHolder properties)
      Updates the diagram view with the given identifier.

      The model has to be of the type of the old model, i.e. the view context associated with the identifier must support the model.
      Parameters:
      id - the diagram identifier (can be null for the default view)
      properties - the property holder containing properties configurations or null
      Returns:
      the view with the identifier or null on failure
    • updateView

      public static IDiagramWorkbenchPart updateView(String id, String name, Object model, org.eclipse.elk.graph.properties.IPropertyHolder properties)
      Updates the diagram view with the given identifier with a specified name and model.

      The model has to be of the type of the old model, i.e. the view context associated with the identifier must support the model.
      Parameters:
      id - the diagram identifier (can be null for the default view)
      name - the name (can be null if the name of the view should remain unchanged)
      model - the model (can be null if the displayed model should remain unchanged)
      properties - the property holder containing properties configurations or null
      Returns:
      the view with the identifier or null on failure
    • updateView

      public static IDiagramWorkbenchPart updateView(ViewContext viewContext)
      Updates the diagram view corresponding to the given ViewContext.

      The viewContext's current input model is taken as new input.
      Parameters:
      viewContext - the ViewContext of the diagram to be updated
      Returns:
      the view with the identifier or null on failure
    • updateView

      public static IDiagramWorkbenchPart updateView(ViewContext viewContext, Object model)
      Updates the diagram view corresponding to the given ViewContext.

      The model has to be of the type of the old model, i.e. the view context associated with the identifier must support the model.
      Parameters:
      viewContext - the ViewContext of the diagram to be updated
      model - the new model, if null the current input model is taken
      Returns:
      the view with the identifier or null on failure
    • createView

      public static DiagramViewPart createView(String id, String name, Object model)
      Creates a DiagramViewPart showing the desired diagram of model. The diagram view will exhibit the given name and can be addressed via the specified id.
      Parameters:
      id - the diagram identifier (can be null for the default view)
      name - the name, may be null if the view should be created with the default name
      model - the model, may be null if the view should be created without an initial model
      Returns:
      the view with the identifier (newly created or reused if it exists already), or null on failure
    • createView

      public static DiagramViewPart createView(String id, String name, Object model, org.eclipse.elk.graph.properties.IPropertyHolder properties)
      Creates a DiagramViewPart showing the desired diagram of model. The diagram view will exhibit the given name and can be addressed via the specified id.
      Parameters:
      id - the diagram identifier (can be null for the default view)
      name - the name, may be null if the view should be created with the default name
      model - the model, may be null if the view should be created without an initial model
      properties - the property holder containing properties configurations or null
      Returns:
      the view with the identifier (newly created or reused if it exists already), or null on failure
    • initializeView

      public static DiagramViewPart initializeView(DiagramViewPart diagramView, Object model, String name, org.eclipse.elk.graph.properties.IPropertyHolder properties)
      (Re-)Initializes the given DiagramViewPart.
      This involves the creation of a ViewContext, the execution the matching implementation AbstractDiagramSynthesis, the application of automatic layout. and the update of the diagram side bar entries.
      Parameters:
      diagramView - the DiagramViewPart, must not be null
      name - the name (can be null if the view should be created with the default name)
      model - the model (can be null if the view should be created without an initial model)
      properties - the property holder containing properties configurations or null
      Returns:
      diagramView for convenience
    • registerView

      public void registerView(IDiagramWorkbenchPart part)
      Allows IDiagramWorkbenchParts that are not created via this manager to be registered, e.g. DiagramEditorParts. This is (currently) necessary in order to let the side bar work correctly (diagram refresh), since those event listener call updateView(String, IPropertyHolder).
      Parameters:
      part - the IDiagramWorkbenchPart to register
    • unregisterView

      public void unregisterView(IDiagramWorkbenchPart part)
      Is package protected in order to be callable from DiagramViewPart.dispose().
      Parameters:
      part - the part being closed
    • closeView

      public static boolean closeView(String id)
      Closes the diagram view associated with the given id.
      Parameters:
      id - the identifier of the view to be closed.
      Returns:
      true if a view could be closed successfully, and false otherwise.
    • partClosed

      public void partClosed(org.eclipse.ui.IWorkbenchPart part)
      Specified by:
      partClosed in interface org.eclipse.ui.IPartListener
    • partOpened

      public void partOpened(org.eclipse.ui.IWorkbenchPart part)
      Specified by:
      partOpened in interface org.eclipse.ui.IPartListener
    • partActivated

      public void partActivated(org.eclipse.ui.IWorkbenchPart part)
      Specified by:
      partActivated in interface org.eclipse.ui.IPartListener
    • partDeactivated

      public void partDeactivated(org.eclipse.ui.IWorkbenchPart part)
      Specified by:
      partDeactivated in interface org.eclipse.ui.IPartListener
    • partBroughtToTop

      public void partBroughtToTop(org.eclipse.ui.IWorkbenchPart part)
      Specified by:
      partBroughtToTop in interface org.eclipse.ui.IPartListener