1 11 package org.eclipse.pde.internal.ui.wizards.target; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.runtime.IPath; 16 import org.eclipse.jface.viewers.IStructuredSelection; 17 import org.eclipse.pde.internal.ui.PDEPlugin; 18 import org.eclipse.pde.internal.ui.PDEPluginImages; 19 import org.eclipse.pde.internal.ui.PDEUIMessages; 20 import org.eclipse.ui.IWorkbench; 21 import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; 22 23 public class NewTargetDefinitionWizard extends BasicNewResourceWizard { 24 25 TargetDefinitionWizardPage fPage; 26 IPath fInitialPath = null; 27 IPath fFilePath = null; 28 29 public void addPages() { 30 fPage = new TargetDefinitionWizardPage("profile", getSelection()); if (fInitialPath != null) 32 fPage.setContainerFullPath(fInitialPath); 33 addPage(fPage); 34 } 35 36 public boolean performFinish() { 37 try { 38 getContainer().run(false, true, getOperation()); 39 fFilePath = fPage.getContainerFullPath().append(fPage.getFileName()); 40 } catch (InvocationTargetException e) { 41 PDEPlugin.logException(e); 42 return false; 43 } catch (InterruptedException e) { 44 return false; 45 } 46 return true; 47 } 48 49 public void init(IWorkbench workbench, IStructuredSelection currentSelection) { 50 super.init(workbench, currentSelection); 51 setWindowTitle(PDEUIMessages.NewTargetProfileWizard_title); 52 setNeedsProgressMonitor(true); 53 } 54 55 protected void initializeDefaultPageImageDescriptor() { 56 setDefaultPageImageDescriptor(PDEPluginImages.DESC_TARGET_WIZ); 57 } 58 59 private BaseTargetDefinitionOperation getOperation() { 60 int option = fPage.getInitializationOption(); 61 if (option == TargetDefinitionWizardPage.USE_DEFAULT) 62 return new BaseTargetDefinitionOperation(fPage.createNewFile()); 63 else if (option == TargetDefinitionWizardPage.USE_CURRENT_TP) 64 return new TargetDefinitionFromPlatformOperation(fPage.createNewFile()); 65 return new TargetDefinitionFromTargetOperation(fPage.createNewFile(), fPage.getTargetId()); 66 } 67 68 public void setInitialPath(IPath path) { 69 fInitialPath = path; 70 } 71 72 public IPath getFilePath() { 73 return fFilePath; 74 } 75 76 } 77 | Popular Tags |