1 11 package org.eclipse.team.internal.ui.synchronize.actions; 12 13 import org.eclipse.core.resources.mapping.ResourceMapping; 14 import org.eclipse.jface.action.Action; 15 import org.eclipse.jface.action.IMenuManager; 16 import org.eclipse.jface.viewers.IStructuredSelection; 17 import org.eclipse.team.internal.ui.Utils; 18 import org.eclipse.team.internal.ui.synchronize.ConfigureRefreshScheduleDialog; 19 import org.eclipse.team.internal.ui.synchronize.IRefreshable; 20 import org.eclipse.team.ui.synchronize.*; 21 import org.eclipse.ui.IActionBars; 22 23 public class RefreshActionContribution extends SynchronizePageActionGroup { 24 private Action configureSchedule; 26 private Action refreshSelectionAction; 27 private org.eclipse.team.internal.ui.mapping.RemoveFromViewAction removeFromViewAction; 28 private org.eclipse.team.internal.ui.mapping.RestoreRemovedItemsAction restoreRemovedItemsAction; 29 30 33 public void initialize(final ISynchronizePageConfiguration configuration) { 34 super.initialize(configuration); 35 final ISynchronizePageSite site = configuration.getSite(); 36 final ModelSynchronizeParticipant participant = (ModelSynchronizeParticipant)configuration.getParticipant(); 37 if (participant.doesSupportSynchronize()) { 39 refreshSelectionAction = new Action() { 40 public void run() { 41 IStructuredSelection selection = (IStructuredSelection)site.getSelectionProvider().getSelection(); 42 ResourceMapping[] mappings = Utils.getResourceMappings(selection.toArray()); 43 participant.refresh(site.getWorkbenchSite(), mappings); 44 } 45 }; 46 Utils.initAction(refreshSelectionAction, "action.refreshWithRemote."); refreshSelectionAction.setActionDefinitionId("org.eclipse.team.ui.synchronizeLast"); refreshSelectionAction.setId("org.eclipse.team.ui.synchronizeLast"); 50 Object o = participant.getAdapter(IRefreshable.class); 51 if (o instanceof IRefreshable) { 52 final IRefreshable refreshable = (IRefreshable) o; 53 configureSchedule = new Action() { 54 public void run() { 55 ConfigureRefreshScheduleDialog d = new ConfigureRefreshScheduleDialog( 56 site.getShell(), refreshable.getRefreshSchedule()); 57 d.setBlockOnOpen(false); 58 d.open(); 59 } 60 }; 61 Utils.initAction(configureSchedule, "action.configureSchedulel."); } 63 } 64 removeFromViewAction = new org.eclipse.team.internal.ui.mapping.RemoveFromViewAction(configuration); 65 restoreRemovedItemsAction = new org.eclipse.team.internal.ui.mapping.RestoreRemovedItemsAction(configuration); 66 appendToGroup(ISynchronizePageConfiguration.P_VIEW_MENU, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, restoreRemovedItemsAction); 67 } 68 69 72 public void fillContextMenu(IMenuManager manager) { 73 if (findGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP) != null 74 && findGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP) != null) { 75 appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, refreshSelectionAction); 77 appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, removeFromViewAction); 78 } else { 79 appendToGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, refreshSelectionAction); 80 appendToGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, removeFromViewAction); 81 } 82 } 83 84 87 public void fillActionBars(IActionBars actionBars) { 88 super.fillActionBars(actionBars); 89 if(actionBars != null) { 90 IMenuManager menu = actionBars.getMenuManager(); 92 if (findGroup(menu, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP) != null 93 && findGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP) != null) { 94 appendToGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP, configureSchedule); 95 } else { 96 appendToGroup(menu, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, configureSchedule); 97 } 98 } 99 } 100 } 101 | Popular Tags |