sk.uniba.euromath.editor
Class EditorSite

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 sk.uniba.euromath.editor.EditorSite
All Implemented Interfaces:
IAdaptable, IExecutableExtension, ISelectionProvider, IEditorPart, ISaveablePart, IWorkbenchPart, IWorkbenchPart2, IWorkbenchPartOrientation, IFocusListener, IDOMSelectionChangedListener, IDOMSelectionProvider, IEditorDataReceiver

public final class EditorSite
extends EditorPart
implements IDOMSelectionProvider, IDOMSelectionChangedListener, ISelectionProvider, IEditorDataReceiver, IFocusListener

TODO STUDVA recoment

Is a View, is a true compound editor, composites of IEditors.

This class houses instances of IEditors: chooses from available, creates and/or destroys instances of IEditors when required and creates and positions Composites for them.

Is is also ISelectionProvider and owns XMLSelection. Other IXMLSelectionProviders refernces this XMLSelection, modifies it and send changes back to EditorSite through methods setSelection(...) or selectionChanged(...)

Is also responsible for loading, transforming, saving. Main functionality is driven by GENE.

Acts as view in MultiViewXMLEditor.

Author:
Tomáš Studva, Martin Vysny, Martin Kollar
See Also:
IEditor

Field Summary
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Constructor Summary
EditorSite(MultiViewXMLEditor parentMultiEditor)
          Constructor.
 
Method Summary
 void addFocusListener(IFocusListener listener)
          Adds listener as focus listener.
 void addSelectionChangedListener(IDOMSelectionChangedListener listener)
          Adds a listener for selection changes in this selection provider.
 void addSelectionChangedListener(ISelectionChangedListener listener)
           
 void createPartControl(Composite parent)
           
 void dataChanged(Map<CoordinatorInputKey,GeneDataProvider.RendererSite> rendererKeys, CoordinatorInputKey rootKey, Map<CoordinatorInputKey,Set<CoordinatorInputKey>> nametreeHierarchy, Map<String,CoordinatorInputKey> geneIdMapping, Set<CoordinatorInputKey> newKeys, Set<CoordinatorInputKey> deletedKeys)
           Editor site instance receives data change events using this method.
 void dispose()
           
 void doSave(IProgressMonitor monitor)
           
 void doSaveAs()
           
 void focusGained(IEditor editor)
          IEditor has gained focus.
 void focusLost(IEditor editor)
          IEditor has lost focus.
 MultiViewActionContributor getActionContributor()
           
 IEditor getActiveEditor()
          Returns active editor.
 Object getAdapter(Class adapter)
          Returns the adapter for the specified class.
 Collection<IEditor> getAllIEditors()
          Returns all IEditors in this site.
 DOMIntervalSet getDOMSelection()
          Returns copy of the current selection of provider.
 XMLOutlinePage getOutlinePage()
          Returns outline page instance.
 MultiViewXMLEditor getParentMultiEditor()
          Returns multi editor containing this EditorSite instance as child view.
 Composite getRootComposite()
           
 IEditor getRootEditor()
          Returns root editor.
 ISelection getSelection()
           
 Set<String> getVisualizedIds()
          Returns ids of nodes which are graphically rendered(represented) by at least one IEditor.
 XMLAccess getXMLAccess()
          Returns document instance.
 void init(IEditorSite site, IEditorInput input)
           
 void initReceiver()
          Initializes the receiver.
 boolean isDirty()
           
 boolean isRootEditor(IEditor editor)
          Test if IEditor is root editor.
 boolean isSaveAsAllowed()
           
 void removeFocusListener(IFocusListener listener)
          Removes listener.
 void removeSelectionChangedListener(IDOMSelectionChangedListener listener)
          Removes the given selection change listener from this selection provider.
 void removeSelectionChangedListener(ISelectionChangedListener listener)
           
 void selectionChanged(DOMSelectionChangedEvent event)
          Source of event can be IEditor ContentOutline something else for future All this sources should be IXMLSelectionProviders, but more imporatant is that their IXMLSelection have to be "synchronized" with other IXMLSelectionProviders
 void setActionContributor(MultiViewActionContributor actionContributor)
          Initializes every IEditor with shared action registry.
 void setFocus()
          Sets focus to activete this EditorSite.
 void setSelection(DOMIntervalSet selection)
          Routes this new IXMLSelection to all listeners
 void setSelection(DOMIntervalSet selection, Boolean toAll)
          Fires SelectionEvent to all listeners, if toAll is true.
 void setSelection(ISelection selection)
           
protected  void startSelectionListening()
          Starts listening to selection change events.
protected  void stopSelectionListening()
          Stops listening to selection change events.
 
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
addPropertyListener, firePropertyChange, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getSite, getTitle, getTitleImage, removePropertyListener, 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
 

Constructor Detail

EditorSite

public EditorSite(MultiViewXMLEditor parentMultiEditor)
Constructor.

Parameters:
parentMultiEditor - host for this EditorSite.
Method Detail

doSave

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

doSaveAs

public void doSaveAs()
Specified by:
doSaveAs in interface ISaveablePart
Specified by:
doSaveAs in class EditorPart
See Also:
ISaveablePart.doSaveAs()

init

public void init(IEditorSite site,
                 IEditorInput input)
          throws PartInitException
Specified by:
init in interface IEditorPart
Specified by:
init in class EditorPart
Throws:
PartInitException
See Also:
IEditorPart.init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)

isDirty

public boolean isDirty()
Specified by:
isDirty in interface ISaveablePart
Specified by:
isDirty in class EditorPart
See Also:
ISaveablePart.isDirty()

isSaveAsAllowed

public boolean isSaveAsAllowed()
Specified by:
isSaveAsAllowed in interface ISaveablePart
Specified by:
isSaveAsAllowed in class EditorPart
See Also:
ISaveablePart.isSaveAsAllowed()

initReceiver

public void initReceiver()
Description copied from interface: IEditorDataReceiver
Initializes the receiver. Called only once.

Specified by:
initReceiver in interface IEditorDataReceiver

dataChanged

public void dataChanged(Map<CoordinatorInputKey,GeneDataProvider.RendererSite> rendererKeys,
                        CoordinatorInputKey rootKey,
                        Map<CoordinatorInputKey,Set<CoordinatorInputKey>> nametreeHierarchy,
                        Map<String,CoordinatorInputKey> geneIdMapping,
                        Set<CoordinatorInputKey> newKeys,
                        Set<CoordinatorInputKey> deletedKeys)
                 throws EditorException
Description copied from interface: IEditorDataReceiver

Editor site instance receives data change events using this method.

Parameters must NOT be changed. For more info on the parameters see GeneDataProvider class.

Specified by:
dataChanged in interface IEditorDataReceiver
Parameters:
rendererKeys - Maps input pipe ID to a renderer instance. Shows current state - keys recently deleted (keys present in the deletedKeys set) are not present.
rootKey - The root key of the hierarchy. It is not expected to be changed between dataChanged calls, only in extreme situation when whole document is scraped and recreated.
nametreeHierarchy - The nametree (key) hierarchy. Maps key to a set of its children. If key is missing from the map, maps to null value or an empty set then the nametree does not have any children. Shows current state - keys recently deleted (keys present in the deletedKeys set) are not present.
geneIdMapping - Maps GENE-generated ids to the coordinator input key instance. Used by renderer context to map from GENE id (provided to the renderer) to child renderer instance. Shows current state - keys recently deleted (keys present in the deletedKeys set) are not present.
newKeys - Contains set of new keys (keys that were not introduced in previous GENE output processing).
deletedKeys - Contains set of keys that were introduced in previous GENE output processing but they are missing in current data.
Throws:
EditorException - if fatal exception occurs. Editor errors should be handled by the receiver properly (for example by replacing the editor canvas with an Error banner).
See Also:
IEditorDataReceiver.dataChanged(java.util.Map, CoordinatorInputKey, java.util.Map, java.util.Map, java.util.Set, java.util.Set)

createPartControl

public void createPartControl(Composite parent)
Specified by:
createPartControl in interface IWorkbenchPart
Specified by:
createPartControl in class WorkbenchPart

getOutlinePage

public XMLOutlinePage getOutlinePage()
Returns outline page instance.

Returns:
outline page instance

setFocus

public void setFocus()
Sets focus to activete this EditorSite. As active editor is choosed last active or root editor.

Specified by:
setFocus in interface IWorkbenchPart
Specified by:
setFocus in class WorkbenchPart

getActiveEditor

public IEditor getActiveEditor()
Returns active editor.

Returns:
IEditor with focus

getRootEditor

public IEditor getRootEditor()
Returns root editor.

Returns:
root IEditor

getParentMultiEditor

public MultiViewXMLEditor getParentMultiEditor()
Returns multi editor containing this EditorSite instance as child view.

Returns:
parent multi editor

getXMLAccess

public XMLAccess getXMLAccess()
Returns document instance.

Returns:
xmlaccess instance

addSelectionChangedListener

public void addSelectionChangedListener(IDOMSelectionChangedListener listener)
Description copied from interface: IDOMSelectionProvider
Adds a listener for selection changes in this selection provider. Has no effect if an identical listener is already registered.

Specified by:
addSelectionChangedListener in interface IDOMSelectionProvider
Parameters:
listener - a DOM selection changed listener

removeSelectionChangedListener

public void removeSelectionChangedListener(IDOMSelectionChangedListener listener)
Description copied from interface: IDOMSelectionProvider
Removes the given selection change listener from this selection provider. Has no affect if listener is not registered.

Specified by:
removeSelectionChangedListener in interface IDOMSelectionProvider
Parameters:
listener - a DOM selection changed listener

getDOMSelection

public DOMIntervalSet getDOMSelection()
Description copied from interface: IDOMSelectionProvider
Returns copy of the current selection of provider.

Specified by:
getDOMSelection in interface IDOMSelectionProvider
Returns:
the current selection by copy

setSelection

public void setSelection(DOMIntervalSet selection)
Routes this new IXMLSelection to all listeners

Specified by:
setSelection in interface IDOMSelectionProvider
Parameters:
selection - DOM selection to set

setSelection

public void setSelection(DOMIntervalSet selection,
                         Boolean toAll)
Fires SelectionEvent to all listeners, if toAll is true. Otherwise fires SelectionEvent only to active editor, if it provides selections (is IXMLSelectionProvider)

Parameters:
selection - IXMLSelection
toAll - true means route in all IEditors, that provides selections false route only in active editor, if it provides selections

stopSelectionListening

protected void stopSelectionListening()
Stops listening to selection change events.


startSelectionListening

protected void startSelectionListening()
Starts listening to selection change events.


selectionChanged

public void selectionChanged(DOMSelectionChangedEvent event)
Source of event can be All this sources should be IXMLSelectionProviders, but more imporatant is that their IXMLSelection have to be "synchronized" with other IXMLSelectionProviders

Specified by:
selectionChanged in interface IDOMSelectionChangedListener
Parameters:
event - SelectionChangedEvent If event.getSelection() is not instance of XMLSelection, does nothing.

setActionContributor

public void setActionContributor(MultiViewActionContributor actionContributor)
Initializes every IEditor with shared action registry.

Parameters:
actionContributor -

getAdapter

public Object getAdapter(Class adapter)
Returns the adapter for the specified class.

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

isRootEditor

public boolean isRootEditor(IEditor editor)
Test if IEditor is root editor. If root editor doesn't exists, every time returns true.

Parameters:
editor - to test
Returns:
true if editor is a rootEditor

getActionContributor

public MultiViewActionContributor getActionContributor()
Returns:
Returns the actionContributor.

addFocusListener

public void addFocusListener(IFocusListener listener)
Adds listener as focus listener. Listener is added if is not yet listening.

Parameters:
listener - to add

removeFocusListener

public void removeFocusListener(IFocusListener listener)
Removes listener. If not listener is not listening, nothing is done.

Parameters:
listener - to remove

focusGained

public void focusGained(IEditor editor)
IEditor has gained focus. Send message to focus listeners.

Specified by:
focusGained in interface IFocusListener
Parameters:
editor - which has acquired focus

focusLost

public void focusLost(IEditor editor)
IEditor has lost focus. Send message to focus listeners.

Specified by:
focusLost in interface IFocusListener
Parameters:
editor - which has lost focus

getAllIEditors

public Collection<IEditor> getAllIEditors()
Returns all IEditors in this site.

Returns:
collection of all IEditors in this site

getVisualizedIds

public Set<String> getVisualizedIds()
Returns ids of nodes which are graphically rendered(represented) by at least one IEditor. Id's are without :N.

Returns:
list of ids which are visualized by at least one IEditor

getRootComposite

public Composite getRootComposite()
Returns:
Returns the rootComposite.

addSelectionChangedListener

public void addSelectionChangedListener(ISelectionChangedListener listener)
Specified by:
addSelectionChangedListener in interface ISelectionProvider

getSelection

public ISelection getSelection()
Specified by:
getSelection in interface ISelectionProvider

removeSelectionChangedListener

public void removeSelectionChangedListener(ISelectionChangedListener listener)
Specified by:
removeSelectionChangedListener in interface ISelectionProvider

setSelection

public void setSelection(ISelection selection)
Specified by:
setSelection in interface ISelectionProvider

dispose

public void dispose()
Specified by:
dispose in interface IWorkbenchPart
Overrides:
dispose in class WorkbenchPart


Copyright © 2003-2006 null. All Rights Reserved.