1 11 package org.eclipse.team.internal.ui.synchronize; 12 13 import org.eclipse.compare.ICompareNavigator; 14 import org.eclipse.jface.action.*; 15 import org.eclipse.jface.viewers.AbstractTreeViewer; 16 import org.eclipse.jface.viewers.Viewer; 17 import org.eclipse.team.internal.ui.Utils; 18 import org.eclipse.team.internal.ui.synchronize.actions.ExpandAllAction; 19 import org.eclipse.team.internal.ui.synchronize.actions.NavigateAction; 20 import org.eclipse.team.ui.synchronize.*; 21 import org.eclipse.ui.IActionBars; 22 23 26 public class NavigationActionGroup extends SynchronizePageActionGroup { 27 28 private ExpandAllAction expandAllAction; 29 private Action collapseAll; 30 private NavigateAction gotoNext; 31 private NavigateAction gotoPrevious; 32 33 public void initialize(ISynchronizePageConfiguration configuration) { 34 super.initialize(configuration); 35 final Viewer viewer = configuration.getPage().getViewer(); 36 if (viewer instanceof AbstractTreeViewer) { 37 38 expandAllAction = new ExpandAllAction((AbstractTreeViewer) viewer); 39 Utils.initAction(expandAllAction, "action.expandAll."); 41 collapseAll = new Action() { 42 public void run() { 43 if (viewer == null || viewer.getControl().isDisposed() || !(viewer instanceof AbstractTreeViewer)) return; 44 viewer.getControl().setRedraw(false); 45 ((AbstractTreeViewer)viewer).collapseToLevel(viewer.getInput(), AbstractTreeViewer.ALL_LEVELS); 46 viewer.getControl().setRedraw(true); 47 } 48 }; 49 Utils.initAction(collapseAll, "action.collapseAll."); 51 ICompareNavigator nav = (ICompareNavigator)configuration.getProperty(SynchronizePageConfiguration.P_NAVIGATOR); 52 if (nav != null) { 53 gotoNext = new NavigateAction(configuration, true ); 54 gotoPrevious = new NavigateAction(configuration, false ); 55 } 56 } 57 } 58 public void fillContextMenu(IMenuManager manager) { 59 appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, expandAllAction); 60 } 61 public void fillActionBars(IActionBars actionBars) { 62 IToolBarManager manager = actionBars.getToolBarManager(); 63 if (gotoNext != null) 64 appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, gotoNext); 65 if (gotoPrevious != null) 66 appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, gotoPrevious); 67 appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, collapseAll); 68 } 69 } 70 | Popular Tags |