KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > synchronize > SubscriberParticipantWizard


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 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.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 /**
23  * This is the class registered with the org.eclipse.team.ui.synchronizeWizard
24  */

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     /* (non-Javadoc)
36      * @see org.eclipse.jface.wizard.Wizard#getWindowTitle()
37      */

38     public String JavaDoc getWindowTitle() {
39         return TeamUIMessages.GlobalRefreshSubscriberPage_0; //$NON-NLS-1$
40
}
41     
42     /* (non-Javadoc)
43      * @see org.eclipse.jface.wizard.Wizard#addPages()
44      */

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 JavaDoc[] { getName() })); //$NON-NLS-1$
53
startingPage.setDescription(NLS.bind(TeamUIMessages.SubscriberParticipantWizard_1, new String JavaDoc[] { importWizard.getWindowTitle() })); //$NON-NLS-1$
54
}
55         } else {
56             selectionPage = new GlobalRefreshResourceSelectionPage(getRootResources());
57             selectionPage.setTitle(NLS.bind(TeamUIMessages.GlobalRefreshSubscriberPage_1, new String JavaDoc[] { getName() })); //$NON-NLS-1$
58
selectionPage.setMessage(TeamUIMessages.GlobalRefreshSubscriberPage_2); //$NON-NLS-1$
59
addPage(selectionPage);
60         }
61     }
62
63     /* (non-Javadoc)
64      * @see org.eclipse.jface.wizard.IWizard#performFinish()
65      */

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                 // We don't know in which site to show progress because a participant could actually be shown in multiple sites.
75
participant.run(null /* no site */);
76             }
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     protected abstract IResource[] getRootResources();
122     
123     protected abstract SubscriberParticipant createParticipant(ISynchronizeScope scope);
124
125     protected abstract String JavaDoc getName();
126     
127     protected abstract IWizard getImportWizard();
128 }
129
Popular Tags