Search in sources :

Example 6 with IDecoratorManager

use of org.eclipse.ui.IDecoratorManager in project InformationSystem by ObeoNetwork.

the class RequirementLinkerPlugin method installDecoratorListenerOnSession.

private void installDecoratorListenerOnSession(Session session) {
    TransactionalEditingDomain ted = session.getTransactionalEditingDomain();
    if (ted != null) {
        NotificationFilter notificationFilter = NotificationFilter.createFeatureFilter(RequirementPackage.Literals.REQUIREMENT__REFERENCED_OBJECT);
        ted.addResourceSetListener(new ResourceSetListenerImpl(notificationFilter) {

            @Override
            public boolean isPostcommitOnly() {
                return true;
            }

            @Override
            public void resourceSetChanged(ResourceSetChangeEvent event) {
                PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

                    public void run() {
                        IDecoratorManager decoratorManager = PlatformUI.getWorkbench().getDecoratorManager();
                        decoratorManager.update(ObjectWithRequirement.DECORATOR_ID);
                    }
                });
            }
        });
    }
}
Also used : TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) ResourceSetChangeEvent(org.eclipse.emf.transaction.ResourceSetChangeEvent) ResourceSetListenerImpl(org.eclipse.emf.transaction.ResourceSetListenerImpl) IDecoratorManager(org.eclipse.ui.IDecoratorManager) NotificationFilter(org.eclipse.emf.transaction.NotificationFilter)

Example 7 with IDecoratorManager

use of org.eclipse.ui.IDecoratorManager in project InformationSystem by ObeoNetwork.

the class Activator method installAllDecoratorListeners.

/**
 * Installs a Session listener to refresh decorators for objects with requirements on all sessions
 */
private void installAllDecoratorListeners() {
    // it could happen depending on the plugin starting order
    for (Session session : SessionManager.INSTANCE.getSessions()) {
        installDecoratorListenerOnSession(session);
    }
    SessionManager.INSTANCE.addSessionsListener(new SessionManagerListener() {

        public void notifyAddSession(Session newSession) {
            installDecoratorListenerOnSession(newSession);
        }

        public void viewpointSelected(Viewpoint selectedSirius) {
        // Do nothing
        }

        public void viewpointDeselected(Viewpoint deselectedSirius) {
        // Do nothing
        }

        public void notifyRemoveSession(Session removedSession) {
        // Do nothing
        }

        public void notify(Session updated, int notification) {
        // Do nothing
        }
    });
    IDecoratorManager decoratorManager = PlatformUI.getWorkbench().getDecoratorManager();
    decoratorManager.addListener(new ILabelProviderListener() {

        public void labelProviderChanged(LabelProviderChangedEvent event) {
            boolean decoratorEnabled = ObjectWithRequirement.isDecoratorEnabled();
            if (requirementsDecoratorEnabled != decoratorEnabled) {
                // Value changed, we have to refresh diagrams
                refreshDecorationsOnAllSessions();
                requirementsDecoratorEnabled = decoratorEnabled;
            }
        }
    });
}
Also used : SessionManagerListener(org.eclipse.sirius.business.api.session.SessionManagerListener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) IDecoratorManager(org.eclipse.ui.IDecoratorManager) LabelProviderChangedEvent(org.eclipse.jface.viewers.LabelProviderChangedEvent) Viewpoint(org.eclipse.sirius.viewpoint.description.Viewpoint) Session(org.eclipse.sirius.business.api.session.Session) IEditingSession(org.eclipse.sirius.ui.business.api.session.IEditingSession)

Aggregations

IDecoratorManager (org.eclipse.ui.IDecoratorManager)7 IFolder (org.eclipse.core.resources.IFolder)4 DecoratingLabelProvider (org.eclipse.jface.viewers.DecoratingLabelProvider)4 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)4 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)4 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)4 ElementTreeSelectionDialog (org.eclipse.ui.dialogs.ElementTreeSelectionDialog)4 ISelectionStatusValidator (org.eclipse.ui.dialogs.ISelectionStatusValidator)4 WorkbenchContentProvider (org.eclipse.ui.model.WorkbenchContentProvider)4 WorkbenchLabelProvider (org.eclipse.ui.model.WorkbenchLabelProvider)4 IWebProject (com.liferay.ide.core.IWebProject)2 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IPath (org.eclipse.core.runtime.IPath)2 CoreException (org.eclipse.core.runtime.CoreException)1 EObject (org.eclipse.emf.ecore.EObject)1 NotificationFilter (org.eclipse.emf.transaction.NotificationFilter)1 ResourceSetChangeEvent (org.eclipse.emf.transaction.ResourceSetChangeEvent)1 ResourceSetListenerImpl (org.eclipse.emf.transaction.ResourceSetListenerImpl)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1