1 11 package org.eclipse.team.internal.ui.mapping; 12 13 import org.eclipse.jface.action.IContributionItem; 14 import org.eclipse.jface.action.IMenuManager; 15 import org.eclipse.jface.viewers.Viewer; 16 import org.eclipse.team.internal.ui.synchronize.actions.RefactorActionGroup; 17 import org.eclipse.team.ui.mapping.ITeamContentProviderManager; 18 import org.eclipse.team.ui.mapping.SynchronizationActionProvider; 19 import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration; 20 import org.eclipse.ui.*; 21 import org.eclipse.ui.actions.ActionContext; 22 import org.eclipse.ui.navigator.*; 23 24 27 public class ResourceModelActionProvider extends SynchronizationActionProvider { 28 29 private RefactorActionGroup refactorActions; 30 31 public ResourceModelActionProvider() { 32 } 33 34 37 protected void initialize() { 38 super.initialize(); 39 ResourceMergeHandler mergeHandler = new ResourceMergeHandler( 41 (ISynchronizePageConfiguration)getExtensionStateModel().getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_PAGE_CONFIGURATION), 42 false ); 43 registerHandler(MERGE_ACTION_ID, mergeHandler); 44 ResourceMergeHandler overwriteHandler = new ResourceMergeHandler( 45 (ISynchronizePageConfiguration)getExtensionStateModel().getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_PAGE_CONFIGURATION), 46 true ); 47 registerHandler(OVERWRITE_ACTION_ID, overwriteHandler); 48 ResourceMarkAsMergedHandler markAsMergedHandler = new ResourceMarkAsMergedHandler( 49 (ISynchronizePageConfiguration)getExtensionStateModel().getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_PAGE_CONFIGURATION)); 50 registerHandler(MARK_AS_MERGE_ACTION_ID, markAsMergedHandler); 51 52 ICommonViewerSite cvs = getActionSite().getViewSite(); 53 ISynchronizePageConfiguration configuration = getSynchronizePageConfiguration(); 54 if (cvs instanceof ICommonViewerWorkbenchSite && configuration != null) { 55 ICommonViewerWorkbenchSite cvws = (ICommonViewerWorkbenchSite) cvs; 56 final IWorkbenchPartSite wps = cvws.getSite(); 57 if (wps instanceof IViewSite) { 58 refactorActions = new RefactorActionGroup(configuration.getSite(), getNavigatorContentService(configuration)); 59 } 60 } 61 } 62 63 private INavigatorContentService getNavigatorContentService(ISynchronizePageConfiguration configuration) { 64 Viewer v = configuration.getPage().getViewer(); 65 if (v instanceof CommonViewer) { 66 CommonViewer cv = (CommonViewer) v; 67 return cv.getNavigatorContentService(); 68 } 69 return null; 70 } 71 72 75 public void fillActionBars(IActionBars actionBars) { 76 super.fillActionBars(actionBars); 77 if (refactorActions != null) refactorActions.fillActionBars(actionBars); 78 } 79 80 83 public void fillContextMenu(IMenuManager menu) { 84 super.fillContextMenu(menu); 85 IContributionItem editGroup = menu.find(ISynchronizePageConfiguration.EDIT_GROUP); 86 if (refactorActions != null && editGroup != null) { 87 refactorActions.fillContextMenu(menu, editGroup.getId()); 88 } 89 } 90 91 94 public void updateActionBars() { 95 super.updateActionBars(); 96 if (refactorActions != null) refactorActions.updateActionBars(); 97 } 98 99 102 public void dispose() { 103 super.dispose(); 104 if (refactorActions != null) refactorActions.dispose(); 105 } 106 107 110 public void setContext(ActionContext context) { 111 super.setContext(context); 112 if (refactorActions != null) refactorActions.setContext(context); 113 } 114 } 115 | Popular Tags |