47829d855f507f978e330291da29ff87d0832367
[phpeclipse.git] /
1 /*******************************************************************************
2  * Copyright (c) 2000, 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 Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpeclipse.phpeditor;
12
13 import org.eclipse.ui.IActionBars;
14 import org.eclipse.ui.IEditorPart;
15 import org.eclipse.ui.texteditor.ITextEditor;
16
17 import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
18
19 public class CompilationUnitEditorActionContributor extends BasicEditorActionContributor {
20         
21         public CompilationUnitEditorActionContributor() {
22                 super();                                
23         }
24
25         /*
26          * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
27          */
28         public void setActiveEditor(IEditorPart part) {
29                 super.setActiveEditor(part);
30                 
31                 ITextEditor textEditor= null;
32                 if (part instanceof ITextEditor)
33                         textEditor= (ITextEditor) part;
34                  
35                 // Source menu.
36                 IActionBars bars= getActionBars();              
37                 bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(textEditor, "Comment")); //$NON-NLS-1$
38                 bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment")); //$NON-NLS-1$
39                 bars.setGlobalActionHandler(PHPdtActionConstants.TOGGLE_COMMENT, getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
40                 bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(textEditor, "Format")); //$NON-NLS-1$
41                 bars.setGlobalActionHandler(PHPdtActionConstants.ADD_BLOCK_COMMENT, getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
42                 bars.setGlobalActionHandler(PHPdtActionConstants.REMOVE_BLOCK_COMMENT, getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
43                 bars.setGlobalActionHandler(PHPdtActionConstants.INDENT, getAction(textEditor, "Indent")); //$NON-NLS-1$ //$NON-NLS-2$
44         }
45 }