Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-02-24 05:04:25 -0500
committerCamille Letavernier2014-02-24 05:04:25 -0500
commit9b50c9f7352aadc10fd3cf8edde085fb7fe8c45c (patch)
tree0bd8f4ade769cd1784b24cd270af4732a5d4ec02
parent8453106764584e276edf897355b3bf4f114201fd (diff)
downloadorg.eclipse.papyrus-9b50c9f7352aadc10fd3cf8edde085fb7fe8c45c.tar.gz
org.eclipse.papyrus-9b50c9f7352aadc10fd3cf8edde085fb7fe8c45c.tar.xz
org.eclipse.papyrus-9b50c9f7352aadc10fd3cf8edde085fb7fe8c45c.zip
402525: [Widgets / Transactions] Papyrus dialogs should be transactional
https://bugs.eclipse.org/bugs/show_bug.cgi?id=402525 Fix regression in new-Property dialog caused by commit 2729a76. Conflicts: plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java16
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java6
2 files changed, 15 insertions, 7 deletions
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java
index 316f82fe411..acf76ee0a6e 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java
@@ -49,10 +49,12 @@ import org.eclipse.papyrus.sysml.service.types.utils.ConnectorUtils;
import org.eclipse.papyrus.uml.diagram.common.util.CrossReferencerUtil;
import org.eclipse.papyrus.uml.service.types.utils.ElementUtil;
import org.eclipse.papyrus.uml.service.types.utils.NamedElementHelper;
+import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.Connector;
import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Port;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.Type;
@@ -191,11 +193,15 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
* @return
*/
private ICommand getDestroyAssociatedNestedConnectorCommand(Property property, ICommand command) {
- List<Connector> instancesFilteredByType = org.eclipse.papyrus.uml.tools.utils.ElementUtil.getInstancesFilteredByType(property.getModel(), Connector.class, null);
- List<Connector> connectorToDestroy = ConnectorUtils.filterConnectorByPropertyInNestedConnectorEnd(instancesFilteredByType, (Property)property);
- for(Connector connector : connectorToDestroy) {
- ICommand destroyConnectorCommand = getDestroyConnectorCommand(connector);
- command = CompositeCommand.compose(command, destroyConnectorCommand);
+ Package rootPackage = PackageUtil.getRootPackage(property);
+ // When creating a property in a new-element dialog, it is not attached to the model, yet. So, there will be no need to worry about connectors
+ if(rootPackage != null) {
+ List<Connector> instancesFilteredByType = org.eclipse.papyrus.uml.tools.utils.ElementUtil.getInstancesFilteredByType(rootPackage, Connector.class, null);
+ List<Connector> connectorToDestroy = ConnectorUtils.filterConnectorByPropertyInNestedConnectorEnd(instancesFilteredByType, property);
+ for(Connector connector : connectorToDestroy) {
+ ICommand destroyConnectorCommand = getDestroyConnectorCommand(connector);
+ command = CompositeCommand.compose(command, destroyConnectorCommand);
+ }
}
return command;
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
index 45a9370a0d5..ee26427a093 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2008, 2009 CEA LIST.
+ * Copyright (c) 2008, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@
* Contributors:
* Remi SCHNEKENBURGER (CEA LIST) Remi.schnekenburger@cea.fr - Initial API and implementation
* Yann TANGUY (CEA LIST) yann.tanguy@cea.fr
+ * Christian W. Damus (CEA) - bug 402525
*
*****************************************************************************/
package org.eclipse.papyrus.uml.tools.utils;
@@ -134,7 +135,8 @@ public class PackageUtil {
* @return the top {@link Package} for the specified element
*/
public static Package getRootPackage(Element element) {
- return getRootPackage(element.getNearestPackage());
+ Package nearest = element.getNearestPackage();
+ return (nearest == null) ? null : getRootPackage(nearest);
}
/**

Back to the top