KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > product > ProductIntroWizard


1 /*******************************************************************************
2  * Copyright (c) 2005 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.product;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.jface.dialogs.MessageDialog;
16 import org.eclipse.jface.wizard.Wizard;
17 import org.eclipse.pde.internal.core.iproduct.IProduct;
18 import org.eclipse.pde.internal.ui.PDEPluginImages;
19 import org.eclipse.pde.internal.ui.PDEUIMessages;
20
21 public class ProductIntroWizard extends Wizard {
22
23     private ProductDefinitonWizardPage fProductDefinitionPage;
24     private ProductIntroWizardPage fNewIntroPage;
25     private boolean fNeedNewProduct;
26     private String JavaDoc fIntroId;
27     private String JavaDoc fProductId;
28     private String JavaDoc fPluginId;
29     private String JavaDoc fApplication;
30     private IProduct fProduct;
31     
32     public ProductIntroWizard(IProduct product, boolean needNewProduct) {
33         setDefaultPageImageDescriptor(PDEPluginImages.DESC_DEFCON_WIZ);
34         setNeedsProgressMonitor(true);
35         fProduct = product;
36         fNeedNewProduct = needNewProduct;
37         setWindowTitle(PDEUIMessages.ProductIntroWizard_title);
38     }
39     
40     public void addPages() {
41         if (fNeedNewProduct) {
42             fProductDefinitionPage = new ProductDefinitonWizardPage("product", fProduct); //$NON-NLS-1$
43
addPage(fProductDefinitionPage);
44         }
45         fNewIntroPage = new ProductIntroWizardPage("intro", fProduct); //$NON-NLS-1$
46
addPage(fNewIntroPage);
47     }
48
49     public boolean performFinish() {
50         try {
51             if (fNeedNewProduct) {
52                 fProductId = fProductDefinitionPage.getProductId();
53                 fPluginId = fProductDefinitionPage.getDefiningPlugin();
54                 fApplication = fProductDefinitionPage.getApplication();
55                 String JavaDoc newProductName = fProductDefinitionPage.getProductName();
56                 if (newProductName != null)
57                     fProduct.setName(newProductName);
58                 fProduct.setId(getProductId());
59                 fProduct.setApplication(fApplication);
60                 getContainer().run(
61                         false,
62                         true,
63                         new ProductDefinitionOperation(fProduct,
64                                 fPluginId, fProductId, fApplication,
65                                 getContainer().getShell()));
66             }
67             
68             fIntroId = fNewIntroPage.getIntroId();
69             if (fPluginId == null)
70                 fPluginId = fNewIntroPage.getDefiningPlugin();
71             getContainer().run(
72                     false,
73                     true,
74                     new ProductIntroOperation(fProduct, fPluginId, fIntroId, getContainer().getShell()));
75         } catch (InvocationTargetException JavaDoc e) {
76             MessageDialog.openError(getContainer().getShell(), PDEUIMessages.ProductDefinitionWizard_error, e.getTargetException().getMessage());
77             return false;
78         } catch (InterruptedException JavaDoc e) {
79             return false;
80         }
81         return true;
82     }
83     
84     public String JavaDoc getIntroId() {
85         return fIntroId;
86     }
87     
88     public String JavaDoc getProductId() {
89         return fPluginId + "." + fProductId; //$NON-NLS-1$
90
}
91     
92     public String JavaDoc getApplication() {
93         return fApplication;
94     }
95
96 }
97
Popular Tags