1 11 package org.eclipse.team.internal.ccvs.ui.mappings; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.core.resources.mapping.ResourceMapping; 15 import org.eclipse.jface.wizard.IWizard; 16 import org.eclipse.jface.wizard.WizardPage; 17 import org.eclipse.swt.widgets.Shell; 18 import org.eclipse.team.core.mapping.ISynchronizationContext; 19 import org.eclipse.team.core.mapping.ISynchronizationScopeManager; 20 import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; 21 import org.eclipse.team.internal.ccvs.ui.*; 22 import org.eclipse.team.internal.ccvs.ui.actions.CommitAction; 23 import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant; 24 import org.eclipse.team.internal.ccvs.ui.wizards.CheckoutWizard; 25 import org.eclipse.team.internal.ui.mapping.ModelElementSelectionPage; 26 import org.eclipse.team.internal.ui.synchronize.GlobalRefreshElementSelectionPage; 27 import org.eclipse.team.internal.ui.synchronize.GlobalRefreshResourceSelectionPage; 28 import org.eclipse.team.ui.TeamUI; 29 import org.eclipse.team.ui.synchronize.*; 30 31 public class ModelSynchronizeWizard extends ParticipantSynchronizeWizard { 32 33 private GlobalRefreshElementSelectionPage selectionPage; 34 35 private boolean isShowModelSync() { 36 return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_ENABLE_MODEL_SYNC); 37 } 38 39 42 protected void createParticipant() { 43 if (isShowModelSync()) { 44 ISynchronizeParticipant participant = createParticipant( 45 ((ModelElementSelectionPage)selectionPage).getSelectedMappings()); 46 TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[]{participant}); 47 participant.run(null ); 49 } else { 50 IResource[] resources = ((GlobalRefreshResourceSelectionPage)selectionPage).getRootResources(); 51 if (resources != null && resources.length > 0) { 52 SubscriberParticipant participant = createParticipant(((GlobalRefreshResourceSelectionPage)selectionPage).getSynchronizeScope()); 53 TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[]{participant}); 54 participant.run(null ); 56 } 57 } 58 } 59 60 63 protected final WizardPage createScopeSelectionPage() { 64 if (isShowModelSync()) 65 selectionPage = new ModelElementSelectionPage(getRootResources()); 66 else 67 selectionPage = new GlobalRefreshResourceSelectionPage(getRootResources()); 68 return selectionPage; 69 } 70 71 public static ISynchronizeParticipant createWorkspaceParticipant(ResourceMapping[] selectedMappings, Shell shell) { 72 ISynchronizationScopeManager manager = WorkspaceSubscriberContext.createWorkspaceScopeManager(selectedMappings, true, CommitAction.isIncludeChangeSets(shell, CVSUIMessages.SyncAction_1)); 73 WorkspaceModelParticipant p = new WorkspaceModelParticipant( 74 WorkspaceSubscriberContext.createContext(manager, ISynchronizationContext.THREE_WAY)); 75 return p; 76 } 77 78 public ModelSynchronizeWizard() { 79 super(); 80 setNeedsProgressMonitor(isShowModelSync()); 81 } 82 83 protected ISynchronizeParticipant createParticipant(ResourceMapping[] selectedMappings) { 84 return createWorkspaceParticipant(selectedMappings, getShell()); 85 } 86 87 protected SubscriberParticipant createParticipant(ISynchronizeScope scope) { 88 IResource[] roots = scope.getRoots(); 90 if (roots == null) { 91 roots = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().roots(); 92 } 93 WorkspaceSynchronizeParticipant participant = (WorkspaceSynchronizeParticipant)SubscriberParticipant.getMatchingParticipant(WorkspaceSynchronizeParticipant.ID, roots); 94 if (participant == null) { 96 return new WorkspaceSynchronizeParticipant(scope); 97 } else { 98 return participant; 99 } 100 } 101 102 protected String getPageTitle() { 103 ISynchronizeParticipantDescriptor desc = TeamUI.getSynchronizeManager().getParticipantDescriptor(WorkspaceModelParticipant.ID); 104 if(desc != null) { 105 return desc.getName(); 106 } else { 107 return CVSUIMessages.CVSSynchronizeWizard_0; 108 } 109 } 110 111 protected IWizard getImportWizard() { 112 return new CheckoutWizard(); 113 } 114 115 protected IResource[] getRootResources() { 116 return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().roots(); 117 } 118 119 } 120 | Popular Tags |