本文整理汇总了Java中org.python.pydev.plugin.nature.PythonNature.addNature方法的典型用法代码示例。如果您正苦于以下问题:Java PythonNature.addNature方法的具体用法?Java PythonNature.addNature怎么用?Java PythonNature.addNature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.python.pydev.plugin.nature.PythonNature
的用法示例。
在下文中一共展示了PythonNature.addNature方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSourceFolder
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* Creates a source folder and configures the project to use it and the junit.jar
*
* @param addNature if false, no nature will be initially added to the project (if true, the nature will be added)
*/
protected IFolder createSourceFolder(IProgressMonitor monitor, IProject project, boolean addNature, boolean isJython)
throws CoreException {
IFolder sourceFolder = project.getFolder(new Path("src"));
if (!sourceFolder.exists()) {
sourceFolder.create(true, true, monitor);
}
if (addNature) {
String name = project.getName();
if (isJython) {
PythonNature.addNature(project, monitor, PythonNature.JYTHON_VERSION_2_1, "/" + name +
"/src|/" + name
+
"/grinder.jar", null, null, null);
} else {
PythonNature.addNature(project, monitor, PythonNature.PYTHON_VERSION_2_6, "/" + name +
"/src", null,
null, null);
}
}
return sourceFolder;
}
示例2: run
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
public void run(IAction action) {
if (selectedProject == null) {
return;
}
try {
PythonNature.addNature(selectedProject, null, null, null, null, null, null);
} catch (CoreException e) {
Log.log(e);
}
}
示例3: getPythonNature
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
* @return the python nature associated with this editor.
* @throws NotConfiguredInterpreterException
*/
@Override
public IPythonNature getPythonNature() throws MisconfigurationException {
IProject project = getProject();
if (project == null || !project.isOpen()) {
return null;
}
IPythonNature pythonNature = PythonNature.getPythonNature(project);
if (pythonNature != null) {
return pythonNature;
}
//if it's an external file, there's the possibility that it won't be added even here.
pythonNature = PythonNature.addNature(this.getEditorInput());
if (pythonNature != null) {
return pythonNature;
}
File editorFile = getEditorFile();
if (editorFile == null) {
return null;
}
Tuple<IPythonNature, String> infoForFile = PydevPlugin.getInfoForFile(editorFile);
if (infoForFile == null) {
NotConfiguredInterpreterException e = new NotConfiguredInterpreterException();
ErrorDialog.openError(EditorUtils.getShell(), "Error: no interpreter configured",
"Interpreter not configured\n(Please, Configure it under window->preferences->PyDev)",
PydevPlugin.makeStatus(IStatus.ERROR, e.getMessage(), e));
throw e;
}
pythonNature = infoForFile.o1;
return pythonNature;
}
示例4: addNature
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
public static synchronized void addNature(IProject project, IProgressMonitor monitor) throws CoreException {
if (project == null || !project.isOpen()) {
return;
}
if (monitor == null) {
monitor = new NullProgressMonitor();
}
IProjectDescription desc = project.getDescription();
if (!project.hasNature(PythonNature.PYTHON_NATURE_ID)) {
//also add the python nature if it still wasn't added.
PythonNature.addNature(project, null, null, null, null, null, null);
}
//only add the django nature if it still hasn't been added.
if (!project.hasNature(DJANGO_NATURE_ID)) {
String[] natures = desc.getNatureIds();
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = DJANGO_NATURE_ID;
desc.setNatureIds(newNatures);
project.setDescription(desc, monitor);
}
}
示例5: doCreateNew
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
protected IFile doCreateNew(IProgressMonitor monitor) throws CoreException {
IProject project = filePage.getValidatedProject();
String name = filePage.getValidatedName();
IPath source = filePage.getSourceToLink();
if (project == null || !project.exists()) {
throw new RuntimeException("The project selected does not exist in the workspace.");
}
IPythonPathNature pathNature = PythonNature.getPythonPathNature(project);
if (pathNature == null) {
IPythonNature nature = PythonNature.addNature(project, monitor, null, null, null, null, null);
pathNature = nature.getPythonPathNature();
if (pathNature == null) {
throw new RuntimeException("Unable to add the nature to the seleted project.");
}
}
if (source == null || !source.toFile().exists()) {
throw new RuntimeException("The source to link to, " + source.toString() + ", does not exist.");
}
IFolder folder = project.getFolder(name);
if (!folder.exists()) {
folder.createLink(source, IResource.BACKGROUND_REFRESH, monitor);
}
String newPath = folder.getFullPath().toString();
String curr = pathNature.getProjectSourcePath(true);
if (curr == null) {
curr = "";
}
if (curr.endsWith("|")) {
curr = curr.substring(0, curr.length() - 1);
}
String newPathRel = PyStructureConfigHelpers.convertToProjectRelativePath(
project.getFullPath().toString(), newPath);
if (curr.length() > 0) {
//there is already some path
Set<String> projectSourcePathSet = pathNature.getProjectSourcePathSet(true);
if (!projectSourcePathSet.contains(newPath)) {
//only add to the path if it doesn't already contain the new path
curr += "|" + newPathRel;
}
} else {
//there is still no other path
curr = newPathRel;
}
pathNature.setProjectSourcePath(curr);
PythonNature.getPythonNature(project).rebuildPath();
return null;
}
示例6: doCreateNew
import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
protected IFile doCreateNew(IProgressMonitor monitor) throws CoreException {
IProject project = filePage.getValidatedProject();
String name = filePage.getValidatedName();
if (project == null || !project.exists()) {
throw new RuntimeException("The project selected does not exist in the workspace.");
}
IPythonPathNature pathNature = PythonNature.getPythonPathNature(project);
if (pathNature == null) {
IPythonNature nature = PythonNature.addNature(project, monitor, null, null, null, null, null);
pathNature = nature.getPythonPathNature();
if (pathNature == null) {
throw new RuntimeException("Unable to add the nature to the seleted project.");
}
}
IFolder folder = project.getFolder(name);
if (folder.exists()) {
Log.log("Source folder already exists. Nothing new was created");
return null;
}
folder.create(true, true, monitor);
String newPath = folder.getFullPath().toString();
String curr = pathNature.getProjectSourcePath(false);
if (curr == null) {
curr = "";
}
if (curr.endsWith("|")) {
curr = curr.substring(0, curr.length() - 1);
}
String newPathRel = PyStructureConfigHelpers.convertToProjectRelativePath(
project.getFullPath().toString(), newPath);
if (curr.length() > 0) {
//there is already some path
Set<String> projectSourcePathSet = pathNature.getProjectSourcePathSet(true);
if (!projectSourcePathSet.contains(newPath)) {
//only add to the path if it doesn't already contain the new path
curr += "|" + newPathRel;
}
} else {
//there is still no other path
curr = newPathRel;
}
pathNature.setProjectSourcePath(curr);
PythonNature.getPythonNature(project).rebuildPath();
return null;
}