KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > wizards > GlobalSynchronizeWizard


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.internal.ui.wizards;
12
13 import org.eclipse.jface.dialogs.IDialogSettings;
14 import org.eclipse.jface.wizard.IWizard;
15 import org.eclipse.jface.wizard.Wizard;
16 import org.eclipse.team.internal.ui.*;
17 import org.eclipse.team.internal.ui.ITeamUIImages;
18 import org.eclipse.team.internal.ui.TeamUIPlugin;
19 import org.eclipse.team.ui.TeamImages;
20 import org.eclipse.team.ui.synchronize.ISynchronizeParticipantReference;
21 import org.eclipse.ui.IWorkbench;
22
23 /**
24  * The wizard for synchronizing a synchronize participant.
25  *
26  * @since 3.0
27  */

28 public class GlobalSynchronizeWizard extends Wizard {
29     
30     private final static String JavaDoc DIALOG_SETTINGS_SECTION= "SynchronizeWizard"; //$NON-NLS-1$
31

32     protected IWorkbench workbench;
33     protected GlobalRefreshWizardSelectionPage mainPage;
34     protected ISynchronizeParticipantReference participant;
35
36     public GlobalSynchronizeWizard() {
37         setWindowTitle(TeamUIMessages.GlobalSynchronizeWizard_11);
38         setDefaultPageImageDescriptor(TeamImages.getImageDescriptor(ITeamUIImages.IMG_WIZBAN_SHARE));
39         setForcePreviousAndNextButtons(true);
40         setNeedsProgressMonitor(false);
41         
42         final IDialogSettings pluginSettings= TeamUIPlugin.getPlugin().getDialogSettings();
43         IDialogSettings wizardSettings= pluginSettings.getSection(DIALOG_SETTINGS_SECTION);
44         if (wizardSettings == null) {
45             pluginSettings.addNewSection(DIALOG_SETTINGS_SECTION);
46             wizardSettings= pluginSettings.getSection(DIALOG_SETTINGS_SECTION);
47         }
48         setDialogSettings(wizardSettings);
49     }
50     
51     /*
52      * @see Wizard#addPages
53      */

54     public void addPages() {
55         mainPage = new GlobalRefreshWizardSelectionPage();
56         addPage(mainPage);
57     }
58     
59     /* (non-Javadoc)
60      * @see org.eclipse.jface.wizard.IWizard#canFinish()
61      */

62     public boolean canFinish() {
63         // If we are on the first page, never allow finish unless the selected
64
// wizard has no pages.
65
if (getContainer().getCurrentPage() == mainPage) {
66             if (mainPage.getSelectedWizard() != null && mainPage.getNextPage() == null) {
67                 return true;
68             }
69             return false;
70         }
71         return super.canFinish();
72     }
73
74     /*
75      * @see Wizard#performFinish
76      */

77     public boolean performFinish() {
78         // If we are on the first page and the selected wizard has no pages then allow it to finish.
79
if (getContainer().getCurrentPage() == mainPage) {
80             IWizard noPageWizard = mainPage.getSelectedWizard();
81             if (noPageWizard != null) {
82                 if (noPageWizard.canFinish()) {
83                     mainPage.savePageSettings();
84                     return noPageWizard.performFinish();
85                 }
86             }
87         }
88         mainPage.savePageSettings();
89         return true;
90     }
91 }
92
Popular Tags