Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Pascual2014-09-18 07:09:30 +0000
committerGabriel Pascual2014-10-17 08:37:54 +0000
commit4ed8958a9c94bc466e87119e9a30335b16e07a2e (patch)
tree9e6db951fa9c6b7534410ee366d842bec21e1ed7 /plugins/views
parentccd4ecc63cd7beecd0a0ce0e342524968a38c4f7 (diff)
downloadorg.eclipse.papyrus-4ed8958a9c94bc466e87119e9a30335b16e07a2e.tar.gz
org.eclipse.papyrus-4ed8958a9c94bc466e87119e9a30335b16e07a2e.tar.xz
org.eclipse.papyrus-4ed8958a9c94bc466e87119e9a30335b16e07a2e.zip
436952: [Submodel] Deletion of a model fragment does not delete the
model fragment resources https://bugs.eclipse.org/bugs/show_bug.cgi?id=436952 - Shift the handlers and contributions of Model Explorer menu to Model Explorer"plugin : "Create submodel" and "Reintegrate submodel" - Add Uncontrol of control mode to delete actions ( Model explorer and Diagram) Change-Id: I601cc4cd482e2b2d2f5a6acfc0b3bce76fa69b82 Signed-off-by: Gabriel Pascual <gabriel.pascual@all4tec.net>
Diffstat (limited to 'plugins/views')
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF134
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/icons/CreateSubModel_16.pngbin0 -> 547 bytes
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/icons/ReintegrateSubModel_16.pngbin0 -> 576 bytes
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml73
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/ControlCommandHandler.java160
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/DeleteCommandHandler.java23
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/UncontrolCommandHandler.java50
7 files changed, 372 insertions, 68 deletions
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF
index e20d2df20d2..730835b4c58 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/META-INF/MANIFEST.MF
@@ -1,67 +1,67 @@
-Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.views.modelexplorer,
- org.eclipse.papyrus.views.modelexplorer.actionprovider,
- org.eclipse.papyrus.views.modelexplorer.actions,
- org.eclipse.papyrus.views.modelexplorer.commands,
- org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview,
- org.eclipse.papyrus.views.modelexplorer.dialog,
- org.eclipse.papyrus.views.modelexplorer.dnd,
- org.eclipse.papyrus.views.modelexplorer.factory,
- org.eclipse.papyrus.views.modelexplorer.handler,
- org.eclipse.papyrus.views.modelexplorer.matching,
- org.eclipse.papyrus.views.modelexplorer.preferences,
- org.eclipse.papyrus.views.modelexplorer.queries
-Bundle-ActivationPolicy: lazy
-Bundle-Localization: plugin
-Bundle-Name: %pluginName
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.ui.navigator;bundle-version="3.4.0",
- org.eclipse.papyrus.infra.core;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.0.1",
- org.eclipse.emf.converter;bundle-version="2.5.0",
- org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="1.0.1",
- org.eclipse.emf.ecore.editor;bundle-version="2.6.0",
- org.eclipse.emf.workspace.ui;bundle-version="1.3.0",
- org.eclipse.core.expressions;bundle-version="3.4.200",
- org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.services.decoration;bundle-version="1.0.1",
- org.eclipse.emf.transaction;bundle-version="1.4.0",
- org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
- org.eclipse.gmf.runtime.common.core;bundle-version="1.4.1",
- org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.4.0",
- org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.4.0",
- org.eclipse.papyrus.infra.emf;bundle-version="1.0.1",
- com.google.guava;bundle-version="11.0.0",
- org.eclipse.papyrus.infra.widgets;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.1",
- org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.6.0",
- org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.services.semantic;bundle-version="1.0.1",
- org.eclipse.emf.ecore,
- org.eclipse.papyrus.infra.services.navigation;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.tools;bundle-version="1.0.1",
- org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.util.ui;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.util.emf.ui;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.efacet.core;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.efacet;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="1.0.1",
- org.eclipse.papyrus.emf.facet.util.emf.core;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="1.0.1"
-Bundle-Vendor: %providerName
-Bundle-Version: 1.0.1.qualifier
-Bundle-Activator: org.eclipse.papyrus.views.modelexplorer.Activator
-Bundle-ManifestVersion: 2
-Import-Package: org.eclipse.papyrus.emf.facet.custom.core
-Bundle-SymbolicName: org.eclipse.papyrus.views.modelexplorer;singleton
- :=true
-
+Manifest-Version: 1.0
+Export-Package: org.eclipse.papyrus.views.modelexplorer,
+ org.eclipse.papyrus.views.modelexplorer.actionprovider,
+ org.eclipse.papyrus.views.modelexplorer.actions,
+ org.eclipse.papyrus.views.modelexplorer.commands,
+ org.eclipse.papyrus.views.modelexplorer.core.ui.pagebookview,
+ org.eclipse.papyrus.views.modelexplorer.dialog,
+ org.eclipse.papyrus.views.modelexplorer.dnd,
+ org.eclipse.papyrus.views.modelexplorer.factory,
+ org.eclipse.papyrus.views.modelexplorer.handler,
+ org.eclipse.papyrus.views.modelexplorer.matching,
+ org.eclipse.papyrus.views.modelexplorer.preferences,
+ org.eclipse.papyrus.views.modelexplorer.queries
+Bundle-ActivationPolicy: lazy
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.navigator;bundle-version="3.4.0",
+ org.eclipse.papyrus.infra.core;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.core.log;bundle-version="1.0.1",
+ org.eclipse.emf.converter;bundle-version="2.5.0",
+ org.eclipse.papyrus.infra.core.sasheditor.di;bundle-version="1.0.1",
+ org.eclipse.emf.ecore.editor;bundle-version="2.6.0",
+ org.eclipse.emf.workspace.ui;bundle-version="1.3.0",
+ org.eclipse.core.expressions;bundle-version="3.4.200",
+ org.eclipse.papyrus.infra.services.edit;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.services.decoration;bundle-version="1.0.1",
+ org.eclipse.emf.transaction;bundle-version="1.4.0",
+ org.eclipse.gmf.runtime.notation;bundle-version="1.5.0",
+ org.eclipse.gmf.runtime.common.core;bundle-version="1.4.1",
+ org.eclipse.gmf.runtime.emf.commands.core;bundle-version="1.4.0",
+ org.eclipse.gmf.runtime.emf.type.core;bundle-version="1.4.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.0.1",
+ com.google.guava;bundle-version="11.0.0",
+ org.eclipse.papyrus.infra.widgets;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.1",
+ org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.6.0",
+ org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.services.semantic;bundle-version="1.0.1",
+ org.eclipse.emf.ecore,
+ org.eclipse.papyrus.infra.services.navigation;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.tools;bundle-version="1.0.1",
+ org.eclipse.papyrus.extensionpoints.editors;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.custom.metamodel;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.util.ui;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.query.java.core;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.custom.core;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.util.emf.ui;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.efacet.core;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.efacet;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="1.0.1",
+ org.eclipse.papyrus.emf.facet.util.emf.core;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.viewpoints.policy;bundle-version="1.0.1",
+ org.eclipse.papyrus.infra.services.controlmode;bundle-version="1.0.1"
+Bundle-Vendor: %providerName
+Bundle-Version: 1.0.1.qualifier
+Bundle-Activator: org.eclipse.papyrus.views.modelexplorer.Activator
+Bundle-ManifestVersion: 2
+Import-Package: org.eclipse.papyrus.emf.facet.custom.core
+Bundle-SymbolicName: org.eclipse.papyrus.views.modelexplorer;singleton
+ :=true
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/icons/CreateSubModel_16.png b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/icons/CreateSubModel_16.png
new file mode 100644
index 00000000000..2140dc439e1
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/icons/CreateSubModel_16.png
Binary files differ
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/icons/ReintegrateSubModel_16.png b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/icons/ReintegrateSubModel_16.png
new file mode 100644
index 00000000000..a9ddbb8b0cd
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/icons/ReintegrateSubModel_16.png
Binary files differ
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
index 2dccfc07903..212afac9ee0 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/plugin.xml
@@ -489,4 +489,77 @@ TODO: PAPYRUS EMF-FACET update uiCustom Here
order="500">
</target>
</extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.papyrus.views.modelexplorer.handler.ControlCommandHandler"
+ description="Move this submodel into its own resource (file)"
+ id="org.eclipse.papyrus.infra.services.controlmode.createsubmodel"
+ name="Create submodel unit">
+ <commandParameter
+ id="org.eclipse.papyrus.infra.services.controlmode.useDialogParameter"
+ name="Show control mode dialog"
+ optional="true">
+ <values
+ class="org.eclipse.papyrus.infra.services.controlmode.commands.ControlModeCommandParameterValues">
+ </values>
+ </commandParameter>
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.views.modelexplorer.handler.UncontrolCommandHandler"
+ description="Reintegrate this submodel into the resource (file) of the parent model"
+ id="org.eclipse.papyrus.infra.services.controlmode.reintegratesubmodel"
+ name="Reintegrate submodel unit into parent model">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup?after=tools">
+ <command
+ commandId="org.eclipse.papyrus.infra.services.controlmode.createsubmodel"
+ icon="icons/CreateSubModel_16.png"
+ label="Create submodel unit"
+ style="push"
+ tooltip="Move this submodel into its own resource (file)">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.services.controlmode.isFragmentModel"
+ value="false">
+ </test>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.infra.services.controlmode.reintegratesubmodel"
+ icon="icons/ReintegrateSubModel_16.png"
+ label="Reintegrate submodel unit into parent model"
+ style="push"
+ tooltip="Reintegrate this submodel into the resource (file) of the parent model">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <and>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.services.controlmode.isFragmentModel"
+ value="true">
+ </test>
+ <test
+ forcePluginActivation="true"
+ property="org.eclipse.papyrus.infra.services.controlmode.isParentLoaded"
+ value="true">
+ </test>
+ </and>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
</plugin>
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/ControlCommandHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/ControlCommandHandler.java
new file mode 100644
index 00000000000..87919d895dd
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/ControlCommandHandler.java
@@ -0,0 +1,160 @@
+/*****************************************************************************
+ * Copyright (c) 2013, 2014 Atos, 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:
+ * Arthur Daussy (Atos) arthur.daussy@atos.net - Initial API and implementation
+ * Christian W. Damus (CEA LIST) - pluggable providers of fragment-resource selection dialogs
+ * Christian W. Damus (CEA) - bug 410346
+ * Juan Cadavid <juan.cadavid@cea.fr> - bug 399877
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436952
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.views.modelexplorer.handler;
+
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.ParameterValuesException;
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
+import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeManager;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModePlugin;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.IControlModeManager;
+import org.eclipse.papyrus.infra.services.controlmode.commands.ControlModeCommandParameterValues;
+import org.eclipse.papyrus.infra.services.controlmode.ui.IControlModeFragmentDialogProvider;
+import org.eclipse.papyrus.infra.services.controlmode.util.LabelHelper;
+import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Handler used to control an element
+ *
+ * @author adaussy
+ */
+public class ControlCommandHandler extends AbstractModelExplorerHandler {
+
+ public static final String CONTROLMODE_USE_DIALOG_PARAMETER = "org.eclipse.papyrus.infra.services.controlmode.useDialogParameter";
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ List<EObject> selection = getCurrentSelectionAdaptedToType(event, EObject.class);
+ if (selection == null || selection.isEmpty() || selection.size() > 1) {
+ NotificationBuilder.createInfoPopup("Nothing to control").run();
+ return null;
+ }
+ EObject eObjectToControl = selection.get(0);
+
+ if (getShowDialogParameterValue(event)) {
+ IControlModeFragmentDialogProvider provider = getDialogProvider(eObjectToControl);
+ Dialog dialog = provider.createDialog(Display.getCurrent().getActiveShell(), eObjectToControl.eResource(), getDefaultLabelResource(eObjectToControl));
+ if (dialog.open() == Window.OK) {
+ ControlModeRequest controlRequest = ControlModeRequest.createUIControlModelRequest(getEditingDomain(), eObjectToControl, provider.getSelectedURI(dialog));
+ IControlModeManager controlMng = ControlModeManager.getInstance();
+ ICommand controlCommand = controlMng.getControlCommand(controlRequest);
+ getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(controlCommand));
+ }
+ } else {
+ URI defaultURI = computeDefaultURI(eObjectToControl.eResource(), getDefaultLabelResource(eObjectToControl));
+ ControlModeRequest controlRequest = ControlModeRequest.createUIControlModelRequest(getEditingDomain(), eObjectToControl, defaultURI);
+ IControlModeManager controlMng = ControlModeManager.getInstance();
+ ICommand controlCommand = controlMng.getControlCommand(controlRequest);
+ getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(controlCommand));
+ }
+ return null;
+ }
+
+ public URI computeDefaultURI(Resource currentResource, String defaultName) {
+ String ext = currentResource.getURI().fileExtension();
+ URI uri = currentResource.getURI().trimSegments(1);
+ uri = uri.appendSegment(defaultName).appendFileExtension(ext);
+ return uri;
+ }
+
+ /**
+ *
+ * @param event
+ * @return true if the dialog will be displayed to the user, false if it will be bypassed and the default values will be used
+ */
+ protected Boolean getShowDialogParameterValue(ExecutionEvent event) {
+ Boolean showDialogValue = null;
+
+ ControlModeCommandParameterValues parameterValues = null;
+ try {
+ Command command = event.getCommand();
+ parameterValues = (ControlModeCommandParameterValues) command.getParameter(CONTROLMODE_USE_DIALOG_PARAMETER).getValues();
+ showDialogValue = parameterValues.get("showDialog");
+ if (showDialogValue == null) {
+ showDialogValue = true; // By default, the dialog is always displayed to the user
+ }
+ } catch (ParameterValuesException e) {
+ ControlModePlugin.log.error("Parameter values exception in control mode command.", e);
+ } catch (NotDefinedException e) {
+ ControlModePlugin.log.error("Parameter not defined for control mode command.", e);
+ }
+ return showDialogValue;
+ }
+
+ IControlModeFragmentDialogProvider getDialogProvider(EObject context) {
+ try {
+ ModelSet modelSet = ServiceUtilsForEObject.getInstance().getModelSet(context);
+ return AdapterUtils.adapt(modelSet, IControlModeFragmentDialogProvider.class, IControlModeFragmentDialogProvider.DEFAULT);
+ } catch (ServiceException e) {
+ // can't get the model set? Odd
+ ControlModePlugin.log.error("Cannot obtain ModelSet for controlled object.", e);
+ return IControlModeFragmentDialogProvider.DEFAULT;
+ }
+ }
+
+ /**
+ * Compute a default name for the new resource
+ * TODO plug in naming strategy
+ *
+ * @param eObject
+ * @return
+ */
+ protected String getDefaultLabelResource(EObject eObject) {
+ String defaultName = null;
+ EStructuralFeature feature = eObject.eClass().getEStructuralFeature("name");
+ if (feature != null) {
+ Object eGet = eObject.eGet(feature);
+ if (eGet instanceof String) {
+ defaultName = (String) eGet;
+ }
+ }
+ if (defaultName == null) {
+ defaultName = LabelHelper.getPrettyLabel(eObject);
+ Pattern p = Pattern.compile("<<.*?>>|<.*?>");
+ defaultName = p.matcher(defaultName).replaceAll("").trim();
+ }
+ StringBuilder b = new StringBuilder();
+ for (Character c : defaultName.toCharArray()) {
+ if (Character.isJavaIdentifierPart(c)) {
+ b.append(c);
+ } else {
+ b.append("_");
+ }
+ }
+ return b.toString();
+ }
+
+}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/DeleteCommandHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/DeleteCommandHandler.java
index 3152e28b17e..a3cb865b0cd 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/DeleteCommandHandler.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/DeleteCommandHandler.java
@@ -8,8 +8,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec - Bug 436952
*
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.handler;
@@ -22,6 +22,7 @@ import org.eclipse.core.commands.IHandler;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.UnexecutableCommand;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
@@ -30,8 +31,13 @@ import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeManager;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.IControlModeManager;
+import org.eclipse.papyrus.infra.services.controlmode.util.ControlHelper;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.views.modelexplorer.Activator;
/**
* Default handler for Delete command used in the ModelExplorer contextual menu.
@@ -106,6 +112,21 @@ public class DeleteCommandHandler extends AbstractCommandHandler implements IHan
if (provider == null) {
continue;
}
+
+ // Look for uncontrol mode command
+ TransactionalEditingDomain editingDomain = null;
+ try {
+ editingDomain = ServiceUtilsForEObject.getInstance().getTransactionalEditingDomain(selectedEObject);
+ } catch (ServiceException e) {
+ Activator.log.error(e);
+ }
+ if (editingDomain !=null && ControlHelper.isRootControlledObject(selectedEObject)) {
+ ControlModeRequest controlRequest = ControlModeRequest.createUIUncontrolModelRequest(editingDomain, selectedEObject);
+ IControlModeManager controlMng = ControlModeManager.getInstance();
+ ICommand controlCommand = controlMng.getUncontrolCommand(controlRequest);
+
+ gmfCommand = CompositeCommand.compose(gmfCommand, controlCommand);
+ }
// Retrieve delete command from the Element Edit service
DestroyElementRequest request = new DestroyElementRequest(selectedEObject, false);
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/UncontrolCommandHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/UncontrolCommandHandler.java
new file mode 100644
index 00000000000..625f905f330
--- /dev/null
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/UncontrolCommandHandler.java
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (c) 2013 Atos.
+ *
+ *
+ * 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:
+ * Arthur Daussy (Atos) arthur.daussy@atos.net - Initial API and implementation
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436952
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.views.modelexplorer.handler;
+
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeManager;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.IControlModeManager;
+import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
+
+/**
+ * Handler use to uncontrol an element
+ *
+ * @author adaussy
+ *
+ */
+public class UncontrolCommandHandler extends AbstractModelExplorerHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ List<EObject> selection = getCurrentSelectionAdaptedToType(event, EObject.class);
+ if (selection == null || selection.isEmpty() || selection.size() > 1) {
+ NotificationBuilder.createInfoPopup("Nothing to Uncontrol").run();
+ return null;
+ }
+ EObject eObjectToControl = selection.get(0);
+ ControlModeRequest controlRequest = ControlModeRequest.createUIUncontrolModelRequest(getEditingDomain(), eObjectToControl);
+ IControlModeManager controlMng = ControlModeManager.getInstance();
+ ICommand controlCommand = controlMng.getUncontrolCommand(controlRequest);
+ getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(controlCommand));
+ return null;
+ }
+}

Back to the top