org.eclipse.graphiti.ui.editor
Class DefaultPaletteBehavior

java.lang.Object
  extended by org.eclipse.graphiti.ui.editor.DefaultPaletteBehavior

public class DefaultPaletteBehavior
extends Object

This class can be subclassed by clients to adapt the palette appearance and behavior of the Graphiti diagram Editor. The API is very much aligned with the way GEF handles the palette within its editors, see GraphicalEditorWithFlyoutPalette for more information on that. To exchange the default implementation you have to return an instance of your subclass in the method DiagramBehavior.createPaletteBehaviour().
Note that there is always a 1:1 relation with a DiagramBehavior.

Since:
0.9

Field Summary
protected static int DEFAULT_PALETTE_SIZE
          The initial size of the palette.
protected  DiagramBehavior diagramBehavior
          The associated DiagramBehavior
private  PaletteRoot paletteRoot
           
protected static String PROPERTY_PALETTE_DOCK_LOCATION
          Property name for storing the location (east, west) of the palette within the editor in an Eclipse preference store.
protected static String PROPERTY_PALETTE_SIZE
          Property name for storing the size of the palette within the editor in an Eclipse preference store.
protected static String PROPERTY_PALETTE_STATE
          Property name for storing the state (collapsed, expanded, hidden) of the palette within the editor in an Eclipse preference store.
 
Constructor Summary
DefaultPaletteBehavior(DiagramBehavior diagramBehavior)
          Creates a new standard palette behaviour for a Graphiti diagram editor.
 
Method Summary
protected  PaletteRoot createPaletteRoot()
          Creates the PaletteRoot of this editor.
protected  PaletteViewerProvider createPaletteViewerProvider()
          Returns the PaletteViewerProvider, which can be used to create a new PaletteViewer.
 void dispose()
          Disposes this instance.
 FlyoutPreferences getPalettePreferences()
          Returns the Graphiti specific preferences for the palette.
 PaletteRoot getPaletteRoot()
          Returns the already existing PaletteRoot instance for the DiagramBehavior associated the this palette behavior or creates a new PaletteRoot instance in case none exists.
private  IPreferenceStore getPreferenceStore()
           
 void initializeViewer()
          Initializes the used GEF palette viewer to display the palette as defined.
 void refreshPalette()
          Refreshes the palette.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_PALETTE_DOCK_LOCATION

protected static final String PROPERTY_PALETTE_DOCK_LOCATION
Property name for storing the location (east, west) of the palette within the editor in an Eclipse preference store.

See Also:
Constant Field Values

PROPERTY_PALETTE_SIZE

protected static final String PROPERTY_PALETTE_SIZE
Property name for storing the size of the palette within the editor in an Eclipse preference store.

See Also:
Constant Field Values

PROPERTY_PALETTE_STATE

protected static final String PROPERTY_PALETTE_STATE
Property name for storing the state (collapsed, expanded, hidden) of the palette within the editor in an Eclipse preference store.

See Also:
Constant Field Values

DEFAULT_PALETTE_SIZE

protected static final int DEFAULT_PALETTE_SIZE
The initial size of the palette.

See Also:
Constant Field Values

diagramBehavior

protected final DiagramBehavior diagramBehavior
The associated DiagramBehavior

Since:
0.10

paletteRoot

private PaletteRoot paletteRoot
Constructor Detail

DefaultPaletteBehavior

public DefaultPaletteBehavior(DiagramBehavior diagramBehavior)
Creates a new standard palette behaviour for a Graphiti diagram editor. The passed DiagramBehavior is closely linked to this instance (1:1 relation) and both instances will have a common lifecycle.

Parameters:
diagramEditor - The associated DiagramBehavior.
Since:
0.10
Method Detail

createPaletteRoot

protected PaletteRoot createPaletteRoot()
Creates the PaletteRoot of this editor. To retrieve the PaletteRoot object use getPaletteRoot() instead which will return an already existing instance or create a new one by delegating to this method.

Returns:
a new Graphiti specific PaletteRoot instance
See Also:
org.eclipse.graphiti.ui.editor.GraphicalEditorIncludingPalette#getPaletteRoot()

getPaletteRoot

public PaletteRoot getPaletteRoot()
Returns the already existing PaletteRoot instance for the DiagramBehavior associated the this palette behavior or creates a new PaletteRoot instance in case none exists.

Returns:
a new Graphiti specific PaletteRoot instance

initializeViewer

public void initializeViewer()
Initializes the used GEF palette viewer to display the palette as defined. The default implementation initializes the preference store with the GEF DefaultPaletteViewerPreferences and triggers a refresh of the palette.


getPalettePreferences

public FlyoutPreferences getPalettePreferences()
Returns the Graphiti specific preferences for the palette. This method will be called by the GEF GraphicalEditorWithFlyoutPalette during initialization.

Returns:
a Graphiti specific instanceof FlyoutPreferences.

createPaletteViewerProvider

protected PaletteViewerProvider createPaletteViewerProvider()
Returns the PaletteViewerProvider, which can be used to create a new PaletteViewer. This method can be overwritten to return a subclass of the PaletteViewerProvider, which configures the PaletteViewer with a different ContextMenu, with a PaletteCustomizer or with a different IPreferencesStore. Do not call this method directly, instead call getPaletteViewerProvider(), which buffers the created object.

By default this method returns a new PaletteViewerProvider.

Returns:
The PaletteViewerProvider, which can be used to create a new PaletteViewer.

refreshPalette

public void refreshPalette()
Refreshes the palette.


dispose

public void dispose()
Disposes this instance. Must be called before closing the associated Graphiti diagram editor. The default implementation clears the paletteRoot reference.


getPreferenceStore

private IPreferenceStore getPreferenceStore()


Copyright (c) SAP AG 2005, 2012.