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.IPath;
17 import org.eclipse.core.runtime.IPluginDescriptor;
18 import org.eclipse.core.runtime.IStatus;
19 import org.eclipse.core.runtime.Path;
20 import org.eclipse.core.runtime.Platform;
21 import org.eclipse.core.runtime.Status;
22 import org.eclipse.jface.preference.IPreferenceStore;
23 import org.eclipse.swt.widgets.Display;
24 import org.eclipse.swt.widgets.Shell;
25 import org.eclipse.ui.IWorkbenchPage;
26 import org.eclipse.ui.IWorkbenchWindow;
27 import org.eclipse.ui.PlatformUI;
28 import org.eclipse.ui.plugin.AbstractUIPlugin;
29 import org.osgi.framework.BundleContext;
32 * The main plugin class to be used in the desktop.
34 public class PHPHelpPlugin extends AbstractUIPlugin {
35 public static final String PHP_CHM_ENABLED = "_php_chm_enabled";
36 public static final String PHP_CHM_FILE = "_php_chm_file";
37 public static final String PHP_CHM_COMMAND = "_php_chm_command";
40 * The id of the PHP plugin (value <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;
49 public PHPHelpPlugin(IPluginDescriptor descriptor) {
55 * Returns the shared instance.
57 public static PHPHelpPlugin getDefault() {
61 * Returns the workspace instance.
63 public static IWorkspace getWorkspace() {
64 return ResourcesPlugin.getWorkspace();
67 public static IWorkbenchPage getActivePage() {
68 return getDefault().internalGetActivePage();
71 private IWorkbenchPage internalGetActivePage() {
72 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
74 return window.getActivePage();
78 public static IWorkbenchWindow getActiveWorkbenchWindow() {
79 return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
82 public static Shell getActiveWorkbenchShell() {
83 return getActiveWorkbenchWindow().getShell();
86 // public static String getPluginId() {
87 // return getDefault().getDescriptor().getUniqueIdentifier();
90 public static void log(IStatus status) {
91 getDefault().getLog().log(status);
94 public static void log(int severity, String message) {
95 Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null);
98 public static void log(Throwable e) {
99 log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$
102 public static boolean isDebug() {
103 return getDefault().isDebugging();
106 // static IPath getInstallLocation() {
107 // return new Path(getDefault().getDescriptor().getInstallURL().getFile());
110 protected void initializeDefaultPreferences(IPreferenceStore store) {
111 // windows preferences:
112 String windowsSystem = Platform.getWS();
114 if (windowsSystem.equals(Platform.WS_WIN32)) {
115 store.setDefault(PHP_CHM_ENABLED, "false");
116 store.setDefault(PHP_CHM_FILE, "c:\\wampp2\\php\\php_manual_en.chm");
117 store.setDefault(PHP_CHM_COMMAND, "hh.exe \"mk:@MSITStore:{0}::/en/function.{1}.html\"");
119 store.setDefault(PHP_CHM_ENABLED, "false");
120 store.setDefault(PHP_CHM_FILE, "");
121 store.setDefault(PHP_CHM_COMMAND, "");
127 * Returns the standard display to be used. The method first checks, if
128 * the thread calling this method has an associated display. If so, this
129 * display is returned. Otherwise the method returns the default display.
131 public static Display getStandardDisplay() {
132 Display display = Display.getCurrent();
133 if (display == null) {
134 display = Display.getDefault();
139 // public void startup() throws CoreException {
141 // IAdapterManager manager = Platform.getAdapterManager();
142 // manager.registerAdapters(new PHPElementAdapterFactory(), PHPElement.class);
143 // manager.registerAdapters(new ResourceAdapterFactory(), IResource.class);
144 // // externalTools.startUp();
145 // getStandardDisplay().asyncExec(new Runnable() {
146 // public void run() {
147 // //initialize the variable context manager
148 // VariableContextManager.getDefault();
154 // * @see org.eclipse.core.runtime.Plugin#shutdown()
156 // public void shutdown() throws CoreException {
157 // // externalTools.shutDown();
158 // ColorManager.getDefault().dispose();
162 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
164 public void start(BundleContext context) throws Exception {
165 super.start(context);
166 // IAdapterManager manager = Platform.getAdapterManager();
167 // manager.registerAdapters(new PHPElementAdapterFactory(), PHPElement.class);
168 // manager.registerAdapters(new ResourceAdapterFactory(), IResource.class);
169 // // externalTools.startUp();
170 // getStandardDisplay().asyncExec(new Runnable() {
171 // public void run() {
172 // //initialize the variable context manager
173 // VariableContextManager.getDefault();
178 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
180 public void stop(BundleContext context) throws Exception {
181 // ColorManager.getDefault().dispose();