1 11 package org.eclipse.jdt.internal.ui.workingsets; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.core.runtime.Assert; 18 19 import org.eclipse.jface.action.Action; 20 import org.eclipse.jface.action.ActionContributionItem; 21 import org.eclipse.jface.action.IContributionItem; 22 import org.eclipse.jface.action.IMenuManager; 23 24 import org.eclipse.ui.IActionBars; 25 import org.eclipse.ui.IWorkbenchPartSite; 26 import org.eclipse.ui.actions.ActionGroup; 27 28 public class WorkingSetShowActionGroup extends ActionGroup implements IWorkingSetActionGroup { 29 30 private List fContributions= new ArrayList (); 31 private ConfigureWorkingSetAction fConfigureWorkingSetAction; 32 private WorkingSetModel fWorkingSetModel; 33 private final IWorkbenchPartSite fSite; 34 35 public WorkingSetShowActionGroup(IWorkbenchPartSite site) { 36 Assert.isNotNull(site); 37 fSite= site; 38 } 39 40 public void setWorkingSetMode(WorkingSetModel model) { 41 Assert.isNotNull(model); 42 fWorkingSetModel= model; 43 if (fConfigureWorkingSetAction != null) 44 fConfigureWorkingSetAction.setWorkingSetModel(fWorkingSetModel); 45 } 46 47 50 public void fillActionBars(IActionBars actionBars) { 51 super.fillActionBars(actionBars); 52 IMenuManager menuManager= actionBars.getMenuManager(); 53 fillViewMenu(menuManager); 54 } 55 56 public void fillViewMenu(IMenuManager menuManager) { 57 fConfigureWorkingSetAction= new ConfigureWorkingSetAction(fSite); 58 if (fWorkingSetModel != null) 59 fConfigureWorkingSetAction.setWorkingSetModel(fWorkingSetModel); 60 addAction(menuManager, fConfigureWorkingSetAction); 61 } 62 63 public void cleanViewMenu(IMenuManager menuManager) { 64 for (Iterator iter= fContributions.iterator(); iter.hasNext();) { 65 IContributionItem removed= menuManager.remove((IContributionItem) iter.next()); 66 if (removed != null) { 67 removed.dispose(); 68 } 69 } 70 fContributions.clear(); 71 } 72 73 private void addAction(IMenuManager menuManager, Action action) { 74 IContributionItem item= new ActionContributionItem(action); 75 menuManager.appendToGroup(ACTION_GROUP, item); 76 fContributions.add(item); 77 } 78 } 79 | Popular Tags |