A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.webbrowser / src / net / sourceforge / phpeclipse / webbrowser / internal / WebBrowserUIPlugin.java
1 /**
2  * Copyright (c) 2003 IBM Corporation and others.
3  * All rights reserved. � This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  �*
8  * Contributors:
9  *    IBM - Initial API and implementation
10  */
11 package net.sourceforge.phpeclipse.webbrowser.internal;
12
13 import java.text.MessageFormat;
14
15 import org.eclipse.core.runtime.Platform;
16 import org.eclipse.ui.plugin.AbstractUIPlugin;
17 import org.osgi.framework.BundleContext;
18
19 /**
20  * The main web browser plugin class.
21  */
22 public class WebBrowserUIPlugin extends AbstractUIPlugin {
23         // Web browser plugin id
24         public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.webbrowser";
25
26         // singleton instance of this class
27         private static WebBrowserUIPlugin singleton;
28
29         /**
30          * Create the WebBrowserUIPlugin
31          */
32         public WebBrowserUIPlugin() {
33                 super();
34                 singleton = this;
35         }
36
37         /**
38          * Returns the singleton instance of this plugin.
39          * 
40          * @return net.sourceforge.phpeclipse.webbrowser.WebBrowserPlugin
41          */
42         public static WebBrowserUIPlugin getInstance() {
43                 return singleton;
44         }
45
46         /**
47          * Returns the translated String found with the given key.
48          * 
49          * @param key
50          *            java.lang.String
51          * @return java.lang.String
52          */
53         public static String getResource(String key) {
54                 try {
55                         return Platform.getResourceString(getInstance().getBundle(), key);
56                 } catch (Exception e) {
57                         return key;
58                 }
59         }
60
61         /**
62          * Returns the translated String found with the given key, and formatted
63          * with the given arguments using java.text.MessageFormat.
64          * 
65          * @param key
66          *            java.lang.String
67          * @param arg
68          *            java.lang.String
69          * @return java.lang.String
70          */
71         public static String getResource(String key, String arg) {
72                 try {
73                         String text = getResource(key);
74                         return MessageFormat.format(text, new String[] { arg });
75                 } catch (Exception e) {
76                         return key;
77                 }
78         }
79
80         public void start(BundleContext context) throws Exception {
81                 super.start(context);
82                 WebBrowserPreference.initializeDefaultPreferences();
83         }
84
85         /**
86          * Shuts down this plug-in and saves all plug-in state.
87          * 
88          * @exception Exception
89          */
90         public void stop(BundleContext context) throws Exception {
91                 super.stop(context);
92                 BrowserManager.getInstance().dispose();
93         }
94 }