]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/DeployedSlcSystem.java
Refactor SLC IDE
[gpl/argeo-slc.git] / ide / plugins / org.argeo.slc.ide.ui / src / org / argeo / slc / ide / ui / DeployedSlcSystem.java
diff --git a/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/DeployedSlcSystem.java b/ide/plugins/org.argeo.slc.ide.ui/src/org/argeo/slc/ide/ui/DeployedSlcSystem.java
new file mode 100644 (file)
index 0000000..8992432
--- /dev/null
@@ -0,0 +1,50 @@
+package org.argeo.slc.ide.ui;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.List;\r
+import java.util.Vector;\r
+\r
+import org.eclipse.core.runtime.CoreException;\r
+import org.eclipse.jdt.launching.IVMInstall;\r
+import org.eclipse.jdt.launching.JavaRuntime;\r
+\r
+public class DeployedSlcSystem implements SlcSystem {\r
+       private File baseDir;\r
+       private String relLibDir = "lib";\r
+\r
+       public DeployedSlcSystem(String baseDirPath) {\r
+               try {\r
+                       this.baseDir = new File(baseDirPath).getCanonicalFile();\r
+               } catch (IOException e) {\r
+                       throw new RuntimeException("Cannot get path for " + baseDirPath, e);\r
+               }\r
+       }\r
+\r
+       public String[] getClasspath() throws CoreException {\r
+               List<String> classpath = new Vector<String>();\r
+               File libDir = new File(baseDir.getPath() + File.separator + relLibDir);\r
+               File[] files = libDir.listFiles();\r
+               for (File file : files) {\r
+                       try {\r
+                               classpath.add(file.getCanonicalPath());\r
+                       } catch (IOException e) {\r
+                               throw new RuntimeException("Cannot get path for " + file, e);\r
+                       }\r
+               }\r
+               return classpath.toArray(new String[classpath.size()]);\r
+       }\r
+\r
+       public IVMInstall getVmInstall() throws CoreException {\r
+               return JavaRuntime.getDefaultVMInstall();\r
+       }\r
+\r
+       public String getAntHome() {\r
+               return baseDir.getPath();\r
+       }\r
+\r
+       public String getJavaLibraryPath() {\r
+               return baseDir.getPath() + File.separator + "bin";\r
+       }\r
+\r
+}\r