Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2015-11-18 08:48:24 +0000
committerGerrit Code Review @ Eclipse.org2015-11-25 09:47:59 +0000
commit8d0c365545b5b1523c54ced2fd13438abc7586c4 (patch)
tree43c8e10a80301c3f3ddaeef9825ca8d2278efc47 /plugins/infra/viewpoints
parent6e99ae12c6453caeebf232da1c6a9f7dadab08e3 (diff)
downloadorg.eclipse.papyrus-8d0c365545b5b1523c54ced2fd13438abc7586c4.tar.gz
org.eclipse.papyrus-8d0c365545b5b1523c54ced2fd13438abc7586c4.tar.xz
org.eclipse.papyrus-8d0c365545b5b1523c54ced2fd13438abc7586c4.zip
[viewpoints] Add a listener mechanism to notify current viewpoint change
Change-Id: Iaba31550fa92466bd32d7d5bbec942541338bde1 Signed-off-by: Florian Noyrit <florian.noyrit@cea.fr>
Diffstat (limited to 'plugins/infra/viewpoints')
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF1
-rwxr-xr-xplugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/plugin.xml1
-rw-r--r--plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/schema/policycheckerlistener.exsd102
-rw-r--r--plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java3
-rw-r--r--plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/IPolicyCheckerListener.java22
-rw-r--r--plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/IPolicyCheckerListenerExtensionPoint.java25
-rw-r--r--plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/PolicyCheckerNotifier.java64
7 files changed, 218 insertions, 0 deletions
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF
index 54a435b2cbd..44cd99b71a7 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/META-INF/MANIFEST.MF
@@ -1,5 +1,6 @@
Manifest-Version: 1.0
Export-Package: org.eclipse.papyrus.infra.viewpoints.policy,
+ org.eclipse.papyrus.infra.viewpoints.policy.listener,
org.eclipse.papyrus.infra.viewpoints.policy.query,
org.eclipse.papyrus.infra.viewpoints.style,
org.eclipse.papyrus.infra.viewpoints.style.impl,
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/plugin.xml b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/plugin.xml
index 1ab148ef25b..190ef26820a 100755
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/plugin.xml
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/plugin.xml
@@ -4,6 +4,7 @@
<extension-point id="org.eclipse.papyrus.infra.viewpoints.policy.custom" name="Custom Viewpoints Policy" schema="schema/custom.exsd"/>
<extension-point id="org.eclipse.papyrus.infra.viewpoints.policy.profilehelper" name="Viewpoints Policy Profile Helper" schema="schema/profilehelper.exsd"/>
<extension-point id="org.eclipse.papyrus.infra.viewpoints.policy.viewType" name="View Type Definition" schema="schema/viewType.exsd"/>
+ <extension-point id="org.eclipse.papyrus.infra.viewpoints.policy.policycheckerlistener" name="PolicyChecker Listener" schema="schema/policycheckerlistener.exsd"/>
<extension
point="org.eclipse.emf.ecore.generated_package">
<package
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/schema/policycheckerlistener.exsd b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/schema/policycheckerlistener.exsd
new file mode 100644
index 00000000000..45e9ff9d96b
--- /dev/null
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/schema/policycheckerlistener.exsd
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.papyrus.infra.viewpoints.policy" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appinfo>
+ <meta.schema plugin="org.eclipse.papyrus.infra.viewpoints.policy" id="org.eclipse.papyrus.infra.viewpoints.policy.policycheckerlistener" name="PolicyChecker Listener"/>
+ </appinfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appinfo>
+ <meta.element />
+ </appinfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="policycheckerlistener"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute translatable="true"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="policycheckerlistener">
+ <complexType>
+ <attribute name="listenerClass" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.infra.viewpoints.policy.listener.IPolicyCheckerListener"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="since"/>
+ </appinfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="examples"/>
+ </appinfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="apiinfo"/>
+ </appinfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appinfo>
+ <meta.section type="implementation"/>
+ </appinfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java
index b6f5db99843..979cbc43027 100644
--- a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/PolicyChecker.java
@@ -54,6 +54,7 @@ import org.eclipse.papyrus.infra.viewpoints.configuration.PapyrusViewpoint;
import org.eclipse.papyrus.infra.viewpoints.iso42010.ArchitectureViewpoint;
import org.eclipse.papyrus.infra.viewpoints.iso42010.ModelKind;
import org.eclipse.papyrus.infra.viewpoints.iso42010.Stakeholder;
+import org.eclipse.papyrus.infra.viewpoints.policy.listener.PolicyCheckerNotifier;
/**
* The <code>PolicyChecker</code> enforces the viewpoints configuration as a policy in the user interface
@@ -281,6 +282,7 @@ public class PolicyChecker {
public static PolicyChecker getCurrent() {
if (currentPolicyChecker == null) {
currentPolicyChecker = new PolicyChecker();
+ PolicyCheckerNotifier.getInstance().fire(currentPolicyChecker);
}
return currentPolicyChecker;
}
@@ -293,6 +295,7 @@ public class PolicyChecker {
*/
public static void setCurrent(PolicyChecker pc) {
currentPolicyChecker = pc;
+ PolicyCheckerNotifier.getInstance().fire(pc);
}
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/IPolicyCheckerListener.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/IPolicyCheckerListener.java
new file mode 100644
index 00000000000..70af1d36b34
--- /dev/null
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/IPolicyCheckerListener.java
@@ -0,0 +1,22 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.viewpoints.policy.listener;
+
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+
+public interface IPolicyCheckerListener {
+
+ void policyCheckerChanged(PolicyChecker policyChecker);
+
+}
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/IPolicyCheckerListenerExtensionPoint.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/IPolicyCheckerListenerExtensionPoint.java
new file mode 100644
index 00000000000..c6d74722043
--- /dev/null
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/IPolicyCheckerListenerExtensionPoint.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.viewpoints.policy.listener;
+
+import org.eclipse.papyrus.infra.viewpoints.policy.Activator;
+
+public interface IPolicyCheckerListenerExtensionPoint {
+
+
+ /** ID of the extension point */
+ public final static String EXTENSION_POINT_ID = Activator.PLUGIN_ID + ".policycheckerlistener";
+
+ public static final String LISTENER_CLASS = "listenerClass";
+ }
diff --git a/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/PolicyCheckerNotifier.java b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/PolicyCheckerNotifier.java
new file mode 100644
index 00000000000..80fdab2243c
--- /dev/null
+++ b/plugins/infra/viewpoints/org.eclipse.papyrus.infra.viewpoints.policy/src/org/eclipse/papyrus/infra/viewpoints/policy/listener/PolicyCheckerNotifier.java
@@ -0,0 +1,64 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.viewpoints.policy.listener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.viewpoints.policy.Activator;
+import org.eclipse.papyrus.infra.viewpoints.policy.PolicyChecker;
+
+public class PolicyCheckerNotifier {
+
+ private static PolicyCheckerNotifier notifier;
+
+ private static List<IPolicyCheckerListener> listeners;
+
+
+ public static synchronized PolicyCheckerNotifier getInstance() {
+ if (notifier == null) {
+ notifier = new PolicyCheckerNotifier();
+ listeners = new ArrayList<IPolicyCheckerListener>();
+ notifier.init();
+ }
+ return notifier;
+ }
+
+ public void clearListeners() {
+ listeners.clear();
+ }
+
+ public void fire(PolicyChecker policyChecker) {
+ for (IPolicyCheckerListener policyCheckerListener : listeners) {
+ policyCheckerListener.policyCheckerChanged(policyChecker);
+ }
+ }
+
+ void init() {
+ IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(IPolicyCheckerListenerExtensionPoint.EXTENSION_POINT_ID);
+ for (IConfigurationElement configurationElement : elements) {
+ try {
+ Object listenerClass = configurationElement.createExecutableExtension(IPolicyCheckerListenerExtensionPoint.LISTENER_CLASS);
+ if (listenerClass instanceof IPolicyCheckerListener) {
+ listeners.add((IPolicyCheckerListener) listenerClass);
+ }
+ } catch (CoreException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+}

Back to the top