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 ActiveEditorObserver
INSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyStereotype(EObject eObject)
Executes the operation of applying stereotypes on givenEObject
void
cleanUp()
The cleanup is executed if the profile application view in workbench is closing, but not the Workbench.void
eObjectSelected(EObject eObject)
Notifies the extended plug-in that the new selection on an instance ofEObject
was registered.ProfileApplicationDecorator
findProfileApplicationDecorator(EObject eObject)
If we needProfileApplicationDecorator
because of its extended functionalities, and callingEObject.eContainer()
will eventually returnProfileApplication
but we cannot cast it toProfileApplicationDecorator
.IWorkbenchPart
getLastActiveEditorPart()
String
getModelIdForWorkbenchPart(IWorkbenchPart part)
void
refreshDecoration(EObject eObject)
The method collects all stereotypes applied toeObject
from profile applications that can be found for this model inProfileApplicationRegistry
and then informs active editor decorator to decorate the eObject.void
refreshDecorations(Collection<EObject> eObjects)
It calls therefreshDecoration(EObject)
for eachEObject
.void
refreshViewer()
Complete refresh of the viewer tree if needed.void
refreshViewer(Object object)
Collection can be provided as parameter.void
revealElement(Object element)
void
setActivateViewFilter(boolean activateFilter)
void
setProfileApplicationChanged()
This method will be called fromProfileApplicationDecoratorReflectiveItemProviderAdapterFactory
when notification is fired that an attribute is changed in properties view.void
setViewer(TreeViewer viewer)
To set the Tree Viewer from outside.void
updateViewer(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:
applyStereotype
in interfacePluginExtensionOperationsListener
-
eObjectSelected
public void eObjectSelected(EObject eObject)
Notifies the extended plug-in that the new selection on an instance ofEObject
was registered.- Specified by:
eObjectSelected
in interfacePluginExtensionOperationsListener
-
setActivateViewFilter
public void setActivateViewFilter(boolean activateFilter)
- Parameters:
activateFilter
-true
orfalse
-
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 ofEObject
s for which decorations must be refreshed.
-
refreshDecoration
public void refreshDecoration(EObject eObject)
The method collects all stereotypes applied toeObject
from profile applications that can be found for this model inProfileApplicationRegistry
and 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 fromProfileApplicationDecoratorReflectiveItemProviderAdapterFactory
when 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 needProfileApplicationDecorator
because of its extended functionalities, and callingEObject.eContainer()
will eventually returnProfileApplication
but 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:
-
-