public IProject createNewProject(IPath newPath, String name, IProgressMonitor monitor) { IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(name); IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IProjectDescription description = workspace.newProjectDescription(newProject.getName()); description.setLocation(newPath); // run the new project creation operation try { boolean doit = false; if (!newProject.exists()) { // Defect 24558 - Text Importer may result in New Project being created with NO PATH, so // check if NULL // before if (newPath != null && OSPlatformUtil.isWindows()) { // check to see if path exists but case is different IPath path = new Path(FileUiUtils.INSTANCE.getExistingCaseVariantFileName(newPath)); newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment()); description.setLocation(path); doit = !newProject.exists(); } else { doit = true; } if (doit) { createProject(description, newProject, monitor); } } } catch (CoreException e) { if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { MessageDialog.openError( getShell(), ResourceMessages.NewProject_errorMessage, NLS.bind(ResourceMessages.NewProject_caseVariantExistsError, newProject.getName())); } else { ErrorDialog.openError( getShell(), ResourceMessages.NewProject_errorMessage, null, // no special message e.getStatus()); } return null; } catch (Exception theException) { return null; } configureProject(newProject); return newProject; }
/** * @see org.teiid.designer.core.workspace.ModelWorkspace#createModelProject(java.lang.String, * java.lang.String, org.eclipse.core.runtime.IProgressMonitor) * @since 4.0 */ @Override public ModelProject createModelProject( final String name, final IPath path, final IProgressMonitor monitor) throws CoreException { CoreArgCheck.isNotNull(name); // Check if project already exists if (findModelProject(name) != null) { throw new ModelWorkspaceException( ModelerCore.Util.getString( "ModelWorkspaceImpl.cannotCreateModelProject", name)); // $NON-NLS-1$ } // Validate name final IWorkspace workspace = ModelerCore.getWorkspace(); final IStatus status = workspace.validateName(name, IResource.PROJECT); if (!status.isOK()) { throw new ModelWorkspaceException( new ModelStatusImpl(status.getSeverity(), status.getCode(), status.getMessage())); } // Create new model project final IProject project = workspace.getRoot().getProject(name); final IProjectDescription desc = workspace.newProjectDescription(project.getName()); desc.setLocation(path); desc.setNatureIds(MODEL_NATURES); final IWorkspaceRunnable op = new IWorkspaceRunnable() { @Override public void run(final IProgressMonitor monitor) throws CoreException { project.create(desc, monitor); project.open(monitor); } }; workspace.run(op, monitor); return new ModelProjectImpl(project, this); }
private IProject createProject(final GridProjectProperties props, final IProgressMonitor monitor) throws CoreException { monitor.subTask(Messages.getString("GridProjectCreationOperation.init_task")); // $NON-NLS-1$ String projectName = props.getProjectName(); IPath projectPath = props.getProjectLocation(); IProject[] referencesProjects = props.getReferencesProjects(); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); IProject project = workspaceRoot.getProject(projectName); IStatus status = ResourcesPlugin.getWorkspace().validateProjectLocation(project, projectPath); if (status.getSeverity() != IStatus.OK) { throw new CoreException(status); } IProjectDescription desc = project.getWorkspace().newProjectDescription(projectName); desc.setLocation(projectPath); if (referencesProjects != null) { desc.setReferencedProjects(referencesProjects); } project.create(desc, new SubProgressMonitor(monitor, 50)); project.open(new SubProgressMonitor(monitor, 50)); createProjectStructure(project, props); setProjectProperties(project, props); if (monitor.isCanceled()) { throw new OperationCanceledException(); } return project; }
private void createExternalSourceArchivesProject(IProject project, IProgressMonitor monitor) throws CoreException { IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName()); IPath stateLocation = CeylonPlugin.getInstance().getStateLocation(); desc.setLocation(stateLocation.append(EXTERNAL_PROJECT_NAME)); project.create(desc, IResource.HIDDEN, monitor); }
@Before public void setUp() throws Exception { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); FileUtils.mkdir(new File(root.getLocation().toFile(), "Sub"), true); gitDir = new File(new File(root.getLocation().toFile(), "Sub"), Constants.DOT_GIT); repository = FileRepositoryBuilder.create(gitDir); repository.create(); project = root.getProject(TEST_PROJECT); project.create(null); project.open(null); IProjectDescription description = project.getDescription(); description.setLocation(root.getLocation().append(TEST_PROJECT_LOC)); project.move(description, IResource.FORCE, null); project2 = root.getProject(TEST_PROJECT2); project2.create(null); project2.open(null); gitDir2 = new File(project2.getLocation().toFile().getAbsoluteFile(), Constants.DOT_GIT); repository2 = FileRepositoryBuilder.create(gitDir2); repository2.create(); RepositoryMapping mapping = RepositoryMapping.create(project, gitDir); RepositoryMapping mapping2 = RepositoryMapping.create(project2, gitDir2); GitProjectData projectData = new GitProjectData(project); GitProjectData projectData2 = new GitProjectData(project2); projectData.setRepositoryMappings(Collections.singletonList(mapping)); projectData.store(); projectData2.setRepositoryMappings(Collections.singletonList(mapping2)); projectData2.store(); GitProjectData.add(project, projectData); GitProjectData.add(project2, projectData2); RepositoryProvider.map(project, GitProvider.class.getName()); RepositoryProvider.map(project2, GitProvider.class.getName()); JGitTestUtil.write( new File(repository.getWorkTree(), TEST_PROJECT + "/" + TEST_FILE), "Some data"); JGitTestUtil.write(new File(repository2.getWorkTree(), TEST_FILE2), "Some other data"); project.refreshLocal(IResource.DEPTH_INFINITE, null); project2.refreshLocal(IResource.DEPTH_INFINITE, null); git = new Git(repository); git.add().addFilepattern(".").call(); git.commit().setMessage("Initial commit").call(); git = new Git(repository2); git.add().addFilepattern(".").call(); git.commit().setMessage("Initial commit").call(); git.branchRename().setNewName("main").call(); }
public void testSwitchBranchClosesOpenProjectsThatDontExistOnDestinationBranch() throws Throwable { testAddBranch(); assertCurrentBranch("master"); assertSwitchBranch("my_new_branch"); GitIndex index = getRepo().index(); assertTrue("Expected changed file listing to be empty", index.changedFiles().isEmpty()); // Create a new project on this branch! String projectName = "project_on_branch" + System.currentTimeMillis(); File projectDir = getRepo().workingDirectory().append(projectName).toFile(); projectDir.mkdirs(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IProject project = workspace.getRoot().getProject(projectName); IProjectDescription description = workspace.newProjectDescription(projectName); description.setLocation(getRepo().workingDirectory().append(projectName)); project.create(description, new NullProgressMonitor()); // Commit the project on this branch! index.refresh(new NullProgressMonitor()); // Now there should be a single file that's been changed! List<ChangedFile> changed = index.changedFiles(); assertEquals( "repository changed file listing should contain one entry for new .project file, but does not", 1, changed.size()); // Make sure it's shown as having unstaged changes only and is NEW assertNewUnstagedFile(changed.get(0)); // Stage the new file assertStageFiles(index, changed); assertNewStagedFile(changed.get(0)); assertCommit(index, "Initial commit"); assertSwitchBranch("master"); // Assert that the new project is closed! project = workspace.getRoot().getProject(projectName); assertFalse(project.isOpen()); // assert that there's no .project file stranded there File dotProject = new File(projectDir, IProjectDescription.DESCRIPTION_FILE_NAME); assertFalse(dotProject.exists()); }
private IProject createProject(String dirPath) throws CoreException { long start = System.currentTimeMillis(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); String projectName = "test"; IProject project = root.getProject(projectName); IProjectDescription description = workspace.newProjectDescription(projectName); description.setLocation(new Path(dirPath)); project.create(description, null); project.open(null); long delta = System.currentTimeMillis() - start; System.out.println("Open project in " + delta + " ms"); return project; }
/** * Creates CDT project in a specific path in workspace adding specified configurations and opens * it. * * @param projectName - project name. * @param pathInWorkspace - path relative to workspace root. * @param configurationIds - array of configuration IDs. * @return - new {@link IProject}. * @throws CoreException - if the project can't be created. * @throws OperationCanceledException... */ public static IProject createCDTProject( String projectName, String pathInWorkspace, String[] configurationIds) throws OperationCanceledException, CoreException { CCorePlugin cdtCorePlugin = CCorePlugin.getDefault(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); IProject project = root.getProject(projectName); IndexerPreferences.set(project, IndexerPreferences.KEY_INDEXER_ID, IPDOMManager.ID_NO_INDEXER); resourcesCreated.add(project); IProjectDescription prjDescription = workspace.newProjectDescription(projectName); if (pathInWorkspace != null) { IPath absoluteLocation = root.getLocation().append(pathInWorkspace); prjDescription.setLocation(absoluteLocation); } if (configurationIds != null && configurationIds.length > 0) { ICProjectDescriptionManager prjDescManager = cdtCorePlugin.getProjectDescriptionManager(); project.create(NULL_MONITOR); project.open(NULL_MONITOR); ICProjectDescription icPrjDescription = prjDescManager.createProjectDescription(project, false); ICConfigurationDescription baseConfiguration = cdtCorePlugin.getPreferenceConfiguration(TestCfgDataProvider.PROVIDER_ID); for (String cfgId : configurationIds) { icPrjDescription.createConfiguration(cfgId, cfgId + " Name", baseConfiguration); } prjDescManager.setProjectDescription(project, icPrjDescription); } project = cdtCorePlugin.createCDTProject(prjDescription, project, NULL_MONITOR); waitForProjectRefreshToFinish(); Assert.assertNotNull(project); project.open(null); Assert.assertTrue(project.isOpen()); return project; }
protected boolean createProject( final IProgressMonitor monitor, final IPath projectLocation, final String projectName, final Collection<IPath> includeDirs, final Collection<IPath> sourceDirs, final IPath outputDir) throws InvocationTargetException { final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IProject project = workspace.getRoot().getProject(projectName); final IProjectDescription description = workspace.newProjectDescription(projectName); description.setLocation(projectLocation); final ICommand[] old = description.getBuildSpec(), specs = new ICommand[old.length + 1]; System.arraycopy(old, 0, specs, 0, old.length); final ICommand command = description.newCommand(); command.setBuilderName(ErlangPlugin.BUILDER_ID); specs[old.length] = command; description.setBuildSpec(specs); description.setNatureIds(new String[] {ErlangPlugin.NATURE_ID}); try { monitor.beginTask(WizardMessages.WizardProjectsImportPage_CreateProjectsTask, 1000); project.create(description, monitor); // final int subTicks = 600 / fileSystemObjects.size(); // createLinks(theProjectPath, fileSystemObjects, monitor, project, // subTicks); // project.create(description, IResource.REPLACE, // new SubProgressMonitor(monitor, 30)); project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 300)); final OldErlangProjectProperties erlangProjectProperties = new OldErlangProjectProperties(project); erlangProjectProperties.setIncludeDirs(includeDirs); erlangProjectProperties.setSourceDirs(sourceDirs); erlangProjectProperties.setOutputDir(outputDir); } catch (final CoreException e) { throw new InvocationTargetException(e); } finally { monitor.done(); } return true; }
/** * Create a new java project * * @param projectName a project name * @return newProject a new project resource handle */ public static IProject createJavaProject(final String projectName) throws CoreException { // 1. Get the project from the workspace final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); final IProject newProject = root.getProject(projectName); final IProjectDescription description = newProject.getWorkspace().newProjectDescription(projectName); // 2. Create a project if it does not already exist if (!newProject.exists()) { description.setLocation(null); newProject.create(description, null); } if (!newProject.isOpen()) { newProject.open(null); } // 4. Make it a Java Project addJavaNature(newProject); return newProject; }
/** * Creates the Acceleo project. * * @param monitor The progress monitor. */ private void createProject(IProgressMonitor monitor) { try { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(newProjectPage.getProjectName()); IPath location = newProjectPage.getLocationPath(); if (!project.exists()) { IProjectDescription desc = project.getWorkspace().newProjectDescription(newProjectPage.getProjectName()); if (ResourcesPlugin.getWorkspace().getRoot().getLocation().equals(location)) { location = null; } desc.setLocation(location); project.create(desc, monitor); project.open(monitor); boolean shouldGenerateModules = !(getContainer().getCurrentPage() instanceof WizardNewProjectCreationPage); convert( project, newProjectPage.getSelectedJVM(), newAcceleoModulesCreationPage.getAllModules(), shouldGenerateModules, monitor); IWorkingSet[] workingSets = newProjectPage.getSelectedWorkingSets(); getWorkbench().getWorkingSetManager().addToWorkingSets(project, workingSets); project.build( IncrementalProjectBuilder.FULL_BUILD, AcceleoBuilder.BUILDER_ID, new HashMap<String, String>(), monitor); } } catch (CoreException e) { AcceleoUIActivator.log(e, true); } }
public void testRepoRelativePath() throws Throwable { IProject project = null; try { GitRepository repo = createRepo(); IPath repoPath = repo.workingDirectory(); String projectName = repoPath.lastSegment(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IProjectDescription description = workspace.newProjectDescription(projectName); description.setLocation(repoPath); project = workspace.getRoot().getProject(projectName); project.create(description, null); project.open(null); IPath relativePath = repo.relativePath(project); assertTrue("Expected relative path of root of repo to be empty", relativePath.isEmpty()); } finally { if (project != null) { project.delete(true, null); } } }
private void createProject(IFeatureModel model, IProgressMonitor monitor) throws CoreException { String name = model.getFeature().getId(); IFeaturePlugin[] plugins = model.getFeature().getPlugins(); for (int i = 0; i < plugins.length; i++) { if (name.equals(plugins[i].getId())) { name += "-feature"; // $NON-NLS-1$ break; } } String task = NLS.bind(MDEUIMessages.FeatureImportWizard_operation_creating2, name); monitor.beginTask(task, 9); try { IProject project = fRoot.getProject(name); if (project.exists() || new File(project.getParent().getLocation().toFile(), name).exists()) { if (queryReplace(project)) { if (!project.exists()) project.create(new SubProgressMonitor(monitor, 1)); project.delete(true, true, new SubProgressMonitor(monitor, 1)); try { RepositoryProvider.unmap(project); } catch (TeamException e) { } } else { return; } } else { monitor.worked(1); } IProjectDescription description = MDEPlugin.getWorkspace().newProjectDescription(name); if (fTargetPath != null) description.setLocation(fTargetPath.append(name)); project.create(description, new SubProgressMonitor(monitor, 1)); if (!project.isOpen()) { project.open(null); } File featureDir = new File(model.getInstallLocation()); importContent( featureDir, project.getFullPath(), FileSystemStructureProvider.INSTANCE, null, new SubProgressMonitor(monitor, 1)); IFolder folder = project.getFolder("META-INF"); // $NON-NLS-1$ if (folder.exists()) { folder.delete(true, null); } if (fBinary) { // Mark this project so that we can show image overlay // using the label decorator project.setPersistentProperty( MDECore.EXTERNAL_PROJECT_PROPERTY, MDECore.BINARY_PROJECT_VALUE); } createBuildProperties(project); setProjectNatures(project, model, monitor); if (project.hasNature(JavaCore.NATURE_ID)) setClasspath(project, model, monitor); } finally { monitor.done(); } }
private IProject createExternalFoldersProject(IProgressMonitor monitor) { IProject project = getExternalFoldersProject(); if (!project.isAccessible()) { try { if (!project.exists()) { IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName()); IPath stateLocation = DLTKCore.getPlugin().getStateLocation(); desc.setLocation(stateLocation.append(EXTERNAL_PROJECT_NAME)); project.create(desc, IResource.HIDDEN, monitor); } try { project.open(monitor); } catch (CoreException e1) { // .project or folder on disk have been deleted, recreate // them IPath stateLocation = DLTKCore.getPlugin().getStateLocation(); IPath projectPath = stateLocation.append(EXTERNAL_PROJECT_NAME); projectPath.toFile().mkdirs(); FileOutputStream output = new FileOutputStream( projectPath.append(IScriptProjectFilenames.PROJECT_FILENAME).toOSString()); try { output.write( ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$ "<projectDescription>\n" //$NON-NLS-1$ + " <name>" //$NON-NLS-1$ + EXTERNAL_PROJECT_NAME + "</name>\n" + //$NON-NLS-1$ " <comment></comment>\n" + //$NON-NLS-1$ " <projects>\n" + //$NON-NLS-1$ " </projects>\n" + //$NON-NLS-1$ " <buildSpec>\n" + //$NON-NLS-1$ " </buildSpec>\n" + //$NON-NLS-1$ " <natures>\n" + //$NON-NLS-1$ " </natures>\n" + //$NON-NLS-1$ "</projectDescription>") .getBytes()); //$NON-NLS-1$ } finally { output.close(); } project.open(null); } } catch (CoreException e) { Util.log(e, "Problem creating hidden project for external folders"); // $NON-NLS-1$ return project; } catch (IOException e) { Util.log(e, "Problem creating hidden project for external folders"); // $NON-NLS-1$ return project; } } return project; }
/** * Move the project structure to the location provided by user. Also configure JDK, server, server * application and key features like session affinity, caching, debugging if user wants to do so. * * @param projName : Name of the project * @param projLocation : Location of the project * @param isDefault : whether location of project is default * @param selWorkingSets * @param workingSetManager * @param depMap : stores configurations done on WATagPage * @param ftrMap : stores configurations done on WAKeyFeaturesPage * @param selProj */ private void doFinish( String projName, String projLocation, boolean isDefault, IWorkingSet[] selWorkingSets, IWorkingSetManager workingSetManager, Map<String, String> depMap, Map<String, Boolean> ftrMap, IProject selProj) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); IProject project = null; try { WindowsAzureRole role = waProjMgr.getRoles().get(0); // logic for handling deploy page components and their values. if (!depMap.isEmpty()) { File templateFile = new File(depMap.get("tempFile")); role = WizardUtilMethods.configureJDKServer(role, depMap); /* * Handling adding server application * without configuring server/JDK. * Always add cloud attributes as * approot directory is not created yet * hence all applications are * imported from outside of the Azure project */ if (!tabPg.getAppsAsNames().isEmpty()) { for (int i = 0; i < tabPg.getAppsList().size(); i++) { AppCmpntParam app = tabPg.getAppsList().get(i); if (!app.getImpAs().equalsIgnoreCase(Messages.helloWorld)) { role.addServerApplication( app.getImpSrc(), app.getImpAs(), app.getImpMethod(), templateFile, true); } } } } /** Handling for HelloWorld application in plug-in */ if (tabPg != null) { if (!tabPg.getAppsAsNames().contains(Messages.helloWorld)) { List<WindowsAzureRoleComponent> waCompList = waProjMgr.getRoles().get(0).getServerApplications(); for (WindowsAzureRoleComponent waComp : waCompList) { if (waComp.getDeployName().equalsIgnoreCase(Messages.helloWorld) && waComp.getImportPath().isEmpty()) { waComp.delete(); } } } } role = WizardUtilMethods.configureKeyFeatures(role, ftrMap); waProjMgr.save(); WindowsAzureProjectManager.moveProjFromTemp(projName, projLocation); String launchFilePath = projLocation + File.separator + projName + LAUNCH_FILE_PATH; ParseXML.setProjectNameinLaunch(launchFilePath, Messages.pWizWinAzureProj, projName); root.touch(null); project = root.getProject(projName); IProjectDescription projDescription = workspace.newProjectDescription(projName); Path path = new Path(projLocation + File.separator + projName); projDescription.setLocation(path); projDescription.setNatureIds(new String[] {WAProjectNature.NATURE_ID}); if (!project.exists()) { if (isDefault) { project.create(null); } else { project.create(projDescription, null); } } project.open(null); projDescription = project.getDescription(); projDescription.setName(projName); projDescription.setNatureIds(new String[] {WAProjectNature.NATURE_ID}); project.move(projDescription, IResource.FORCE, null); workingSetManager.addToWorkingSets(project, selWorkingSets); root.touch(null); if (project != null) { WADependencyBuilder builder = new WADependencyBuilder(); builder.addBuilder(project, "com.persistent.winazure.eclipseplugin.Builder"); } } catch (Exception e) { Display.getDefault() .syncExec( new Runnable() { public void run() { MessageDialog.openError(null, Messages.pWizErrTitle, Messages.pWizErrMsg); } }); Activator.getDefault().log(Messages.pWizErrMsg, e); } }
private IProject openProject(final IPath projectPath) throws CoreException { final ResourceSet set = ScaResourceFactoryUtil.createResourceSet(); final IProgressMonitor progressMonitor = new NullProgressMonitor(); final IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IWorkspaceRoot root = workspace.getRoot(); final IWorkspaceDescription description = workspace.getDescription(); final File projectPathFile = projectPath.toFile(); final IPath projectDescriptionPath = projectPath.append(".project"); if (!projectPathFile.isDirectory()) { throw new IllegalStateException("Provided project path must be a directory"); } if (!projectDescriptionPath.toFile().exists()) { throw new IllegalStateException("Provided project path must include .project file"); } final IProjectDescription projDesc = workspace.loadProjectDescription(projectDescriptionPath); final IProject project = root.getProject(projDesc.getName()); if (project.exists()) { // If the project exists, make sure that it is the same project the user requested // ...this should only happen if the user forced a workspace with -data // that already contained a project with the same name but different path // from the one provided on the command line if (!project.getLocation().equals(projectPath.makeAbsolute())) { throw new IllegalStateException( "Provided project path conflicts with existing project in workspace"); } } else { // If the project doesn't exist in the workspace, create a linked project projDesc.setName(projDesc.getName()); if (Platform.getLocation().isPrefixOf(projectPath)) { projDesc.setLocation(null); } else { projDesc.setLocation(projectPath); } final WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { @Override protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { final SubMonitor progressMonitor = SubMonitor.convert(monitor, 1); System.out.println( "Loading project " + projDesc.getName() + " " + projDesc.getLocation()); project.create(projDesc, progressMonitor.newChild(1)); } }; try { operation.run(new NullProgressMonitor()); } catch (final InvocationTargetException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (final InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } // Finally open the project Assert.isTrue(project.exists()); final WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { @Override protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { project.open(monitor); } }; try { operation.run(new NullProgressMonitor()); } catch (final InvocationTargetException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (final InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } return project; }
private IProjectDescription createProjectDescription() { IWorkspace workspace = ResourcesPlugin.getWorkspace(); IProjectDescription result = workspace.newProjectDescription(projectName); result.setLocation(projectLocation); return result; }
/** * Creates a new project resource with the entered name. * * @return the created project resource, or <code>null</code> if the project was not created */ protected IProject createNewProject(final Object... additionalArgsToConfigProject) { // get a project handle final IProject newProjectHandle = projectPage.getProjectHandle(); // get a project descriptor IPath defaultPath = Platform.getLocation(); IPath newPath = projectPage.getLocationPath(); if (defaultPath.equals(newPath)) { newPath = null; } else { // The user entered the path and it's the same as it'd be if he chose the default path. IPath withName = defaultPath.append(newProjectHandle.getName()); if (newPath.toFile().equals(withName.toFile())) { newPath = null; } } IWorkspace workspace = ResourcesPlugin.getWorkspace(); final IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); description.setLocation(newPath); // update the referenced project if provided if (referencePage != null) { IProject[] refProjects = referencePage.getReferencedProjects(); if (refProjects.length > 0) { description.setReferencedProjects(refProjects); } } final String projectType = projectPage.getProjectType(); final String projectInterpreter = projectPage.getProjectInterpreter(); // define the operation to create a new project WorkspaceModifyOperation op = new WorkspaceModifyOperation() { protected void execute(IProgressMonitor monitor) throws CoreException { createAndConfigProject( newProjectHandle, description, projectType, projectInterpreter, monitor, additionalArgsToConfigProject); } }; // run the operation to create a new project try { getContainer().run(true, true, op); } catch (InterruptedException e) { return null; } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof CoreException) { if (((CoreException) t).getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { MessageDialog.openError( getShell(), "Unable to create project", "Another project with the same name (and different case) already exists."); } else { ErrorDialog.openError( getShell(), "Unable to create project", null, ((CoreException) t).getStatus()); } } else { // Unexpected runtime exceptions and errors may still occur. PydevPlugin.log(IStatus.ERROR, t.toString(), t); MessageDialog.openError(getShell(), "Unable to create project", t.getMessage()); } return null; } return newProjectHandle; }