KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > merge > MergeWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.merge;
12
13
14 import org.eclipse.core.resources.IProject;
15 import org.eclipse.core.resources.IResource;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.jface.wizard.Wizard;
18 import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber;
19 import org.eclipse.team.internal.ccvs.core.CVSTag;
20 import org.eclipse.team.internal.ccvs.ui.*;
21 import org.eclipse.team.internal.ccvs.ui.subscriber.MergeSynchronizeParticipant;
22 import org.eclipse.team.ui.TeamUI;
23 import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
24
25 public class MergeWizard extends Wizard {
26     MergeWizardStartPage startPage;
27     MergeWizardEndPage endPage;
28     IResource[] resources;
29
30     public void addPages() {
31         // when merging multiple resources, use the tags found on the first selected
32
// resource. This makes sense because you would typically merge resources that
33
// have a common context and are versioned and branched together.
34
IProject projectForTagRetrieval = resources[0].getProject();
35                 
36         setWindowTitle(Policy.bind("MergeWizard.title")); //$NON-NLS-1$
37
ImageDescriptor mergeImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_MERGE);
38         startPage = new MergeWizardStartPage("startPage", Policy.bind("MergeWizard.start"), mergeImage); //$NON-NLS-1$ //$NON-NLS-2$
39
startPage.setProject(projectForTagRetrieval);
40         addPage(startPage);
41         endPage = new MergeWizardEndPage("endPage", Policy.bind("MergeWizard.end"), mergeImage, startPage); //$NON-NLS-1$ //$NON-NLS-2$
42
endPage.setProject(projectForTagRetrieval);
43         addPage(endPage);
44     }
45
46     /*
47      * @see IWizard#performFinish()
48      */

49     public boolean performFinish() {
50         
51         CVSTag startTag = startPage.getTag();
52         CVSTag endTag = endPage.getTag();
53         
54         // First check if there is an existing matching participant, if so then re-use it
55
MergeSynchronizeParticipant participant = MergeSynchronizeParticipant.getMatchingParticipant(resources, startTag, endTag);
56         if(participant == null) {
57             CVSMergeSubscriber s = new CVSMergeSubscriber(resources, startTag, endTag);
58             participant = new MergeSynchronizeParticipant(s);
59             TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant});
60         }
61         participant.refresh(resources, Policy.bind("Participant.merging"), Policy.bind("Participant.mergingDetail", participant.getName()), null); //$NON-NLS-1$ //$NON-NLS-2$
62
return true;
63     }
64     
65     /*
66      * Set the resources that should be merged.
67      */

68     public void setResources(IResource[] resources) {
69         this.resources = resources;
70     }
71 }
72
Popular Tags