Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2012-09-03 13:53:44 -0400
committerSopot Cela2012-09-03 13:53:44 -0400
commit7987d2bc86d672747f5e73b6e63921a211f0f929 (patch)
treed08df509158fe8143abaababa2b425107f571d88
parentcaaf4d61e99e6f31be8ac4a30b6e3265b7ca4db5 (diff)
downloadorg.eclipse.e4.tools-7987d2bc86d672747f5e73b6e63921a211f0f929.tar.gz
org.eclipse.e4.tools-7987d2bc86d672747f5e73b6e63921a211f0f929.tar.xz
org.eclipse.e4.tools-7987d2bc86d672747f5e73b6e63921a211f0f929.zip
bug 382717: [Tooling] Find in fragments only works if ApplicationXMI
property is set on the product https://bugs.eclipse.org/bugs/show_bug.cgi?id=382717
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java50
1 files changed, 32 insertions, 18 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java
index 4f4718d5..62a37da5 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.pde.internal.core.PDEExtensionRegistry;
public class TargetElementProviders implements IModelElementProvider {
+ private static final String APP_E4XMI_DEFAULT = "Application.e4xmi";
private ResourceSet resourceSet;
public void getModelElements(Filter filter, ModelResultHandler handler) {
@@ -53,29 +54,19 @@ public class TargetElementProviders implements IModelElementProvider {
for( IExtension ext : extensions ) {
for( IConfigurationElement el : ext.getConfigurationElements() ) {
if( el.getName().equals("product") ) {
+ boolean xmiPropertyPresent = false;
for( IConfigurationElement prop: el.getChildren("property") ) {
if( prop.getAttribute("name").equals("applicationXMI") ) {
String v = prop.getAttribute("value");
- String[] s = v.split("/");
- URI uri;
-// System.err.println("Product-Ext: Checking: " + v + " => P:" + s[0] + "");
- IProject p = root.getProject(s[0]);
- if( p.exists() && p.isOpen() ) {
- uri = URI.createPlatformResourceURI(v, true );
- } else {
- uri = URI.createURI("platform:/plugin/" + v );
- }
-
-// System.err.println(uri);
- try {
- resourceSet.getResource(uri, true);
- } catch (Exception e) {
- e.printStackTrace();
-// System.err.println("=============> Failing");
- }
+ setUpResourceSet(root, v);
+ xmiPropertyPresent = true;
break;
}
}
+ if (!xmiPropertyPresent){
+ setUpResourceSet(root, ext.getNamespaceIdentifier()+"/"+APP_E4XMI_DEFAULT);
+ break;
+ }
}
}
}
@@ -83,6 +74,29 @@ public class TargetElementProviders implements IModelElementProvider {
applyFilter(filter, handler);
}
+
+ private void setUpResourceSet(IWorkspaceRoot root, String v) {
+ String[] s = v.split("/");
+ URI uri;
+// System.err.println("Product-Ext: Checking: " + v + " => P:" + s[0] + "");
+ IProject p = root.getProject(s[0]);
+ if( p.exists() && p.isOpen() ) {
+ uri = URI.createPlatformResourceURI(v, true );
+ } else {
+ uri = URI.createURI("platform:/plugin/" + v );
+ }
+
+// System.err.println(uri);
+ try {
+ //prevent some unnecessary calls by checking the uri
+ if (resourceSet.getURIConverter().exists(uri, null)
+ )
+ resourceSet.getResource(uri, true);
+ } catch (Exception e) {
+ e.printStackTrace();
+// System.err.println("=============> Failing");
+ }
+ }
private void applyFilter(Filter filter, ModelResultHandler handler) {
for (Resource res : resourceSet.getResources()) {
@@ -95,7 +109,7 @@ public class TargetElementProviders implements IModelElementProvider {
// .println("Skipped because it is an import");
} else {
if (o.eClass().equals(filter.eClass)) {
- System.err.println("Found: " + o);
+// System.err.println("Found: " + o);
handler.result(o);
}
}

Back to the top