Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2017-09-26 08:55:16 +0000
committerCamille Letavernier2017-09-28 14:16:41 +0000
commitd368b639835790932c19d0c61fd855a23b464ab0 (patch)
tree01e982eb2c58ec51ae74e0db49e55d52a9151004
parent90a0576baac1f9189164e1463ca5369e9487dcc3 (diff)
downloadorg.eclipse.papyrus-d368b639835790932c19d0c61fd855a23b464ab0.tar.gz
org.eclipse.papyrus-d368b639835790932c19d0c61fd855a23b464ab0.tar.xz
org.eclipse.papyrus-d368b639835790932c19d0c61fd855a23b464ab0.zip
Bug 525129: Transaction Exception in the Palette Editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=525129 Change-Id: Ic3ac65ed913dba090ea36a925ab886ef68907ab9 Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com> (cherry picked from commit 40cfa954acc1b003a31c9086ea1e1bf59416078b)
-rw-r--r--plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/META-INF/MANIFEST.MF2
-rw-r--r--plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/pom.xml2
-rw-r--r--plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteconfigurationEditor.java48
3 files changed, 37 insertions, 15 deletions
diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/META-INF/MANIFEST.MF
index d28119cc224..76c896674ac 100644
--- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor;singleton:=true
-Bundle-Version: 3.1.0.qualifier
+Bundle-Version: 3.1.1.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.presentation.PaletteConfigurationEditorPlugin$Implementation
Bundle-Vendor: %providerName
diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/pom.xml b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/pom.xml
index 8acb217f887..b0fc00ef1d7 100644
--- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/pom.xml
+++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/pom.xml
@@ -8,6 +8,6 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor</artifactId>
- <version>3.1.0-SNAPSHOT</version>
+ <version>3.1.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteconfigurationEditor.java b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteconfigurationEditor.java
index 6891d0663a1..f922a5529fb 100644
--- a/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteconfigurationEditor.java
+++ b/plugins/infra/gmfdiag/paletteconfiguration/org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor/src/org/eclipse/papyrus/infra/gmfdiag/paletteconfiguration/presentation/CustomPaletteconfigurationEditor.java
@@ -12,6 +12,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.presentation;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EventObject;
@@ -38,9 +39,9 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl;
+import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.CommandParameter;
import org.eclipse.emf.edit.command.CreateChildCommand;
import org.eclipse.emf.edit.command.DeleteCommand;
@@ -54,7 +55,6 @@ import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.emf.transaction.RollbackException;
import org.eclipse.emf.transaction.TransactionalCommandStack;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.impl.TransactionalCommandStackImpl;
@@ -499,12 +499,15 @@ public class CustomPaletteconfigurationEditor extends PaletteconfigurationEditor
}
Iterator<?> it = selection.iterator();
+ Collection<Configuration> toDelete = new ArrayList<>();
while (it.hasNext()) {
Object object = it.next();
if (object instanceof Configuration) {
- EcoreUtil.delete((EObject) object);
+ toDelete.add((Configuration)object);
}
}
+ Command command = new DeleteCommand(editingDomain, toDelete);
+ editingDomain.getCommandStack().execute(command);
selectionViewer.refresh();
}
};
@@ -532,7 +535,8 @@ public class CustomPaletteconfigurationEditor extends PaletteconfigurationEditor
drawer.setLabel(DRAWER_LABEL);
// Set the drawer on the palette configuration
EList<DrawerConfiguration> drawerConfigurations = ((PaletteConfiguration) palette).getDrawerConfigurations();
- drawerConfigurations.add(drawer);
+ Command command = new AddCommand(editingDomain, drawerConfigurations, drawer);
+ editingDomain.getCommandStack().execute(command);
selectionViewer.refresh();
}
}
@@ -560,17 +564,22 @@ public class CustomPaletteconfigurationEditor extends PaletteconfigurationEditor
separator.setLabel(SEPARATOR_LABEL);
separator.setId(CreatePaletteItemUtil.generateID(SEPARATOR_LABEL));
+ final Command command;
if (object instanceof DrawerConfiguration) {
// Add separator at the end of drawer own configuration
- ((DrawerConfiguration) object).getOwnedConfigurations().add(separator);
+ command = new AddCommand(editingDomain, ((DrawerConfiguration) object).getOwnedConfigurations(), separator);
} else if (object instanceof ChildConfiguration) {
// retrieve parent
EList<ChildConfiguration> ownedConfigurations = ((DrawerConfiguration) ((ChildConfiguration) object).eContainer()).getOwnedConfigurations();
int index = ownedConfigurations.indexOf(object);
// adds the separator
- ownedConfigurations.add(index, separator);
+ command = new AddCommand(editingDomain, ownedConfigurations, separator, index);
+ } else {
+ return;
}
+
+ editingDomain.getCommandStack().execute(command);
selectionViewer.expandToLevel(object, 1);
selectionViewer.refresh();
}
@@ -598,17 +607,21 @@ public class CustomPaletteconfigurationEditor extends PaletteconfigurationEditor
stack.setLabel(STACK_LABEL);
stack.setId(CreatePaletteItemUtil.generateID(STACK_LABEL));
+ final Command command;
if (object instanceof DrawerConfiguration) {
// Add separator at the end of drawer own configuration
- ((DrawerConfiguration) object).getOwnedConfigurations().add(stack);
+ command = new AddCommand(editingDomain, ((DrawerConfiguration) object).getOwnedConfigurations(), stack);
} else if (object instanceof ChildConfiguration) {
// retrieve parent
EList<ChildConfiguration> ownedConfigurations = ((DrawerConfiguration) ((ChildConfiguration) object).eContainer()).getOwnedConfigurations();
int index = ownedConfigurations.indexOf(object);
// adds the stack
- ownedConfigurations.add(index, stack);
+ command = new AddCommand(editingDomain, ownedConfigurations, stack, index);
+ } else {
+ return;
}
+ editingDomain.getCommandStack().execute(command);
selectionViewer.expandToLevel(object, 1);
selectionViewer.refresh();
}
@@ -635,12 +648,15 @@ public class CustomPaletteconfigurationEditor extends PaletteconfigurationEditor
// Set label & Id
tool.setLabel(NEW_TOOL_LABEL);
+ final Command command;
if (object instanceof DrawerConfiguration || object instanceof StackConfiguration) {
- // Add separator at the end of drawer own configuration
+ // Add tool at the end of drawer own configuration
if (object instanceof DrawerConfiguration) {
- ((DrawerConfiguration) object).getOwnedConfigurations().add(tool);
+ command = new AddCommand(editingDomain, ((DrawerConfiguration) object).getOwnedConfigurations(), tool);
} else if (object instanceof StackConfiguration) {
- ((StackConfiguration) object).getOwnedConfigurations().add(tool);
+ command = new AddCommand(editingDomain, ((StackConfiguration) object).getOwnedConfigurations(), tool);
+ } else {
+ return;
}
} else if (object instanceof ChildConfiguration) {
// retrieve parent
@@ -649,13 +665,19 @@ public class CustomPaletteconfigurationEditor extends PaletteconfigurationEditor
if (eContainer instanceof DrawerConfiguration) {
EList<ChildConfiguration> ownedConfigurations = ((DrawerConfiguration) eContainer).getOwnedConfigurations();
int index = ownedConfigurations.indexOf(object);
- ownedConfigurations.add(index, tool);
+ command = new AddCommand(editingDomain, ownedConfigurations, tool, index);
} else if (eContainer instanceof StackConfiguration) {
EList<LeafConfiguration> ownedConfigurations = ((StackConfiguration) eContainer).getOwnedConfigurations();
int index = ownedConfigurations.indexOf(object);
- ownedConfigurations.add(index, tool);
+ command = new AddCommand(editingDomain, ownedConfigurations, tool, index);
+ } else {
+ return;
}
+ } else {
+ return;
}
+
+ editingDomain.getCommandStack().execute(command);
selectionViewer.expandToLevel(object, 1);
selectionViewer.refresh();
}

Back to the top