KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > WizardNode


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;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.jface.dialogs.MessageDialog;
15 import org.eclipse.jface.wizard.IWizard;
16 import org.eclipse.jface.wizard.IWizardNode;
17 import org.eclipse.jface.wizard.WizardSelectionPage;
18 import org.eclipse.pde.internal.ui.PDEUIMessages;
19 import org.eclipse.pde.ui.IBasePluginWizard;
20 import org.eclipse.swt.graphics.Point;
21
22 public abstract class WizardNode implements IWizardNode {
23     private IWizard wizard;
24     private WizardSelectionPage parentWizardPage;
25     protected WizardElement wizardElement;
26
27 public WizardNode(WizardSelectionPage parentPage, WizardElement element) {
28     parentWizardPage = parentPage;
29     wizardElement = element;
30 }
31 protected abstract IBasePluginWizard createWizard() throws CoreException;
32 public void dispose() {
33     if (wizard != null) {
34         wizard.dispose();
35         wizard = null;
36     }
37 }
38 public WizardElement getElement() {
39     return wizardElement;
40 }
41 public Point getExtent() {
42     return new Point(-1, -1);
43 }
44 public IWizard getWizard() {
45     if (wizard != null)
46         return wizard; // we've already created it
47

48     IBasePluginWizard pluginWizard;
49     try {
50         pluginWizard = createWizard(); // create instance of target wizard
51
} catch (CoreException e) {
52         if (parentWizardPage instanceof BaseWizardSelectionPage)
53             ((BaseWizardSelectionPage)parentWizardPage).setDescriptionText(""); //$NON-NLS-1$
54
parentWizardPage.setErrorMessage(PDEUIMessages.Errors_CreationError_NoWizard);
55         MessageDialog.openError(
56             parentWizardPage.getWizard().getContainer().getShell(),
57             PDEUIMessages.Errors_CreationError,
58             PDEUIMessages.Errors_CreationError_NoWizard);
59         return null;
60     }
61     wizard = pluginWizard;
62     //wizard.setUseContainerState(false);
63
return wizard;
64 }
65 public boolean isContentCreated() {
66     return wizard != null;
67 }
68 }
69
Popular Tags