]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/Activator.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.common / src / org / simantics / browsing / ui / common / Activator.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.browsing.ui.common;
13
14 import java.net.URL;
15
16 import org.eclipse.core.runtime.Plugin;
17 import org.osgi.framework.BundleContext;
18
19 /**
20  * The activator class controls the plug-in life cycle
21  */
22 public class Activator extends Plugin {
23
24     // The plug-in ID
25     public static final String PLUGIN_ID = "org.simantics.browsing.ui.common";
26
27     /** Error logger */
28     private ErrorLogger errorLogger = new ErrorLogger(this);
29     
30     private static Activator plugin;
31     
32     /* (non-Javadoc)
33      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
34      */
35     public void start(BundleContext context) throws Exception {
36         super.start(context);
37         plugin = this;
38     }
39
40     /* (non-Javadoc)
41      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
42      */
43     public void stop(BundleContext context) throws Exception {
44         super.stop(context);
45         plugin = null;
46     }
47
48     public static Activator getDefault() {
49         return plugin;
50     }
51     
52     public static URL getDefaultResource(String name) {
53         Activator plugin = getDefault();
54         if(plugin == null) throw new IllegalStateException("The plugin is not active.");
55         return plugin.getBundle().getResource(name);
56     }
57     
58     public ErrorLogger getErrorLogger() {
59         return errorLogger;
60     }  
61     
62 }