KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > ui > internal > HelpUIPlugin


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.ui.internal;
12
13 import org.eclipse.core.runtime.IStatus;
14 import org.eclipse.core.runtime.Platform;
15 import org.eclipse.core.runtime.Status;
16 import org.eclipse.core.runtime.jobs.Job;
17 import org.eclipse.help.internal.HelpPlugin;
18 import org.eclipse.help.internal.base.BaseHelpSystem;
19 import org.eclipse.help.internal.base.HelpBasePlugin;
20 import org.eclipse.help.internal.base.HelpEvaluationContext;
21 import org.eclipse.help.internal.dynamic.FilterResolver;
22 import org.eclipse.help.internal.search.federated.IndexerJob;
23 import org.eclipse.help.ui.internal.dynamic.FilterResolverExtension;
24 import org.eclipse.help.ui.internal.util.ErrorUtil;
25 import org.eclipse.jface.dialogs.ErrorDialog;
26 import org.eclipse.ui.IWorkbench;
27 import org.eclipse.ui.PlatformUI;
28 import org.eclipse.ui.plugin.AbstractUIPlugin;
29 import org.osgi.framework.BundleContext;
30
31 /**
32  * This class is Help UI plugin.
33  */

34 public class HelpUIPlugin extends AbstractUIPlugin {
35
36     public final static String JavaDoc PLUGIN_ID = "org.eclipse.help.ui"; //$NON-NLS-1$
37
// debug options
38
public static boolean DEBUG = false;
39     public static boolean DEBUG_INFOPOP = false;
40
41     private static HelpUIPlugin plugin;
42
43     // private static BundleContext bundleContext;
44
/**
45      * Logs an Error message with an exception. Note that the message should already be localized to
46      * proper locale. ie: Resources.getString() should already have been called
47      */

48     public static synchronized void logError(String JavaDoc message, Throwable JavaDoc ex) {
49         logError(message, ex, true, false);
50     }
51
52     public static synchronized void logError(String JavaDoc message, Throwable JavaDoc ex, boolean log, boolean openDialog) {
53         if (message == null)
54             message = ""; //$NON-NLS-1$
55
Status errorStatus = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, ex);
56         HelpPlugin.getDefault().getLog().log(errorStatus);
57         if (openDialog)
58             ErrorDialog.openError(null, null, null, errorStatus);
59     }
60
61     /**
62      * Provides access to singleton
63      *
64      * @return HelpUIPlugin
65      */

66     public static HelpUIPlugin getDefault() {
67         return plugin;
68     }
69
70     /*
71      * (non-Javadoc)
72      *
73      * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
74      */

75     public void stop(BundleContext context) throws Exception JavaDoc {
76         plugin = null;
77         // Make sure we cancel indexer if it is currently running
78
Job.getJobManager().cancel(IndexerJob.FAMILY);
79         super.stop(context);
80     }
81
82     /*
83      * (non-Javadoc)
84      *
85      * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
86      */

87     public void start(BundleContext context) throws Exception JavaDoc {
88         super.start(context);
89         plugin = this;
90
91         FilterResolver.setExtension(new FilterResolverExtension());
92         HelpEvaluationContext.setContext(HelpUIEvaluationContext.getContext());
93
94         // bundleContext = context;
95
// Setup debugging options
96
DEBUG = isDebugging();
97         if (DEBUG) {
98             DEBUG_INFOPOP = "true".equalsIgnoreCase(Platform.getDebugOption(PLUGIN_ID + "/debug/infopop")); //$NON-NLS-1$ //$NON-NLS-2$
99
}
100
101         if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_WORKBENCH)
102             // UI may get activated during standalone
103
BaseHelpSystem.setDefaultErrorUtil(new ErrorUtil());
104
105         if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_WORKBENCH) {
106             // This is workbench scenario. Set activity support of base help to
107
// use workbench activity support
108
IWorkbench workbench = PlatformUI.getWorkbench();
109             if (workbench != null) {
110                 HelpBasePlugin.setActivitySupport(new HelpActivitySupport(workbench));
111             }
112         }
113     }
114 }
115
Popular Tags