Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Leacu2017-10-09 14:32:55 -0400
committerPaul Leacu2017-10-09 14:32:55 -0400
commitaa5e1d0312487dff3447ef1277659e17a1aa1622 (patch)
tree224324c0ed3bda193314f734333730d3eb0ee448
parent453256c50c4797cfb434c00e4328a4f33c41644f (diff)
downloadorg.eclipse.bpmn2-modeler-aa5e1d0312487dff3447ef1277659e17a1aa1622.tar.gz
org.eclipse.bpmn2-modeler-aa5e1d0312487dff3447ef1277659e17a1aa1622.tar.xz
org.eclipse.bpmn2-modeler-aa5e1d0312487dff3447ef1277659e17a1aa1622.zip
[525779] Verify new diagram creation before dereferencing.
Change-Id: Ia754e7a9acb04ce62dbce8e36e7e501647d38df7 Signed-off-by: Paul Leacu <pleacu@redhat.com>
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java42
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/DefaultBPMN2Editor.java4
-rw-r--r--plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/wizards/BPMN2DiagramCreator.java3
3 files changed, 28 insertions, 21 deletions
diff --git a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java
index 114a868c..c1aaa760 100644
--- a/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java
+++ b/plugins/org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/di/DIUtils.java
@@ -458,30 +458,34 @@ public class DIUtils {
editor.getEditingDomain().getResourceSet().getResources().get(0);
final Diagram newDiagram = createDiagram(bpmnDiagram.getName());
- final IFeatureProvider featureProvider = dtp.getFeatureProvider();
- TransactionalEditingDomain domain = editor.getEditingDomain();
- domain.getCommandStack().execute(new RecordingCommand(domain) {
- protected void doExecute() {
- resource.getContents().add(newDiagram);
- newDiagram.setActive(true);
- featureProvider.link(newDiagram, bpmnDiagram);
- }
- });
+ if (newDiagram != null) {
+ final IFeatureProvider featureProvider = dtp.getFeatureProvider();
+ TransactionalEditingDomain domain = editor.getEditingDomain();
+ domain.getCommandStack().execute(new RecordingCommand(domain) {
+ protected void doExecute() {
+ resource.getContents().add(newDiagram);
+ newDiagram.setActive(true);
+ featureProvider.link(newDiagram, bpmnDiagram);
+ }
+ });
+ }
return newDiagram;
}
public static Diagram createDiagram(String diagramName) {
final Diagram diagram = Graphiti.getPeCreateService().createDiagram("BPMN2", diagramName, true); //$NON-NLS-1$
- Bpmn2Preferences prefs = Bpmn2Preferences.getInstance();
- ShapeStyle ss = prefs.getShapeStyle(ShapeStyle.Category.GRID);
- diagram.setGridUnit(ss.getDefaultWidth());
- diagram.setVerticalGridUnit(ss.getDefaultHeight());
- diagram.setSnapToGrid(ss.getSnapToGrid());
- GraphicsAlgorithm ga = diagram.getGraphicsAlgorithm();
- IGaService gaService = Graphiti.getGaService();
- ga.setForeground(gaService.manageColor(diagram, ss.getShapeForeground()));
- ss = prefs.getShapeStyle(ShapeStyle.Category.CANVAS);
- ga.setBackground(gaService.manageColor(diagram, ss.getShapeBackground()));
+ if (diagram != null) {
+ Bpmn2Preferences prefs = Bpmn2Preferences.getInstance();
+ ShapeStyle ss = prefs.getShapeStyle(ShapeStyle.Category.GRID);
+ diagram.setGridUnit(ss.getDefaultWidth());
+ diagram.setVerticalGridUnit(ss.getDefaultHeight());
+ diagram.setSnapToGrid(ss.getSnapToGrid());
+ GraphicsAlgorithm ga = diagram.getGraphicsAlgorithm();
+ IGaService gaService = Graphiti.getGaService();
+ ga.setForeground(gaService.manageColor(diagram, ss.getShapeForeground()));
+ ss = prefs.getShapeStyle(ShapeStyle.Category.CANVAS);
+ ga.setBackground(gaService.manageColor(diagram, ss.getShapeBackground()));
+ }
return diagram;
}
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/DefaultBPMN2Editor.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/DefaultBPMN2Editor.java
index 810bb5a8..c3b39f2c 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/DefaultBPMN2Editor.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/editor/DefaultBPMN2Editor.java
@@ -858,7 +858,7 @@ public class DefaultBPMN2Editor extends DiagramEditor implements IPreferenceChan
part = BPMN2DiagramCreator.openEditor(input);
}
catch (Exception e) {
- e.printStackTrace();
+ Activator.logError(e);
}
return part;
@@ -876,7 +876,7 @@ public class DefaultBPMN2Editor extends DiagramEditor implements IPreferenceChan
* helper class used to handle setInput() of the editor, because of it's complexity split it up in own class,
* which may be overridden and customized
*
- * @author Flavio Donzé
+ * @author Flavio Donz
*
*/
public class EditorInputHelper {
diff --git a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/wizards/BPMN2DiagramCreator.java b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/wizards/BPMN2DiagramCreator.java
index 13ed1ff7..571d5802 100644
--- a/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/wizards/BPMN2DiagramCreator.java
+++ b/plugins/org.eclipse.bpmn2.modeler.ui/src/org/eclipse/bpmn2/modeler/ui/wizards/BPMN2DiagramCreator.java
@@ -53,6 +53,9 @@ public class BPMN2DiagramCreator {
String modelName = modelUri.trimFragment().trimFileExtension().lastSegment();
// We still need to create a Diagram object for this editor
final Diagram diagram = DIUtils.createDiagram(modelName); //$NON-NLS-1$
+
+ if (diagram == null)
+ return null;
if (otherEditor!=null) {
// reuse the temp Diagram File from other editor

Back to the top