1 11 package org.eclipse.pde.internal.ui.wizards.product; 12 13 import java.lang.reflect.InvocationTargetException ; 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 fIntroId; 27 private String fProductId; 28 private String fPluginId; 29 private String 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); addPage(fProductDefinitionPage); 44 } 45 fNewIntroPage = new ProductIntroWizardPage("intro", fProduct); 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 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 e) { 76 MessageDialog.openError(getContainer().getShell(), PDEUIMessages.ProductDefinitionWizard_error, e.getTargetException().getMessage()); 77 return false; 78 } catch (InterruptedException e) { 79 return false; 80 } 81 return true; 82 } 83 84 public String getIntroId() { 85 return fIntroId; 86 } 87 88 public String getProductId() { 89 return fPluginId + "." + fProductId; } 91 92 public String getApplication() { 93 return fApplication; 94 } 95 96 } 97 | Popular Tags |