Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGéry Deloge2017-03-10 17:05:31 +0000
committerGerrit Code Review @ Eclipse.org2017-03-13 08:40:23 +0000
commitcb10068854ce727bc5004e997663ae0a3ae2ffd6 (patch)
tree061999f527b4c1aad131ec2c35c37aa57360630f /plugins
parent814e53cdc604131f93925eef8d7f4bd31edd5061 (diff)
downloadorg.eclipse.papyrus-cb10068854ce727bc5004e997663ae0a3ae2ffd6.tar.gz
org.eclipse.papyrus-cb10068854ce727bc5004e997663ae0a3ae2ffd6.tar.xz
org.eclipse.papyrus-cb10068854ce727bc5004e997663ae0a3ae2ffd6.zip
Bug 513481: [Infra][Gmfdiag] NPE in AbstractPapyrusGmfCreateDiagramCommandHandler
Change-Id: I461bd6c5e31aa1c26cd42de6e78ce34d5a7e6fc9 Signed-off-by: Géry Deloge <gery.deloge@cea.fr>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java
index d71196c25ae..101c4953423 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/AbstractPapyrusGmfCreateDiagramCommandHandler.java
@@ -48,7 +48,6 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.infra.emf.gmf.command.CheckedOperationHistory;
import org.eclipse.papyrus.commands.ICreationCommand;
import org.eclipse.papyrus.commands.OpenDiagramCommand;
import org.eclipse.papyrus.infra.core.language.ILanguageService;
@@ -57,11 +56,10 @@ import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler2;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
import org.eclipse.papyrus.infra.core.resource.ReadOnlyAxis;
import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModelUtils;
-import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.emf.gmf.command.CheckedOperationHistory;
import org.eclipse.papyrus.infra.emf.readonly.ReadOnlyManager;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResource;
import org.eclipse.papyrus.infra.gmfdiag.common.messages.Messages;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
@@ -129,7 +127,6 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
if (notationResource == null) {
return CommandResult.newErrorCommandResult("Cannot create a diagram on the selected element (ReadOnly?)"); //$NON-NLS-1$
}
- Resource diResource = DiModelUtils.getDiResource(modelSet);
if (owner == null) {
Resource modelResource = ILanguageService.getLanguageModels(modelSet).stream()
@@ -201,8 +198,6 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
Diagram diagram = doCreateDiagram(notationResource, owner, element, prototype, name);
if (diagram != null) {
- IPageManager pageManager = ServiceUtilsForResource.getInstance().getService(IPageManager.class, diResource);
- pageManager.addPage(diagram);
return CommandResult.newOKCommandResult(diagram);
}
@@ -338,11 +333,12 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
*/
@Override
public final Diagram createDiagram(ModelSet modelSet, EObject owner, String name) {
+ Diagram diagram = null;
ViewPrototype proto = ViewPrototype.get(getCreatedDiagramType(), owner, owner);
- if (proto == null) {
- return null;
+ if (proto != null) {
+ diagram = createDiagram(modelSet, owner, owner, proto, name);
}
- return createDiagram(modelSet, owner, owner, proto, name);
+ return diagram;
}
@@ -441,6 +437,7 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
Creator creator = new Creator(modelSet, owner, element, prototype, name);
try {
CommandResult commandResult = creator.createDiagram();
+ if (commandResult != null) {
if (!commandResult.getStatus().isOK()) {
return commandResult;
}
@@ -449,6 +446,7 @@ public abstract class AbstractPapyrusGmfCreateDiagramCommandHandler extends Abst
diagramElement = diagram.getElement();
diagramOwner = DiagramUtils.getOwner(diagram);
return commandResult;
+ }
} catch (ServiceException e) {
Activator.log.error(e);
}

Back to the top