diff options
author | Shuai Li | 2015-03-17 12:26:58 +0000 |
---|---|---|
committer | Shuai Li | 2015-03-18 14:42:15 +0000 |
commit | 4caf3eb6924db41fb7ef81c8f57b9cdcdfec61f0 (patch) | |
tree | c1113392dbecba47cc191457eca1d6edbc2ee73f /extraplugins/uml | |
parent | 9589a3fb7f16346701f669561e6dd6ed8aabfd0b (diff) | |
download | org.eclipse.papyrus-4caf3eb6924db41fb7ef81c8f57b9cdcdfec61f0.tar.gz org.eclipse.papyrus-4caf3eb6924db41fb7ef81c8f57b9cdcdfec61f0.tar.xz org.eclipse.papyrus-4caf3eb6924db41fb7ef81c8f57b9cdcdfec61f0.zip |
Bug 462461 [EMF Compare] Contextual popup menu in Model Explorer is
missing
- Added Model Explorer context menu "Compare With" and "Each Other" item
- Use Eclipse core expressions to check selection is adaptable to
EObject
- Remove property tester
- Remove UML file icon of "each other" item because diagrams can be
compared too.
- Copyright header
- Rename some variables
Change-Id: I2eb0db160c1c1cedb67b6f6e861fd88dea44940c
Signed-off-by: Shuai Li <shuai.li@cea.fr>
Diffstat (limited to 'extraplugins/uml')
3 files changed, 230 insertions, 79 deletions
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/META-INF/MANIFEST.MF b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/META-INF/MANIFEST.MF index 64b4fb46f79..ef6188449c8 100644 --- a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/META-INF/MANIFEST.MF +++ b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/META-INF/MANIFEST.MF @@ -1,23 +1,25 @@ -Manifest-Version: 1.0
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.core.expressions;bundle-version="3.4.500",
- org.eclipse.core.resources;bundle-version="3.8.100",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.1.0",
- org.eclipse.emf.compare.ide.ui;bundle-version="3.0.0",
- org.eclipse.emf.edit;bundle-version="2.9.0",
- org.eclipse.emf.common,
- org.eclipse.uml2.uml;bundle-version="4.1.0",
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.1.0",
- org.eclipse.uml2.uml.edit;bundle-version="4.1.0",
- org.eclipse.emf.compare.edit;bundle-version="3.1.0"
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.1.0.qualifier
-Bundle-Name: %pluginName
-Bundle-Activator: org.eclipse.papyrus.uml.compare.ui.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.uml.compare.ui;singleton:=tru
- e
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-
+Manifest-Version: 1.0 +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.expressions;bundle-version="3.4.500", + org.eclipse.core.resources;bundle-version="3.8.100", + org.eclipse.papyrus.infra.core.log;bundle-version="1.1.0", + org.eclipse.emf.compare.ide.ui;bundle-version="3.0.0", + org.eclipse.emf.edit;bundle-version="2.9.0", + org.eclipse.emf.common, + org.eclipse.uml2.uml;bundle-version="4.1.0", + org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.1.0", + org.eclipse.uml2.uml.edit;bundle-version="4.1.0", + org.eclipse.emf.compare.edit;bundle-version="3.1.0", + org.eclipse.papyrus.infra.emf, + org.eclipse.compare +Bundle-Vendor: %providerName +Bundle-ActivationPolicy: lazy +Bundle-Version: 1.1.0.qualifier +Bundle-Name: %pluginName +Bundle-Activator: org.eclipse.papyrus.uml.compare.ui.Activator +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.uml.compare.ui;singleton:=tru + e +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 + diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/plugin.xml b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/plugin.xml index a29a66de652..5eb383a09d1 100644 --- a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/plugin.xml +++ b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/plugin.xml @@ -1,56 +1,116 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <!-- <extension
- point="org.eclipse.ui.commands">
- <command
- categoryId="org.eclipse.papyrus.editor.category"
- description="Open the Papyrus Model Compare Editor"
- id="org.eclipse.papyrus.uml.compare.ui.command"
- name="Papyrus Model Compare Editor">
- </command>
- </extension>
- <extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.papyrus.uml.compare.ui.handler.CompareUMLFileHandler"
- commandId="org.eclipse.papyrus.uml.compare.ui.command">
- </handler>
-
-
- </extension>
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- allPopups="true"
- locationURI="popup:org.eclipse.ui.popup.any?after=additions">
- <command
- commandId="org.eclipse.papyrus.uml.compare.ui.command"
- style="push">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="selection">
- <iterate
- ifEmpty="false"
- operator="and">
- <adapt
- type="org.eclipse.core.resources.IFile">
- </adapt>
- </iterate>
- </with>
- </visibleWhen>
- </command>
-</menuContribution>
- </extension> -->
- <extension
- point="org.eclipse.emf.compare.edit.adapterFactory">
- <factory
- class="org.eclipse.papyrus.uml.compare.ui.provider.PapyrusCompareAdapterFactory"
- ranking="11"
- supportedTypes="org.eclipse.emf.edit.provider.IItemLabelProvider"
- uri="http://www.eclipse.org/uml2/5.0.0/UML">
- </factory>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension + point="org.eclipse.ui.handlers"> + <handler + class="org.eclipse.papyrus.uml.compare.ui.actions.CompareInEditor" + commandId="org.eclipse.papyrus.uml.compare.ui.compareInEditor"> + <activeWhen> + <with + variable="selection"> + <and> + <or> + <count + value="2"> + </count> + <count + value="3"> + </count> + </or> + <iterate> + <adapt + type="org.eclipse.emf.ecore.EObject"> + <instanceof + value="org.eclipse.emf.ecore.EObject"> + </instanceof> + </adapt> + </iterate> + </and> + </with> + </activeWhen> + </handler> + </extension> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + allPopups="false" + locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?after=org.eclipse.papyrus.infra.emf.readonly.EnableWriteCommand"> + <separator + name="org.eclipse.papyrus.uml.compare.ui.compareGroup" + visible="true"> + </separator> + <menu + icon="icons/papyrus_compare_16x16.png" + id="org.eclipse.papyrus.uml.compare.ui.compareWithMenu" + label="Compare With"> + <command + commandId="org.eclipse.papyrus.uml.compare.ui.compareInEditor" + id="org.eclipse.papyrus.uml.compare.ui.compareInEditor" + label="Each Other" + style="push" + tooltip="Papyrus UML Compare"> + </command> + </menu> + </menuContribution> + </extension> + <extension + point="org.eclipse.ui.commands"> + <command + id="org.eclipse.papyrus.uml.compare.ui.compareInEditor" + name="Compare in Editor"> + </command> + </extension> + <!-- <extension + point="org.eclipse.ui.commands"> + <command + categoryId="org.eclipse.papyrus.editor.category" + description="Open the Papyrus Model Compare Editor" + id="org.eclipse.papyrus.uml.compare.ui.command" + name="Papyrus Model Compare Editor"> + </command> + </extension> + <extension + point="org.eclipse.ui.handlers"> + <handler + class="org.eclipse.papyrus.uml.compare.ui.handler.CompareUMLFileHandler" + commandId="org.eclipse.papyrus.uml.compare.ui.command"> + </handler> + + + </extension> + <extension + point="org.eclipse.ui.menus"> + <menuContribution + allPopups="true" + locationURI="popup:org.eclipse.ui.popup.any?after=additions"> + <command + commandId="org.eclipse.papyrus.uml.compare.ui.command" + style="push"> + <visibleWhen + checkEnabled="false"> + <with + variable="selection"> + <iterate + ifEmpty="false" + operator="and"> + <adapt + type="org.eclipse.core.resources.IFile"> + </adapt> + </iterate> + </with> + </visibleWhen> + </command> +</menuContribution> + </extension> --> + <extension + point="org.eclipse.emf.compare.edit.adapterFactory"> + <factory + class="org.eclipse.papyrus.uml.compare.ui.provider.PapyrusCompareAdapterFactory" + ranking="11" + supportedTypes="org.eclipse.emf.edit.provider.IItemLabelProvider" + uri="http://www.eclipse.org/uml2/5.0.0/UML"> + </factory> + </extension> + +</plugin> diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/src/org/eclipse/papyrus/uml/compare/ui/actions/CompareInEditor.java b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/src/org/eclipse/papyrus/uml/compare/ui/actions/CompareInEditor.java new file mode 100644 index 00000000000..6ca87c291eb --- /dev/null +++ b/extraplugins/uml/compare/org.eclipse.papyrus.uml.compare.ui/src/org/eclipse/papyrus/uml/compare/ui/actions/CompareInEditor.java @@ -0,0 +1,89 @@ +/***************************************************************************** + * Copyright (c) 2015 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: + * CEA LIST - Initial API and implementation + * Shuai Li - shuai.li@cea.fr + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.compare.ui.actions; + +import java.util.Iterator; + +import org.eclipse.compare.CompareEditorInput; +import org.eclipse.compare.CompareUI; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.compare.ide.ui.internal.EMFCompareIDEUIMessages; +import org.eclipse.emf.compare.ide.ui.internal.handler.AbstractCompareHandler; +import org.eclipse.emf.compare.ide.ui.internal.handler.SelectAncestorDialog; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.handlers.HandlerUtil; + +public class CompareInEditor extends AbstractCompareHandler { + + public Object execute(ExecutionEvent event) throws ExecutionException { + AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); + + final IWorkbenchPart activePart = HandlerUtil.getActivePart(event); + final ISelection selection = HandlerUtil.getCurrentSelection(event); + + if (selection instanceof IStructuredSelection) { + Iterator<?> selectionIterator = ((IStructuredSelection) selection).iterator(); + Notifier left = null; + Notifier right = null; + Notifier origin = null; + + left = (Notifier) EMFHelper.getEObject(selectionIterator.next()); + if (selectionIterator.hasNext()) { + right = (Notifier) EMFHelper.getEObject(selectionIterator.next()); + } + if (selectionIterator.hasNext()) { + origin = (Notifier) EMFHelper.getEObject(selectionIterator.next()); + } + + if (origin != null) { + Shell shell = HandlerUtil.getActiveShell(event); + SelectAncestorDialog dialog = new SelectAncestorDialog(shell, adapterFactory, new Notifier[] {left, right, origin}); + if (dialog.open() == Window.CANCEL) { + return null; + } else { +// left = dialog.leftNotifier; +// right = dialog.rightNotifier; +// origin = dialog.originNotifier; + // TODO + } + } + + // Do not compare an object with its ancestor (e.g. operation with its owner class). + if (left instanceof EObject + && right instanceof EObject + && (EcoreUtil.isAncestor((EObject) left, (EObject) right) || EcoreUtil.isAncestor((EObject) right, (EObject) left))) { + MessageDialog.openInformation(activePart.getSite().getShell(), "EMF Compare", EMFCompareIDEUIMessages.getString("CompareSelfWithAncestor")); + } else { + final CompareEditorInput input = createCompareEditorInput(activePart, adapterFactory, left, right, origin); + CompareUI.openCompareEditor(input); + } + } + + return null; + } +} |