KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > ui > synchronize > ParticipantSynchronizeWizard


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

11 package org.eclipse.team.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
20 /**
21  * This is a convenience class for creating wizards for use with the
22  * <code>org.eclipse.team.ui.synchronizeWizard</code> extension point.
23  *
24  * @since 3.2
25  */

26 public abstract class ParticipantSynchronizeWizard extends Wizard {
27
28     private WizardPage selectionPage;
29     private IWizard importWizard;
30     
31     /**
32      * Create the wizard.
33      */

34     protected ParticipantSynchronizeWizard() {
35         setDefaultPageImageDescriptor(TeamImages.getImageDescriptor(ITeamUIImages.IMG_WIZBAN_SHARE));
36         setNeedsProgressMonitor(false);
37     }
38     
39     /* (non-Javadoc)
40      * @see org.eclipse.jface.wizard.Wizard#getWindowTitle()
41      */

42     public String JavaDoc getWindowTitle() {
43         return TeamUIMessages.GlobalRefreshSubscriberPage_0;
44     }
45     
46     /* (non-Javadoc)
47      * @see org.eclipse.jface.wizard.Wizard#addPages()
48      */

49     public void addPages() {
50         if (getRootResources().length == 0) {
51             importWizard = getImportWizard();
52             if (importWizard != null){
53                 importWizard.setContainer(getContainer());
54                 importWizard.addPages();
55                 IWizardPage startingPage = importWizard.getStartingPage();
56                 if (startingPage != null) {
57                     startingPage.setTitle(NLS.bind(TeamUIMessages.SubscriberParticipantWizard_0, new String JavaDoc[] { getPageTitle() }));
58                     startingPage.setDescription(NLS.bind(TeamUIMessages.SubscriberParticipantWizard_1, new String JavaDoc[] { importWizard.getWindowTitle() }));
59                 }
60             }
61         } else {
62             selectionPage = createScopeSelectionPage();
63             selectionPage.setTitle(NLS.bind(TeamUIMessages.GlobalRefreshSubscriberPage_1, new String JavaDoc[] { getPageTitle() }));
64             selectionPage.setMessage(TeamUIMessages.GlobalRefreshSubscriberPage_2);
65             addPage(selectionPage);
66         }
67     }
68
69     /* (non-Javadoc)
70      * @see org.eclipse.jface.wizard.IWizard#performFinish()
71      */

72     public boolean performFinish() {
73         if (importWizard != null) {
74             return importWizard.performFinish();
75         } else {
76             createParticipant();
77             return true;
78         }
79     }
80     
81     /* (non-Javadoc)
82      * @see org.eclipse.jface.wizard.Wizard#getNextPage(org.eclipse.jface.wizard.IWizardPage)
83      */

84     public IWizardPage getNextPage(IWizardPage page) {
85         if(importWizard != null ) {
86             return importWizard.getNextPage(page);
87         }
88         return super.getNextPage(page);
89     }
90     
91     /* (non-Javadoc)
92      * @see org.eclipse.jface.wizard.Wizard#performCancel()
93      */

94     public boolean performCancel() {
95         if(importWizard != null) {
96             return importWizard.performCancel();
97         }
98         return super.performCancel();
99     }
100     
101     /* (non-Javadoc)
102      * @see org.eclipse.jface.wizard.Wizard#canFinish()
103      */

104     public boolean canFinish() {
105         if(importWizard != null) {
106             return importWizard.canFinish();
107         }
108         return super.canFinish();
109     }
110     
111     /* (non-Javadoc)
112      * @see org.eclipse.jface.wizard.Wizard#getStartingPage()
113      */

114     public IWizardPage getStartingPage() {
115         if(importWizard != null) {
116             return importWizard.getStartingPage();
117         }
118         return super.getStartingPage();
119     }
120
121     /**
122      * Return the page title for the page used by this wizard.
123      * @return the page title for the page used by this wizard
124      */

125     protected abstract String JavaDoc getPageTitle();
126     
127     /**
128      * Return a wizard that can be used to populate the workspace
129      * if there are no resources returned from {@link #getRootResources()}.
130      * @return a wizard that can be used to populate the workspace
131      */

132     protected abstract IWizard getImportWizard();
133     
134     /**
135      * Return the resources that are the roots of the resource
136      * trees that can be considered for inclusion.
137      * @return the resources that are the roots of the resource
138      * trees that can be considered for inclusion
139      */

140     protected abstract IResource[] getRootResources();
141     
142     /**
143      * Create the page which allows the user to select the scope
144      * for the operation.
145      * @return the page which allows the user to select the scope
146      * for the operation
147      */

148     protected abstract WizardPage createScopeSelectionPage();
149     
150     /**
151      * Method called from {@link #performFinish()} to create
152      * a participant. This participant will be added to the
153      * Synchronize view.
154      */

155     protected abstract void createParticipant();
156     
157 }
158
Popular Tags