Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2011-01-28 17:05:38 +0000
committerHenrik Rentz-Reichert2011-01-28 17:05:38 +0000
commit635957ae0eaf508602216ec555e500908de4a232 (patch)
treef3d3b5f0975e46804edf54ceb4e66822658fab8b /plugins
parent9f929db356936cd2a8894a99c8b8f8b99c5b3f6f (diff)
downloadorg.eclipse.etrice-635957ae0eaf508602216ec555e500908de4a232.tar.gz
org.eclipse.etrice-635957ae0eaf508602216ec555e500908de4a232.tar.xz
org.eclipse.etrice-635957ae0eaf508602216ec555e500908de4a232.zip
ui.structure: generalize DiagramAccess for non-platform resources
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java36
1 files changed, 26 insertions, 10 deletions
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java
index 704d9f6f2..cc710c56a 100644
--- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java
+++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/DiagramAccess.java
@@ -12,6 +12,7 @@
package org.eclipse.etrice.ui.structure;
+import java.io.File;
import java.io.IOException;
import java.util.Collections;
@@ -48,21 +49,36 @@ public class DiagramAccess {
return null;
URI uri = resource.getURI();
- if (!uri.isPlatformResource())
- return null;
- uri = uri.trimSegments(1);
- IFolder parentFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(uri.toPlatformString(true)));
-
- IFolder diagramFolder = parentFolder.getFolder(DIAGRAMS_FOLDER_NAME);
+ // TODOHRR: put common diagram access code into ui.common
+ // make abstract methods get fileEtension() and populateDiagram()
- RoomModel model = (RoomModel) sc.eContainer();
+ String modelName = ((RoomModel) sc.eContainer()).getName();
- IFile diagramFile = diagramFolder.getFile(model.getName()+"."+sc.getName()+".structure");
- URI diagURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
+ URI diagURI = null;
+ boolean exists = false;
+ if (uri.isPlatformResource()) {
+ uri = uri.trimSegments(1);
+ IFolder parentFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(uri.toPlatformString(true)));
+ IFolder diagramFolder = parentFolder.getFolder(DIAGRAMS_FOLDER_NAME);
+
+ IFile diagramFile = diagramFolder.getFile(modelName+"."+sc.getName()+".structure");
+ diagURI = URI.createPlatformResourceURI(diagramFile.getFullPath().toString(), true);
+ exists = diagramFile.exists();
+ }
+ else {
+ uri = uri.trimSegments(1);
+ File diagramFile = new File(uri.toFileString());
+ diagramFile = new File(diagramFile.getParent()
+ +File.separator+DIAGRAMS_FOLDER_NAME
+ +File.separator+modelName+"."+sc.getName()+".structure");
+ diagURI = URI.createFileURI(diagramFile.getPath());
+ exists = diagramFile.exists();
+ }
+
ResourceSet rs = new ResourceSetImpl();
- if (diagramFile.exists()) {
+ if (exists) {
Resource diagRes = rs.getResource(diagURI, true);
if (diagRes.getContents().isEmpty())
return null;

Back to the top