当前位置: 首页>>代码示例>>Java>>正文


Java PythonNature.addNature方法代码示例

本文整理汇总了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;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:27,代码来源:AbstractWorkbenchTestCase.java

示例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);
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:13,代码来源:PyAddNature.java

示例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;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:39,代码来源:PyEdit.java

示例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);
        }
    }
 
开发者ID:fabioz,项目名称:Pydev,代码行数:28,代码来源:DjangoNature.java

示例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;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:50,代码来源:PythonExistingSourceFolderWizard.java

示例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;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:48,代码来源:PythonSourceFolderWizard.java


注:本文中的org.python.pydev.plugin.nature.PythonNature.addNature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。