1 11 package org.eclipse.pde.internal.ui.wizards.product; 12 13 import java.lang.reflect.InvocationTargetException ; 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 32 public void addPages() { 33 fMainPage = new ProductFileWizardPage("product", getSelection()); addPage(fMainPage); 35 } 36 37 40 public boolean performFinish() { 41 try { 42 getContainer().run(false, true, getOperation()); 43 } catch (InvocationTargetException e) { 44 PDEPlugin.logException(e); 45 return false; 46 } catch (InterruptedException 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 65 public void init(IWorkbench workbench, IStructuredSelection currentSelection) { 66 super.init(workbench, currentSelection); 67 setWindowTitle(PDEUIMessages.NewProductFileWizard_windowTitle); 68 setNeedsProgressMonitor(true); 69 } 70 71 74 protected void initializeDefaultPageImageDescriptor() { 75 setDefaultPageImageDescriptor(PDEPluginImages.DESC_PRODUCT_WIZ); 76 } 77 78 } 79 | Popular Tags |