]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d/src/org/simantics/g3d/tools/PluginTools.java
3D framework (Simca 2012)
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / g3d / tools / PluginTools.java
1 package org.simantics.g3d.tools;\r
2 \r
3 import java.io.File;\r
4 import java.net.URL;\r
5 \r
6 import org.eclipse.core.runtime.FileLocator;\r
7 import org.eclipse.core.runtime.IPath;\r
8 import org.eclipse.core.runtime.Path;\r
9 import org.osgi.framework.Bundle;\r
10 \r
11 public class PluginTools {\r
12         \r
13          public static String getAbsolutePath(Bundle inBundle, String fullpath) {\r
14                 IPath path = new Path(fullpath);\r
15                 URL u = FileLocator.find(inBundle, path, null);\r
16                 if (u != null) {\r
17                     try {\r
18                         u = FileLocator.resolve(u);\r
19                         if ("file".equals(u.getProtocol())) {\r
20                             return new File(u.getFile()).getAbsolutePath();\r
21                         }\r
22                     } catch (Exception e) {\r
23                     }\r
24                 }\r
25                 return null;\r
26             }\r
27 \r
28 }\r