A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.webbrowser / src / net / sourceforge / phpeclipse / webbrowser / internal / WebBrowserEditorActionBarContributor.java
1 /**
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
7  �*
8  * Contributors:
9  *    IBM - Initial API and implementation
10  */
11 package net.sourceforge.phpeclipse.webbrowser.internal;
12
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;
18
19 /**
20  * ActionBarContributor for the Web browser. Just adds cut, copy, paste actions.
21  */
22 public class WebBrowserEditorActionBarContributor implements
23                 IEditorActionBarContributor {
24         protected IActionBars actionBars;
25
26         /**
27          * WebBrowserEditorActionBarContributor constructor comment.
28          */
29         public WebBrowserEditorActionBarContributor() {
30                 super();
31         }
32
33         /**
34          * Initializes this contributor, which is expected to add contributions as
35          * required to the given action bars and global action handlers.
36          * 
37          * @param bars
38          *            the action bars
39          */
40         public void init(IActionBars bars, IWorkbenchPage page) {
41                 this.actionBars = bars;
42         }
43
44         /**
45          * Sets the active editor for the contributor. Implementors should
46          * disconnect from the old editor, connect to the new editor, and update the
47          * actions to reflect the new editor.
48          * 
49          * @param targetEditor
50          *            the new editor target
51          */
52         public void setActiveEditor(IEditorPart targetEditor) {
53                 if (targetEditor instanceof WebBrowserEditor) {
54                         WebBrowserEditor editor = (WebBrowserEditor) targetEditor;
55
56                         actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(),
57                                         editor.getCopyAction());
58                         actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), editor
59                                         .getCutAction());
60                         actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(),
61                                         editor.getPasteAction());
62
63                         editor.updateActions();
64                 }
65         }
66
67         /**
68          * Disposes this contributor.
69          */
70         public void dispose() {
71         }
72 }