You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2015/10/05 17:39:00 UTC

svn commit: r1706857 - /uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/query/ui/QueryComposite.java

Author: pkluegl
Date: Mon Oct  5 15:39:00 2015
New Revision: 1706857

URL: http://svn.apache.org/viewvc?rev=1706857&view=rev
Log:
UIMA-4631
- allow external files

Modified:
    uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/query/ui/QueryComposite.java

Modified: uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/query/ui/QueryComposite.java
URL: http://svn.apache.org/viewvc/uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/query/ui/QueryComposite.java?rev=1706857&r1=1706856&r2=1706857&view=diff
==============================================================================
--- uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/query/ui/QueryComposite.java (original)
+++ uima/ruta/trunk/ruta-ep-addons/src/main/java/org/apache/uima/ruta/query/ui/QueryComposite.java Mon Oct  5 15:39:00 2015
@@ -29,9 +29,12 @@ import org.apache.uima.caseditor.editor.
 import org.apache.uima.ruta.addons.RutaAddonsPlugin;
 import org.apache.uima.ruta.ide.core.RutaLanguageToolkit;
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IWorkspace;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.dltk.internal.ui.editor.ScriptSourceViewer;
 import org.eclipse.dltk.ui.DLTKUILanguageManager;
@@ -521,10 +524,32 @@ public class QueryComposite extends org.
   }
 
   public static IFile getIFile(String location) {
-    IPath s = Path.fromOSString(location);
+    IPath path = Path.fromOSString(location);
     IWorkspace workspace = ResourcesPlugin.getWorkspace();
-    IFile ifile = workspace.getRoot().getFileForLocation(s);
-    return ifile;
+    IFile file = workspace.getRoot().getFileForLocation(path);
+
+    if (file == null) {
+      // no located in the workspace?
+      try {
+        IProject project = workspace.getRoot().getProject("External Files");
+        if (!project.exists()) {
+          project.create(null);
+        }
+        if (!project.isOpen()) {
+          project.open(null);
+        }
+        IFile extFile = project.getFile(path.lastSegment());
+        if(extFile.exists()) {
+          extFile.delete(true, false, new NullProgressMonitor());
+        }
+        extFile.createLink(path, IResource.NONE, null);
+        file = extFile;
+      } catch (Exception e) {
+        RutaAddonsPlugin.error(e);
+      }
+    }
+    
+    return file;
   }
 
   public void setInformation(String content) {