org.eclipse.emf.codegen.ecore.genmodel.presentation
Class GenModelEditor

java.lang.Object
  |
  +--org.eclipse.ui.part.WorkbenchPart
        |
        +--org.eclipse.ui.part.EditorPart
              |
              +--org.eclipse.ui.part.MultiPageEditorPart
                    |
                    +--org.eclipse.emf.codegen.ecore.genmodel.presentation.GenModelEditor
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, IEditingDomainProvider, org.eclipse.ui.IEditorPart, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.jface.action.IMenuListener, org.eclipse.ui.ISaveablePart, org.eclipse.jface.viewers.ISelectionProvider, org.eclipse.ui.IWorkbenchPart

public class GenModelEditor
extends org.eclipse.ui.part.MultiPageEditorPart
implements IEditingDomainProvider, org.eclipse.jface.viewers.ISelectionProvider, org.eclipse.jface.action.IMenuListener

This is an example of a GenModel model editor.


Inner Class Summary
 class GenModelEditor.ReverseAdapterFactoryContentProvider
          
 
Field Summary
protected  ComposedAdapterFactory adapterFactory
          This is the one adapter factory used for providing views of the model.
protected  org.eclipse.jface.viewers.Viewer currentViewer
          This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.
protected  AdapterFactoryEditingDomain editingDomain
          This keeps track of the editing domain that is used to track all changes to the model.
protected  org.eclipse.jface.viewers.ISelection editorSelection
          This keeps track of the selection of the editor as a whole.
protected  org.eclipse.ui.IPartListener partListener
          This listens for when the outline becomes active
protected  org.eclipse.ui.views.properties.PropertySheetPage propertySheetPage
          This is the property sheet page.
protected  org.eclipse.core.resources.IResourceChangeListener resourceChangeListener
          This listens for workspace changes.
protected  org.eclipse.jface.viewers.ISelectionChangedListener selectionChangedListener
          This listens to which ever viewer is active.
protected  java.util.Collection selectionChangedListeners
          This keeps track of all the ISelectionChangedListeners that are listening to this editor.
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
GenModelEditor()
          This creates a model editor.
 
Method Summary
 void addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
          This implements ISelectionProvider.
protected  void createContextMenuFor(org.eclipse.jface.viewers.StructuredViewer viewer)
          This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
 void createPages()
          This is the method used by the framework to install your own controls.
 void dispose()
          
 void doSave(org.eclipse.core.runtime.IProgressMonitor progressMonitor)
          This is for implementing IEditorPart and simply saves the model file.
 void doSaveAs()
          This also changes the editor's input.
protected  void firePropertyChange(int action)
          This is here for the listener to be able to call it.
 EditingDomainActionBarContributor getActionBarContributor()
          
 org.eclipse.ui.IActionBars getActionBars()
          
 java.lang.Object getAdapter(java.lang.Class key)
          This is how the framework determines which interfaces we implement.
 AdapterFactory getAdapterFactory()
          
 EditingDomain getEditingDomain()
          This returns the editing domain as required by the IEditingDomainProvider interface.
 org.eclipse.ui.views.properties.IPropertySheetPage getPropertySheetPage()
          This accesses a cached version of the property sheet.
 org.eclipse.jface.viewers.ISelection getSelection()
          This implements ISelectionProvider to return this editor's overall selection.
 void gotoMarker(org.eclipse.core.resources.IMarker marker)
          
 void handleActivate()
          Handles activation of the editor or it's associated views.
protected  void handleChangedResources()
          Handles what to do with changed resources on activation.
protected  boolean handleDirtyConflict()
          Shows a dialog that asks if conflicting changes should be discarded.
protected  void hideTabs()
           
 void init(org.eclipse.ui.IEditorSite site, org.eclipse.ui.IEditorInput editorInput)
          This is called during startup.
protected  void initialize(GenModel genModel)
           
 boolean isDirty()
          This is for implementing IEditorPart and simply tests the command stack.
 boolean isSaveAsAllowed()
          This always returns false because it is not current supported.
 void menuAboutToShow(org.eclipse.jface.action.IMenuManager menuManager)
          This implements IMenuListener to help fill the context menus with contributions from the Edit menu.
protected  void pageChange(int pageIndex)
          This is used to track the active viewer.
 void removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
          This implements ISelectionProvider.
 void setCurrentViewer(org.eclipse.jface.viewers.Viewer viewer)
          This makes sure that one content viewer, either for the current page or the outline view, if it has focus, is the current one.
 void setFocus()
          
 void setSelection(org.eclipse.jface.viewers.ISelection selection)
          This implements ISelectionProvider to set this editor's overall selection.
 void setSelectionToViewer(java.util.Collection collection)
          This sets the selection into whichever viewer is active.
 void setStatusLineManager(org.eclipse.jface.viewers.ISelection selection)
          
 void validate()
           
 
Methods inherited from class org.eclipse.ui.part.MultiPageEditorPart
addPage, addPage, createPartControl, createSite, getActiveEditor, getActivePage, getContainer, getControl, getEditor, getPageCount, getPageImage, getPageText, handlePropertyChange, removePage, setActivePage, setControl, setPageImage, setPageText
 
Methods inherited from class org.eclipse.ui.part.EditorPart
getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setInput
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPropertyListener, getConfigurationElement, getDefaultImage, getSite, getTitle, getTitleImage, removePropertyListener, setInitializationData, setSite, setTitle, setTitleImage, setTitleToolTip
 
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

editingDomain

protected AdapterFactoryEditingDomain editingDomain
This keeps track of the editing domain that is used to track all changes to the model.

adapterFactory

protected ComposedAdapterFactory adapterFactory
This is the one adapter factory used for providing views of the model.

propertySheetPage

protected org.eclipse.ui.views.properties.PropertySheetPage propertySheetPage
This is the property sheet page.

currentViewer

protected org.eclipse.jface.viewers.Viewer currentViewer
This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.

selectionChangedListener

protected org.eclipse.jface.viewers.ISelectionChangedListener selectionChangedListener
This listens to which ever viewer is active.

selectionChangedListeners

protected java.util.Collection selectionChangedListeners
This keeps track of all the ISelectionChangedListeners that are listening to this editor.

editorSelection

protected org.eclipse.jface.viewers.ISelection editorSelection
This keeps track of the selection of the editor as a whole.

partListener

protected org.eclipse.ui.IPartListener partListener
This listens for when the outline becomes active

resourceChangeListener

protected org.eclipse.core.resources.IResourceChangeListener resourceChangeListener
This listens for workspace changes.
Constructor Detail

GenModelEditor

public GenModelEditor()
This creates a model editor.
Method Detail

handleActivate

public void handleActivate()
Handles activation of the editor or it's associated views.

handleChangedResources

protected void handleChangedResources()
Handles what to do with changed resources on activation.

initialize

protected void initialize(GenModel genModel)

handleDirtyConflict

protected boolean handleDirtyConflict()
Shows a dialog that asks if conflicting changes should be discarded.

firePropertyChange

protected void firePropertyChange(int action)
This is here for the listener to be able to call it.
Overrides:
firePropertyChange in class org.eclipse.ui.part.WorkbenchPart

setSelectionToViewer

public void setSelectionToViewer(java.util.Collection collection)
This sets the selection into whichever viewer is active.

getEditingDomain

public EditingDomain getEditingDomain()
This returns the editing domain as required by the IEditingDomainProvider interface. This is important for implementing the static methods of AdapterFactoryEditingDomain and for supporting CommandAction.
Specified by:
getEditingDomain in interface IEditingDomainProvider

setCurrentViewer

public void setCurrentViewer(org.eclipse.jface.viewers.Viewer viewer)
This makes sure that one content viewer, either for the current page or the outline view, if it has focus, is the current one.

createContextMenuFor

protected void createContextMenuFor(org.eclipse.jface.viewers.StructuredViewer viewer)
This creates a context menu for the viewer and adds a listener as well registering the menu for extension.

createPages

public void createPages()
This is the method used by the framework to install your own controls.
Overrides:
createPages in class org.eclipse.ui.part.MultiPageEditorPart

hideTabs

protected void hideTabs()

pageChange

protected void pageChange(int pageIndex)
This is used to track the active viewer.
Overrides:
pageChange in class org.eclipse.ui.part.MultiPageEditorPart

getAdapter

public java.lang.Object getAdapter(java.lang.Class key)
This is how the framework determines which interfaces we implement.
Overrides:
getAdapter in class org.eclipse.ui.part.WorkbenchPart

getPropertySheetPage

public org.eclipse.ui.views.properties.IPropertySheetPage getPropertySheetPage()
This accesses a cached version of the property sheet.

isDirty

public boolean isDirty()
This is for implementing IEditorPart and simply tests the command stack.
Overrides:
isDirty in class org.eclipse.ui.part.MultiPageEditorPart

doSave

public void doSave(org.eclipse.core.runtime.IProgressMonitor progressMonitor)
This is for implementing IEditorPart and simply saves the model file.
Overrides:
doSave in class org.eclipse.ui.part.EditorPart

isSaveAsAllowed

public boolean isSaveAsAllowed()
This always returns false because it is not current supported.
Overrides:
isSaveAsAllowed in class org.eclipse.ui.part.EditorPart

doSaveAs

public void doSaveAs()
This also changes the editor's input.
Overrides:
doSaveAs in class org.eclipse.ui.part.EditorPart

gotoMarker

public void gotoMarker(org.eclipse.core.resources.IMarker marker)
Overrides:
gotoMarker in class org.eclipse.ui.part.EditorPart

init

public void init(org.eclipse.ui.IEditorSite site,
                 org.eclipse.ui.IEditorInput editorInput)
          throws org.eclipse.ui.PartInitException,
                 org.eclipse.ui.PartInitException,
                 org.eclipse.ui.PartInitException,
                 org.eclipse.ui.PartInitException,
                 org.eclipse.ui.PartInitException,
                 org.eclipse.ui.PartInitException,
                 org.eclipse.ui.PartInitException,
                 org.eclipse.ui.PartInitException,
                 org.eclipse.ui.PartInitException,
                 org.eclipse.ui.PartInitException
This is called during startup.
Overrides:
init in class org.eclipse.ui.part.MultiPageEditorPart

setFocus

public void setFocus()
Overrides:
setFocus in class org.eclipse.ui.part.MultiPageEditorPart

addSelectionChangedListener

public void addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
This implements ISelectionProvider.
Specified by:
addSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider

removeSelectionChangedListener

public void removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
This implements ISelectionProvider.
Specified by:
removeSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider

getSelection

public org.eclipse.jface.viewers.ISelection getSelection()
This implements ISelectionProvider to return this editor's overall selection.
Specified by:
getSelection in interface org.eclipse.jface.viewers.ISelectionProvider

setSelection

public void setSelection(org.eclipse.jface.viewers.ISelection selection)
This implements ISelectionProvider to set this editor's overall selection. Calling this result will notify the listeners.
Specified by:
setSelection in interface org.eclipse.jface.viewers.ISelectionProvider

setStatusLineManager

public void setStatusLineManager(org.eclipse.jface.viewers.ISelection selection)

menuAboutToShow

public void menuAboutToShow(org.eclipse.jface.action.IMenuManager menuManager)
This implements IMenuListener to help fill the context menus with contributions from the Edit menu.
Specified by:
menuAboutToShow in interface org.eclipse.jface.action.IMenuListener

getActionBarContributor

public EditingDomainActionBarContributor getActionBarContributor()

getActionBars

public org.eclipse.ui.IActionBars getActionBars()

getAdapterFactory

public AdapterFactory getAdapterFactory()

dispose

public void dispose()
Overrides:
dispose in class org.eclipse.ui.part.MultiPageEditorPart

validate

public void validate()

Copyright 2001-2003 IBM Corporation and others.
All Rights Reserved.