Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-02-17 18:06:24 +0000
committerChristian W. Damus2014-02-17 18:06:24 +0000
commit1d41b58f48ba237c17aee66ca9ead14081e51dc6 (patch)
tree292023ad06fd0bb122fd39c4c22e5c2f39a979e6
parentfabfcd1ea165f9240a7717137fc3d354b1e36922 (diff)
downloadorg.eclipse.papyrus-1d41b58f48ba237c17aee66ca9ead14081e51dc6.tar.gz
org.eclipse.papyrus-1d41b58f48ba237c17aee66ca9ead14081e51dc6.tar.xz
org.eclipse.papyrus-1d41b58f48ba237c17aee66ca9ead14081e51dc6.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.
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.service.types/src/org/eclipse/papyrus/sysml/service/types/helper/advice/PropertyEditHelperAdvice.java19
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/PackageUtil.java6
2 files changed, 17 insertions, 8 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 8b6dda12852..d028b869d48 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
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011-2012 CEA LIST.
+ * Copyright (c) 2011-2014 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
@@ -9,6 +9,7 @@
* Contributors:
*
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 402525
*
*****************************************************************************/
package org.eclipse.papyrus.sysml.service.types.helper.advice;
@@ -49,10 +50,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;
@@ -195,11 +198,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)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 81ce8faf333..f8f000c683d 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;
@@ -138,7 +139,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