1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. 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
9 IBM Corporation - Initial implementation
11 **********************************************************************/
12 package net.sourceforge.phpdt.phphelp;
14 import org.eclipse.core.resources.IWorkspace;
15 import org.eclipse.core.resources.ResourcesPlugin;
16 import org.eclipse.core.runtime.IStatus;
17 import org.eclipse.core.runtime.Platform;
18 import org.eclipse.core.runtime.Status;
19 import org.eclipse.jface.preference.IPreferenceStore;
20 import org.eclipse.swt.widgets.Display;
21 import org.eclipse.swt.widgets.Shell;
22 import org.eclipse.ui.IWorkbenchPage;
23 import org.eclipse.ui.IWorkbenchWindow;
24 import org.eclipse.ui.PlatformUI;
25 import org.eclipse.ui.plugin.AbstractUIPlugin;
26 import org.osgi.framework.BundleContext;
29 * The main plugin class to be used in the desktop.
31 public class PHPHelpPlugin extends AbstractUIPlugin {
32 public static final String PHP_CHM_ENABLED = "_php_chm_enabled";
34 public static final String PHP_CHM_FILE = "_php_chm_file";
36 public static final String PHP_CHM_COMMAND = "_php_chm_command";
39 * The id of the PHP plugin (value
40 * <code>"net.sourceforge.phpeclipse.phphelp"</code>).
42 public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.phphelp"; //$NON-NLS-1$
44 // The shared instance.
45 private static PHPHelpPlugin plugin;
50 public PHPHelpPlugin() {
56 * Returns the shared instance.
58 public static PHPHelpPlugin getDefault() {
63 * Returns the workspace instance.
65 public static IWorkspace getWorkspace() {
66 return ResourcesPlugin.getWorkspace();
69 public static IWorkbenchPage getActivePage() {
70 return getDefault().internalGetActivePage();
73 private IWorkbenchPage internalGetActivePage() {
74 IWorkbenchWindow window = PlatformUI.getWorkbench()
75 .getActiveWorkbenchWindow();
77 return window.getActivePage();
81 public static IWorkbenchWindow getActiveWorkbenchWindow() {
82 return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
85 public static Shell getActiveWorkbenchShell() {
86 return getActiveWorkbenchWindow().getShell();
89 public static void log(IStatus status) {
90 getDefault().getLog().log(status);
93 public static void log(int severity, String message) {
94 Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message,
99 public static void log(Throwable e) {
100 log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR,
101 "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$
104 public static boolean isDebug() {
105 return getDefault().isDebugging();
108 protected void initializeDefaultPreferences(IPreferenceStore store) {
109 // windows preferences:
110 String windowsSystem = Platform.getWS();
112 if (windowsSystem.equals(Platform.WS_WIN32)) {
113 store.setDefault(PHP_CHM_ENABLED, "false");
115 .setDefault(PHP_CHM_FILE,
116 "c:\\wampp2\\php\\php_manual_en.chm");
117 store.setDefault(PHP_CHM_COMMAND,
118 "hh.exe \"mk:@MSITStore:{0}::/en/function.{1}.html\"");
120 store.setDefault(PHP_CHM_ENABLED, "false");
121 store.setDefault(PHP_CHM_FILE, "");
122 store.setDefault(PHP_CHM_COMMAND, "");
128 * Returns the standard display to be used. The method first checks, if the
129 * thread calling this method has an associated display. If so, this display
130 * is returned. Otherwise the method returns the default display.
132 public static Display getStandardDisplay() {
133 Display display = Display.getCurrent();
134 if (display == null) {
135 display = Display.getDefault();
140 // public void startup() throws CoreException {
142 // IAdapterManager manager = Platform.getAdapterManager();
143 // manager.registerAdapters(new PHPElementAdapterFactory(),
144 // PHPElement.class);
145 // manager.registerAdapters(new ResourceAdapterFactory(), IResource.class);
146 // // externalTools.startUp();
147 // getStandardDisplay().asyncExec(new Runnable() {
148 // public void run() {
149 // //initialize the variable context manager
150 // VariableContextManager.getDefault();
156 // * @see org.eclipse.core.runtime.Plugin#shutdown()
158 // public void shutdown() throws CoreException {
159 // // externalTools.shutDown();
160 // ColorManager.getDefault().dispose();
166 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
168 public void start(BundleContext context) throws Exception {
169 super.start(context);
170 // IAdapterManager manager = Platform.getAdapterManager();
171 // manager.registerAdapters(new PHPElementAdapterFactory(),
172 // PHPElement.class);
173 // manager.registerAdapters(new ResourceAdapterFactory(),
175 // // externalTools.startUp();
176 // getStandardDisplay().asyncExec(new Runnable() {
177 // public void run() {
178 // //initialize the variable context manager
179 // VariableContextManager.getDefault();
187 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
189 public void stop(BundleContext context) throws Exception {
190 // ColorManager.getDefault().dispose();