1 package org.simantics.spreadsheet.common;
\r
3 import java.io.UnsupportedEncodingException;
\r
4 import java.net.MalformedURLException;
\r
6 import java.net.URLDecoder;
\r
8 import org.osgi.framework.BundleActivator;
\r
9 import org.osgi.framework.BundleContext;
\r
12 public class Activator implements BundleActivator {
\r
15 * Name of the log file.
\r
17 public static String LOG_FILE_NAME = "spreadsheet.log";
\r
20 public static final String BUNDLE_ID = "org.simantics.spreadsheet.common"; //$NON-NLS-1$
\r
22 // The shared instance
\r
23 private static Activator plugin;
\r
28 public Activator() {
\r
33 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
\r
36 public void start(BundleContext context) throws Exception {
\r
39 String prop = System.getProperty("osgi.instance.area", null);
\r
42 URL url = new URL(prop);
\r
43 if ("file".equals(url .getProtocol())) {
\r
45 File path = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
\r
48 if (path.exists() && path.canWrite()) {
\r
49 File logFile = new File(path, LOG_FILE_NAME);
\r
50 if (!logFile.exists() || (logFile.isFile() && logFile.canWrite()))
\r
51 LOG_FILE_NAME = logFile.getAbsolutePath();
\r
54 } catch (UnsupportedEncodingException e) {
\r
55 // Should never happen since UTF-8 is always supported.
\r
58 } catch (MalformedURLException e) {
\r
66 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
\r
69 public void stop(BundleContext context) throws Exception {
\r
74 * Returns the shared instance
\r
76 * @return the shared instance
\r
78 public static Activator getDefault() {
\r