1 11 package org.eclipse.team.internal.ui.synchronize; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.jface.wizard.*; 15 import org.eclipse.osgi.util.NLS; 16 import org.eclipse.team.internal.ui.ITeamUIImages; 17 import org.eclipse.team.internal.ui.TeamUIMessages; 18 import org.eclipse.team.ui.TeamImages; 19 import org.eclipse.team.ui.TeamUI; 20 import org.eclipse.team.ui.synchronize.*; 21 22 25 public abstract class SubscriberParticipantWizard extends Wizard { 26 27 private GlobalRefreshResourceSelectionPage selectionPage; 28 private IWizard importWizard; 29 30 public SubscriberParticipantWizard() { 31 setDefaultPageImageDescriptor(TeamImages.getImageDescriptor(ITeamUIImages.IMG_WIZBAN_SHARE)); 32 setNeedsProgressMonitor(false); 33 } 34 35 38 public String getWindowTitle() { 39 return TeamUIMessages.GlobalRefreshSubscriberPage_0; } 41 42 45 public void addPages() { 46 if (getRootResources().length == 0) { 47 importWizard = getImportWizard(); 48 importWizard.setContainer(getContainer()); 49 importWizard.addPages(); 50 IWizardPage startingPage = importWizard.getStartingPage(); 51 if (startingPage != null) { 52 startingPage.setTitle(NLS.bind(TeamUIMessages.SubscriberParticipantWizard_0, new String [] { getName() })); startingPage.setDescription(NLS.bind(TeamUIMessages.SubscriberParticipantWizard_1, new String [] { importWizard.getWindowTitle() })); } 55 } else { 56 selectionPage = new GlobalRefreshResourceSelectionPage(getRootResources()); 57 selectionPage.setTitle(NLS.bind(TeamUIMessages.GlobalRefreshSubscriberPage_1, new String [] { getName() })); selectionPage.setMessage(TeamUIMessages.GlobalRefreshSubscriberPage_2); addPage(selectionPage); 60 } 61 } 62 63 66 public boolean performFinish() { 67 if (importWizard != null) { 68 return importWizard.performFinish(); 69 } else { 70 IResource[] resources = selectionPage.getRootResources(); 71 if (resources != null && resources.length > 0) { 72 SubscriberParticipant participant = createParticipant(selectionPage.getSynchronizeScope()); 73 TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[]{participant}); 74 participant.run(null ); 76 } 77 return true; 78 } 79 } 80 81 84 public IWizardPage getNextPage(IWizardPage page) { 85 if(importWizard != null ) { 86 return importWizard.getNextPage(page); 87 } 88 return super.getNextPage(page); 89 } 90 91 94 public boolean performCancel() { 95 if(importWizard != null) { 96 return importWizard.performCancel(); 97 } 98 return super.performCancel(); 99 } 100 101 104 public boolean canFinish() { 105 if(importWizard != null) { 106 return importWizard.canFinish(); 107 } 108 return super.canFinish(); 109 } 110 111 114 public IWizardPage getStartingPage() { 115 if(importWizard != null) { 116 return importWizard.getStartingPage(); 117 } 118 return super.getStartingPage(); 119 } 120 121 protected abstract IResource[] getRootResources(); 122 123 protected abstract SubscriberParticipant createParticipant(ISynchronizeScope scope); 124 125 protected abstract String getName(); 126 127 protected abstract IWizard getImportWizard(); 128 } 129 | Popular Tags |