KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > navigator > resources > actions > RefactorActionProvider


1 /*******************************************************************************
2  * Copyright (c) 2006 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  ******************************************************************************/

11
12 package org.eclipse.ui.internal.navigator.resources.actions;
13
14 import org.eclipse.core.commands.operations.IUndoContext;
15 import org.eclipse.core.resources.ResourcesPlugin;
16 import org.eclipse.jface.action.IMenuManager;
17 import org.eclipse.swt.widgets.Tree;
18 import org.eclipse.ui.IActionBars;
19 import org.eclipse.ui.actions.ActionContext;
20 import org.eclipse.ui.navigator.CommonActionProvider;
21 import org.eclipse.ui.navigator.ICommonActionExtensionSite;
22 import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
23 import org.eclipse.ui.operations.UndoRedoActionGroup;
24
25 /**
26  * @since 3.2
27  *
28  */

29 public class RefactorActionProvider extends CommonActionProvider {
30
31     private UndoRedoActionGroup undoRedoGroup;
32
33     private RefactorActionGroup refactorGroup;
34
35     private ICommonActionExtensionSite site;
36
37     /*
38      * (non-Javadoc)
39      *
40      * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
41      */

42     public void init(ICommonActionExtensionSite anActionSite) {
43         site = anActionSite;
44         refactorGroup = new RefactorActionGroup(site.getViewSite().getShell(), (Tree)site.getStructuredViewer().getControl());
45
46         IUndoContext workspaceContext = (IUndoContext) ResourcesPlugin
47                 .getWorkspace().getAdapter(IUndoContext.class);
48         undoRedoGroup = new UndoRedoActionGroup(((ICommonViewerWorkbenchSite) anActionSite.getViewSite()).getSite(),
49                 workspaceContext, true);
50     }
51
52     public void dispose() {
53         undoRedoGroup.dispose();
54         refactorGroup.dispose();
55     }
56
57     public void fillActionBars(IActionBars actionBars) {
58         undoRedoGroup.fillActionBars(actionBars);
59         refactorGroup.fillActionBars(actionBars);
60     }
61
62     public void fillContextMenu(IMenuManager menu) {
63         undoRedoGroup.fillContextMenu(menu);
64         refactorGroup.fillContextMenu(menu);
65     }
66
67     public void setContext(ActionContext context) {
68         undoRedoGroup.setContext(context);
69         refactorGroup.setContext(context);
70     }
71
72     public void updateActionBars() {
73         undoRedoGroup.updateActionBars();
74         refactorGroup.updateActionBars();
75     }
76
77 }
78
Popular Tags