diff options
author | eperico | 2010-09-06 12:54:15 +0000 |
---|---|---|
committer | eperico | 2010-09-06 12:54:15 +0000 |
commit | b6fecc3e61c0a1e815085acd3b30e26455f06fb3 (patch) | |
tree | 8b31a2ebc166a40377676bed18521ef82d09cff9 | |
parent | e5d5ec6e381dba15e03fd9d5a8c16773ae197463 (diff) | |
download | org.eclipse.papyrus-b6fecc3e61c0a1e815085acd3b30e26455f06fb3.tar.gz org.eclipse.papyrus-b6fecc3e61c0a1e815085acd3b30e26455f06fb3.tar.xz org.eclipse.papyrus-b6fecc3e61c0a1e815085acd3b30e26455f06fb3.zip |
NEW - bug 321296: [Control Mode] Bug with Control Action : Null Pointer Exception
https://bugs.eclipse.org/bugs/show_bug.cgi?id=321296
patch provided by Mathieu Velten
-rw-r--r-- | plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java index ebda1abb406..b08d008a0e9 100644 --- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java +++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java @@ -229,6 +229,7 @@ public class ControlCommand extends AbstractTransactionalCommand { child.setResourceURL(newURLResolved);
ControledResource resource = model.getModelRoot();
+ Resource parentResource = null;
// create the controled resource according to the control action
ControledResource parent = null;
@@ -236,7 +237,8 @@ public class ControlCommand extends AbstractTransactionalCommand { parent = historyFactory.eINSTANCE.createControledResource();
parent.setResourceURL(currentURLResolved);
parent.getChildren().add(child);
- compoundCommand.append(new AddCommand(domain, model.getResource().getContents(), Collections.singleton(parent)));
+ parentResource = model.getResource();
+ compoundCommand.append(new AddCommand(domain, parentResource.getContents(), Collections.singleton(parent)));
} else {
if(isCurrentURL(currentURLResolved, resource)) {
parent = resource;
@@ -256,22 +258,27 @@ public class ControlCommand extends AbstractTransactionalCommand { if(parent == null) {
parent = historyFactory.eINSTANCE.createControledResource();
parent.setResourceURL(currentURLResolved);
- resource.eResource().getContents().add(parent);
+ parentResource = resource.eResource();
+ compoundCommand.append(new AddCommand(domain, parentResource.getContents(), Collections.singleton(parent)));
}
if(parent != null) {
compoundCommand.append(AddCommand.create(domain, parent, historyPackage.Literals.CONTROLED_RESOURCE__CHILDREN, Collections.singleton(child)));
}
}
List<ControledResource> controledFromParent = new LinkedList<ControledResource>();
- Resource parentResource = parent.eResource();
- for(EObject e : parentResource.getContents()) {
- if(e instanceof ControledResource) {
- ControledResource aControled = (ControledResource)e;
- controledFromParent.add(aControled);
- for(Iterator<EObject> i = aControled.eAllContents(); i.hasNext();) {
- EObject tmp = i.next();
- if(tmp instanceof ControledResource) {
- controledFromParent.add((ControledResource)tmp);
+ if(parentResource == null) {
+ parentResource = parent.eResource();
+ }
+ if(parentResource != null) {
+ for(EObject e : parentResource.getContents()) {
+ if(e instanceof ControledResource) {
+ ControledResource aControled = (ControledResource)e;
+ controledFromParent.add(aControled);
+ for(Iterator<EObject> i = aControled.eAllContents(); i.hasNext();) {
+ EObject tmp = i.next();
+ if(tmp instanceof ControledResource) {
+ controledFromParent.add((ControledResource)tmp);
+ }
}
}
}
|