1 11 package org.eclipse.ui.internal.ide.dialogs; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.jface.dialogs.IDialogSettings; 15 import org.eclipse.jface.dialogs.MessageDialog; 16 import org.eclipse.jface.resource.ImageDescriptor; 17 import org.eclipse.jface.viewers.IStructuredSelection; 18 import org.eclipse.osgi.util.NLS; 19 import org.eclipse.ui.INewWizard; 20 import org.eclipse.ui.IWorkbench; 21 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 22 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 23 24 28 public class NewProjectWizard extends MultiStepWizard implements 29 INewWizard { 30 31 private WizardNewProjectNameAndLocationPage creationPage; 33 34 35 private IProject newProject; 37 38 private String initialProjectName; 40 41 42 46 public NewProjectWizard() { 47 super(); 48 49 IDEWorkbenchPlugin plugin = IDEWorkbenchPlugin.getDefault(); 50 IDialogSettings workbenchSettings = plugin.getDialogSettings(); 51 IDialogSettings section = workbenchSettings 52 .getSection("NewProjectWizard"); if (section == null) { 54 section = workbenchSettings.addNewSection("NewProjectWizard"); } 56 setDialogSettings(section); 57 } 58 59 62 protected void addCustomPages() { 63 creationPage = new WizardNewProjectNameAndLocationPage( 64 "newProjectCreationPage"); creationPage.setTitle(IDEWorkbenchMessages.NewProjectWizard_title); 66 creationPage.setDescription(IDEWorkbenchMessages.WizardNewProjectCreationPage_description); 67 creationPage.setInitialProjectName(initialProjectName); 68 this.addPage(creationPage); 69 70 } 71 72 75 protected boolean canFinishOnReviewPage() { 76 return getSteps().length == 1; 78 } 79 80 83 protected String getConfigurePageTitle() { 84 return IDEWorkbenchMessages.NewProjectWizard_title; 85 } 86 87 90 protected String getConfigurePageDescription() { 91 return IDEWorkbenchMessages.WizardProjectConfigurePage_description; 92 } 93 94 97 protected String getReviewPageTitle() { 98 return IDEWorkbenchMessages.NewProjectWizard_title; 99 } 100 101 104 protected String getReviewPageDescription() { 105 return IDEWorkbenchMessages.WizardProjectReviewPage_description; 106 } 107 108 111 protected String getFinishStepLabel(WizardStep[] steps) { 112 if (steps.length > 2) { 117 return super.getFinishStepLabel(steps); 118 } else { 119 return null; 120 } 121 } 122 123 129 public IProject getNewProject() { 130 return newProject; 131 } 132 133 136 public IProject getProject() { 137 return newProject; 138 } 139 140 143 boolean handleMissingStepWizard(WizardStep step) { 144 MessageDialog 145 .openError( 146 getShell(), 147 IDEWorkbenchMessages.NewProjectWizard_errorTitle, 148 NLS.bind(IDEWorkbenchMessages.NewProjectWizard_noWizard, step.getLabel())); 149 return false; 150 } 151 152 155 public void init(IWorkbench workbench, IStructuredSelection currentSelection) { 156 initializeDefaultPageImageDescriptor(); 157 setWindowTitle(IDEWorkbenchMessages.NewProjectWizard_windowTitle); 158 } 159 160 163 protected void initializeDefaultPageImageDescriptor() { 164 ImageDescriptor desc = IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/newprj_wiz.png"); setDefaultPageImageDescriptor(desc); 166 167 } 168 169 175 public void setInitialProjectName(String name) { 176 if (name == null) { 177 initialProjectName = null; 178 } else { 179 initialProjectName = name.trim(); 180 } 181 } 182 183 186 void setNewProject(IProject project) { 187 newProject = project; 188 } 189 } 190 | Popular Tags |