diff options
Diffstat (limited to 'plugins/uml/diagram')
4 files changed, 143 insertions, 104 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/StereotypePasteStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/StereotypePasteStrategy.java index bb774f32fd8..df1f675eb6b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/StereotypePasteStrategy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/StereotypePasteStrategy.java @@ -1,6 +1,6 @@ /***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * + * Copyright (c) 2014, 2021 CEA LIST. + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,6 +10,7 @@ * * Contributors: * Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation + * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - bug 573807 *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.common.strategy.paste; @@ -70,7 +71,7 @@ public class StereotypePasteStrategy extends AbstractPasteStrategy implements IP /* * (non-Javadoc) - * + * * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getLabel() */ public String getLabel() { @@ -79,7 +80,7 @@ public class StereotypePasteStrategy extends AbstractPasteStrategy implements IP /* * (non-Javadoc) - * + * * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getID() */ public String getID() { @@ -88,7 +89,7 @@ public class StereotypePasteStrategy extends AbstractPasteStrategy implements IP /* * (non-Javadoc) - * + * * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getDescription() */ public String getDescription() { @@ -97,7 +98,7 @@ public class StereotypePasteStrategy extends AbstractPasteStrategy implements IP /* * (non-Javadoc) - * + * * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#dependsOn() */ @Override @@ -107,7 +108,7 @@ public class StereotypePasteStrategy extends AbstractPasteStrategy implements IP /* * (non-Javadoc) - * + * * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#getSemanticCommand(org.eclipse.emf.edit.domain.EditingDomain, * org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard) */ @@ -122,7 +123,7 @@ public class StereotypePasteStrategy extends AbstractPasteStrategy implements IP // 1. init all ApplyStereotypeCommand for (Iterator<Object> iterator = papyrusClipboard.iterator(); iterator.hasNext();) { - Object object = (Object) iterator.next(); + Object object = iterator.next(); // get target Element EObject target = papyrusClipboard.getTragetCopyFromInternalClipboardCopy(object); if (target != null && target instanceof Element) { @@ -136,19 +137,22 @@ public class StereotypePasteStrategy extends AbstractPasteStrategy implements IP DuplicateStereotypeCommand applyStereotypeCommand = new DuplicateStereotypeCommand((TransactionalEditingDomain) domain, (Element) target, (Element) targetOwner, stereotypeApplication); Stereotype stereotypeInTargetContext = applyStereotypeCommand.getStereotypeInTargetContext(); - Profile profile = stereotypeInTargetContext.getProfile(); - - if (isProfileAppliedRecursive(targetPackage, profile)) { - compoundCommand.append(applyStereotypeCommand); - } else { // Profile is missing - Activator.getDefault().logInfo(profile.getName() + " is missing", null); - List<DuplicateStereotypeCommand> stereotypeListMissingProfiles = missingProfiles.get(profile); - if (stereotypeListMissingProfiles != null && !stereotypeListMissingProfiles.isEmpty()) { - stereotypeListMissingProfiles.add(applyStereotypeCommand); - } else { - stereotypeListMissingProfiles = new ArrayList<DuplicateStereotypeCommand>(); - stereotypeListMissingProfiles.add(applyStereotypeCommand); - missingProfiles.put(profile, stereotypeListMissingProfiles); + // might be null, if copied model element does no longer exist (since editor is closed) + if (stereotypeInTargetContext != null) { + Profile profile = stereotypeInTargetContext.getProfile(); + + if (isProfileAppliedRecursive(targetPackage, profile)) { + compoundCommand.append(applyStereotypeCommand); + } else { // Profile is missing + Activator.getDefault().logInfo(profile.getName() + " is missing", null); + List<DuplicateStereotypeCommand> stereotypeListMissingProfiles = missingProfiles.get(profile); + if (stereotypeListMissingProfiles != null && !stereotypeListMissingProfiles.isEmpty()) { + stereotypeListMissingProfiles.add(applyStereotypeCommand); + } else { + stereotypeListMissingProfiles = new ArrayList<DuplicateStereotypeCommand>(); + stereotypeListMissingProfiles.add(applyStereotypeCommand); + missingProfiles.put(profile, stereotypeListMissingProfiles); + } } } } @@ -255,7 +259,7 @@ public class StereotypePasteStrategy extends AbstractPasteStrategy implements IP /* * (non-Javadoc) - * + * * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy#prepare(org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard) */ @Override diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/META-INF/MANIFEST.MF index b566df1ad9f..c1f7c2bda2c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/META-INF/MANIFEST.MF +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/META-INF/MANIFEST.MF @@ -25,7 +25,7 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.6.0,4.0.0)", org.eclipse.uml2.uml.editor;bundle-version="[5.5.0,6.0.0)" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy -Bundle-Version: 3.0.0.qualifier +Bundle-Version: 3.0.100.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-Activator: org.eclipse.papyrus.uml.diagram.menu.Activator diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/plugin.xml index f5322b31ed9..e82ea048453 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/plugin.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/plugin.xml @@ -32,12 +32,16 @@ label="&Diagram" tooltip="Diagram Menu"> <visibleWhen> - <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + <and> + <with + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> + </and> </visibleWhen> </menu> </menuContribution> @@ -207,12 +211,14 @@ tooltip="Line Style Action"> <visibleWhen> <and> - <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + <with + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -229,11 +235,13 @@ <visibleWhen> <and> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -250,11 +258,13 @@ <visibleWhen> <and> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -267,11 +277,13 @@ <visibleWhen> <and> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -284,11 +296,13 @@ <visibleWhen> <and> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -301,11 +315,13 @@ <visibleWhen> <and> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -318,11 +334,13 @@ <visibleWhen> <and> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -335,11 +353,13 @@ <visibleWhen> <and> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -352,11 +372,13 @@ <visibleWhen> <and> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -373,10 +395,12 @@ <visibleWhen checkEnabled="false"> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> </with> </visibleWhen> </command> @@ -387,12 +411,14 @@ tooltip="Auto Size"> <visibleWhen> <and> - <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + <with + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -405,11 +431,13 @@ <visibleWhen> <and> <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </command> @@ -419,22 +447,29 @@ <visibleWhen checkEnabled="false"> <and> - <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + <with + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> </and> </visibleWhen> </dynamic> - <visibleWhen> - <with - variable="activeEditorId"> - <equals - value="org.eclipse.papyrus.infra.core.papyrusEditor"> - </equals> - </with> + <visibleWhen + checkEnabled="false"> + <and> + <with + variable="selection"> + <test + forcePluginActivation="false" + property="org.eclipse.papyrus.infra.gmfdiag.internal.common.expressions.PapyrusGMFDiagramTester.isPapyrusGMFDiagramActive" + value="true"> + </test> + </with> + </and> </visibleWhen> </toolbar> </menuContribution> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/pom.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/pom.xml index d2ca70dad93..287d17915b8 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/pom.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.menu/pom.xml @@ -7,6 +7,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.diagram.menu</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>3.0.100-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file |