2
* Created on Jan 22, 2006
4
package org.python.pydev.ui.wizards.files;
6
import org.eclipse.core.resources.IFile;
7
import org.eclipse.core.resources.IFolder;
8
import org.eclipse.core.resources.IProject;
9
import org.eclipse.core.runtime.CoreException;
10
import org.eclipse.core.runtime.IProgressMonitor;
11
import org.python.pydev.core.IPythonNature;
12
import org.python.pydev.core.IPythonPathNature;
13
import org.python.pydev.plugin.nature.PythonNature;
15
public class PythonSourceFolderWizard extends AbstractPythonWizard {
17
public static final String WIZARD_ID = "org.python.pydev.ui.wizards.files.PythonSourceFolderWizard";
20
protected PythonAbstractPathPage createPathPage() {
21
return new PythonAbstractPathPage("Create a new Source Folder", selection){
24
protected boolean shouldCreateSourceFolderSelect() {
29
protected boolean shouldCreatePackageSelect() {
37
protected IFile doCreateNew(IProgressMonitor monitor) throws CoreException {
38
IProject project = filePage.getValidatedProject();
39
String name = filePage.getValidatedName();
40
if(project == null || !project.exists()){
41
throw new RuntimeException("The project selected does not exist in the workspace.");
43
IPythonPathNature pathNature = PythonNature.getPythonPathNature(project);
44
if(pathNature == null){
45
IPythonNature nature = PythonNature.addNature(project, monitor);
46
pathNature = nature.getPythonPathNature();
47
if(pathNature == null){
48
throw new RuntimeException("Unable to add the nature to the seleted project.");
51
IFolder folder = project.getFolder(name);
53
folder.create(true, true, monitor);
55
String newPath = folder.getFullPath().toString();
57
String curr = pathNature.getProjectSourcePath();
61
if(curr.endsWith("|")){
62
curr = curr.substring(0, curr.length()-1);
64
if(curr.length() > 0){
65
//there is already some path
68
//there is still no other path
71
pathNature.setProjectSourcePath(curr);
72
PythonNature.getPythonNature(project).rebuildPath();