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
10 Klaus Hartlage - www.eclipseproject.de
11 **********************************************************************/
12 package net.sourceforge.phpeclipse.actions;
14 import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
15 import org.eclipse.jface.action.IAction;
16 import org.eclipse.jface.text.TextSelection;
17 import org.eclipse.jface.viewers.ISelection;
18 import org.eclipse.ui.IEditorActionDelegate;
19 import org.eclipse.ui.IEditorPart;
20 import org.eclipse.ui.IWorkbenchWindow;
21 import org.eclipse.ui.actions.ActionDelegate;
23 public class PHPEclipseShowContextHelp extends ActionDelegate implements IEditorActionDelegate {
25 private IWorkbenchWindow window;
26 private PHPEditor editor;
28 public void dispose() {
31 public void init(IWorkbenchWindow window) {
35 public void selectionChanged(IAction action, ISelection selection) {
36 if (!selection.isEmpty()) {
37 if (selection instanceof TextSelection) {
38 action.setEnabled(true);
39 } else if (window.getActivePage() != null && window.getActivePage().getActivePart() != null) {
45 public void run(IAction action) {
47 IEditorPart targetEditor = window.getActivePage().getActiveEditor();
48 if (targetEditor != null && (targetEditor instanceof PHPEditor)) {
49 editor = (PHPEditor) targetEditor;
53 editor.openContextHelp();
57 public void setActiveEditor(IAction action, IEditorPart targetEditor) {
58 if (targetEditor != null && (targetEditor instanceof PHPEditor)) {
59 editor = (PHPEditor) targetEditor;