01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.exports;
11:
12: import org.eclipse.jface.dialogs.IDialogSettings;
13: import org.eclipse.jface.viewers.IStructuredSelection;
14: import org.eclipse.jface.wizard.IWizardPage;
15: import org.eclipse.jface.wizard.Wizard;
16: import org.eclipse.pde.internal.ui.IPreferenceConstants;
17: import org.eclipse.pde.internal.ui.PDEPlugin;
18: import org.eclipse.pde.internal.ui.PDEUIMessages;
19: import org.eclipse.ui.IExportWizard;
20: import org.eclipse.ui.IWorkbench;
21: import org.eclipse.ui.PlatformUI;
22:
23: public abstract class BaseExportWizard extends Wizard implements
24: IExportWizard, IPreferenceConstants {
25:
26: protected IStructuredSelection fSelection;
27:
28: /**
29: * The constructor.
30: */
31: public BaseExportWizard() {
32: PDEPlugin.getDefault().getLabelProvider().connect(this );
33: IDialogSettings masterSettings = PDEPlugin.getDefault()
34: .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 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 getSettingsSectionName();
58:
59: public void init(IWorkbench workbench,
60: IStructuredSelection selection) {
61: fSelection = selection;
62: }
63:
64: public boolean performFinish() {
65: saveSettings();
66: if (!PlatformUI.getWorkbench().saveAllEditors(true))
67: return false;
68:
69: if (!performPreliminaryChecks())
70: return false;
71:
72: if (!confirmDelete())
73: return false;
74:
75: scheduleExportJob();
76: return true;
77: }
78:
79: protected void saveSettings() {
80: IDialogSettings settings = getDialogSettings();
81: IWizardPage[] pages = getPages();
82: for (int i = 0; i < pages.length; i++) {
83: ((AbstractExportWizardPage) pages[i])
84: .saveSettings(settings);
85: }
86: }
87:
88: protected abstract boolean performPreliminaryChecks();
89:
90: protected abstract boolean confirmDelete();
91:
92: protected abstract void scheduleExportJob();
93:
94: }
|