1 11 package org.eclipse.pde.internal.ui.wizards.plugin; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.resources.IProject; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IConfigurationElement; 18 import org.eclipse.core.runtime.IExecutableExtension; 19 import org.eclipse.core.runtime.IPath; 20 import org.eclipse.jface.wizard.IWizardPage; 21 import org.eclipse.pde.internal.ui.PDEPlugin; 22 import org.eclipse.pde.internal.ui.PDEPluginImages; 23 import org.eclipse.pde.internal.ui.PDEUIMessages; 24 import org.eclipse.pde.internal.ui.wizards.IProjectProvider; 25 import org.eclipse.pde.internal.ui.wizards.NewWizard; 26 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; 27 28 public class NewFragmentProjectWizard extends NewWizard implements IExecutableExtension { 29 30 private NewProjectCreationPage fMainPage; 31 private ContentPage fContentPage; 32 private FragmentFieldData fFragmentData; 33 private IProjectProvider fProjectProvider; 34 private IConfigurationElement fConfig; 35 36 public NewFragmentProjectWizard() { 37 setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWFRAGPRJ_WIZ); 38 setWindowTitle(PDEUIMessages.NewFragmentProjectWizard_title); 39 setNeedsProgressMonitor(true); 40 PDEPlugin.getDefault().getLabelProvider().connect(this); 41 fFragmentData = new FragmentFieldData(); 42 } 43 44 47 public void addPages() { 48 fMainPage = new NewProjectCreationPage("main", fFragmentData, true); fMainPage.setTitle(PDEUIMessages.NewProjectWizard_MainPage_ftitle); 50 fMainPage.setDescription(PDEUIMessages.NewProjectWizard_MainPage_fdesc); 51 addPage(fMainPage); 52 53 fProjectProvider = new IProjectProvider() { 54 public String getProjectName() { 55 return fMainPage.getProjectName(); 56 } 57 public IProject getProject() { 58 return fMainPage.getProjectHandle(); 59 } 60 public IPath getLocationPath() { 61 return fMainPage.getLocationPath(); 62 } 63 }; 64 fContentPage = new FragmentContentPage("page2", fProjectProvider, fMainPage, fFragmentData); addPage(fContentPage); 66 } 67 68 71 public boolean canFinish() { 72 IWizardPage page = getContainer().getCurrentPage(); 73 return (page.isPageComplete() && page!=fMainPage); 74 } 75 80 public boolean performFinish() { 81 try { 82 fMainPage.updateData(); 83 fContentPage.updateData(); 84 BasicNewProjectResourceWizard.updatePerspective(fConfig); 85 getContainer().run(false, true, 86 new NewProjectCreationOperation(fFragmentData, fProjectProvider, null)); 87 return true; 88 } catch (InvocationTargetException e) { 89 PDEPlugin.logException(e); 90 } catch (InterruptedException e) { 91 } 92 return false; 93 } 94 95 98 public void dispose() { 99 super.dispose(); 100 PDEPlugin.getDefault().getLabelProvider().disconnect(this); 101 } 102 103 106 public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { 107 fConfig = config; 108 } 109 110 public String getFragmentId() { 111 return fFragmentData.getId(); 112 } 113 } 114 | Popular Tags |