KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > exports > BaseExportWizard


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.pde.internal.ui.wizards.exports;
12
13 import org.eclipse.jface.dialogs.IDialogSettings;
14 import org.eclipse.jface.viewers.IStructuredSelection;
15 import org.eclipse.jface.wizard.IWizardPage;
16 import org.eclipse.jface.wizard.Wizard;
17 import org.eclipse.pde.internal.ui.IPreferenceConstants;
18 import org.eclipse.pde.internal.ui.PDEPlugin;
19 import org.eclipse.pde.internal.ui.PDEUIMessages;
20 import org.eclipse.ui.IExportWizard;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.PlatformUI;
23
24 public abstract class BaseExportWizard extends Wizard
25                 implements IExportWizard, IPreferenceConstants {
26
27     protected IStructuredSelection fSelection;
28
29     /**
30      * The constructor.
31      */

32     public BaseExportWizard() {
33         PDEPlugin.getDefault().getLabelProvider().connect(this);
34         IDialogSettings masterSettings = PDEPlugin.getDefault().getDialogSettings();
35         setNeedsProgressMonitor(true);
36         setDialogSettings(getSettingsSection(masterSettings));
37         setWindowTitle(PDEUIMessages.BaseExportWizard_wtitle);
38     }
39     
40     public void dispose() {
41         PDEPlugin.getDefault().getLabelProvider().disconnect(this);
42         super.dispose();
43     }
44
45     public IStructuredSelection getSelection() {
46         return fSelection;
47     }
48
49     public IDialogSettings getSettingsSection(IDialogSettings master) {
50         String JavaDoc name = getSettingsSectionName();
51         IDialogSettings settings = master.getSection(name);
52         if (settings == null)
53             settings = master.addNewSection(name);
54         return settings;
55     }
56     
57     protected abstract String JavaDoc getSettingsSectionName();
58
59     public void init(IWorkbench workbench, IStructuredSelection selection) {
60         fSelection = selection;
61     }
62     
63     public boolean performFinish() {
64         saveSettings();
65         if (!PlatformUI.getWorkbench().saveAllEditors(true))
66             return false;
67                 
68         if (!performPreliminaryChecks())
69             return false;
70         
71         if (!confirmDelete())
72             return false;
73         
74         scheduleExportJob();
75         return true;
76     }
77     
78     protected void saveSettings() {
79         IDialogSettings settings = getDialogSettings();
80         IWizardPage[] pages = getPages();
81         for (int i = 0; i < pages.length; i++) {
82             ((AbstractExportWizardPage)pages[i]).saveSettings(settings);
83         }
84     }
85     
86     protected abstract boolean performPreliminaryChecks();
87     
88     protected abstract boolean confirmDelete();
89     
90     protected abstract void scheduleExportJob();
91     
92 }
93
Popular Tags