]> git.uio.no Git - ifi-stolz-refaktor.git/blame - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditorActionContributor.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / javaeditor / CompilationUnitEditorActionContributor.java
CommitLineData
1b2798f6
EK
1/*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.jdt.internal.ui.javaeditor;
12
13import java.util.ResourceBundle;
14
15import org.eclipse.jface.action.IAction;
16import org.eclipse.jface.action.IMenuManager;
17
18import org.eclipse.ui.IActionBars;
19import org.eclipse.ui.IEditorPart;
20import org.eclipse.ui.IWorkbenchActionConstants;
21
22import org.eclipse.ui.texteditor.ITextEditor;
23import org.eclipse.ui.texteditor.ITextEditorActionConstants;
24import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
25import org.eclipse.ui.texteditor.RetargetTextEditorAction;
26
27import org.eclipse.jdt.ui.IContextMenuConstants;
28import org.eclipse.jdt.ui.actions.JdtActionConstants;
29
30public class CompilationUnitEditorActionContributor extends BasicCompilationUnitEditorActionContributor {
31
32 private RetargetTextEditorAction fToggleInsertModeAction;
33
34 public CompilationUnitEditorActionContributor() {
35 super();
36
37 ResourceBundle b= JavaEditorMessages.getBundleForConstructedKeys();
38
39 fToggleInsertModeAction= new RetargetTextEditorAction(b, "CompilationUnitEditorActionContributor.ToggleInsertMode.", IAction.AS_CHECK_BOX); //$NON-NLS-1$
40 fToggleInsertModeAction.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
41 }
42
43
44 /*
45 * @see org.eclipse.jdt.internal.ui.javaeditor.BasicEditorActionContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
46 */
47 @Override
48 public void contributeToMenu(IMenuManager menu) {
49 super.contributeToMenu(menu);
50
51 IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
52 if (editMenu != null) {
53 editMenu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleInsertModeAction);
54 }
55 }
56
57 /*
58 * @see IEditorActionBarContributor#setActiveEditor(IEditorPart)
59 */
60 @Override
61 public void setActiveEditor(IEditorPart part) {
62 super.setActiveEditor(part);
63
64 ITextEditor textEditor= null;
65 if (part instanceof ITextEditor)
66 textEditor= (ITextEditor) part;
67
68 // Source menu.
69 IActionBars bars= getActionBars();
70 bars.setGlobalActionHandler(JdtActionConstants.COMMENT, getAction(textEditor, "Comment")); //$NON-NLS-1$
71 bars.setGlobalActionHandler(JdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment")); //$NON-NLS-1$
72 bars.setGlobalActionHandler(JdtActionConstants.TOGGLE_COMMENT, getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
73 bars.setGlobalActionHandler(JdtActionConstants.FORMAT, getAction(textEditor, "Format")); //$NON-NLS-1$
74 bars.setGlobalActionHandler(JdtActionConstants.FORMAT_ELEMENT, getAction(textEditor, "QuickFormat")); //$NON-NLS-1$
75 bars.setGlobalActionHandler(JdtActionConstants.ADD_BLOCK_COMMENT, getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
76 bars.setGlobalActionHandler(JdtActionConstants.REMOVE_BLOCK_COMMENT, getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
77 bars.setGlobalActionHandler(JdtActionConstants.INDENT, getAction(textEditor, "Indent")); //$NON-NLS-1$
78
79 IAction action= getAction(textEditor, ITextEditorActionConstants.REFRESH);
80 bars.setGlobalActionHandler(ITextEditorActionConstants.REFRESH, action);
81
82 fToggleInsertModeAction.setAction(getAction(textEditor, ITextEditorActionConstants.TOGGLE_INSERT_MODE));
83 }
84}