org.eclipse.gmt.umlx.editor
Class MultiViewerSelectionSupervisor

java.lang.Object
  extended by org.eclipse.ui.part.MultiPageSelectionProvider
      extended by org.eclipse.gmt.umlx.editor.MultiViewerSelectionSupervisor
All Implemented Interfaces:
ISelectionSupervisor, org.eclipse.jface.viewers.IPostSelectionProvider, org.eclipse.jface.viewers.ISelectionProvider, org.eclipse.ui.ISelectionListener

public class MultiViewerSelectionSupervisor
extends org.eclipse.ui.part.MultiPageSelectionProvider
implements ISelectionSupervisor, org.eclipse.ui.ISelectionListener

MultiViewerSelectionSupervisor supervises the selection to and from an EditPartViewer. Supervision recognises that at most one EditPartViewer is in-focus and not all are necessarily visible. Selections emanating from out-of-focus EditPartViewers are ignored, except to remember the associated selection should it become in-focus. Selections to invisible EditPartViewers are suppressed untiol such time as the EditPartViewer becomes visible. These suppressions substantially reduce the redundant multi-way selection cross-notifications. Additionally the supervised selection is in model objects, which are mapped to and from appropriate EditPartViewer-specific objects before the selection is propagated. This ensures that selections can consistently prtopgate between different classes of viewer, some EditPartViewer-based and others using standard Platform protocols. The supervisor inherits from MultiPageSelectionProvider to avoid limitations in the use of MultiPageSelectionProvider from MultiPageEditorPart. The supervisor may nonethelerss be used with a single page editor


Constructor Summary
MultiViewerSelectionSupervisor(ActiveEditDomain editDomain)
           
 
Method Summary
 void addViewer(org.eclipse.gef.EditPartViewer viewer)
          Configure the supervisor to interact with a further EditPartViewer.
 void firePostSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
           
 void fireSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent modelEvent)
          Fires a selection changed event to notify all selection changed listeners of the changed selection of model objects.
 org.eclipse.jface.viewers.ISelection getSelection()
          Get the list of currently selected model objects.
 boolean isInFocus(ViewerSupervisor viewerSupervisor)
           
 void removeViewer(org.eclipse.gef.EditPartViewer viewer)
          Configure the supervisor to stop interacting with a given EditPartViewer.
 void selectionChanged(org.eclipse.ui.IWorkbenchPart part, org.eclipse.jface.viewers.ISelection modelSelection)
          Respond to a selection change notification from the WorkbenchPart.
 void setInFocusViewer(org.eclipse.gef.EditPartViewer viewer)
          Configure the supervisor to accept selections from and direct selections to a particular viewer, that must have been previously defined by addViewer().
 void setInvisible(org.eclipse.gef.EditPartViewer viewer)
          Configure viewer as invisible and therefore not to be given selections.
 void setPageSite(org.eclipse.ui.IWorkbenchSite site)
          Configure the supervisor to interact with a given workbenchSite.
 void setSelection(org.eclipse.jface.viewers.ISelection modelSelection)
          Define the selection from the WorkbenchPart model object domain.
 void setVisible(org.eclipse.gef.EditPartViewer viewer)
          Configure viewer as visible and requiring up-to-date selections.
static java.lang.String toString(org.eclipse.jface.viewers.ISelection modelSelection)
          Define the selection from the WorkbenchPart model object domain.
 void unsetPageSite(org.eclipse.ui.IWorkbenchSite site)
          Cancel the configuration for a given workbenchSite.
 
Methods inherited from class org.eclipse.ui.part.MultiPageSelectionProvider
addPostSelectionChangedListener, addSelectionChangedListener, getMultiPageEditor, removePostSelectionChangedListener, removeSelectionChangedListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvider
addSelectionChangedListener, removeSelectionChangedListener
 

Constructor Detail

MultiViewerSelectionSupervisor

public MultiViewerSelectionSupervisor(ActiveEditDomain editDomain)
Method Detail

toString

public static java.lang.String toString(org.eclipse.jface.viewers.ISelection modelSelection)
Define the selection from the WorkbenchPart model object domain.


addViewer

public void addViewer(org.eclipse.gef.EditPartViewer viewer)
Configure the supervisor to interact with a further EditPartViewer.

Specified by:
addViewer in interface ISelectionSupervisor
Parameters:
viewer - the additional viewer

firePostSelectionChanged

public void firePostSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
Overrides:
firePostSelectionChanged in class org.eclipse.ui.part.MultiPageSelectionProvider

fireSelectionChanged

public void fireSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent modelEvent)
Fires a selection changed event to notify all selection changed listeners of the changed selection of model objects.

Specified by:
fireSelectionChanged in interface ISelectionSupervisor
Overrides:
fireSelectionChanged in class org.eclipse.ui.part.MultiPageSelectionProvider
Parameters:
modelEvent - the selection change event

getSelection

public org.eclipse.jface.viewers.ISelection getSelection()
Get the list of currently selected model objects.

Specified by:
getSelection in interface org.eclipse.jface.viewers.ISelectionProvider
Overrides:
getSelection in class org.eclipse.ui.part.MultiPageSelectionProvider

isInFocus

public boolean isInFocus(ViewerSupervisor viewerSupervisor)
Specified by:
isInFocus in interface ISelectionSupervisor

removeViewer

public void removeViewer(org.eclipse.gef.EditPartViewer viewer)
Configure the supervisor to stop interacting with a given EditPartViewer.

Specified by:
removeViewer in interface ISelectionSupervisor
Parameters:
viewer - the obsolete viewer

selectionChanged

public void selectionChanged(org.eclipse.ui.IWorkbenchPart part,
                             org.eclipse.jface.viewers.ISelection modelSelection)
Respond to a selection change notification from the WorkbenchPart.

Specified by:
selectionChanged in interface org.eclipse.ui.ISelectionListener

setInFocusViewer

public void setInFocusViewer(org.eclipse.gef.EditPartViewer viewer)
Configure the supervisor to accept selections from and direct selections to a particular viewer, that must have been previously defined by addViewer().

Specified by:
setInFocusViewer in interface ISelectionSupervisor
Parameters:
viewer - the viewer

setInvisible

public void setInvisible(org.eclipse.gef.EditPartViewer viewer)
Configure viewer as invisible and therefore not to be given selections.

Specified by:
setInvisible in interface ISelectionSupervisor

setPageSite

public void setPageSite(org.eclipse.ui.IWorkbenchSite site)
Configure the supervisor to interact with a given workbenchSite.

Specified by:
setPageSite in interface ISelectionSupervisor
Parameters:
site - the workbench site

setSelection

public void setSelection(org.eclipse.jface.viewers.ISelection modelSelection)
Define the selection from the WorkbenchPart model object domain.

Specified by:
setSelection in interface org.eclipse.jface.viewers.ISelectionProvider
Overrides:
setSelection in class org.eclipse.ui.part.MultiPageSelectionProvider

setVisible

public void setVisible(org.eclipse.gef.EditPartViewer viewer)
Configure viewer as visible and requiring up-to-date selections.

Specified by:
setVisible in interface ISelectionSupervisor

unsetPageSite

public void unsetPageSite(org.eclipse.ui.IWorkbenchSite site)
Cancel the configuration for a given workbenchSite.

Specified by:
unsetPageSite in interface ISelectionSupervisor
Parameters:
site - the workbench site