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;
11:
12: import org.eclipse.core.runtime.CoreException;
13: import org.eclipse.jface.dialogs.MessageDialog;
14: import org.eclipse.jface.wizard.IWizard;
15: import org.eclipse.jface.wizard.IWizardNode;
16: import org.eclipse.jface.wizard.WizardSelectionPage;
17: import org.eclipse.pde.internal.ui.PDEUIMessages;
18: import org.eclipse.pde.ui.IBasePluginWizard;
19: import org.eclipse.swt.graphics.Point;
20:
21: public abstract class WizardNode implements IWizardNode {
22: private IWizard wizard;
23: private WizardSelectionPage parentWizardPage;
24: protected WizardElement wizardElement;
25:
26: public WizardNode(WizardSelectionPage parentPage,
27: WizardElement element) {
28: parentWizardPage = parentPage;
29: wizardElement = element;
30: }
31:
32: protected abstract IBasePluginWizard createWizard()
33: throws CoreException;
34:
35: public void dispose() {
36: if (wizard != null) {
37: wizard.dispose();
38: wizard = null;
39: }
40: }
41:
42: public WizardElement getElement() {
43: return wizardElement;
44: }
45:
46: public Point getExtent() {
47: return new Point(-1, -1);
48: }
49:
50: public IWizard getWizard() {
51: if (wizard != null)
52: return wizard; // we've already created it
53:
54: IBasePluginWizard pluginWizard;
55: try {
56: pluginWizard = createWizard(); // create instance of target wizard
57: } catch (CoreException e) {
58: if (parentWizardPage instanceof BaseWizardSelectionPage)
59: ((BaseWizardSelectionPage) parentWizardPage)
60: .setDescriptionText(""); //$NON-NLS-1$
61: parentWizardPage
62: .setErrorMessage(PDEUIMessages.Errors_CreationError_NoWizard);
63: MessageDialog.openError(parentWizardPage.getWizard()
64: .getContainer().getShell(),
65: PDEUIMessages.Errors_CreationError,
66: PDEUIMessages.Errors_CreationError_NoWizard);
67: return null;
68: }
69: wizard = pluginWizard;
70: //wizard.setUseContainerState(false);
71: return wizard;
72: }
73:
74: public boolean isContentCreated() {
75: return wizard != null;
76: }
77: }
|