Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: gnu.trove2;bundle-version="2.0.4",
org.simantics.databoard;bundle-version="0.5.2",
- org.eclipse.osgi;bundle-version="3.6.0"
+ org.eclipse.osgi;bundle-version="3.6.0",
+ org.eclipse.core.runtime;bundle-version="3.6.0"
Export-Package: org.simantics.modelica,
org.simantics.modelica.data
Bundle-Activator: org.simantics.modelica.Activator
import java.io.IOException;\r
import java.io.InputStream;\r
import java.io.PrintStream;\r
-import java.net.URI;\r
import java.net.URL;\r
-import java.net.URLConnection;\r
+import java.net.URLDecoder;\r
import java.util.HashMap;\r
\r
-import org.eclipse.osgi.framework.internal.core.BundleURLConnection;\r
+import org.eclipse.core.runtime.FileLocator;\r
+import org.eclipse.core.runtime.Platform;\r
import org.osgi.framework.Bundle;\r
\r
public class ModelicaManager {\r
OSType os = calculateOS();\r
\r
if (os == OSType.UNKNOWN)\r
- throw new UnsatisfiedLinkError("unknown OS '" + osName + "' cannot load native fastlz library");\r
+ throw new UnsatisfiedLinkError("unknown OS '" + osName + "' for running OpenModelica");\r
\r
// Teemu's stuff, testing openmodelica in a plugin\r
if(dir == null && os.equals(OSType.WINDOWS)) {\r
\r
- for(Bundle bundle : Activator.getContext().getBundles()) {\r
- if(bundle.getSymbolicName().equals("org.simantics.openmodelica.win32")) {\r
- try{\r
- URL entry = bundle.getEntry(".");\r
- if(entry != null) {\r
- URLConnection connection = entry.openConnection();\r
- if(connection instanceof BundleURLConnection) {\r
- URL fileURL = ((BundleURLConnection)connection).getFileURL();\r
- URI uri = new URI(fileURL.toString());\r
- String path = new File(uri).getAbsolutePath();\r
- path = path.substring(0, path.length() - 1);\r
- path = path + "OpenModelica1.5.0\\om.bat";\r
- File f = new File(path);\r
- return f;\r
- }\r
- }\r
- }\r
- catch (Exception e) {\r
- e.printStackTrace();\r
+ Bundle bundle = Platform.getBundle("org.simantics.openmodelica.win32");\r
+ if (bundle != null) {\r
+ try{\r
+ URL entry = bundle.getEntry("/");\r
+ if(entry != null) {\r
+ URL fileURL = FileLocator.toFileURL(entry);\r
+ File root = new File( URLDecoder.decode(fileURL.getPath(), "UTF-8") );\r
+ File f = new File(new File(root, "OpenModelica1.5.0"), "om.bat");\r
+ return f;\r
}\r
-\r
+ }\r
+ catch (Exception e) {\r
+ e.printStackTrace();\r
}\r
}\r
}\r