private IProject createNewProject() { if (newProject != null) { return newProject; } // get a project handle final IProject newProjectHandle = mainPage.getProjectHandle(); // get a project descriptor URI location = null; if (!mainPage.useDefaults()) { location = mainPage.getLocationURI(); } IProjectDescription description = ResourceUtil.getProjectDescription( mainPage.getLocationPath(), sample.getNatures(), ArrayUtil.NO_STRINGS); description.setName(newProjectHandle.getName()); description.setLocationURI(location); try { if (sample.isRemote()) { cloneFromGit(sample.getLocation(), newProjectHandle, description); } else { doBasicCreateProject(newProjectHandle, description); // FIXME Move the logic for extracting/applying samples to IProjectSample! See // IProjectTemplate! ZipUtil.extract( new File(sample.getLocation()), newProjectHandle.getLocation(), ZipUtil.Conflict.PROMPT, new NullProgressMonitor()); doPostProjectCreation(newProjectHandle); } } catch (IOException e) { return null; } catch (CoreException e) { return null; } newProject = newProjectHandle; return newProject; }
@Override public void addPages() { super.addPages(); mainPage = new WizardNewProjectCreationPage("basicNewProjectPage") // $NON-NLS-1$ { @Override public void createControl(Composite parent) { super.createControl(parent); validatePage(); } @Override protected boolean validatePage() { boolean valid = super.validatePage(); if (!valid) { return false; } // Check if there's already a directory/files at the destination IPath location = getLocationPath(); if (useDefaults()) { // needs to append the project name since getLocationPath() returns the workspace path // in this case location = location.append(getProjectName()); } File file = location.toFile(); if (file.exists()) { setMessage(Messages.NewSampleProjectWizard_LocationExistsMessage, WARNING); return true; } setErrorMessage(null); setMessage(null); return true; } }; mainPage.setTitle(Messages.NewSampleProjectWizard_ProjectPage_Title); mainPage.setDescription(Messages.NewSampleProjectWizard_ProjectPage_Description); addPage(mainPage); String name = sample.getName(); if (name != null) { mainPage.setInitialProjectName(name); } }
private void doPostProjectCreation(IProject newProject) { ISampleProjectHandler projectHandler = sample.getProjectHandler(); if (projectHandler != null) { projectHandler.projectCreated(newProject); } }