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


Java PythonNature.getPythonNature方法代码示例

本文整理汇总了Java中org.python.pydev.plugin.nature.PythonNature.getPythonNature方法的典型用法代码示例。如果您正苦于以下问题:Java PythonNature.getPythonNature方法的具体用法?Java PythonNature.getPythonNature怎么用?Java PythonNature.getPythonNature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.python.pydev.plugin.nature.PythonNature的用法示例。


在下文中一共展示了PythonNature.getPythonNature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doIt

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
private boolean doIt() {
    IProject project = getProject();

    if (project != null) {
        PythonNature pythonNature = PythonNature.getPythonNature(project);

        try {
            String projectInterpreter = projectConfig.getProjectInterpreter();
            if (projectInterpreter == null) {
                return false;
            }
            pythonNature.setVersion(projectConfig.getSelectedPythonOrJythonAndGrammarVersion(), projectInterpreter);
        } catch (CoreException e) {
            Log.log(e);
        }
    }
    return true;
}
 
开发者ID:HuaweiSNC,项目名称:OpsDev,代码行数:19,代码来源:PyProjectPythonDetails.java

示例2: AdditionalProjectInterpreterInfo

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
public AdditionalProjectInterpreterInfo(IProject project) throws MisconfigurationException {
    super(false);
    Assert.isNotNull(project);
    this.project = project;
    this.nature = PythonNature.getPythonNature(project);

    File f;
    try {
        f = AnalysisPlugin.getStorageDirForProject(project);
    } catch (NullPointerException e) {
        //it may fail in tests... (save it in default folder in this cases)
        Log.logInfo("Error getting persisting folder", e);
        f = new File(".");
    }
    persistingFolder = f;

    persistingLocation = new File(persistingFolder, "AdditionalProjectInterpreterInfo.pydevinfo");

    init();
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:21,代码来源:AdditionalProjectInterpreterInfo.java

示例3: doActionOnResource

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
protected int doActionOnResource(IResource next, IProgressMonitor monitor) {
    List<IFile> filesToVisit = new ArrayList<IFile>();
    if (next instanceof IContainer) {
        List<IFile> l = PyFileListing.getAllIFilesBelow((IContainer) next);

        for (Iterator<IFile> iter = l.iterator(); iter.hasNext();) {
            IFile element = iter.next();
            if (element != null) {
                filesToVisit.add(element);
            }
        }
    } else if (next instanceof IFile) {
        filesToVisit.add((IFile) next);
    }

    PythonNature nature = PythonNature.getPythonNature(next);
    forceCodeAnalysisOnFiles(nature, monitor, filesToVisit, filesVisited);
    return 1;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:21,代码来源:ForceCodeAnalysisOnTree.java

示例4: getRunnerConfigRun

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
protected String getRunnerConfigRun(ILaunchConfiguration conf, String mode, ILaunch launch) {
    try {
        IProject project = PythonRunnerConfig.getProjectFromConfiguration(conf);
        PythonNature nature = PythonNature.getPythonNature(project);
        if (nature != null) {
            switch (nature.getInterpreterType()) {
                case IInterpreterManager.INTERPRETER_TYPE_JYTHON:
                    return PythonRunnerConfig.RUN_JYTHON;
                case IInterpreterManager.INTERPRETER_TYPE_PYTHON:
                    return PythonRunnerConfig.RUN_REGULAR;
                case IInterpreterManager.INTERPRETER_TYPE_IRONPYTHON:
                    return PythonRunnerConfig.RUN_IRONPYTHON;
            }
            throw new RuntimeException("Unable to get the run configuration for interpreter type: "
                    + nature.getInterpreterType());
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    throw new RuntimeException("Unable to get the run configuration");
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:23,代码来源:DjangoLaunchConfigurationDelegate.java

示例5: setLaunchAndRelatedInfo

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
public void setLaunchAndRelatedInfo(ILaunch launch) {
    this.setLaunch(launch);
    if (launch != null) {
        IDebugTarget debugTarget = launch.getDebugTarget();
        IInterpreterInfo projectInterpreter = null;
        if (debugTarget instanceof PyDebugTarget) {
            PyDebugTarget pyDebugTarget = (PyDebugTarget) debugTarget;
            PythonNature nature = PythonNature.getPythonNature(pyDebugTarget.project);
            if (nature != null) {
                ArrayList<IPythonNature> natures = new ArrayList<>(1);
                natures.add(nature);
                this.setNaturesUsed(natures);
                try {
                    projectInterpreter = nature.getProjectInterpreter();
                    this.setInterpreterInfo(projectInterpreter);
                } catch (Throwable e1) {
                    Log.log(e1);
                }
            }
        }
    }

}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:24,代码来源:PydevConsoleInterpreter.java

示例6: getPythonNature

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
 * @return The nature to be used for this breakpoint or null if it cannot be determined.
 */
private IPythonNature getPythonNature() {
    IMarker marker = getMarker();
    IPythonNature nature = PythonNature.getPythonNature(marker.getResource());
    if (nature == null) {
        try {
            String externalPath = (String) marker.getAttribute(PyBreakpoint.PY_BREAK_EXTERNAL_PATH_ID);
            if (externalPath != null) {
                Tuple<IPythonNature, String> infoForFile = PydevPlugin.getInfoForFile(new File(externalPath));
                if (infoForFile != null) {
                    nature = infoForFile.o1;
                }
            }
        } catch (CoreException e) {
            throw new RuntimeException(e);
        }
    }
    return nature;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:22,代码来源:PyBreakpoint.java

示例7: setSelected

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
private void setSelected() {
        PythonNature pythonNature = PythonNature.getPythonNature(getProject());
        try {
            //Set whether it's Python/Jython
            String version = pythonNature.getVersion();
            if (IPythonNature.Versions.ALL_PYTHON_VERSIONS.contains(version)) {
                projectConfig.radioPy.setSelection(true);

            } 
//            else if (IPythonNature.Versions.ALL_IRONPYTHON_VERSIONS.contains(version)) {
//                projectConfig.radioIron.setSelection(true);
//
//            } else if (IPythonNature.Versions.ALL_JYTHON_VERSIONS.contains(version)) {
//                projectConfig.radioJy.setSelection(true);
//            }

            //We must set the grammar version too (that's from a string in the format "Python 2.4" and we only want
            //the version).
            String v = StringUtils.split(version, ' ').get(1);
            projectConfig.comboGrammarVersion.setText(v);

            //Update interpreter
            projectConfig.selectionListener.widgetSelected(null);
            String configuredInterpreter = pythonNature.getProjectInterpreterName();
            if (configuredInterpreter != null) {
                projectConfig.interpretersChoice.setText(configuredInterpreter);
            }

        } catch (CoreException e) {
            Log.log(e);
        }
    }
 
开发者ID:HuaweiSNC,项目名称:OpsDev,代码行数:33,代码来源:PyProjectPythonDetails.java

示例8: isValid

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
public boolean isValid(ILaunchConfiguration launchConfig) {
    boolean result = super.isValid(launchConfig);

    if (result) {
        setErrorMessage(null);
        setMessage(null);

        String projectName = fProjectText.getText();
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IResource resource = workspace.getRoot().findMember(projectName);

        if (resource == null) {
            setErrorMessage("Invalid project");
            result = false;
        } else if (resource instanceof IProject) {
            IProject project = (IProject) resource;
            PythonNature nature = PythonNature.getPythonNature(project);
            if (nature == null) {
                setErrorMessage("Invalid project (no python nature associated).");
                result = false;
            }
        }
    }

    return result;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:28,代码来源:ProjectBlock.java

示例9: getPythonpathFromConfiguration

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
 * Can be used to extract the pythonpath used from a given configuration.
 *
 * @param conf the configuration from where we want to get the pythonpath
 * @return a string with the pythonpath used (with | as a separator)
 * @throws CoreException
 * @throws InvalidRunException
 * @throws MisconfigurationException
 */
public static String getPythonpathFromConfiguration(ILaunchConfiguration conf, IInterpreterManager manager)
        throws CoreException, InvalidRunException, MisconfigurationException {
    IProject p = getProjectFromConfiguration(conf);
    PythonNature pythonNature = PythonNature.getPythonNature(p);
    if (pythonNature == null) {
        throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, "Project should have a python nature: "
                + p.getName(), null));
    }
    IInterpreterInfo l = getInterpreterLocation(conf, pythonNature, manager);
    return SimpleRunner.makePythonPathEnvString(pythonNature, l, manager);
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:21,代码来源:PythonRunnerConfig.java

示例10: setUp

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    closeWelcomeView();
    configureInterpreters();

    IProgressMonitor monitor = new NullProgressMonitor();
    IProject project = createProject(monitor, "coverage_test_project");
    sourceFolder = createSourceFolder(monitor, project, true, false);
    IFile initFile = createPackageStructure(sourceFolder, "pack_cov", monitor);
    modCov = initFile.getParent().getFile(new Path("mod_cov.py"));
    setFileContents(modCov, getModCovContents());

    PythonNature nature = PythonNature.getPythonNature(project);
    waitForNatureToBeRecreated(nature);
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:16,代码来源:PyCodeCoverageTestWorkbench.java

示例11: createSoureModule

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
 * @param resource
 * @param document
 * @return
 * @throws MisconfigurationException
 */
protected SourceModule createSoureModule(IResource resource, IDocument document, String moduleName)
        throws MisconfigurationException {
    SourceModule module;
    PythonNature nature = PythonNature.getPythonNature(resource.getProject());
    IFile f = (IFile) resource;
    String file = f.getRawLocation().toOSString();
    module = AbstractModule.createModuleFromDoc(moduleName, new File(file), document, nature, true);
    return module;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:16,代码来源:PyDevBuilderVisitor.java

示例12: performOk

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
 * Saves values.
 */
@Override
public boolean performOk() {

    try {
        IPythonPathNature pythonPathNature = PythonNature.getPythonPathNature(project);
        Map<String, String> variableSubstitution = pythonPathNature.getVariableSubstitution(false);

        boolean changed = update(DjangoConstants.DJANGO_MANAGE_VARIABLE, variableSubstitution,
                textDjangoManage.getText(), pythonPathNature);

        changed = update(DjangoConstants.DJANGO_SETTINGS_MODULE, variableSubstitution,
                textDjangoSettings.getText(), pythonPathNature) || changed;

        if (changed) {
            pythonPathNature.setVariableSubstitution(variableSubstitution);
            PythonNature pythonNature = PythonNature.getPythonNature(project);

            if (pythonNature != null && (changed || pythonNature.getAstManager() == null)) {
                pythonNature.rebuildPath();
            }
        }

    } catch (Exception e) {
        Log.log(e);
    }
    return true;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:31,代码来源:DjangoProjectProperties.java

示例13: okPressed

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
/**
 * Sets the internal pythonpath chosen.
 */
@Override
protected void okPressed() {
    setSelectedFrame(null);
    if (checkboxForCurrentEditor.isEnabled() && checkboxForCurrentEditor.getSelection()) {
        IProject project = this.activeEditor.getProject();
        PythonNature nature = PythonNature.getPythonNature(project);
        natures.add(nature);
        IInterpreterManager relatedInterpreterManager = nature.getRelatedInterpreterManager();
        this.interpreterManager = relatedInterpreterManager;

    } else if (checkboxPython.isEnabled() && checkboxPython.getSelection()) {
        this.interpreterManager = PydevPlugin.getPythonInterpreterManager();

    } else if (checkboxPythonDebug.isEnabled() && checkboxPythonDebug.getSelection()) {
        setSelectedFrame(getSuspendedFrame());
        this.interpreterManager = PydevPlugin.getPythonInterpreterManager();

    } else if (checkboxJython.isEnabled() && checkboxJython.getSelection()) {
        this.interpreterManager = PydevPlugin.getJythonInterpreterManager();

    } else if (checkboxJythonEclipse.isEnabled() && checkboxJythonEclipse.getSelection()) {
        this.interpreterManager = new JythonEclipseInterpreterManager();

    } else if (checkboxIronpython.isEnabled() && checkboxIronpython.getSelection()) {
        this.interpreterManager = PydevPlugin.getIronpythonInterpreterManager();

    }

    super.okPressed();
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:34,代码来源:ChooseProcessTypeDialog.java

示例14: getTargetNature

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
public IPythonNature getTargetNature() {
    if (target != null) {
        return PythonNature.getPythonNature(target);
    }
    return nature;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:8,代码来源:ModuleRenameRefactoringRequest.java

示例15: getFileInProject

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
@Override
protected IFile getFileInProject(IPath location, IProject project) {
    IFile file = super.getFileInProject(location, project);
    if (file != null) {
        return file;
    }
    PythonNature nature = PythonNature.getPythonNature(project);
    if (nature != null) {
        IPythonPathNature pythonPathNature = nature.getPythonPathNature();
        try {
            //Paths
            Set<IResource> projectSourcePathSet = pythonPathNature.getProjectSourcePathFolderSet();
            for (IResource iResource : projectSourcePathSet) {
                if (iResource instanceof IContainer) {
                    //I.e.: don't consider zip files
                    IContainer iContainer = (IContainer) iResource;
                    file = getFileInContainer(location, iContainer);
                    if (file != null) {
                        return file;
                    }
                }
            }
        } catch (CoreException e) {
            Log.log(e);
        }
    }
    return null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:29,代码来源:PySourceLocatorBase.java


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