2 * Copyright (c) 2003 IBM Corporation 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 - Initial API and implementation
11 package net.sourceforge.phpeclipse.webbrowser.internal;
13 import org.eclipse.ui.IActionBars;
14 import org.eclipse.ui.IEditorActionBarContributor;
15 import org.eclipse.ui.IEditorPart;
16 import org.eclipse.ui.IWorkbenchPage;
17 import org.eclipse.ui.actions.ActionFactory;
19 * ActionBarContributor for the Web browser.
20 * Just adds cut, copy, paste actions.
22 public class WebBrowserEditorActionBarContributor implements IEditorActionBarContributor {
23 protected IActionBars actionBars;
26 * WebBrowserEditorActionBarContributor constructor comment.
28 public WebBrowserEditorActionBarContributor() {
33 * Initializes this contributor, which is expected to add contributions as
34 * required to the given action bars and global action handlers.
36 * @param bars the action bars
38 public void init(IActionBars bars, IWorkbenchPage page) {
39 this.actionBars = bars;
43 * Sets the active editor for the contributor.
44 * Implementors should disconnect from the old editor, connect to the
45 * new editor, and update the actions to reflect the new editor.
47 * @param targetEditor the new editor target
49 public void setActiveEditor(IEditorPart targetEditor) {
50 if (targetEditor instanceof WebBrowserEditor) {
51 WebBrowserEditor editor = (WebBrowserEditor) targetEditor;
53 actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), editor.getCopyAction());
54 actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), editor.getCutAction());
55 actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), editor.getPasteAction());
57 editor.updateActions();
62 * Disposes this contributor.
64 public void dispose() { }