Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-07-23 14:39:30 +0000
committervlorenzo2012-07-23 14:39:30 +0000
commitc87daaae51284ecf8a8c0542eda149af7659f1cf (patch)
tree75cb6a16b9e9db9b0e53726104cdbc86fbc181bf /extraplugins
parent48d9526d8c7a3adde4468190fa7faf2325c9d40d (diff)
downloadorg.eclipse.papyrus-c87daaae51284ecf8a8c0542eda149af7659f1cf.tar.gz
org.eclipse.papyrus-c87daaae51284ecf8a8c0542eda149af7659f1cf.tar.xz
org.eclipse.papyrus-c87daaae51284ecf8a8c0542eda149af7659f1cf.zip
385726: [UML Compare] Add an action in the Diagram Menu to allow the comparison between to 2 UML Element
https://bugs.eclipse.org/bugs/show_bug.cgi?id=385726
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/META-INF/MANIFEST.MF3
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/plugin.xml64
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/src/org/eclipse/papyrus/uml/compare/utils/UMLComparePropertyTester.java83
3 files changed, 127 insertions, 23 deletions
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/META-INF/MANIFEST.MF b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/META-INF/MANIFEST.MF
index c3a145af44e..f78626e8c52 100644
--- a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/META-INF/MANIFEST.MF
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/META-INF/MANIFEST.MF
@@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.tools;bundle-version="0.9.0",
org.eclipse.emf.transaction,
org.eclipse.papyrus.uml.compare.diff,
- org.eclipse.papyrus.infra.emf.compare.diff
+ org.eclipse.papyrus.infra.emf.compare.diff,
+ org.eclipse.core.expressions
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.uml.compare.editor
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/plugin.xml b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/plugin.xml
index 83bfdce961b..07bfe3075cc 100644
--- a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/plugin.xml
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/plugin.xml
@@ -36,28 +36,48 @@
</extension>
<extension
point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="false"
- locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup">
- <command
- commandId="org.eclipse.papyrus.uml.compare.command"
- icon="icons/papyrus_compare_16x16.png"
- label="Compare 2 elements"
- style="push"
- tooltip="Compare 2 elements">
- <visibleWhen
- checkEnabled="false">
- <and>
- <with
- variable="activeEditorId">
- <equals
- value="org.eclipse.papyrus.infra.core.papyrusEditor">
- </equals>
- </with>
- </and>
- </visibleWhen>
- </command>
- </menuContribution>
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.ui.popup.any">
+ <command
+ commandId="org.eclipse.papyrus.uml.compare.command"
+ icon="icons/papyrus_compare_16x16.png"
+ label="Compare 2 UML Elements"
+ style="push"
+ tooltip="Compare 2 UML Elements">
+ <visibleWhen
+ checkEnabled="true">
+ <or>
+ <and>
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.uml.compare.property.isCorrectSelection"
+ value="true">
+ </test>
+ </with>
+ <with
+ variable="activeEditorId">
+ <equals
+ value="org.eclipse.papyrus.infra.core.papyrusEditor">
+ </equals>
+ </with>
+ </and>
+ </or>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.papyrus.uml.compare.utils.UMLComparePropertyTester"
+ id="org.eclipse.papyrus.uml.compare.property"
+ namespace="org.eclipse.papyrus.uml.compare.property"
+ properties="isCorrectSelection"
+ type="org.eclipse.jface.viewers.IStructuredSelection">
+ </propertyTester>
</extension>
</plugin>
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/src/org/eclipse/papyrus/uml/compare/utils/UMLComparePropertyTester.java b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/src/org/eclipse/papyrus/uml/compare/utils/UMLComparePropertyTester.java
new file mode 100644
index 00000000000..67b168b3eb7
--- /dev/null
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare/src/org/eclipse/papyrus/uml/compare/utils/UMLComparePropertyTester.java
@@ -0,0 +1,83 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.compare.utils;
+
+import java.util.Iterator;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+
+/*
+ *
+ *
+ *TODO : should be replace by the correct test on the plugin.xml, when it will work (see bug 385744)
+ * the correct test in the plugin.xml :
+ * activeWhen
+ * with selection
+ * iterate
+ * adapt to EObject
+ */
+public class UMLComparePropertyTester extends PropertyTester {
+
+ /**
+ * The property to test
+ */
+ private static final String IS_CORRECT_SELECTION = "isCorrectSelection"; //$NON-NLS-1$
+
+ /**
+ *
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ *
+ * @param receiver
+ * @param property
+ * @param args
+ * @param expectedValue
+ * @return
+ */
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if(IS_CORRECT_SELECTION.equals(property) && receiver instanceof IStructuredSelection && expectedValue instanceof Boolean) {
+ return testCurrentSelection((IStructuredSelection)receiver).equals(expectedValue);
+ }
+ return false;
+ }
+
+ /**
+ * Test the type of the diagram
+ *
+ * @param iEditor
+ * the current editor
+ * @param expectedValue
+ * the expected value : the wanted diagram type
+ * @return <code>true</code> if the current diagram has the wanted type
+ */
+ protected Boolean testCurrentSelection(final IStructuredSelection selection) {
+ final Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
+ boolean answer = selection.size() == 2;
+ while(iterator.hasNext() && answer) {
+ Object current = iterator.next();
+ if(current instanceof IAdaptable) {
+ final Object eObject = ((IAdaptable)current).getAdapter(EObject.class);
+ if(eObject == null) {
+ answer = false;
+ }
+ } else {
+ answer = false;
+ }
+ }
+ return answer;
+ }
+}

Back to the top