Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2018-04-08 15:39:39 -0400
committerJuergen Haug2018-04-09 03:26:18 -0400
commitd1dab866b5986c7e9ec36cdc1d9c9a6fde6d73c4 (patch)
tree2c5f6e1f228b0c9d7f89b9309af639a75e5a685f
parent781366591a71b6afa42797f084826beb97879ef2 (diff)
downloadorg.eclipse.etrice-d1dab866b5986c7e9ec36cdc1d9c9a6fde6d73c4.tar.gz
org.eclipse.etrice-d1dab866b5986c7e9ec36cdc1d9c9a6fde6d73c4.tar.xz
org.eclipse.etrice-d1dab866b5986c7e9ec36cdc1d9c9a6fde6d73c4.zip
added first support for model import from archives
-rw-r--r--plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/StandardModelLocator.java21
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java9
-rw-r--r--runtime/org.eclipse.etrice.modellib.java/build.gradle5
3 files changed, 22 insertions, 13 deletions
diff --git a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/StandardModelLocator.java b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/StandardModelLocator.java
index 8a598e180..ddf23819b 100644
--- a/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/StandardModelLocator.java
+++ b/plugins/org.eclipse.etrice.core.common/src/org/eclipse/etrice/core/common/scoping/StandardModelLocator.java
@@ -59,8 +59,9 @@ public class StandardModelLocator implements IModelLocator {
try {
URIConverter converter = resource==null? null : resource.getResourceSet().getURIConverter();
URI canonical = getCanonicalFileURI(resolve, converter);
- if (canonical.isPlatform()) {
- resolve = "platform:/resource" + canonical.toPlatformString(true);
+ // TODO handle non-file URIs more generically
+ if(canonical != null && (canonical.isFile() || canonical.isArchive() || canonical.isPlatform() || canonical.scheme() == "classpath")) {
+ resolve = canonical.toString();
}
else {
resolve = canonical.toFileString();
@@ -280,17 +281,15 @@ public class StandardModelLocator implements IModelLocator {
}
private URI getCanonicalFileURI(String uriString, URIConverter uriConverter) throws IOException {
- URI uri;
- if (uriString.startsWith(CLASSPATH) || uriString.startsWith("platform:/") || uriString.startsWith("file:/")) {
+ URI uri = null;
+ try {
+ // try valid uri
uri = URI.createURI(uriString);
+ } catch(IllegalArgumentException e1) {
}
- else {
- try {
- uri = URI.createFileURI(uriString);
- }
- catch (IllegalArgumentException e) {
- throw new IOException();
- }
+ if(uri == null || !(uri.isFile() || uri.isArchive() || uri.isPlatform() || uri.scheme() == "classpath")) {
+ // try file path
+ uri = URI.createFileURI(uriString);
}
URI normalized = uri;
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java
index 638e9c71c..841d6b17e 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java
@@ -153,10 +153,15 @@ public class ModelLoader {
*/
private boolean addResourceURI(String uri) {
URI can = null;
- if (uri.startsWith("platform:/") || uri.startsWith("classpath:/") || uri.startsWith("file:/"))
+ try {
+ // try valid uri
can = URI.createURI(uri);
- else
+ } catch(IllegalArgumentException e1) {
+ }
+ if(can == null || !(can.isFile() || can.isArchive() || can.isPlatform() || can.scheme() == "classpath")) {
+ // try file path
can = URI.createFileURI(uri);
+ }
if (loadedModelURIs.contains(can))
return false;
diff --git a/runtime/org.eclipse.etrice.modellib.java/build.gradle b/runtime/org.eclipse.etrice.modellib.java/build.gradle
index 4d49f6b64..9a5d77227 100644
--- a/runtime/org.eclipse.etrice.modellib.java/build.gradle
+++ b/runtime/org.eclipse.etrice.modellib.java/build.gradle
@@ -1,5 +1,6 @@
apply plugin: 'java'
+apply from: "$rootDir/gradle/publish.gradle"
apply from: "$rootDir/gradle/etGenerator.gradle"
def models = [
@@ -17,6 +18,10 @@ sourceSets {
java {
srcDirs = ['src-gen']
}
+ resources {
+ srcDirs = [projectDir]
+ includes = ['model/*.room']
+ }
}
}

Back to the top