1 11 12 package org.eclipse.pde.internal.ui.wizards.cheatsheet; 13 14 import java.lang.reflect.InvocationTargetException ; 15 16 import org.eclipse.core.resources.IFile; 17 import org.eclipse.jface.operation.IRunnableWithProgress; 18 import org.eclipse.jface.viewers.IStructuredSelection; 19 import org.eclipse.pde.internal.ui.PDEPlugin; 20 import org.eclipse.pde.internal.ui.PDEPluginImages; 21 import org.eclipse.pde.internal.ui.PDEUIMessages; 22 import org.eclipse.ui.INewWizard; 23 import org.eclipse.ui.IWorkbench; 24 import org.eclipse.ui.wizards.newresource.BasicNewFileResourceWizard; 25 26 30 public class NewCSFileWizard extends BasicNewFileResourceWizard implements INewWizard { 31 32 protected CSFileWizardPage fMainPage; 33 34 37 public NewCSFileWizard() { 38 super(); 39 } 40 41 44 public void addPages() { 45 fMainPage = new CSFileWizardPage("cheatsheet", getSelection()); addPage(fMainPage); 47 } 48 49 52 public void init(IWorkbench workbench, IStructuredSelection currentSelection) { 53 super.init(workbench, currentSelection); 54 setWindowTitle(PDEUIMessages.NewCheatSheetFileWizard_0); 55 setNeedsProgressMonitor(true); 56 } 57 58 61 protected void initializeDefaultPageImageDescriptor() { 62 setDefaultPageImageDescriptor(PDEPluginImages.DESC_CHEATSHEET_WIZ); 63 } 64 65 68 public boolean performFinish() { 69 try { 70 getContainer().run(false, true, getOperation()); 71 } catch (InvocationTargetException e) { 72 PDEPlugin.logException(e); 73 return false; 74 } catch (InterruptedException e) { 75 return false; 76 } 77 return true; 78 } 79 80 83 private IRunnableWithProgress getOperation() { 84 85 IFile file = fMainPage.createNewFile(); 86 int option = fMainPage.getCheatSheetType(); 87 if (option == CSFileWizardPage.F_SIMPLE_CHEAT_SHEET) { 88 return new SimpleCSCreationOperation(file); 89 } else if (option == CSFileWizardPage.F_COMPOSITE_CHEAT_SHEET) { 90 return new CompCSCreationOperation(file); 91 } 92 PDEPlugin.logErrorMessage("Unknown cheat sheet type encountered"); return null; 95 } 96 } 97 | Popular Tags |