1 /*******************************************************************************
2 * Copyright (c) 2003, 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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.navigator;
13 import org.eclipse.jface.action.IMenuManager;
15 import org.eclipse.ui.IActionBars;
16 import org.eclipse.ui.IViewPart;
17 import org.eclipse.ui.actions.ActionContext;
18 import org.eclipse.ui.navigator.CommonActionProvider;
19 import org.eclipse.ui.navigator.ICommonActionExtensionSite;
20 import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
22 import org.eclipse.jdt.ui.actions.RefactorActionGroup;
25 * Contributes the following actions to the menu on behalf of the JDT content
29 * <li>{@link RefactorActionGroup}. Contributes the "Refactor>" and "Source>" submenus to the context menu.</li>
32 public class JavaNavigatorRefactorActionProvider extends CommonActionProvider {
34 private RefactorActionGroup fRefactorGroup;
37 public void fillActionBars(IActionBars actionBars) {
38 if (fRefactorGroup != null) {
39 fRefactorGroup.fillActionBars(actionBars);
40 fRefactorGroup.retargetFileMenuActions(actionBars);
45 public void fillContextMenu(IMenuManager menu) {
46 if (fRefactorGroup != null) {
47 fRefactorGroup.fillContextMenu(menu);
52 public void init(ICommonActionExtensionSite site) {
53 ICommonViewerWorkbenchSite workbenchSite= null;
54 if (site.getViewSite() instanceof ICommonViewerWorkbenchSite)
55 workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
57 // we only initialize the refactor group when in a view part
58 // (required for the constructor)
59 if (workbenchSite != null) {
60 if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
61 IViewPart viewPart= (IViewPart) workbenchSite.getPart();
63 fRefactorGroup= new RefactorActionGroup(viewPart);
69 public void setContext(ActionContext context) {
70 if (fRefactorGroup != null) {
71 fRefactorGroup.setContext(context);
76 * @see org.eclipse.ui.actions.ActionGroup#dispose()
80 public void dispose() {
81 if (fRefactorGroup != null)
82 fRefactorGroup.dispose();