1 11 package org.eclipse.team.internal.ui.synchronize.actions; 12 13 import org.eclipse.core.resources.IResource; 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.ui.synchronize.*; 20 import org.eclipse.ui.IActionBars; 21 22 25 public final class SubscriberActionContribution extends SynchronizePageActionGroup { 26 27 private Action configureSchedule; 29 private Action refreshSelectionAction; 30 private RemoveFromViewAction removeFromViewAction; 31 private RestoreRemovedItemsAction restoreRemovedItemsAction; 32 33 36 public void initialize(final ISynchronizePageConfiguration configuration) { 37 super.initialize(configuration); 38 final SubscriberParticipant participant = (SubscriberParticipant)configuration.getParticipant(); 39 final ISynchronizePageSite site = configuration.getSite(); 40 if(participant.doesSupportSynchronize()) { 42 43 refreshSelectionAction = new Action() { 44 public void run() { 45 IStructuredSelection selection = (IStructuredSelection)site.getSelectionProvider().getSelection(); 46 IResource[] resources = Utils.getResources(selection.toArray()); 47 if (resources.length == 0) { 48 resources = participant.getResources(); 50 } 51 participant.refresh(resources, null, null, site.getWorkbenchSite()); } 53 }; 54 Utils.initAction(refreshSelectionAction, "action.refreshWithRemote."); refreshSelectionAction.setActionDefinitionId("org.eclipse.team.ui.synchronizeLast"); refreshSelectionAction.setId("org.eclipse.team.ui.synchronizeLast"); 58 configureSchedule = new Action() { 59 public void run() { 60 ConfigureRefreshScheduleDialog d = new ConfigureRefreshScheduleDialog( 61 site.getShell(), participant.getRefreshSchedule()); 62 d.setBlockOnOpen(false); 63 d.open(); 64 } 65 }; 66 Utils.initAction(configureSchedule, "action.configureSchedulel."); } 68 69 removeFromViewAction = new RemoveFromViewAction(configuration); 70 restoreRemovedItemsAction = new RestoreRemovedItemsAction(configuration); 71 appendToGroup(ISynchronizePageConfiguration.P_VIEW_MENU, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, restoreRemovedItemsAction); 72 } 73 74 77 public void fillContextMenu(IMenuManager manager) { 78 if (findGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP) != null 79 && findGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP) != null) { 80 appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, refreshSelectionAction); 82 appendToGroup(manager, ISynchronizePageConfiguration.NAVIGATE_GROUP, removeFromViewAction); 83 } else { 84 appendToGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, refreshSelectionAction); 85 appendToGroup(manager, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, removeFromViewAction); 86 } 87 } 88 89 92 public void fillActionBars(IActionBars actionBars) { 93 super.fillActionBars(actionBars); 94 if(actionBars != null) { 95 IMenuManager menu = actionBars.getMenuManager(); 97 if (findGroup(menu, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP) != null 98 && findGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP) != null) { 99 appendToGroup(menu, ISynchronizePageConfiguration.PREFERENCES_GROUP, configureSchedule); 100 } else { 101 appendToGroup(menu, ISynchronizePageConfiguration.SYNCHRONIZE_GROUP, configureSchedule); 102 } 103 } 104 } 105 } 106 | Popular Tags |