summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetya Sabeva2012-10-16 08:58:13 (EDT)
committerPetya Sabeva2012-10-16 08:58:13 (EDT)
commitff694f44b5b8e79fb16b9378fa7d8bb1cf69eb9a (patch)
tree422972dda0c7d6103e109915c0c10b9cecc1f661
parent95681d2892e927b3f6694728661f556cc96aa2f7 (diff)
downloadwebtools.dali-ff694f44b5b8e79fb16b9378fa7d8bb1cf69eb9a.zip
webtools.dali-ff694f44b5b8e79fb16b9378fa7d8bb1cf69eb9a.tar.gz
webtools.dali-ff694f44b5b8e79fb16b9378fa7d8bb1cf69eb9a.tar.bz2
Bug 391661 - Diagram editor open crashes
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java5
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java35
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java1
3 files changed, 24 insertions, 17 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
index c0e7419..a56301e 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
@@ -89,7 +89,7 @@ public class OpenJpaDiagramActionDelegate implements IObjectActionDelegate {
}
}
- public static IDiagramEditor openDiagramEditor(Diagram diagram) {
+ public static IDiagramEditor openDiagramEditor(final Diagram diagram) {
String diagramName = diagram.getName();
JpaProject jpaProject = ModelIntegrationUtil.getProjectByDiagram(diagramName);
@@ -115,7 +115,8 @@ public class OpenJpaDiagramActionDelegate implements IObjectActionDelegate {
JPADiagramEditor ret = (JPADiagramEditor) editorPart;
wrp.setObj(ret);
PlatformUI.getWorkbench().addWorkbenchListener( new IWorkbenchListener() {
- public boolean preShutdown( IWorkbench workbench, boolean forced ) {
+ public boolean preShutdown( IWorkbench workbench, boolean forced ) {
+ ModelIntegrationUtil.deleteDiagramXMIFile(diagram);
workbenchPage.closeEditor( editorPart, true);
return true;
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java
index 65b8927..46d4886 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/util/ModelIntegrationUtil.java
@@ -191,21 +191,7 @@ public class ModelIntegrationUtil {
String pathName = diagramFileName.toString();
URI resourceURI = URI.createFileURI(pathName);
- final Resource resource = resourceSet.createResource(resourceURI);
- //resource.setTrackingModification(false);
- //(ResourceSetManager.getProjectForResourceSet(resourceSet));
- defaultTransEditDomain.getCommandStack().execute(new RecordingCommand(defaultTransEditDomain) {
- @Override
- protected void doExecute() {
- try {
- resource.load(null);
- } catch (IOException e) {
- JPADiagramEditorPlugin.logInfo("The diagram file does not exist. It will be created"); //$NON-NLS-1$
- JPADiagramEditorPlugin.logInfo(e.getLocalizedMessage());
- }
- }
- });
-
+ final Resource resource = resourceSet.createResource(resourceURI);
if (!resource.isLoaded())
return createNewDiagram(project, defaultTransEditDomain, resourceSet, resource, diagramName, grid, snap);
@@ -380,4 +366,23 @@ public class ModelIntegrationUtil {
return null;
}
+ public static void deleteDiagramXMIFile(final Diagram diagram) {
+ if(diagram != null && diagram.eResource()!=null){
+ TransactionalEditingDomain ted = ModelIntegrationUtil.getTransactionalEditingDomain(diagram);
+ if(ted == null)
+ return;
+ ted.getCommandStack().execute(new RecordingCommand(ted) {
+
+ @Override
+ protected void doExecute() {
+ try {
+ diagram.eResource().delete(null);
+ } catch (IOException e) {
+ JPADiagramEditorPlugin.logInfo("Cannot delete the digram xmi file."); //$NON-NLS-1$
+ JPADiagramEditorPlugin.logInfo(e.getLocalizedMessage());
+ }
+ }
+ });
+ }
+ }
} \ No newline at end of file
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
index 56db9c0..c3c8701 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
@@ -1398,6 +1398,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
final IResource resource = event.getResource();
if (resource != null && !resource.exists() || event.getType() == IResourceChangeEvent.PRE_CLOSE || (event.getType() == IResourceChangeEvent.PRE_DELETE)) {
if (resource instanceof IProject) {
+ ModelIntegrationUtil.deleteDiagramXMIFile(ModelIntegrationUtil.getDiagramByProject((IProject)resource));
final IDiagramTypeProvider provider = featureProvider.getDiagramTypeProvider();
if (provider instanceof JPAEditorDiagramTypeProvider) {
final JPADiagramEditor diagramBySelectedProject = ((JPAEditorDiagramTypeProvider) provider).getDiagramEditor();