]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Use FileLocator.toFileURL to get access to image files 02/3502/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 12 Nov 2019 11:26:22 +0000 (13:26 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 12 Nov 2019 11:26:22 +0000 (13:26 +0200)
gitlab #52

Change-Id: I307a0042b7131502452949d79005d24f198c4cca

org.simantics.g3d/src/org/simantics/g3d/tools/PluginTools.java

index 296f1a1142545cbe7516aaa56af21c4bc831b270..7d4fa67b41116f01fe8a1d4ec1184e931b8a6f47 100644 (file)
@@ -1,39 +1,39 @@
-/*******************************************************************************\r
- * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.g3d.tools;\r
-\r
-import java.io.File;\r
-import java.net.URL;\r
-\r
-import org.eclipse.core.runtime.FileLocator;\r
-import org.eclipse.core.runtime.IPath;\r
-import org.eclipse.core.runtime.Path;\r
-import org.osgi.framework.Bundle;\r
-\r
-public class PluginTools {\r
-       \r
-       public static String getAbsolutePath(Bundle inBundle, String fullpath) {\r
-               IPath path = new Path(fullpath);\r
-               URL u = FileLocator.find(inBundle, path, null);\r
-               if (u != null) {\r
-                       try {\r
-                               u = FileLocator.resolve(u);\r
-                               if ("file".equals(u.getProtocol())) {\r
-                                       return new File(u.getFile()).getAbsolutePath();\r
-                               }\r
-                       } catch (Exception e) {\r
-                       }\r
-               }\r
-               return null;\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.g3d.tools;
+
+import java.io.File;
+import java.net.URL;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.osgi.framework.Bundle;
+
+public class PluginTools {
+       
+       public static String getAbsolutePath(Bundle inBundle, String fullpath) {
+               IPath path = new Path(fullpath);
+               URL u = FileLocator.find(inBundle, path, null);
+               if (u != null) {
+                       try {
+                               u = FileLocator.toFileURL(u);
+                               if ("file".equals(u.getProtocol())) {
+                                       return new File(u.getFile()).getAbsolutePath();
+                               }
+                       } catch (Exception e) {
+                       }
+               }
+               return null;
+       }
+
+}