1 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 29 public class RefactorActionProvider extends CommonActionProvider { 30 31 private UndoRedoActionGroup undoRedoGroup; 32 33 private RefactorActionGroup refactorGroup; 34 35 private ICommonActionExtensionSite site; 36 37 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 |