KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > webapp > HelpWebappPlugin


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.internal.webapp;
12
13 import org.eclipse.core.runtime.*;
14 import org.osgi.framework.*;
15
16 /**
17  * Welp web application plug-in.
18  */

19 public class HelpWebappPlugin extends Plugin {
20     public final static String JavaDoc PLUGIN_ID = "org.eclipse.help.webapp"; //$NON-NLS-1$
21

22     // debug options
23
public static boolean DEBUG = false;
24
25     public static boolean DEBUG_WORKINGSETS = false;
26
27     protected static HelpWebappPlugin plugin;
28
29     //private static BundleContext bundleContext;
30

31     /**
32      * Logs an Error message with an exception.
33      */

34     public static synchronized void logError(String JavaDoc message, Throwable JavaDoc ex) {
35         if (message == null)
36             message = ""; //$NON-NLS-1$
37
Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK,
38                 message, ex);
39         HelpWebappPlugin.getDefault().getLog().log(errorStatus);
40     }
41
42     /**
43      * Logs a Warning message with an exception. Note that the message should
44      * already be localized to proper locale. ie: WebappResources.getString()
45      * should already have been called
46      */

47     public static synchronized void logWarning(String JavaDoc message) {
48         if (HelpWebappPlugin.DEBUG) {
49             if (message == null)
50                 message = ""; //$NON-NLS-1$
51
Status warningStatus = new Status(IStatus.WARNING, PLUGIN_ID,
52                     IStatus.OK, message, null);
53             HelpWebappPlugin.getDefault().getLog().log(warningStatus);
54         }
55     }
56
57     /**
58      * @return the singleton instance of the help webapp plugin
59      */

60     public static HelpWebappPlugin getDefault() {
61         return plugin;
62     }
63
64     /*
65      * (non-Javadoc)
66      *
67      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
68      */

69     public void start(BundleContext context) throws Exception JavaDoc {
70         super.start(context);
71         plugin = this;
72         //bundleContext = context;
73
// Setup debugging options
74
// Setup debugging options
75
DEBUG = isDebugging();
76         if (DEBUG) {
77             DEBUG_WORKINGSETS = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.help.webapp/debug/workingsets")); //$NON-NLS-1$ //$NON-NLS-2$
78
}
79     }
80
81     /*
82      * (non-Javadoc)
83      *
84      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
85      */

86     public void stop(BundleContext context) throws Exception JavaDoc {
87         plugin = null;
88         //bundleContext = null;
89
super.stop(context);
90     }
91 }
92
Popular Tags