Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2017-03-28 17:42:34 +0000
committerFlorian Noyrit2017-03-30 17:42:47 +0000
commita82ba33c9533d3bfb931b7725cff7ac0478511d3 (patch)
treefcd6301bc9325e2b08e33a60930c70868d1bb35d /plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode
parent6177ae6f0aa8abd35d40a30281a11839097be211 (diff)
downloadorg.eclipse.papyrus-a82ba33c9533d3bfb931b7725cff7ac0478511d3.tar.gz
org.eclipse.papyrus-a82ba33c9533d3bfb931b7725cff7ac0478511d3.tar.xz
org.eclipse.papyrus-a82ba33c9533d3bfb931b7725cff7ac0478511d3.zip
[releng] Update plugins and feature version numbers for Oxygen with
Neon.3 as baseline Change-Id: Icb3b699de6846ce60370a1fedc169e1df741ace2
Diffstat (limited to 'plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/META-INF/MANIFEST.MF62
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/pom.xml24
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/CreateControlResource.java400
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/RemoveControlResourceCommand.java352
4 files changed, 418 insertions, 420 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 a4b34478f18..a3fa76949a2 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,31 +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.handler,
- org.eclipse.papyrus.infra.services.controlmode.messages,
- org.eclipse.papyrus.infra.services.controlmode.internal.handler;x-internal:=true,
- org.eclipse.papyrus.infra.services.controlmode.internal.ui;x-internal:=true,
- org.eclipse.papyrus.infra.services.controlmode.participants,
- org.eclipse.papyrus.infra.services.controlmode.ui,
- org.eclipse.papyrus.infra.services.controlmode.util;uses:="org.eclipse.emf.ecore"
-Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="[2.12.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.core;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
- org.eclipse.core.expressions;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
- org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.9.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.infra.emf;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.infra.services.edit;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)",
- org.eclipse.papyrus.infra.onefile;bundle-version="[2.0.0,3.0.0)"
-Bundle-Vendor: %providerName
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 1.5.0.qualifier
-Bundle-Localization: plugin
-Bundle-Name: %pluginName
-Bundle-Activator: org.eclipse.papyrus.infra.services.controlmode.ControlModePlugin
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.infra.services.controlmode;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+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.handler,
+ org.eclipse.papyrus.infra.services.controlmode.messages,
+ org.eclipse.papyrus.infra.services.controlmode.internal.handler;x-internal:=true,
+ org.eclipse.papyrus.infra.services.controlmode.internal.ui;x-internal:=true,
+ org.eclipse.papyrus.infra.services.controlmode.participants,
+ org.eclipse.papyrus.infra.services.controlmode.ui,
+ org.eclipse.papyrus.infra.services.controlmode.util;uses:="org.eclipse.emf.ecore"
+Require-Bundle: org.eclipse.emf.edit.ui;bundle-version="[2.12.0,3.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.core;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
+ org.eclipse.core.expressions;bundle-version="[3.5.0,4.0.0)";visibility:=reexport,
+ org.eclipse.gmf.runtime.emf.type.core;bundle-version="[1.9.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.emf;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.emf.gmf;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.papyrus.infra.services.edit;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.ui;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.types.core;bundle-version="[3.0.0,4.0.0)",
+ org.eclipse.papyrus.infra.onefile;bundle-version="[2.1.0,3.0.0)"
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 2.0.0.qualifier
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-Activator: org.eclipse.papyrus.infra.services.controlmode.ControlModePlugin
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.infra.services.controlmode;singleton:=true
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/pom.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/pom.xml
index 7d1a5981598..5ec3394c246 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/pom.xml
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/pom.xml
@@ -1,13 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.infra-services</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.infra.services.controlmode</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
-</project>
+<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-services</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.services.controlmode</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project> \ No newline at end of file
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/CreateControlResource.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/CreateControlResource.java
index 16174e6f391..ed0c5389f0b 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/CreateControlResource.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/CreateControlResource.java
@@ -1,200 +1,200 @@
-/*****************************************************************************
- * Copyright (c) 2013, 2014 Atos, Christian W. Damus, 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 - bug 399859
- * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436952
- * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436998
- * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.services.controlmode.commands;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
-import org.eclipse.papyrus.infra.services.controlmode.messages.Messages;
-
-/**
- * Command used to create new controlled resource.
- * This command will create the new resources. It will also handle correctly undo and redo
- *
- * @author adaussy
- *
- */
-public class CreateControlResource extends AbstractControlResourceCommand {
-
- /** The Constant MODELSET_ERROR. */
- private static final String MODELSET_ERROR = Messages.getString("CreateControlResource.modelset.error"); //$NON-NLS-1$
-
- /** The Constant CREATION_RESOURCE_ERROR. */
- private static final String CREATION_RESOURCE_ERROR = Messages.getString("CreateControlResource.resource.error"); //$NON-NLS-1$
-
- /**
- * @param request
- * {@link CreateControlResource#request}
- */
- public CreateControlResource(ControlModeRequest request) {
- super(request, Messages.getString("CreateControlResource.command.title"), null); //$NON-NLS-1$
- }
-
- /**
- * @param request
- * {@link CreateControlResource#request}
- * @param newFileExtension
- * {@link CreateControlResource#newFileExtension}
- */
- public CreateControlResource(ControlModeRequest request, String newFileExtension) {
- this(request);
- this.newFileExtension = newFileExtension;
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
-
- Resource resource = getResourceSet().getResource(getTargetUri(), false);
- boolean resourceInSet = resource != null;
- if (resourceInSet) {
- if (failedToLoadBecauseNonExistent(resource) || isNotYetDeteted(resource)) {
- /*
- * It doesn't exist or it will be deleted during the save, so by re-creating it we may actually help to fix unresolved proxies
- * (such as from an out-of-date sash model)
- */
- resource.getResourceSet().getResources().remove(resource);
- resource = null;
- resourceInSet = false;
- }
- }
-
- Resource newResource = null;
- if (resource == null) {
- newResource = getResourceSet().createResource(getTargetUri());
- if (newResource == null) {
- return CommandResult.newErrorCommandResult(CREATION_RESOURCE_ERROR);
- }
- } else {
- // Conserve existing resource to add new controlled object
- newResource = resource;
- }
-
- // Set the new created target to the request if other command need it
- getRequest().setTargetResource(newResource, getFileExtension());
- // Force modified to true to force serialization
- newResource.setModified(true);
- // In case the resource has been uncontrolled before the it's still the resource to delete on save of the model set. So it has to be removed
- getRequest().getModelSet().getResourcesToDeleteOnSave().remove(newResource.getURI());
- return CommandResult.newOKCommandResult(newResource);
- }
-
- /**
- * Checks if the resource is not yet detete.
- *
- * @param resource
- * the resource
- * @return true, if is not yet detete
- */
- protected boolean isNotYetDeteted(Resource resource) {
- boolean result = false;
- ResourceSet resourceSet = getResourceSet();
- if (resourceSet instanceof ModelSet) {
- result = ((ModelSet) resourceSet).getResourcesToDeleteOnSave().contains(resource.getURI());
- }
- return result;
- }
-
- /**
- * Failed to load because non existent.
- *
- * @param resource
- * the resource
- * @return true, if successful
- */
- protected boolean failedToLoadBecauseNonExistent(Resource resource) {
- boolean result = false;
-
- if (resource.getContents().isEmpty() && !resource.getErrors().isEmpty()) {
- // Does it exist to load it?
- result = !resource.getResourceSet().getURIConverter().exists(resource.getURI(), null);
- }
-
- return result;
- }
-
- @Override
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- IStatus superStatus = super.doUndo(monitor, info);
-
- // Delete the related file
- Resource oldResource = getRequest().getTargetResource(getFileExtension());
-
- ModelSet modelSet = getRequest().getModelSet();
- if (modelSet == null) {
- return CommandResult.newErrorCommandResult(MODELSET_ERROR).getStatus();
- }
-
- // Force the main resource to update during save
- Resource resource = getTargetResrource(getRequest().getTargetObject());
- resource.setModified(true);
-
- // Handle old resource
- if (!isControlledResourceLocked(getNewURI())) {
- getResourceSet().getResources().remove(oldResource);
- modelSet.getResourcesToDeleteOnSave().add(oldResource.getURI());
- }
- oldResource.setModified(true);
-
- return superStatus;
- }
-
- /**
- * Get the new URI.
- *
- * @return The new URI.
- * @since 1.5
- */
- protected URI getNewURI(){
- return getRequest().getNewURI();
- }
-
- /**
- * Gets the target resrource.
- *
- * @param objectToUncontrol
- * the object to uncontrol
- * @return the target resrource
- */
- protected Resource getTargetResrource(EObject objectToUncontrol) {
- return getRequest().getModelSet().getAssociatedResource(objectToUncontrol, getFileExtension(), true);
-
- }
-
- @Override
- protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- // Re add the resources to the resourceSet
- Resource oldResource = getRequest().getTargetResource(getFileExtension());
- getResourceSet().getResources().add(oldResource);
-
- ModelSet modelSet = getRequest().getModelSet();
- if (modelSet == null) {
- return CommandResult.newErrorCommandResult(MODELSET_ERROR).getStatus();
- }
-
- modelSet.getResourcesToDeleteOnSave().remove(oldResource.getURI());
- oldResource.setModified(true);
- return super.doRedo(monitor, info);
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013, 2014 Atos, Christian W. Damus, 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 - bug 399859
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436952
+ * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 436998
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.controlmode.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.messages.Messages;
+
+/**
+ * Command used to create new controlled resource.
+ * This command will create the new resources. It will also handle correctly undo and redo
+ *
+ * @author adaussy
+ *
+ */
+public class CreateControlResource extends AbstractControlResourceCommand {
+
+ /** The Constant MODELSET_ERROR. */
+ private static final String MODELSET_ERROR = Messages.getString("CreateControlResource.modelset.error"); //$NON-NLS-1$
+
+ /** The Constant CREATION_RESOURCE_ERROR. */
+ private static final String CREATION_RESOURCE_ERROR = Messages.getString("CreateControlResource.resource.error"); //$NON-NLS-1$
+
+ /**
+ * @param request
+ * {@link CreateControlResource#request}
+ */
+ public CreateControlResource(ControlModeRequest request) {
+ super(request, Messages.getString("CreateControlResource.command.title"), null); //$NON-NLS-1$
+ }
+
+ /**
+ * @param request
+ * {@link CreateControlResource#request}
+ * @param newFileExtension
+ * {@link CreateControlResource#newFileExtension}
+ */
+ public CreateControlResource(ControlModeRequest request, String newFileExtension) {
+ this(request);
+ this.newFileExtension = newFileExtension;
+ }
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException {
+
+ Resource resource = getResourceSet().getResource(getTargetUri(), false);
+ boolean resourceInSet = resource != null;
+ if (resourceInSet) {
+ if (failedToLoadBecauseNonExistent(resource) || isNotYetDeteted(resource)) {
+ /*
+ * It doesn't exist or it will be deleted during the save, so by re-creating it we may actually help to fix unresolved proxies
+ * (such as from an out-of-date sash model)
+ */
+ resource.getResourceSet().getResources().remove(resource);
+ resource = null;
+ resourceInSet = false;
+ }
+ }
+
+ Resource newResource = null;
+ if (resource == null) {
+ newResource = getResourceSet().createResource(getTargetUri());
+ if (newResource == null) {
+ return CommandResult.newErrorCommandResult(CREATION_RESOURCE_ERROR);
+ }
+ } else {
+ // Conserve existing resource to add new controlled object
+ newResource = resource;
+ }
+
+ // Set the new created target to the request if other command need it
+ getRequest().setTargetResource(newResource, getFileExtension());
+ // Force modified to true to force serialization
+ newResource.setModified(true);
+ // In case the resource has been uncontrolled before the it's still the resource to delete on save of the model set. So it has to be removed
+ getRequest().getModelSet().getResourcesToDeleteOnSave().remove(newResource.getURI());
+ return CommandResult.newOKCommandResult(newResource);
+ }
+
+ /**
+ * Checks if the resource is not yet detete.
+ *
+ * @param resource
+ * the resource
+ * @return true, if is not yet detete
+ */
+ protected boolean isNotYetDeteted(Resource resource) {
+ boolean result = false;
+ ResourceSet resourceSet = getResourceSet();
+ if (resourceSet instanceof ModelSet) {
+ result = ((ModelSet) resourceSet).getResourcesToDeleteOnSave().contains(resource.getURI());
+ }
+ return result;
+ }
+
+ /**
+ * Failed to load because non existent.
+ *
+ * @param resource
+ * the resource
+ * @return true, if successful
+ */
+ protected boolean failedToLoadBecauseNonExistent(Resource resource) {
+ boolean result = false;
+
+ if (resource.getContents().isEmpty() && !resource.getErrors().isEmpty()) {
+ // Does it exist to load it?
+ result = !resource.getResourceSet().getURIConverter().exists(resource.getURI(), null);
+ }
+
+ return result;
+ }
+
+ @Override
+ protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IStatus superStatus = super.doUndo(monitor, info);
+
+ // Delete the related file
+ Resource oldResource = getRequest().getTargetResource(getFileExtension());
+
+ ModelSet modelSet = getRequest().getModelSet();
+ if (modelSet == null) {
+ return CommandResult.newErrorCommandResult(MODELSET_ERROR).getStatus();
+ }
+
+ // Force the main resource to update during save
+ Resource resource = getTargetResrource(getRequest().getTargetObject());
+ resource.setModified(true);
+
+ // Handle old resource
+ if (!isControlledResourceLocked(getNewURI())) {
+ getResourceSet().getResources().remove(oldResource);
+ modelSet.getResourcesToDeleteOnSave().add(oldResource.getURI());
+ }
+ oldResource.setModified(true);
+
+ return superStatus;
+ }
+
+ /**
+ * Get the new URI.
+ *
+ * @return The new URI.
+ * @since 2.0
+ */
+ protected URI getNewURI() {
+ return getRequest().getNewURI();
+ }
+
+ /**
+ * Gets the target resrource.
+ *
+ * @param objectToUncontrol
+ * the object to uncontrol
+ * @return the target resrource
+ */
+ protected Resource getTargetResrource(EObject objectToUncontrol) {
+ return getRequest().getModelSet().getAssociatedResource(objectToUncontrol, getFileExtension(), true);
+
+ }
+
+ @Override
+ protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ // Re add the resources to the resourceSet
+ Resource oldResource = getRequest().getTargetResource(getFileExtension());
+ getResourceSet().getResources().add(oldResource);
+
+ ModelSet modelSet = getRequest().getModelSet();
+ if (modelSet == null) {
+ return CommandResult.newErrorCommandResult(MODELSET_ERROR).getStatus();
+ }
+
+ modelSet.getResourcesToDeleteOnSave().remove(oldResource.getURI());
+ oldResource.setModified(true);
+ return super.doRedo(monitor, info);
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/RemoveControlResourceCommand.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/RemoveControlResourceCommand.java
index 94a2690ea1b..da2aa0eb187 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/RemoveControlResourceCommand.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/commands/RemoveControlResourceCommand.java
@@ -1,176 +1,176 @@
-/*****************************************************************************
- * 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 436998
- * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.services.controlmode.commands;
-
-import java.util.Collections;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
-import org.eclipse.papyrus.infra.services.controlmode.messages.Messages;
-
-
-/**
- * Basic command to remove a controlled resource.
- * It handles removal of the resource from resource set (deletion on save of the resources back end).
- * It also handle correctly undo and redo
- *
- * @author adaussy
- *
- */
-public class RemoveControlResourceCommand extends AbstractControlResourceCommand {
-
- /** The Constant PREVIOUS_RESOURCE_ERROR. */
- protected static final String PREVIOUS_RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.previous.resource.error"); //$NON-NLS-1$
-
- /** The Constant TARGET_RESOURCE_ERROR. */
- protected static final String TARGET_RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.target.resource.error"); //$NON-NLS-1$
-
- /** The Constant RESOURCE_ERROR. */
- protected static final String RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.resource.error"); //$NON-NLS-1$
-
- /** The Constant RESOURCESET_ERROR. */
- protected static final String RESOURCESET_ERROR = Messages.getString("RemoveControlResourceCommand.resourceset.error"); //$NON-NLS-1$
-
- /** The Constant CONTROL_OBJECT_ERROR. */
- protected static final String CONTROL_OBJECT_ERROR = Messages.getString("RemoveControlResourceCommand.object.error"); //$NON-NLS-1$
-
- /** The Constant UNCONTROL_COMMAND_TITLE. */
- protected static final String UNCONTROL_COMMAND_TITLE = Messages.getString("RemoveControlResourceCommand.command.title"); //$NON-NLS-1$
-
- /**
- * @param request
- */
- public RemoveControlResourceCommand(ControlModeRequest request) {
- super(request, UNCONTROL_COMMAND_TITLE, Collections.singletonList(WorkspaceSynchronizer.getFile(request.getTargetObject().eResource())));
- }
-
- /**
- * @param request
- * @param fileExtension
- * file extension of the resource you want to handle
- */
- public RemoveControlResourceCommand(ControlModeRequest request, String fileExtension) {
- super(request, fileExtension, UNCONTROL_COMMAND_TITLE, Collections.singletonList(WorkspaceSynchronizer.getFile(request.getTargetObject().eResource())));
- }
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- EObject objectToControl = getRequest().getTargetObject();
- if (objectToControl == null) {
- return CommandResult.newErrorCommandResult(CONTROL_OBJECT_ERROR);
- }
- ModelSet modelSet = getRequest().getModelSet();
- if (modelSet == null) {
- return CommandResult.newErrorCommandResult(RESOURCESET_ERROR);
- }
- Resource resource = modelSet.getResource(getSourceUri(), false);
- if (resource == null) {
- return CommandResult.newErrorCommandResult(RESOURCE_ERROR);
- }
-
- // Delete resource back-end on save
- if (!isControlledResourceLocked(getRequest().getSourceURI())) {
- modelSet.getResourcesToDeleteOnSave().add(resource.getURI());
- }
-
- // Save source and target resource
- Resource targetResource = getTargetResource(objectToControl);
- if (targetResource == null) {
- return CommandResult.newErrorCommandResult(Messages.getString(TARGET_RESOURCE_ERROR, getFileExtension()));
- }
-
- // The target resource needs to be saved else the resolution will not operate
- targetResource.setModified(true);
-
- getRequest().setTargetResource(targetResource, getFileExtension());
- getRequest().setSourceResource(resource, getFileExtension());
-
- // remove resource set
- if (!isControlledResourceLocked(getRequest().getSourceURI())) {
- modelSet.getResources().remove(resource);
- }
-
- return CommandResult.newOKCommandResult();
- }
-
- /**
- * @param objectToControl
- * get the target resource of uncontrol command
- * @return
- */
- protected Resource getTargetResource(EObject objectToUncontrol) {
- return getRequest().getModelSet().getAssociatedResource(objectToUncontrol, getFileExtension(), true);
- }
-
- @Override
- protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- IStatus superStatus = super.doUndo(monitor, info);
- ModelSet modelSet = getRequest().getModelSet();
- if (modelSet == null) {
- return CommandResult.newErrorCommandResult(RESOURCESET_ERROR).getStatus();
- }
- Resource resource = getSourceResource();
- if (resource == null) {
- return CommandResult.newErrorCommandResult(RESOURCE_ERROR).getStatus();
- }
-
- modelSet.getResources().add(resource);
-
- // Notify the model set that the back end of this resource should not be deleted on save
- modelSet.getResourcesToDeleteOnSave().remove(resource.getURI());
- getRequest().getTargetResource(getFileExtension()).setModified(true);
-
- return superStatus;
- }
-
- /**
- * Get the source resource.
- *
- * @return The source resource.
- * @since 1.5
- */
- protected Resource getSourceResource(){
- return getRequest().getSourceResource(getFileExtension());
- }
-
- @Override
- protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- IStatus superStatus = super.doRedo(monitor, info);
- Resource resource = getSourceResource();
- if (resource == null) {
- return CommandResult.newErrorCommandResult(PREVIOUS_RESOURCE_ERROR).getStatus();
- }
- ModelSet modelSet = getRequest().getModelSet();
- if (modelSet == null) {
- return CommandResult.newErrorCommandResult(RESOURCESET_ERROR).getStatus();
- }
-
- if (!isControlledResourceLocked(getRequest().getSourceURI())) {
- modelSet.getResources().remove(resource);
- // Notify the model set that the back end of this resource should be deleted on save
- modelSet.getResourcesToDeleteOnSave().add(resource.getURI());
- }
- return superStatus;
- }
-}
+/*****************************************************************************
+ * 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 436998
+ * Nicolas FAUVERGUE (ALL4TEC) nicolas.fauvergue@all4tec.net - Bug 496905
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.controlmode.commands;
+
+import java.util.Collections;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.services.controlmode.ControlModeRequest;
+import org.eclipse.papyrus.infra.services.controlmode.messages.Messages;
+
+
+/**
+ * Basic command to remove a controlled resource.
+ * It handles removal of the resource from resource set (deletion on save of the resources back end).
+ * It also handle correctly undo and redo
+ *
+ * @author adaussy
+ *
+ */
+public class RemoveControlResourceCommand extends AbstractControlResourceCommand {
+
+ /** The Constant PREVIOUS_RESOURCE_ERROR. */
+ protected static final String PREVIOUS_RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.previous.resource.error"); //$NON-NLS-1$
+
+ /** The Constant TARGET_RESOURCE_ERROR. */
+ protected static final String TARGET_RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.target.resource.error"); //$NON-NLS-1$
+
+ /** The Constant RESOURCE_ERROR. */
+ protected static final String RESOURCE_ERROR = Messages.getString("RemoveControlResourceCommand.resource.error"); //$NON-NLS-1$
+
+ /** The Constant RESOURCESET_ERROR. */
+ protected static final String RESOURCESET_ERROR = Messages.getString("RemoveControlResourceCommand.resourceset.error"); //$NON-NLS-1$
+
+ /** The Constant CONTROL_OBJECT_ERROR. */
+ protected static final String CONTROL_OBJECT_ERROR = Messages.getString("RemoveControlResourceCommand.object.error"); //$NON-NLS-1$
+
+ /** The Constant UNCONTROL_COMMAND_TITLE. */
+ protected static final String UNCONTROL_COMMAND_TITLE = Messages.getString("RemoveControlResourceCommand.command.title"); //$NON-NLS-1$
+
+ /**
+ * @param request
+ */
+ public RemoveControlResourceCommand(ControlModeRequest request) {
+ super(request, UNCONTROL_COMMAND_TITLE, Collections.singletonList(WorkspaceSynchronizer.getFile(request.getTargetObject().eResource())));
+ }
+
+ /**
+ * @param request
+ * @param fileExtension
+ * file extension of the resource you want to handle
+ */
+ public RemoveControlResourceCommand(ControlModeRequest request, String fileExtension) {
+ super(request, fileExtension, UNCONTROL_COMMAND_TITLE, Collections.singletonList(WorkspaceSynchronizer.getFile(request.getTargetObject().eResource())));
+ }
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ EObject objectToControl = getRequest().getTargetObject();
+ if (objectToControl == null) {
+ return CommandResult.newErrorCommandResult(CONTROL_OBJECT_ERROR);
+ }
+ ModelSet modelSet = getRequest().getModelSet();
+ if (modelSet == null) {
+ return CommandResult.newErrorCommandResult(RESOURCESET_ERROR);
+ }
+ Resource resource = modelSet.getResource(getSourceUri(), false);
+ if (resource == null) {
+ return CommandResult.newErrorCommandResult(RESOURCE_ERROR);
+ }
+
+ // Delete resource back-end on save
+ if (!isControlledResourceLocked(getRequest().getSourceURI())) {
+ modelSet.getResourcesToDeleteOnSave().add(resource.getURI());
+ }
+
+ // Save source and target resource
+ Resource targetResource = getTargetResource(objectToControl);
+ if (targetResource == null) {
+ return CommandResult.newErrorCommandResult(Messages.getString(TARGET_RESOURCE_ERROR, getFileExtension()));
+ }
+
+ // The target resource needs to be saved else the resolution will not operate
+ targetResource.setModified(true);
+
+ getRequest().setTargetResource(targetResource, getFileExtension());
+ getRequest().setSourceResource(resource, getFileExtension());
+
+ // remove resource set
+ if (!isControlledResourceLocked(getRequest().getSourceURI())) {
+ modelSet.getResources().remove(resource);
+ }
+
+ return CommandResult.newOKCommandResult();
+ }
+
+ /**
+ * @param objectToControl
+ * get the target resource of uncontrol command
+ * @return
+ */
+ protected Resource getTargetResource(EObject objectToUncontrol) {
+ return getRequest().getModelSet().getAssociatedResource(objectToUncontrol, getFileExtension(), true);
+ }
+
+ @Override
+ protected IStatus doUndo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IStatus superStatus = super.doUndo(monitor, info);
+ ModelSet modelSet = getRequest().getModelSet();
+ if (modelSet == null) {
+ return CommandResult.newErrorCommandResult(RESOURCESET_ERROR).getStatus();
+ }
+ Resource resource = getSourceResource();
+ if (resource == null) {
+ return CommandResult.newErrorCommandResult(RESOURCE_ERROR).getStatus();
+ }
+
+ modelSet.getResources().add(resource);
+
+ // Notify the model set that the back end of this resource should not be deleted on save
+ modelSet.getResourcesToDeleteOnSave().remove(resource.getURI());
+ getRequest().getTargetResource(getFileExtension()).setModified(true);
+
+ return superStatus;
+ }
+
+ /**
+ * Get the source resource.
+ *
+ * @return The source resource.
+ * @since 2.0
+ */
+ protected Resource getSourceResource() {
+ return getRequest().getSourceResource(getFileExtension());
+ }
+
+ @Override
+ protected IStatus doRedo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ IStatus superStatus = super.doRedo(monitor, info);
+ Resource resource = getSourceResource();
+ if (resource == null) {
+ return CommandResult.newErrorCommandResult(PREVIOUS_RESOURCE_ERROR).getStatus();
+ }
+ ModelSet modelSet = getRequest().getModelSet();
+ if (modelSet == null) {
+ return CommandResult.newErrorCommandResult(RESOURCESET_ERROR).getStatus();
+ }
+
+ if (!isControlledResourceLocked(getRequest().getSourceURI())) {
+ modelSet.getResources().remove(resource);
+ // Notify the model set that the back end of this resource should be deleted on save
+ modelSet.getResourcesToDeleteOnSave().add(resource.getURI());
+ }
+ return superStatus;
+ }
+}

Back to the top