summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetya Sabeva2012-10-15 07:34:54 (EDT)
committer Petya Sabeva2012-10-15 07:34:54 (EDT)
commitbfd43f3a8590514529645cdf4c88fc2ac0f10a6c (patch)
tree9ac5d28d66b37453ad57ebb2071dc9aef14590ee
parentb1b50ee8566d5400a668a2006723b8adb8d4e5e8 (diff)
downloadwebtools.dali-bfd43f3a8590514529645cdf4c88fc2ac0f10a6c.zip
webtools.dali-bfd43f3a8590514529645cdf4c88fc2ac0f10a6c.tar.gz
webtools.dali-bfd43f3a8590514529645cdf4c88fc2ac0f10a6c.tar.bz2
[391661] - Diagram editor open crashesv201210151138
-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.java36
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java1
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java2
4 files changed, 26 insertions, 18 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..fc3a697 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 d458bc9..5468e83 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
@@ -190,21 +190,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);
@@ -365,5 +351,25 @@ public class ModelIntegrationUtil {
return ref.get();
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 190ba6c..439f329 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
@@ -1399,6 +1399,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();
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
index 0dcea32..dbd2ed0 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
@@ -597,7 +597,7 @@ public class JpaArtifactFactory {
private void createSimpleAttribute(JavaPersistentType attributeType,
String attributeName, String actName, boolean isCollection,
IType type) throws JavaModelException {
- type.createField(" private " + JPAEditorUtil.returnSimpleName(attributeType.getName()) + " "
+ type.createField(" private " + JPAEditorUtil.returnSimpleName(attributeType.getName()) + " " //$NON-NLS-1$ //$NON-NLS-2$
+ JPAEditorUtil.decapitalizeFirstLetter(actName) + ";", null, false, new NullProgressMonitor()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
type.createMethod(genGetterContents(attributeName,
JPAEditorUtil.returnSimpleName(attributeType.getName()), null,