1 11 package org.eclipse.team.internal.ui.synchronize.actions; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.jface.action.IContributionItem; 15 import org.eclipse.jface.action.IMenuManager; 16 import org.eclipse.team.internal.ui.synchronize.SynchronizePageConfiguration; 17 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 18 import org.eclipse.team.ui.synchronize.ISynchronizePageSite; 19 import org.eclipse.team.ui.synchronize.SynchronizePageActionGroup; 20 import org.eclipse.ui.IActionBars; 21 import org.eclipse.ui.IViewSite; 22 import org.eclipse.ui.IWorkbenchSite; 23 import org.eclipse.ui.actions.ActionContext; 24 25 28 public class DefaultSynchronizePageActions extends SynchronizePageActionGroup { 29 30 private OpenWithActionGroup openWithActions; 32 private RefactorActionGroup refactorActions; 33 private SyncViewerShowPreferencesAction showPreferences; 34 35 38 public void initialize(ISynchronizePageConfiguration configuration) { 39 super.initialize(configuration); 40 final ISynchronizePageSite site = configuration.getSite(); 41 IWorkbenchSite ws = site.getWorkbenchSite(); 42 if (ws instanceof IViewSite) { 43 openWithActions = new OpenWithActionGroup(configuration, true); 44 refactorActions = new RefactorActionGroup(site); 45 configuration.setProperty(SynchronizePageConfiguration.P_OPEN_ACTION, new Action() { 46 public void run() { 47 openWithActions.openInCompareEditor(); 48 } 49 }); 50 showPreferences = new SyncViewerShowPreferencesAction(configuration); 51 } else { 52 } 54 } 55 56 59 public void fillActionBars(IActionBars actionBars) { 60 if (openWithActions != null) openWithActions.fillActionBars(actionBars); 61 if (refactorActions != null) refactorActions.fillActionBars(actionBars); 62 if (actionBars != null && showPreferences != null) { 63 IMenuManager menu = actionBars.getMenuManager(); 64 appendToGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP, showPreferences); 65 } 66 } 67 68 71 public void updateActionBars() { 72 if (openWithActions != null) openWithActions.updateActionBars(); 73 if (refactorActions != null) refactorActions.updateActionBars(); 74 } 75 76 79 public void fillContextMenu(IMenuManager manager) { 80 81 final IContributionItem fileGroup = findGroup(manager, ISynchronizePageConfiguration.FILE_GROUP); 82 if (openWithActions != null && fileGroup != null) { 83 openWithActions.fillContextMenu(manager, fileGroup.getId()); 84 } 85 86 final IContributionItem editGroup = findGroup(manager, ISynchronizePageConfiguration.EDIT_GROUP); 87 if (refactorActions != null && editGroup != null) { 88 refactorActions.fillContextMenu(manager, editGroup.getId()); 89 } 90 } 91 92 95 public void dispose() { 96 super.dispose(); 97 if (refactorActions != null) refactorActions.dispose(); 98 if (openWithActions != null) openWithActions.dispose(); 99 } 100 101 104 public void setContext(ActionContext context) { 105 if (openWithActions != null) openWithActions.setContext(context); 106 if (refactorActions != null) refactorActions.setContext(context); 107 } 108 } 109 | Popular Tags |