|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.s60tools.crashanalyser.corecomponents.plugin; |
|
19 |
|
20 import java.io.File; |
|
21 import java.net.URL; |
|
22 |
|
23 import org.eclipse.core.runtime.FileLocator; |
|
24 import org.eclipse.core.runtime.Plugin; |
|
25 import org.osgi.framework.BundleContext; |
|
26 |
|
27 /** |
|
28 * The activator class controls the plug-in life cycle |
|
29 */ |
|
30 public class CrashAnalyserCoreComponentsPlugin extends Plugin { |
|
31 |
|
32 // The plug-in ID |
|
33 public static final String PLUGIN_ID = "com.nokia.s60tools.crashanalyser.corecomponents"; |
|
34 private String pluginInstallPath = ""; //$NON-NLS-1$ |
|
35 |
|
36 // The shared instance |
|
37 private static CrashAnalyserCoreComponentsPlugin plugin; |
|
38 |
|
39 /** |
|
40 * The constructor |
|
41 */ |
|
42 public CrashAnalyserCoreComponentsPlugin() { |
|
43 // No implementation needed |
|
44 } |
|
45 |
|
46 /* |
|
47 * (non-Javadoc) |
|
48 * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) |
|
49 */ |
|
50 public void start(BundleContext context) throws Exception { |
|
51 super.start(context); |
|
52 plugin = this; |
|
53 } |
|
54 |
|
55 /* |
|
56 * (non-Javadoc) |
|
57 * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) |
|
58 */ |
|
59 public void stop(BundleContext context) throws Exception { |
|
60 plugin = null; |
|
61 super.stop(context); |
|
62 } |
|
63 |
|
64 /** |
|
65 * Returns the shared instance |
|
66 * |
|
67 * @return the shared instance |
|
68 */ |
|
69 public static CrashAnalyserCoreComponentsPlugin getDefault() { |
|
70 return plugin; |
|
71 } |
|
72 |
|
73 /** |
|
74 * Returns the path where this plugin is installed |
|
75 * @return the path where this plugin is installed |
|
76 */ |
|
77 public static String getPluginInstallPath() { |
|
78 try { |
|
79 if ("".equals(plugin.pluginInstallPath)) { //$NON-NLS-1$ |
|
80 // URL to the plugin's root ("/") |
|
81 URL relativeURL = plugin.getBundle().getEntry("/"); //$NON-NLS-1$ |
|
82 // Converting into local path |
|
83 URL localURL = FileLocator.toFileURL(relativeURL); |
|
84 // Getting install location in correct form |
|
85 File f = new File(localURL.getPath()); |
|
86 plugin.pluginInstallPath = f.getAbsolutePath(); |
|
87 } |
|
88 return plugin.pluginInstallPath; |
|
89 } catch (Exception e) { |
|
90 return ""; //$NON-NLS-1$ |
|
91 } |
|
92 } |
|
93 } |