de.cau.cs.kieler.core.model.gmf.triggers
Class ModelChangeTrigger

java.lang.Object
  extended by de.cau.cs.kieler.core.kivi.AbstractTrigger
      extended by de.cau.cs.kieler.core.model.gmf.triggers.ModelChangeTrigger
All Implemented Interfaces:
ITrigger, EventListener, ResourceSetListener, IPartListener

public class ModelChangeTrigger
extends AbstractTrigger
implements IPartListener, ResourceSetListener

A view management Trigger that registered as a ResourceSetChangeListener onto any active Diagram editor. It provides TriggerStates about any model changes. There are two different nested states available, one for the semantic model, one for the GMF notation model.

Rating red

Nested Class Summary
static class ModelChangeTrigger.ActiveEditorState
           A state about the model viewers currently visible, e.g.
static class ModelChangeTrigger.DiagramChangeState
          A state about changes of the diagram model (currently only the GMF notation model).
static class ModelChangeTrigger.ModelChangeState
          A state about changes of the semantic model.
 
Nested classes/interfaces inherited from interface org.eclipse.emf.transaction.ResourceSetListener
ResourceSetListener.Internal
 
Constructor Summary
ModelChangeTrigger()
           
 
Method Summary
protected static TransactionalEditingDomain getEditingDomain(IWorkbenchPart part)
          Get the EditingDomain to a model that is currently opened in the given WorkbenchPart.
 NotificationFilter getFilter()
          No filter set here.
 boolean isAggregatePrecommitListener()
          
protected static boolean isDiagram(IWorkbenchPart part)
          Test if the given WorkbenchPart (Editor/View) contains a Model supported by this Trigger.
 boolean isPostcommitOnly()
          
 boolean isPrecommitOnly()
          
 void partActivated(IWorkbenchPart part)
          
 void partBroughtToTop(IWorkbenchPart part)
          
 void partClosed(IWorkbenchPart part)
          
 void partDeactivated(IWorkbenchPart part)
          
 void partOpened(IWorkbenchPart part)
          
 void register()
          Called when the trigger is activated, e.g., if KIVi is (re-)activated or the first ICombination being fired by such a trigger is loaded.
 void resourceSetChanged(ResourceSetChangeEvent event)
          
 Command transactionAboutToCommit(ResourceSetChangeEvent event)
          
 void unregister()
          Called when the trigger is deactivated, e.g., if the whole KIVi is deactivated.
 
Methods inherited from class de.cau.cs.kieler.core.kivi.AbstractTrigger
isActive, setActive, synchronizedTrigger, trigger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelChangeTrigger

public ModelChangeTrigger()
Method Detail

register

public void register()
Description copied from class: AbstractTrigger
Called when the trigger is activated, e.g., if KIVi is (re-)activated or the first ICombination being fired by such a trigger is loaded. Registers itself where necessary.

Specified by:
register in interface ITrigger
Specified by:
register in class AbstractTrigger

unregister

public void unregister()
Description copied from class: AbstractTrigger
Called when the trigger is deactivated, e.g., if the whole KIVi is deactivated. Unregisters itself where necessary.

Specified by:
unregister in interface ITrigger
Specified by:
unregister in class AbstractTrigger

partActivated

public void partActivated(IWorkbenchPart part)

Specified by:
partActivated in interface IPartListener

partDeactivated

public void partDeactivated(IWorkbenchPart part)

Specified by:
partDeactivated in interface IPartListener

partBroughtToTop

public void partBroughtToTop(IWorkbenchPart part)

Specified by:
partBroughtToTop in interface IPartListener

partClosed

public void partClosed(IWorkbenchPart part)

Specified by:
partClosed in interface IPartListener

partOpened

public void partOpened(IWorkbenchPart part)

Specified by:
partOpened in interface IPartListener

getFilter

public NotificationFilter getFilter()
No filter set here. Doing filtering in the resourceSetChanged method.

Specified by:
getFilter in interface ResourceSetListener

transactionAboutToCommit

public Command transactionAboutToCommit(ResourceSetChangeEvent event)
                                 throws RollbackException

Specified by:
transactionAboutToCommit in interface ResourceSetListener
Throws:
RollbackException

resourceSetChanged

public void resourceSetChanged(ResourceSetChangeEvent event)

Specified by:
resourceSetChanged in interface ResourceSetListener

isAggregatePrecommitListener

public boolean isAggregatePrecommitListener()

Specified by:
isAggregatePrecommitListener in interface ResourceSetListener

isPrecommitOnly

public boolean isPrecommitOnly()

Specified by:
isPrecommitOnly in interface ResourceSetListener

isPostcommitOnly

public boolean isPostcommitOnly()

Specified by:
isPostcommitOnly in interface ResourceSetListener

isDiagram

protected static boolean isDiagram(IWorkbenchPart part)
Test if the given WorkbenchPart (Editor/View) contains a Model supported by this Trigger. Uses the GraphicalFrameworkService to test if there can be a root EditPart obtained.

Parameters:
part - part to check
Returns:
true if part is supported by the GraphicalFrameworkService

getEditingDomain

protected static TransactionalEditingDomain getEditingDomain(IWorkbenchPart part)
Get the EditingDomain to a model that is currently opened in the given WorkbenchPart.

Parameters:
part - the given WorkbenchPart
Returns:
the corresponding editing domain or null if not applicable