diff options
author | Gabriel Pascual | 2014-09-18 07:09:30 +0000 |
---|---|---|
committer | Gabriel Pascual | 2014-10-17 08:37:54 +0000 |
commit | 4ed8958a9c94bc466e87119e9a30335b16e07a2e (patch) | |
tree | 9e6db951fa9c6b7534410ee366d842bec21e1ed7 /plugins/infra | |
parent | ccd4ecc63cd7beecd0a0ce0e342524968a38c4f7 (diff) | |
download | org.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/infra')
7 files changed, 65 insertions, 352 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF index 17d4753c2f8..9c7fb106ad8 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF @@ -1,33 +1,31 @@ -Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.infra.services.controlmode,
- org.eclipse.papyrus.infra.services.controlmode.commands,
- org.eclipse.papyrus.infra.services.controlmode.handlers,
- org.eclipse.papyrus.infra.services.controlmode.participants,
- org.eclipse.papyrus.infra.services.controlmode.ui,
- org.eclipse.papyrus.infra.services.controlmode.util
-Require-Bundle: org.eclipse.emf.edit.ui,
- org.eclipse.papyrus.infra.core;bundle-version="1.0.1",
- org.eclipse.core.expressions;bundle-version="3.4.400",
- org.eclipse.papyrus.infra.core.log;bundle-version="1.0.1",
- com.google.guava;bundle-version="11.0.0",
- org.eclipse.equinox.registry,
- org.eclipse.emf.workspace,
- org.eclipse.gmf.runtime.common.core,
- org.eclipse.gmf.runtime.emf.commands.core,
- org.eclipse.gmf.runtime.emf.type.core,
- org.eclipse.papyrus.views.modelexplorer;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.0.1",
- org.eclipse.papyrus.infra.emf;bundle-version="1.0.1"
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.0.1.qualifier
-Bundle-Localization: plugin
-Bundle-Name: %pluginName
-Bundle-Activator: org.eclipse.papyrus.infra.services.controlmode.Contr
- olModePlugin
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.infra.services.controlmode;si
- ngleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-
+Manifest-Version: 1.0 +Export-Package: org.eclipse.papyrus.infra.services.controlmode, + org.eclipse.papyrus.infra.services.controlmode.commands, + org.eclipse.papyrus.infra.services.controlmode.participants, + org.eclipse.papyrus.infra.services.controlmode.ui, + org.eclipse.papyrus.infra.services.controlmode.util +Require-Bundle: org.eclipse.emf.edit.ui, + org.eclipse.papyrus.infra.core;bundle-version="1.0.1", + org.eclipse.core.expressions;bundle-version="3.4.400", + org.eclipse.papyrus.infra.core.log;bundle-version="1.0.1", + com.google.guava;bundle-version="11.0.0", + org.eclipse.equinox.registry, + org.eclipse.emf.workspace, + org.eclipse.gmf.runtime.common.core, + org.eclipse.gmf.runtime.emf.commands.core, + org.eclipse.gmf.runtime.emf.type.core, + org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.1", + org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.0.1", + org.eclipse.papyrus.infra.emf;bundle-version="1.0.1" +Bundle-Vendor: %providerName +Bundle-ActivationPolicy: lazy +Bundle-Version: 1.0.1.qualifier +Bundle-Localization: plugin +Bundle-Name: %pluginName +Bundle-Activator: org.eclipse.papyrus.infra.services.controlmode.Contr + olModePlugin +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.infra.services.controlmode;si + ngleton:=true +Bundle-RequiredExecutionEnvironment: J2SE-1.5 + diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/build.properties b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/build.properties index 4f9abbaf896..0aec3cc2780 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/build.properties +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/build.properties @@ -1,13 +1,12 @@ -#
-#Mon Sep 12 09:29:37 CEST 2011
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- plugin.properties,\
- schema/,\
- about.html,\
- icons/
-output..=bin/
-src.includes = about.html
-source..=src/
-bin..=bin/
+# +#Mon Sep 12 09:29:37 CEST 2011 +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + plugin.properties,\ + schema/,\ + about.html/ +output..=bin/ +src.includes = about.html +source..=src/ +bin..=bin/ diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/icons/CreateSubModel_16.png b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/icons/CreateSubModel_16.png Binary files differdeleted file mode 100644 index 2140dc439e1..00000000000 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/icons/CreateSubModel_16.png +++ /dev/null diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/icons/ReintegrateSubModel_16.png b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/icons/ReintegrateSubModel_16.png Binary files differdeleted file mode 100644 index a9ddbb8b0cd..00000000000 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/icons/ReintegrateSubModel_16.png +++ /dev/null diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/plugin.xml index 99831629a7c..11687c10a15 100644 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/plugin.xml +++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/plugin.xml @@ -1,96 +1,22 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension-point id="org.eclipse.papyrus.infra.services.controlmode.participant" name="participant" schema="schema/participant.exsd"/>
- <extension
- point="org.eclipse.ui.commands">
- <command
- defaultHandler="org.eclipse.papyrus.infra.services.controlmode.handlers.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.infra.services.controlmode.handlers.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>
-
- <extension
- point="org.eclipse.core.expressions.propertyTesters">
- <propertyTester
- class="org.eclipse.papyrus.infra.services.controlmode.IsControlledFragmentTester"
- id="org.eclipse.papyrus.infra.services.controlmode"
- namespace="org.eclipse.papyrus.infra.services.controlmode"
- properties="isFragmentModel,isParentLoaded"
- type="org.eclipse.jface.viewers.IStructuredSelection">
- </propertyTester>
- </extension>
- <extension
- point="org.eclipse.papyrus.infra.services.controlmode.participant">
- <participant
- class="org.eclipse.papyrus.infra.services.controlmode.participants.SashControlParticipant">
- </participant>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + <extension-point id="org.eclipse.papyrus.infra.services.controlmode.participant" name="participant" schema="schema/participant.exsd"/> + <extension + point="org.eclipse.core.expressions.propertyTesters"> + <propertyTester + class="org.eclipse.papyrus.infra.services.controlmode.IsControlledFragmentTester" + id="org.eclipse.papyrus.infra.services.controlmode" + namespace="org.eclipse.papyrus.infra.services.controlmode" + properties="isFragmentModel,isParentLoaded" + type="org.eclipse.jface.viewers.IStructuredSelection"> + </propertyTester> + </extension> + <extension + point="org.eclipse.papyrus.infra.services.controlmode.participant"> + <participant + class="org.eclipse.papyrus.infra.services.controlmode.participants.SashControlParticipant"> + </participant> + </extension> + +</plugin> diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/ControlCommandHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/ControlCommandHandler.java deleted file mode 100644 index c3fdcb97442..00000000000 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/ControlCommandHandler.java +++ /dev/null @@ -1,160 +0,0 @@ -/*****************************************************************************
- * 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
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.services.controlmode.handlers;
-
-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.papyrus.views.modelexplorer.handler.AbstractModelExplorerHandler;
-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/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/UncontrolCommandHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/UncontrolCommandHandler.java deleted file mode 100644 index 448c4b68778..00000000000 --- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/UncontrolCommandHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/*****************************************************************************
- * 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
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.services.controlmode.handlers;
-
-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;
-import org.eclipse.papyrus.views.modelexplorer.handler.AbstractModelExplorerHandler;
-
-/**
- * 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;
- }
-}
|