1 11 package org.eclipse.ui.internal.navigator.resources.actions; 12 13 import org.eclipse.jface.viewers.IStructuredSelection; 14 import org.eclipse.jface.viewers.StructuredSelection; 15 import org.eclipse.swt.widgets.Shell; 16 import org.eclipse.ui.IActionBars; 17 import org.eclipse.ui.actions.ActionContext; 18 import org.eclipse.ui.actions.AddBookmarkAction; 19 import org.eclipse.ui.actions.AddTaskAction; 20 import org.eclipse.ui.ide.IDEActionFactory; 21 import org.eclipse.ui.navigator.CommonActionProvider; 22 import org.eclipse.ui.navigator.ICommonActionExtensionSite; 23 24 30 public class WorkManagementActionProvider extends CommonActionProvider { 31 32 private AddTaskAction addTaskAction; 33 34 private AddBookmarkAction addBookmarkAction; 35 36 public void init(ICommonActionExtensionSite aSite) { 37 Shell shell = aSite.getViewSite().getShell(); 38 addBookmarkAction = new AddBookmarkAction(shell); 39 addTaskAction = new AddTaskAction(shell); 40 } 41 42 47 public void fillActionBars(IActionBars actionBars) { 48 super.fillActionBars(actionBars); 49 actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), 50 addBookmarkAction); 51 actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), 52 addTaskAction); 53 } 54 55 60 public void setContext(ActionContext context) { 61 super.setContext(context); 62 if (context != null && context.getSelection() instanceof IStructuredSelection) { 63 IStructuredSelection sSel = (IStructuredSelection) context 64 .getSelection(); 65 addBookmarkAction.selectionChanged(sSel); 66 addTaskAction.selectionChanged(sSel); 67 } else { 68 addBookmarkAction.selectionChanged(StructuredSelection.EMPTY); 69 addTaskAction.selectionChanged(StructuredSelection.EMPTY); 70 } 71 } 72 73 } 74 | Popular Tags |