001: /*******************************************************************************
002: * Copyright (c) 2005 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.product;
011:
012: import java.lang.reflect.InvocationTargetException;
013:
014: import org.eclipse.jface.dialogs.MessageDialog;
015: import org.eclipse.jface.wizard.Wizard;
016: import org.eclipse.pde.internal.core.iproduct.IProduct;
017: import org.eclipse.pde.internal.ui.PDEPluginImages;
018: import org.eclipse.pde.internal.ui.PDEUIMessages;
019:
020: public class ProductIntroWizard extends Wizard {
021:
022: private ProductDefinitonWizardPage fProductDefinitionPage;
023: private ProductIntroWizardPage fNewIntroPage;
024: private boolean fNeedNewProduct;
025: private String fIntroId;
026: private String fProductId;
027: private String fPluginId;
028: private String fApplication;
029: private IProduct fProduct;
030:
031: public ProductIntroWizard(IProduct product, boolean needNewProduct) {
032: setDefaultPageImageDescriptor(PDEPluginImages.DESC_DEFCON_WIZ);
033: setNeedsProgressMonitor(true);
034: fProduct = product;
035: fNeedNewProduct = needNewProduct;
036: setWindowTitle(PDEUIMessages.ProductIntroWizard_title);
037: }
038:
039: public void addPages() {
040: if (fNeedNewProduct) {
041: fProductDefinitionPage = new ProductDefinitonWizardPage(
042: "product", fProduct); //$NON-NLS-1$
043: addPage(fProductDefinitionPage);
044: }
045: fNewIntroPage = new ProductIntroWizardPage("intro", fProduct); //$NON-NLS-1$
046: addPage(fNewIntroPage);
047: }
048:
049: public boolean performFinish() {
050: try {
051: if (fNeedNewProduct) {
052: fProductId = fProductDefinitionPage.getProductId();
053: fPluginId = fProductDefinitionPage.getDefiningPlugin();
054: fApplication = fProductDefinitionPage.getApplication();
055: String newProductName = fProductDefinitionPage
056: .getProductName();
057: if (newProductName != null)
058: fProduct.setName(newProductName);
059: fProduct.setId(getProductId());
060: fProduct.setApplication(fApplication);
061: getContainer().run(
062: false,
063: true,
064: new ProductDefinitionOperation(fProduct,
065: fPluginId, fProductId, fApplication,
066: getContainer().getShell()));
067: }
068:
069: fIntroId = fNewIntroPage.getIntroId();
070: if (fPluginId == null)
071: fPluginId = fNewIntroPage.getDefiningPlugin();
072: getContainer().run(
073: false,
074: true,
075: new ProductIntroOperation(fProduct, fPluginId,
076: fIntroId, getContainer().getShell()));
077: } catch (InvocationTargetException e) {
078: MessageDialog.openError(getContainer().getShell(),
079: PDEUIMessages.ProductDefinitionWizard_error, e
080: .getTargetException().getMessage());
081: return false;
082: } catch (InterruptedException e) {
083: return false;
084: }
085: return true;
086: }
087:
088: public String getIntroId() {
089: return fIntroId;
090: }
091:
092: public String getProductId() {
093: return fPluginId + "." + fProductId; //$NON-NLS-1$
094: }
095:
096: public String getApplication() {
097: return fApplication;
098: }
099:
100: }
|