1 11 package org.eclipse.pde.internal.ui.wizards.site; 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.operation.IRunnableWithProgress; 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.NewWizard; 25 import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; 26 27 public class NewSiteProjectWizard extends NewWizard implements IExecutableExtension { 28 29 public static final String DEF_PROJECT_NAME = "project-name"; 31 private NewSiteProjectCreationPage fMainPage; 32 private IConfigurationElement fConfig; 33 34 35 public NewSiteProjectWizard() { 36 setDefaultPageImageDescriptor(PDEPluginImages.DESC_NEWSITEPRJ_WIZ); 37 setDialogSettings(PDEPlugin.getDefault().getDialogSettings()); 38 setNeedsProgressMonitor(true); 39 setWindowTitle(PDEUIMessages.NewSiteWizard_wtitle); 40 } 41 42 public void addPages() { 43 fMainPage = new NewSiteProjectCreationPage("main"); fMainPage.setTitle(PDEUIMessages.NewSiteWizard_MainPage_title); 45 fMainPage.setDescription(PDEUIMessages.NewSiteWizard_MainPage_desc); 46 String pname = getDefaultValue(DEF_PROJECT_NAME); 47 if (pname!=null) 48 fMainPage.setInitialProjectName(pname); 49 addPage(fMainPage); 50 } 51 52 53 public boolean performFinish() { 54 try { 55 BasicNewProjectResourceWizard.updatePerspective(fConfig); 56 final IProject project = fMainPage.getProjectHandle(); 57 final IPath location = fMainPage.getLocationPath(); 58 final String webLocation = fMainPage.getWebLocation(); 59 IRunnableWithProgress op = new NewSiteProjectCreationOperation(getShell().getDisplay(), project, location, webLocation); 60 getContainer().run(false, true, op); 61 } catch (InvocationTargetException e) { 62 PDEPlugin.logException(e); 63 return false; 64 } catch (InterruptedException e) { 65 return false; 66 } 67 return true; 68 } 69 70 public void setInitializationData( 71 IConfigurationElement config, 72 String property, 73 Object data) 74 throws CoreException { 75 this.fConfig = config; 76 } 77 } 78 | Popular Tags |