Class ActiveEditorObserver
- java.lang.Object
-
- org.modelversioning.emfprofile.application.registry.ui.observer.ActiveEditorObserver
-
- All Implemented Interfaces:
PluginExtensionOperationsListener
public class ActiveEditorObserver extends Object implements PluginExtensionOperationsListener
It manages mapping of opened editors of interest to the generated id for an opened model in editor. It is also aPluginExtensionOperationsListener.
-
-
Field Summary
Fields Modifier and Type Field Description static ActiveEditorObserverINSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyStereotype(EObject eObject)Executes the operation of applying stereotypes on givenEObjectvoidcleanUp()The cleanup is executed if the profile application view in workbench is closing, but not the Workbench.voideObjectSelected(EObject eObject)Notifies the extended plug-in that the new selection on an instance ofEObjectwas registered.ProfileApplicationDecoratorfindProfileApplicationDecorator(EObject eObject)If we needProfileApplicationDecoratorbecause of its extended functionalities, and callingEObject.eContainer()will eventually returnProfileApplicationbut we cannot cast it toProfileApplicationDecorator.IWorkbenchPartgetLastActiveEditorPart()StringgetModelIdForWorkbenchPart(IWorkbenchPart part)voidrefreshDecoration(EObject eObject)The method collects all stereotypes applied toeObjectfrom profile applications that can be found for this model inProfileApplicationRegistryand then informs active editor decorator to decorate the eObject.voidrefreshDecorations(Collection<EObject> eObjects)It calls therefreshDecoration(EObject)for eachEObject.voidrefreshViewer()Complete refresh of the viewer tree if needed.voidrefreshViewer(Object object)Collection can be provided as parameter.voidrevealElement(Object element)voidsetActivateViewFilter(boolean activateFilter)voidsetProfileApplicationChanged()This method will be called fromProfileApplicationDecoratorReflectiveItemProviderAdapterFactorywhen notification is fired that an attribute is changed in properties view.voidsetViewer(TreeViewer viewer)To set the Tree Viewer from outside.voidupdateViewer(Object element)Updates the element of the viewer.
-
-
-
Field Detail
-
INSTANCE
public static ActiveEditorObserver INSTANCE
-
-
Method Detail
-
getLastActiveEditorPart
public IWorkbenchPart getLastActiveEditorPart()
-
setViewer
public void setViewer(TreeViewer viewer)
To set the Tree Viewer from outside. After calling this method a part listener will be added on active page which registers activation of editors that can be decorated. Note: without setting a tree viewer the services of this class implementation will work properly.- Parameters:
viewer-
-
refreshViewer
public void refreshViewer()
Complete refresh of the viewer tree if needed.
-
refreshViewer
public void refreshViewer(Object object)
Collection can be provided as parameter. Refresh will be executed asynchronously for whole group of collection items in one runnable.- Parameters:
object- an viewer tree element or a collection of them.
-
updateViewer
public void updateViewer(Object element)
Updates the element of the viewer.- Parameters:
element- of the tree in question.
-
revealElement
public void revealElement(Object element)
-
getModelIdForWorkbenchPart
public String getModelIdForWorkbenchPart(IWorkbenchPart part)
-
applyStereotype
public void applyStereotype(EObject eObject)
Executes the operation of applying stereotypes on givenEObject- Specified by:
applyStereotypein interfacePluginExtensionOperationsListener
-
eObjectSelected
public void eObjectSelected(EObject eObject)
Notifies the extended plug-in that the new selection on an instance ofEObjectwas registered.- Specified by:
eObjectSelectedin interfacePluginExtensionOperationsListener
-
setActivateViewFilter
public void setActivateViewFilter(boolean activateFilter)
- Parameters:
activateFilter-trueorfalse
-
refreshDecorations
public void refreshDecorations(Collection<EObject> eObjects)
It calls therefreshDecoration(EObject)for eachEObject. Note: This method can be used to refresh decorations when loading or unloading profile applications.- Parameters:
eObjects- collection ofEObjects for which decorations must be refreshed.
-
refreshDecoration
public void refreshDecoration(EObject eObject)
The method collects all stereotypes applied toeObjectfrom profile applications that can be found for this model inProfileApplicationRegistryand then informs active editor decorator to decorate the eObject.- Parameters:
eObject- that has stereotype applications
-
cleanUp
public void cleanUp()
The cleanup is executed if the profile application view in workbench is closing, but not the Workbench. If the workbench is closing, then the clean-up will be executed inIWorkbenchListener.preShutdown(IWorkbench, boolean)which calls clean-up for all profile applications inDecoratableEditorPartListener.cleanUpForAllEditorParts().
-
setProfileApplicationChanged
public void setProfileApplicationChanged()
This method will be called fromProfileApplicationDecoratorReflectiveItemProviderAdapterFactorywhen notification is fired that an attribute is changed in properties view. Notifications will be fired for every change, but we are here only interested in scenario when only one tree element is selected and we can find profile application decorator from it, otherwise this method will do nothing.
-
findProfileApplicationDecorator
public ProfileApplicationDecorator findProfileApplicationDecorator(EObject eObject)
If we needProfileApplicationDecoratorbecause of its extended functionalities, and callingEObject.eContainer()will eventually returnProfileApplicationbut we cannot cast it toProfileApplicationDecorator. Thus, the easiest way to get it is to ask theProfileApplicationRegistry, which this method does for you.- Parameters:
eObject-- Returns:
-
-