net.officefloor.eclipse.common.editor
Class AbstractOfficeFloorEditor<M extends Model,C>

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.ui.part.WorkbenchPart
          extended by org.eclipse.ui.part.EditorPart
              extended by org.eclipse.gef.ui.parts.GraphicalEditor
                  extended by org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette
                      extended by net.officefloor.eclipse.common.editor.AbstractOfficeFloorEditor<M,C>
All Implemented Interfaces:
EventListener, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.gef.commands.CommandStackListener, org.eclipse.gef.EditPartFactory, org.eclipse.ui.IEditorPart, org.eclipse.ui.ISaveablePart, org.eclipse.ui.ISelectionListener, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.ui.IWorkbenchPart3, org.eclipse.ui.part.IWorkbenchPartOrientation
Direct Known Subclasses:
ConformEditor, DeskEditor, OfficeEditor, OfficeFloorEditor, SectionEditor

public abstract class AbstractOfficeFloorEditor<M extends Model,C>
extends org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette
implements org.eclipse.gef.EditPartFactory

Provides an abstract GraphicalEditor for the Office Floor items to edit.

Author:
Daniel Sagenschneider

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette
org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette.CustomPalettePage
 
Field Summary
protected  org.eclipse.gef.palette.PaletteRoot paletteRoot
          PaletteRoot.
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
AbstractOfficeFloorEditor()
          Initiate the edit domain and the command stack.
 
Method Summary
 org.eclipse.gef.EditPart createEditPart(org.eclipse.gef.EditPart context, Object model)
          Use the model type to EditPart map to create the appropriate EditPart via its default constructor.
 org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy createGraphicalEditPolicy()
          Creates the GraphicalEditPolicy to be installed.
 org.eclipse.gef.editpolicies.LayoutEditPolicy createLayoutEditPolicy()
          Creates the LayoutEditPolicy to be installed.
protected abstract  C createModelChanges(M model)
          Creates the Model change functionality.
 void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
           
 void doSaveAs()
           
 M getCastedModel()
          Obtains the Model.
 C getModelChanges()
          Obtains the Model change functionality.
protected  org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences getPalettePreferences()
           
protected  org.eclipse.gef.palette.PaletteRoot getPaletteRoot()
           
 org.eclipse.gef.RootEditPart getRootEditPart()
          Obtains the RootEditPart.
protected  void initialiseContextMenu()
          Initialises the context menu.
protected  void initialisePaletteRoot()
          Override to initialise the PaletteRoot.
protected  void initializeGraphicalViewer()
           
 boolean isSaveAsAllowed()
           
protected  void loadEditPartTypes()
          Allows sub classes to trigger the population of the EditPart types.
 void messageError(org.eclipse.core.runtime.IStatus status)
          Displays the IStatus error.
 void messageError(String message)
          Displays the message as an error MessageDialog.
 void messageError(String message, Throwable cause)
          Displays the message and its cause as an error MessageDialog.
 void messageError(Throwable error)
          Displays the Throwable error details as an error MessageDialog.
 void messageStatus(org.eclipse.core.runtime.IStatus status, String title)
          Displays a Dialog for the IStatus.
 void messageWarning(String message)
          Displays the message as a warning MessageDialog.
protected abstract  void populateEditPartTypes(Map<Class<?>,Class<? extends org.eclipse.gef.EditPart>> map)
          Populates the EditPart types for their respective model.
protected abstract  void populateGraphicalEditPolicy(OfficeFloorGraphicalNodeEditPolicy policy)
          Populates the OfficeFloorGraphicalNodeEditPolicy.
protected abstract  void populateLayoutEditPolicy(OfficeFloorLayoutEditPolicy policy)
          Populates the OfficeFloorLayoutEditPolicy.
protected abstract  void populateOperations(List<Operation> list)
          Populates the listing of Operation instances.
protected abstract  M retrieveModel(ConfigurationItem configuration)
          Retrieves the Model.
protected  void setCastedModel(M model)
          Specifies the Model.
protected  void setInput(org.eclipse.ui.IEditorInput input)
           
protected abstract  void storeModel(M model, ConfigurationItem configuration)
          Stores the Model.
 
Methods inherited from class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette
createPalettePage, createPaletteViewerProvider, createPartControl, getAdapter, getGraphicalControl, getPaletteViewerProvider, setEditDomain
 
Methods inherited from class org.eclipse.gef.ui.parts.GraphicalEditor
commandStackChanged, configureGraphicalViewer, createActions, createGraphicalViewer, dispose, firePropertyChange, getActionRegistry, getCommandStack, getEditDomain, getGraphicalViewer, getPropertyActions, getSelectionActions, getSelectionSynchronizer, getStackActions, hookGraphicalViewer, init, initializeActionRegistry, isDirty, selectionChanged, setActionRegistry, setFocus, setGraphicalViewer, updateActions
 
Methods inherited from class org.eclipse.ui.part.EditorPart
checkSite, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInputWithNotify, setPartName
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, 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.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, removePropertyListener
 

Field Detail

paletteRoot

protected org.eclipse.gef.palette.PaletteRoot paletteRoot
PaletteRoot.

Constructor Detail

AbstractOfficeFloorEditor

public AbstractOfficeFloorEditor()
Initiate the edit domain and the command stack.

Method Detail

setCastedModel

protected void setCastedModel(M model)
Specifies the Model.

Parameters:
model - Model.

getCastedModel

public M getCastedModel()
Obtains the Model.

Returns:
Model.

getRootEditPart

public org.eclipse.gef.RootEditPart getRootEditPart()
Obtains the RootEditPart.

Returns:
RootEditPart.

getModelChanges

public C getModelChanges()
Obtains the Model change functionality.

Returns:
Model change functionality.

messageError

public void messageError(Throwable error)
Displays the Throwable error details as an error MessageDialog.

Parameters:
error - Error.

messageError

public void messageError(String message)
Displays the message as an error MessageDialog.

Parameters:
message - Error message.

messageError

public void messageError(String message,
                         Throwable cause)
Displays the message and its cause as an error MessageDialog.

Parameters:
message - Error message.
cause - Cause of error.

messageWarning

public void messageWarning(String message)
Displays the message as a warning MessageDialog.

Parameters:
message - Warning message

messageError

public void messageError(org.eclipse.core.runtime.IStatus status)
Displays the IStatus error.

Parameters:
status - IStatus error.

messageStatus

public void messageStatus(org.eclipse.core.runtime.IStatus status,
                          String title)
Displays a Dialog for the IStatus.

Parameters:
status - IStatus.
title - Title for Dialog.

createLayoutEditPolicy

public org.eclipse.gef.editpolicies.LayoutEditPolicy createLayoutEditPolicy()
Creates the LayoutEditPolicy to be installed.

Returns:
LayoutEditPolicy to be installed.

populateLayoutEditPolicy

protected abstract void populateLayoutEditPolicy(OfficeFloorLayoutEditPolicy policy)
Populates the OfficeFloorLayoutEditPolicy.

Parameters:
policy - OfficeFloorLayoutEditPolicy.

createGraphicalEditPolicy

public org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy createGraphicalEditPolicy()
Creates the GraphicalEditPolicy to be installed.

Returns:
GraphicalEditPolicy to be installed.

populateGraphicalEditPolicy

protected abstract void populateGraphicalEditPolicy(OfficeFloorGraphicalNodeEditPolicy policy)
Populates the OfficeFloorGraphicalNodeEditPolicy.

Parameters:
policy - OfficeFloorGraphicalNodeEditPolicy.

initializeGraphicalViewer

protected void initializeGraphicalViewer()
Overrides:
initializeGraphicalViewer in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette

initialiseContextMenu

protected void initialiseContextMenu()
Initialises the context menu.


populateOperations

protected abstract void populateOperations(List<Operation> list)
Populates the listing of Operation instances.

Parameters:
list - Listing to add Operation instances.

createEditPart

public org.eclipse.gef.EditPart createEditPart(org.eclipse.gef.EditPart context,
                                               Object model)
Use the model type to EditPart map to create the appropriate EditPart via its default constructor.

Specified by:
createEditPart in interface org.eclipse.gef.EditPartFactory

loadEditPartTypes

protected void loadEditPartTypes()
Allows sub classes to trigger the population of the EditPart types.


populateEditPartTypes

protected abstract void populateEditPartTypes(Map<Class<?>,Class<? extends org.eclipse.gef.EditPart>> map)
Populates the EditPart types for their respective model.

Parameters:
mapping - Registry to load the mappings.

setInput

protected void setInput(org.eclipse.ui.IEditorInput input)
Overrides:
setInput in class org.eclipse.ui.part.EditorPart

createModelChanges

protected abstract C createModelChanges(M model)
Creates the Model change functionality.

Parameters:
model - Root Model.
Returns:
Model change functionality.

retrieveModel

protected abstract M retrieveModel(ConfigurationItem configuration)
                                          throws Exception
Retrieves the Model.

Parameters:
configuration - Configuration of the Model.
Returns:
Model to be edited.
Throws:
Exception - If fails to obtain the Model.

doSave

public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
Specified by:
doSave in interface org.eclipse.ui.ISaveablePart
Specified by:
doSave in class org.eclipse.ui.part.EditorPart

storeModel

protected abstract void storeModel(M model,
                                   ConfigurationItem configuration)
                            throws Exception
Stores the Model.

Parameters:
model - Model to be stored.
configuration - Configuration of the Model.
Throws:
Exception - If fails to store the Model.

doSaveAs

public void doSaveAs()
Specified by:
doSaveAs in interface org.eclipse.ui.ISaveablePart
Overrides:
doSaveAs in class org.eclipse.gef.ui.parts.GraphicalEditor

isSaveAsAllowed

public boolean isSaveAsAllowed()
Specified by:
isSaveAsAllowed in interface org.eclipse.ui.ISaveablePart
Overrides:
isSaveAsAllowed in class org.eclipse.gef.ui.parts.GraphicalEditor

getPalettePreferences

protected org.eclipse.gef.ui.palette.FlyoutPaletteComposite.FlyoutPreferences getPalettePreferences()
Overrides:
getPalettePreferences in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette

getPaletteRoot

protected org.eclipse.gef.palette.PaletteRoot getPaletteRoot()
Specified by:
getPaletteRoot in class org.eclipse.gef.ui.parts.GraphicalEditorWithFlyoutPalette

initialisePaletteRoot

protected void initialisePaletteRoot()
Override to initialise the PaletteRoot.

See Also:
getPaletteRoot()


Copyright © 2005-2013. All Rights Reserved.