KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 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.core.resources.IFile;
16 import org.eclipse.jface.operation.IRunnableWithProgress;
17 import org.eclipse.jface.viewers.IStructuredSelection;
18 import org.eclipse.pde.internal.ui.PDEPlugin;
19 import org.eclipse.pde.internal.ui.PDEPluginImages;
20 import org.eclipse.pde.internal.ui.PDEUIMessages;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
23
24
25 public class NewProductFileWizard extends BasicNewResourceWizard {
26     
27     private ProductFileWizardPage fMainPage;
28
29     /* (non-Javadoc)
30      * @see org.eclipse.jface.wizard.Wizard#addPages()
31      */

32     public void addPages() {
33         fMainPage = new ProductFileWizardPage("product", getSelection()); //$NON-NLS-1$
34
addPage(fMainPage);
35     }
36
37     /* (non-Javadoc)
38      * @see org.eclipse.jface.wizard.IWizard#performFinish()
39      */

40     public boolean performFinish() {
41         try {
42             getContainer().run(false, true, getOperation());
43         } catch (InvocationTargetException JavaDoc e) {
44             PDEPlugin.logException(e);
45             return false;
46         } catch (InterruptedException JavaDoc e) {
47             return false;
48         }
49         return true;
50     }
51     
52     private IRunnableWithProgress getOperation() {
53         IFile file = fMainPage.createNewFile();
54         int option = fMainPage.getInitializationOption();
55         if (option == ProductFileWizardPage.USE_LAUNCH_CONFIG)
56             return new ProductFromConfigOperation(file, fMainPage.getSelectedLaunchConfiguration());
57         if (option == ProductFileWizardPage.USE_PRODUCT)
58             return new ProductFromExtensionOperation(file, fMainPage.getSelectedProduct());
59         return new BaseProductCreationOperation(file);
60     }
61     
62     /* (non-Javadoc)
63      * @see org.eclipse.ui.wizards.newresource.BasicNewResourceWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
64      */

65     public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
66         super.init(workbench, currentSelection);
67         setWindowTitle(PDEUIMessages.NewProductFileWizard_windowTitle);
68         setNeedsProgressMonitor(true);
69     }
70     
71     /* (non-Javadoc)
72      * @see org.eclipse.ui.wizards.newresource.BasicNewResourceWizard#initializeDefaultPageImageDescriptor()
73      */

74     protected void initializeDefaultPageImageDescriptor() {
75         setDefaultPageImageDescriptor(PDEPluginImages.DESC_PRODUCT_WIZ);
76     }
77
78 }
79
Popular Tags