1 | package de.uka.ipd.sdq.dsexplore; |
2 | |
3 | import java.io.IOException; |
4 | import java.net.URL; |
5 | |
6 | import org.apache.log4j.PropertyConfigurator; |
7 | import org.eclipse.core.runtime.FileLocator; |
8 | import org.eclipse.core.runtime.Path; |
9 | import org.eclipse.core.runtime.Status; |
10 | import org.eclipse.jface.resource.ImageDescriptor; |
11 | import org.eclipse.ui.plugin.AbstractUIPlugin; |
12 | import org.osgi.framework.BundleContext; |
13 | |
14 | |
15 | |
16 | /** |
17 | * The activator class controls the plug-in life cycle |
18 | */ |
19 | public class DSEPluginActivator extends AbstractUIPlugin { |
20 | |
21 | // The plug-in ID |
22 | public static final String PLUGIN_ID = "de.uka.ipd.sdq.dsexplore"; |
23 | |
24 | // The shared instance |
25 | private static DSEPluginActivator plugin; |
26 | |
27 | //private SimulationDockService service; |
28 | |
29 | /** |
30 | * The constructor |
31 | */ |
32 | public DSEPluginActivator() { |
33 | plugin= this; |
34 | |
35 | } |
36 | |
37 | /* |
38 | * (non-Javadoc) |
39 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) |
40 | */ |
41 | @Override |
42 | public void start(BundleContext context) throws Exception { |
43 | |
44 | super.start(context); |
45 | plugin = this; |
46 | |
47 | PropertyConfigurator.configure(findFile("log4j/log4j.properties")); |
48 | |
49 | //service = new DSESimulationDockService(context); |
50 | |
51 | } |
52 | |
53 | /* |
54 | * (non-Javadoc) |
55 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) |
56 | */ |
57 | @Override |
58 | public void stop(BundleContext context) throws Exception { |
59 | plugin = null; |
60 | |
61 | super.stop(context); |
62 | } |
63 | |
64 | /** |
65 | * Returns the shared instance |
66 | * |
67 | * @return the shared instance |
68 | */ |
69 | public static DSEPluginActivator getDefault() { |
70 | return plugin; |
71 | } |
72 | |
73 | /** |
74 | * Returns an image descriptor for the image file at the given |
75 | * plug-in relative path |
76 | * |
77 | * @param path the path |
78 | * @return the image descriptor |
79 | */ |
80 | public static ImageDescriptor getImageDescriptor(String path) { |
81 | return imageDescriptorFromPlugin(PLUGIN_ID, path); |
82 | } |
83 | |
84 | public static String findFile(String file) |
85 | { |
86 | String result=""; |
87 | try |
88 | { |
89 | |
90 | URL url = FileLocator.find(getDefault().getBundle(), new Path(file), null); |
91 | result= FileLocator.toFileURL(url).getPath().toString(); |
92 | } |
93 | catch(IOException ex) |
94 | { |
95 | ex.printStackTrace(); |
96 | } |
97 | return result; |
98 | } |
99 | |
100 | /**Logs a message to the Eclipse message log. |
101 | * @param severity Severity of the message. |
102 | * @param message The message itself. |
103 | */ |
104 | public static void log(final int severity, final String message) { |
105 | /*Status status = new Status(severity, PLUGIN_ID, message, |
106 | new Throwable()); |
107 | plugin.getLog().log(status);*/ |
108 | plugin.getLog().log(new Status(severity, PLUGIN_ID, message)); |
109 | } |
110 | } |