1 11 package org.eclipse.team.internal.ccvs.ui.wizards; 12 13 14 import java.lang.reflect.InvocationTargetException ; 15 16 import org.eclipse.core.resources.IProject; 17 import org.eclipse.core.resources.mapping.ResourceMapping; 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.jface.resource.ImageDescriptor; 20 import org.eclipse.team.internal.ccvs.core.CVSTag; 21 import org.eclipse.team.internal.ccvs.core.ICVSFolder; 22 import org.eclipse.team.internal.ccvs.core.client.Command; 23 import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; 24 import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; 25 import org.eclipse.team.internal.ccvs.ui.*; 26 import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; 27 import org.eclipse.team.internal.ccvs.ui.tags.*; 28 import org.eclipse.ui.IWorkbenchPart; 29 30 public class UpdateWizard extends ResizableWizard { 31 32 private ResourceMapping[] mappers; 33 private final IWorkbenchPart part; 34 private TagSelectionWizardPage tagSelectionPage; 35 36 public UpdateWizard(IWorkbenchPart part, ResourceMapping[] mappers) { 37 super("UpdateWizard", CVSUIPlugin.getPlugin().getDialogSettings()); this.part = part; 39 this.mappers = mappers; 40 setWindowTitle(CVSUIMessages.UpdateWizard_title); 41 } 42 43 public static void run(IWorkbenchPart part, ResourceMapping[] mappers) { 44 final UpdateWizard wizard = new UpdateWizard(part, mappers); 45 open(part.getSite().getShell(), wizard); 46 } 47 48 public void addPages() { 49 ImageDescriptor substImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_CHECKOUT); 50 tagSelectionPage = new TagSelectionWizardPage("tagPage", CVSUIMessages.UpdateWizard_0, substImage, CVSUIMessages.UpdateWizard_1, TagSource.create(mappers), TagSourceWorkbenchAdapter.INCLUDE_ALL_TAGS); tagSelectionPage.setAllowNoTag(true); 52 tagSelectionPage.setHelpContxtId(IHelpContextIds.UPDATE_TAG_SELETION_PAGE); 53 CVSTag tag = getInitialSelection(); 54 if (tag != null) { 55 tagSelectionPage.setSelection(tag); 56 } 57 addPage(tagSelectionPage); 58 } 59 60 63 private CVSTag getInitialSelection() { 64 try { 65 for (int i = 0; i < mappers.length; i++) { 66 ResourceMapping mapper = mappers[i]; 67 IProject[] projects = mapper.getProjects(); 68 for (int k = 0; k < projects.length; k++) { 69 IProject project = projects[k]; 70 ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project); 71 FolderSyncInfo info = folder.getFolderSyncInfo(); 72 if (info != null) { 73 return info.getTag(); 74 } 75 } 76 } 77 } catch (CoreException e) { 78 CVSUIPlugin.log(e); 79 } 80 return null; 81 } 82 83 86 public boolean performFinish() { 87 try { 88 new UpdateOperation(part, mappers, Command.NO_LOCAL_OPTIONS, tagSelectionPage.getSelectedTag()).run(); 89 } catch (InvocationTargetException e) { 90 CVSUIPlugin.openError(getShell(), null, null, e); 91 return false; 92 } catch (InterruptedException e) { 93 return false; 94 } 95 96 return super.performFinish(); 97 } 98 } 99 | Popular Tags |