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