Search in sources :

Example 1 with SessionManagerListener

use of org.eclipse.sirius.business.api.session.SessionManagerListener 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

ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)1 LabelProviderChangedEvent (org.eclipse.jface.viewers.LabelProviderChangedEvent)1 Session (org.eclipse.sirius.business.api.session.Session)1 SessionManagerListener (org.eclipse.sirius.business.api.session.SessionManagerListener)1 IEditingSession (org.eclipse.sirius.ui.business.api.session.IEditingSession)1 Viewpoint (org.eclipse.sirius.viewpoint.description.Viewpoint)1 IDecoratorManager (org.eclipse.ui.IDecoratorManager)1