Class DiagramViewPart

java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.ui.part.WorkbenchPart
org.eclipse.ui.part.ViewPart
de.cau.cs.kieler.klighd.ui.parts.DiagramViewPart
All Implemented Interfaces:
IDiagramWorkbenchPart, ILayoutConfigProvider, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.ui.IPersistable, org.eclipse.ui.IViewPart, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.ui.IWorkbenchPart3, org.eclipse.ui.part.IWorkbenchPartOrientation

public class DiagramViewPart extends org.eclipse.ui.part.ViewPart implements IDiagramWorkbenchPart, ILayoutConfigProvider
A view which is able to display models in lightweight diagrams.

This class may well be subclassed to use it as a base for custom viewers. In that case, you will want to override createPartControl(Composite) and therein call createDiagramViewer(Composite) to create the diagram viewer.

Author:
mri, chsch, msp, uru
  • Nested Class Summary

    Nested classes/interfaces inherited from interface de.cau.cs.kieler.klighd.IDiagramWorkbenchPart

    IDiagramWorkbenchPart.IDiagramEditorPart
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Action identifier for resetting the layout options in the side bar.
    static final String
    the default name for this view.
    static final String
    The id this ViewPart is registered with in the extension point.

    Fields inherited from interface org.eclipse.ui.IWorkbenchPart

    PROP_TITLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Add the buttons to the tool bar.
    Returns a configuration for the KLighD view.
    protected org.eclipse.swt.widgets.Composite
    createDiagramViewer(org.eclipse.swt.widgets.Composite parent)
    Creates the context viewer and the composite it is placed in and sets up everything properly.
    void
    createPartControl(org.eclipse.swt.widgets.Composite parent)
    void
    protected void
    fillViewMenu(org.eclipse.jface.action.IMenuManager menuManager)
    Fill the view menu with some contributions.
    org.eclipse.jface.action.IAction
    Retrieve an action with the specified identifier.
    org.eclipse.elk.core.LayoutConfigurator
    void
    initialize(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.
    boolean
    Returns true if this ViewPart is disposed.
    protected Object
     
    protected void
    Registers the default print support, may be overriden if necessary.
    void
    void
    resetLayoutConfig(boolean doLayout)
    void
    void
    Sets a new name for the view.
    void
    updateOptions(boolean fitSpace)
    (Re-)Evaluates the diagram (synthesis) and layout options registered in the employed ViewContext and populates the diagram side bar accordingly.

    Methods inherited from class org.eclipse.ui.part.ViewPart

    checkSite, getViewSite, init, init, saveState, setContentDescription, setInitializationData, setPartName

    Methods inherited from class org.eclipse.ui.part.WorkbenchPart

    addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getAdapter, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, getTitleToolTip, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy

    Methods inherited from class org.eclipse.core.commands.common.EventManager

    addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.eclipse.core.runtime.IAdaptable

    getAdapter

    Methods inherited from interface org.eclipse.ui.IWorkbenchPart

    addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
  • Field Details

    • VIEW_ID

      public static final String VIEW_ID
      The id this ViewPart is registered with in the extension point.
      See Also:
    • ACTION_ID_RESET_LAYOUT_OPTIONS

      public static final String ACTION_ID_RESET_LAYOUT_OPTIONS
      Action identifier for resetting the layout options in the side bar.
      See Also:
    • DEFAULT_NAME

      public static final String DEFAULT_NAME
      the default name for this view.
      See Also:
  • Constructor Details

    • DiagramViewPart

      public DiagramViewPart()
  • Method Details

    • createPartControl

      public void createPartControl(org.eclipse.swt.widgets.Composite parent)
      Calls createDiagramViewer(Composite). If this method is overridden, feel free to call that method yourself instead of calling this implementation.
      Specified by:
      createPartControl in interface org.eclipse.ui.IWorkbenchPart
      Specified by:
      createPartControl in class org.eclipse.ui.part.WorkbenchPart
    • createDiagramViewer

      protected org.eclipse.swt.widgets.Composite createDiagramViewer(org.eclipse.swt.widgets.Composite parent)
      Creates the context viewer and the composite it is placed in and sets up everything properly. You may want to pass a parent composite that will only contain the diagram composite. This is because the diagram sidebar will use that same composite to place the sidebar in.
      Parameters:
      parent - the control the composite should be placed in.
      Returns:
      the composite that holds the context viewer.
    • initialize

      public void initialize(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:
      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
    • getViewContext

      public ViewContext getViewContext()
      Specified by:
      getViewContext in interface IDiagramWorkbenchPart
    • getLayoutConfig

      public org.eclipse.elk.core.LayoutConfigurator getLayoutConfig()
      Specified by:
      getLayoutConfig in interface ILayoutConfigProvider
    • resetLayoutConfig

      public void resetLayoutConfig()
      Specified by:
      resetLayoutConfig in interface ILayoutConfigProvider
    • resetLayoutConfig

      public void resetLayoutConfig(boolean doLayout)
      Specified by:
      resetLayoutConfig in interface ILayoutConfigProvider
    • dispose

      public void dispose()
      Specified by:
      dispose in interface org.eclipse.ui.IWorkbenchPart
      Overrides:
      dispose in class org.eclipse.ui.part.WorkbenchPart
    • updateOptions

      public void updateOptions(boolean fitSpace)
      (Re-)Evaluates the diagram (synthesis) and layout options registered in the employed ViewContext and populates the diagram side bar accordingly. For internal use only!
      Parameters:
      fitSpace - if true a ZoomStyle#ZOOM_TO_FIT will applied to the diagram in order to fit into the remaining space
    • isDisposed

      public boolean isDisposed()
      Returns true if this ViewPart is disposed. Since the DiagramViewManager tracks created views it needs to test whether those views are still alive.
      Returns:
      whether dispose() has been called on this ViewPart
    • fillViewMenu

      protected void fillViewMenu(org.eclipse.jface.action.IMenuManager menuManager)
      Fill the view menu with some contributions.
      Parameters:
      menuManager - the menu manager
    • addButtons

      protected void addButtons()
      Add the buttons to the tool bar.
    • loadModel

      protected Object loadModel()
    • configureKlighdProperties

      protected KlighdSynthesisProperties configureKlighdProperties()
      Returns a configuration for the KLighD view. Override this method to use a custom configuration.
      Returns:
      KLighD configuration or null.
      See Also:
    • registerPrintSupport

      protected void registerPrintSupport()
      Registers the default print support, may be overriden if necessary.
    • setFocus

      public void setFocus()
      Specified by:
      setFocus in interface org.eclipse.ui.IWorkbenchPart
      Specified by:
      setFocus in class org.eclipse.ui.part.WorkbenchPart
    • getPartId

      public String getPartId()
      Specified by:
      getPartId in interface IDiagramWorkbenchPart
    • getViewer

      public IViewer getViewer()
      Specified by:
      getViewer in interface IDiagramWorkbenchPart
    • getAction

      public org.eclipse.jface.action.IAction getAction(String id)
      Retrieve an action with the specified identifier.
      Parameters:
      id - an action identifier
      Returns:
      the corresponding action
    • setName

      public void setName(String name)
      Sets a new name for the view.
      Parameters:
      name - the name