org.eclipse.xsd.presentation
Class XSDEditor

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.ui.part.MultiPageEditorPart
                  extended by org.eclipse.xsd.presentation.XSDEditor
All Implemented Interfaces:
IAdaptable, IExecutableExtension, org.eclipse.emf.common.ui.viewer.IViewerProvider, org.eclipse.emf.edit.domain.IEditingDomainProvider, IMenuListener, ISelectionProvider, IEditorPart, ISaveablePart, IWorkbenchPart, IWorkbenchPart2, IWorkbenchPart3, IWorkbenchPartOrientation

public class XSDEditor
extends MultiPageEditorPart
implements org.eclipse.emf.edit.domain.IEditingDomainProvider, ISelectionProvider, IMenuListener, org.eclipse.emf.common.ui.viewer.IViewerProvider

This is a an example of a xsd model editor.


Nested Class Summary
static class XSDEditor.ActionBarContributor
          This is the contributor for the XSD model editor.
static class XSDEditor.GenericXMLLoadAction
           
static class XSDEditor.GenericXMLResourceFactoryImpl
           
static class XSDEditor.GenericXMLResourceImpl
           
 
Field Summary
protected  IContentOutlinePage contentOutlinePage
          This is the content outline page.
protected  IStatusLineManager contentOutlineStatusLineManager
          This is a kludge...
protected  TreeViewer contentOutlineViewer
          This is the content outline page's viewer.
protected  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  org.eclipse.emf.common.ui.ViewerPane currentViewerPane
          This keeps track of the active viewer pane, in the book.
protected  org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain editingDomain
          This keeps track of the editing domain that is used to track all changes to the model.
protected  ISelection editorSelection
          This keeps track of the selection of the editor as a whole.
protected  boolean handledStructuredModelChange
           
protected  IPartListener partListener
          This listens for when things becomes active.
protected  PropertySheetPage propertySheetPage
          This is the property sheet page.
protected  ISelectionChangedListener selectionChangedListener
          This listens to which ever viewer is active.
protected  java.util.Collection<ISelectionChangedListener> selectionChangedListeners
          This keeps track of all the ISelectionChangedListeners that are listening to this editor.
protected  org.eclipse.xsd.presentation.XSDEditor.SelectDiagnosticAction selectNextDiagnosticsAction
          This is the outline action to select the next unresolved component.
protected  org.eclipse.xsd.presentation.XSDEditor.SelectUseAction selectNextUseAction
          This is the outline action to select the next use of a component.
protected  org.eclipse.xsd.presentation.XSDEditor.SelectDiagnosticAction selectPreviousDiagnosticsAction
          This is the outline action to select the previous unresolved component.
protected  org.eclipse.xsd.presentation.XSDEditor.SelectUseAction selectPreviousUseAction
          This is the outline action to select the previous use of a component.
protected  XSDItemProviderAdapterFactory semanticAdapterFactory
          This is the adapter factory used for providing the semantic views of the model.
protected  TreeViewer semanticSelectionViewer
          This is the semantic viewer that shadows the selection in the content outline.
protected  ISourceViewer sourceViewer
           
protected  XSDItemProviderAdapterFactory syntacticAdapterFactory
          This is the adapter factory used for providing the syntactive views of the model.
protected  TreeViewer syntacticSelectionViewer
          This is the syntactic viewer that shadows the selection in the content outline.
protected  TextEditor textEditor
          This source part of the editor.
protected  boolean validateAutomatically
           
protected  XSDSchema xsdSchema
          This keeps track of the root object of the model.
 
Fields inherited from class org.eclipse.ui.part.MultiPageEditorPart
PAGE_CONTAINER_SITE
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
XSDEditor()
          This creates a model editor.
 
Method Summary
 void addSelectionChangedListener(ISelectionChangedListener listener)
          This implements ISelectionProvider.
protected  void createContextMenuFor(StructuredViewer viewer)
          This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
protected  void createModel()
           
 void createPages()
          This is the method used by the framework to install your own controls.
protected  void createResource(java.lang.String uri)
           
protected  void createSemanticsPage()
           
protected  void createSourcePage()
           
protected  void createSyntaxPage()
           
protected  java.lang.String determineEncoding()
           
 void dispose()
          This is called when the editor is disposed.
 void doSave(IProgressMonitor progressMonitor)
          This is for implementing IEditorPart and simply saves the model file.
 void doSaveAs()
          This also changes the editor's input.
protected  void extendedCreateResource(java.lang.String uri)
           
 org.w3c.dom.Element findBestElement(org.w3c.dom.Element element, int line, int column)
           
protected  void firePropertyChange(int action)
          This is here for the listener to be able to call it.
 org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor getActionBarContributor()
          This convenience method provides typed access to the contributor.
 IActionBars getActionBars()
          This convenience method provides access to the actionbars.
 java.lang.Object getAdapter(java.lang.Class key)
          This is how the framework determines which interfaces we implement.
 IContentOutlinePage getContentOutlinePage()
          This accesses a cached version of the content outliner.
 org.eclipse.emf.edit.domain.EditingDomain getEditingDomain()
          This returns the editing domain as required by the IEditingDomainProvider interface.
 IPropertySheetPage getPropertySheetPage()
          This accesses a cached version of the property sheet.
static XSDConcreteComponent getResolvedObject(XSDConcreteComponent xsdConcreteComponent)
          This is a utility function to resolve a component.
 ISelection getSelection()
          This implements ISelectionProvider to return this editor's overall selection.
 Viewer getViewer()
          This returns the viewer as required by the IViewerProvider interface.
 void gotoMarker(IMarker marker)
           
 void handleContentOutlineSelection(ISelection selection)
          This deals with how we want selection in the outliner to affect the other views.
 void handleContentOutlineSelectionForTextEditor(ISelection selection, boolean reveal)
          This deals with how we want selection in the outliner to affect the text editor.
protected  void handleDiagnostics(IProgressMonitor progressMonitor)
           
protected  void handleDocumentChange()
           
protected  void handlePartActivated(IWorkbenchPart workbenchPart)
          This handles part activation.
 void handleSelectedNodes(java.util.Collection<? extends org.w3c.dom.Node> nodes)
           
protected  void handleSourceCaretPosition()
           
protected  void handleStructuredModelChange()
           
 void init(IEditorSite site, IEditorInput editorInput)
          This is called during startup.
protected  void initializeMarkerPosition(IMarker marker, XSDDiagnostic xsdDiagnostic)
           
 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.
 boolean isValidateAutomatically()
           
 void menuAboutToShow(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(ISelectionChangedListener listener)
          This implements ISelectionProvider.
 void setCurrentViewer(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 setCurrentViewerPane(org.eclipse.emf.common.ui.ViewerPane viewerPane)
           
 void setFocus()
           
 void setSelection(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(ISelection selection)
          This shows the selection on the status line.
 void setValidateAutomatically(boolean validateAutomatically)
           
protected  void standardCreateResource(java.lang.String uri)
           
protected  void updateActions()
           
 
Methods inherited from class org.eclipse.ui.part.MultiPageEditorPart
activateSite, addPage, addPage, addPage, addPage, createPageContainer, createPartControl, createSite, deactivateSite, findEditors, getActiveEditor, getActivePage, getContainer, getControl, getEditor, getPageCount, getPageImage, getPageSite, getPageText, handlePropertyChange, initializePageSwitching, removePage, setActiveEditor, setActivePage, setControl, setPageImage, setPageText
 
Methods inherited from class org.eclipse.ui.part.EditorPart
checkSite, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setInput, 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

xsdSchema

protected XSDSchema xsdSchema
This keeps track of the root object of the model.


editingDomain

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


syntacticAdapterFactory

protected XSDItemProviderAdapterFactory syntacticAdapterFactory
This is the adapter factory used for providing the syntactive views of the model.


semanticAdapterFactory

protected XSDItemProviderAdapterFactory semanticAdapterFactory
This is the adapter factory used for providing the semantic views of the model.


contentOutlinePage

protected IContentOutlinePage contentOutlinePage
This is the content outline page.


contentOutlineStatusLineManager

protected IStatusLineManager contentOutlineStatusLineManager
This is a kludge...


contentOutlineViewer

protected TreeViewer contentOutlineViewer
This is the content outline page's viewer.


propertySheetPage

protected PropertySheetPage propertySheetPage
This is the property sheet page.


textEditor

protected TextEditor textEditor
This source part of the editor.


sourceViewer

protected ISourceViewer sourceViewer

syntacticSelectionViewer

protected TreeViewer syntacticSelectionViewer
This is the syntactic viewer that shadows the selection in the content outline. The parent relation must be correctly defined for this to work.


semanticSelectionViewer

protected TreeViewer semanticSelectionViewer
This is the semantic viewer that shadows the selection in the content outline.


currentViewerPane

protected org.eclipse.emf.common.ui.ViewerPane currentViewerPane
This keeps track of the active viewer pane, in the book.


currentViewer

protected 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 ISelectionChangedListener selectionChangedListener
This listens to which ever viewer is active.


selectionChangedListeners

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


editorSelection

protected ISelection editorSelection
This keeps track of the selection of the editor as a whole.


selectNextDiagnosticsAction

protected org.eclipse.xsd.presentation.XSDEditor.SelectDiagnosticAction selectNextDiagnosticsAction
This is the outline action to select the next unresolved component.


selectPreviousDiagnosticsAction

protected org.eclipse.xsd.presentation.XSDEditor.SelectDiagnosticAction selectPreviousDiagnosticsAction
This is the outline action to select the previous unresolved component.


selectNextUseAction

protected org.eclipse.xsd.presentation.XSDEditor.SelectUseAction selectNextUseAction
This is the outline action to select the next use of a component.


selectPreviousUseAction

protected org.eclipse.xsd.presentation.XSDEditor.SelectUseAction selectPreviousUseAction
This is the outline action to select the previous use of a component.


partListener

protected IPartListener partListener
This listens for when things becomes active.


handledStructuredModelChange

protected boolean handledStructuredModelChange

validateAutomatically

protected boolean validateAutomatically
Constructor Detail

XSDEditor

public XSDEditor()
This creates a model editor.

Method Detail

updateActions

protected void updateActions()

determineEncoding

protected java.lang.String determineEncoding()

handleStructuredModelChange

protected void handleStructuredModelChange()

handlePartActivated

protected void handlePartActivated(IWorkbenchPart workbenchPart)
This handles part activation.


firePropertyChange

protected void firePropertyChange(int action)
This is here for the listener to be able to call it.

Overrides:
firePropertyChange in class WorkbenchPart

setSelectionToViewer

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


getEditingDomain

public org.eclipse.emf.edit.domain.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 org.eclipse.emf.edit.domain.IEditingDomainProvider

setCurrentViewerPane

public void setCurrentViewerPane(org.eclipse.emf.common.ui.ViewerPane viewerPane)

setCurrentViewer

public void setCurrentViewer(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.


getViewer

public Viewer getViewer()
This returns the viewer as required by the IViewerProvider interface.

Specified by:
getViewer in interface org.eclipse.emf.common.ui.viewer.IViewerProvider

createContextMenuFor

protected void createContextMenuFor(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.

Specified by:
createPages in class MultiPageEditorPart

createResource

protected void createResource(java.lang.String uri)

standardCreateResource

protected void standardCreateResource(java.lang.String uri)

extendedCreateResource

protected void extendedCreateResource(java.lang.String uri)

createModel

protected void createModel()

handleSourceCaretPosition

protected void handleSourceCaretPosition()

findBestElement

public org.w3c.dom.Element findBestElement(org.w3c.dom.Element element,
                                           int line,
                                           int column)

handleSelectedNodes

public void handleSelectedNodes(java.util.Collection<? extends org.w3c.dom.Node> nodes)

handleDocumentChange

protected void handleDocumentChange()

createSourcePage

protected void createSourcePage()

createSemanticsPage

protected void createSemanticsPage()

createSyntaxPage

protected void createSyntaxPage()

initializeMarkerPosition

protected void initializeMarkerPosition(IMarker marker,
                                        XSDDiagnostic xsdDiagnostic)
                                 throws CoreException
Throws:
CoreException

handleDiagnostics

protected void handleDiagnostics(IProgressMonitor progressMonitor)

pageChange

protected void pageChange(int pageIndex)
This is used to track the active viewer.

Overrides:
pageChange in class MultiPageEditorPart

getAdapter

public java.lang.Object getAdapter(java.lang.Class key)
This is how the framework determines which interfaces we implement.

Specified by:
getAdapter in interface IAdaptable
Overrides:
getAdapter in class MultiPageEditorPart

getResolvedObject

public static XSDConcreteComponent getResolvedObject(XSDConcreteComponent xsdConcreteComponent)
This is a utility function to resolve a component.


getContentOutlinePage

public IContentOutlinePage getContentOutlinePage()
This accesses a cached version of the content outliner.


getPropertySheetPage

public IPropertySheetPage getPropertySheetPage()
This accesses a cached version of the property sheet.


handleContentOutlineSelection

public void handleContentOutlineSelection(ISelection selection)
This deals with how we want selection in the outliner to affect the other views.


handleContentOutlineSelectionForTextEditor

public void handleContentOutlineSelectionForTextEditor(ISelection selection,
                                                       boolean reveal)
This deals with how we want selection in the outliner to affect the text editor.


isDirty

public boolean isDirty()
This is for implementing IEditorPart and simply tests the command stack.

Specified by:
isDirty in interface ISaveablePart
Overrides:
isDirty in class MultiPageEditorPart

doSave

public void doSave(IProgressMonitor progressMonitor)
This is for implementing IEditorPart and simply saves the model file.

Specified by:
doSave in interface ISaveablePart
Specified by:
doSave in class EditorPart

isSaveAsAllowed

public boolean isSaveAsAllowed()
This always returns false because it is not current supported.

Specified by:
isSaveAsAllowed in interface ISaveablePart
Specified by:
isSaveAsAllowed in class EditorPart

doSaveAs

public void doSaveAs()
This also changes the editor's input.

Specified by:
doSaveAs in interface ISaveablePart
Specified by:
doSaveAs in class EditorPart

gotoMarker

public void gotoMarker(IMarker marker)

init

public void init(IEditorSite site,
                 IEditorInput editorInput)
          throws PartInitException
This is called during startup.

Specified by:
init in interface IEditorPart
Overrides:
init in class MultiPageEditorPart
Throws:
PartInitException

setFocus

public void setFocus()
Specified by:
setFocus in interface IWorkbenchPart
Overrides:
setFocus in class MultiPageEditorPart

addSelectionChangedListener

public void addSelectionChangedListener(ISelectionChangedListener listener)
This implements ISelectionProvider.

Specified by:
addSelectionChangedListener in interface ISelectionProvider

removeSelectionChangedListener

public void removeSelectionChangedListener(ISelectionChangedListener listener)
This implements ISelectionProvider.

Specified by:
removeSelectionChangedListener in interface ISelectionProvider

getSelection

public ISelection getSelection()
This implements ISelectionProvider to return this editor's overall selection.

Specified by:
getSelection in interface ISelectionProvider

setSelection

public void setSelection(ISelection selection)
This implements ISelectionProvider to set this editor's overall selection. Calling this result will notify the listeners.

Specified by:
setSelection in interface ISelectionProvider

setStatusLineManager

public void setStatusLineManager(ISelection selection)
This shows the selection on the status line.


menuAboutToShow

public void menuAboutToShow(IMenuManager menuManager)
This implements IMenuListener to help fill the context menus with contributions from the Edit menu.

Specified by:
menuAboutToShow in interface IMenuListener

getActionBarContributor

public org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor getActionBarContributor()
This convenience method provides typed access to the contributor.


getActionBars

public IActionBars getActionBars()
This convenience method provides access to the actionbars.


dispose

public void dispose()
This is called when the editor is disposed.

Specified by:
dispose in interface IWorkbenchPart
Overrides:
dispose in class MultiPageEditorPart

setValidateAutomatically

public void setValidateAutomatically(boolean validateAutomatically)

isValidateAutomatically

public boolean isValidateAutomatically()

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