Package org.python.pydev.core

Examples of org.python.pydev.core.IPythonPathNature


            //and the nature...
            if (nature != null && nature.startRequests()) {

                try {
                    IPythonPathNature pythonPathNature = nature.getPythonPathNature();
                    pythonPathNature.getProjectSourcePath(false); //this is just to update the paths (in case the project name has just changed)

                    List<IFile> resourcesToParse = new ArrayList<IFile>();

                    List<PyDevBuilderVisitor> visitors = getVisitors();
                    notifyVisitingWillStart(visitors, monitor, true, nature);
View Full Code Here


        //project
        if (parentElement instanceof IProject) {
            List<Object> ret = new ArrayList<Object>();
            IProject project = (IProject) parentElement;
            IPythonPathNature nature = PythonNature.getPythonPathNature(project);
            if (nature != null) {
                try {
                    String[] srcPaths = PythonNature.getStrAsStrItems(nature.getProjectSourcePath(true));
                    for (String str : srcPaths) {
                        IResource resource = this.workspaceRoot.findMember(new Path(str));
                        if (resource instanceof IFolder) {
                            IFolder folder = (IFolder) resource;
                            if (folder.exists()) {
View Full Code Here

        }
        for (IPythonNature nature : pythonNatures) {
            try {
                //If they have the same type of the interpreter manager, notify.
                if (this.getInterpreterType() == nature.getInterpreterType()) {
                    IPythonPathNature pythonPathNature = nature.getPythonPathNature();

                    //There's a catch here: if the nature uses some variable defined in the string substitution
                    //from the interpreter info, we need to do a full build instead of only making a notification.
                    String complete = pythonPathNature.getProjectExternalSourcePath(false)
                            + pythonPathNature.getProjectSourcePath(false);

                    PythonNature n = (PythonNature) nature;
                    String projectInterpreterName = n.getProjectInterpreterName();
                    IInterpreterInfo info;
                    if (IPythonNature.DEFAULT_INTERPRETER.equals(projectInterpreterName)) {
View Full Code Here

                        //it should be fast to get it too if it's consistent).
                        if (pythonpath.size() == 0 || currentTimeMillis - m2.checkedPythonpathConsistency > 20 * 1000) {
                            try {
                                IPythonNature n = m.getNature();
                                if (n != null) {
                                    IPythonPathNature pythonPathNature = n.getPythonPathNature();
                                    if (pythonPathNature != null) {
                                        onlyProjectPythonPathStr = pythonPathNature.getOnlyProjectPythonPathStr(true);
                                        m2.checkedPythonpathConsistency = currentTimeMillis;
                                        forceCheck = true;
                                    }
                                }
                            } catch (Exception e) {
View Full Code Here

                IFile f = (IFile) element;
                element = f.getParent();
            }

            if (element instanceof IProject) {
                IPythonPathNature nature = PythonNature.getPythonPathNature((IProject) element);
                if (nature != null) {
                    String[] srcPaths = PythonNature.getStrAsStrItems(nature.getProjectSourcePath(true));
                    if (srcPaths.length > 0) {
                        textSourceFolder.setText(srcPaths[0]);
                        return true;
                    }
                }
View Full Code Here

     * @param f
     * @return
     * @throws CoreException
     */
    public String getSrcFolderFromFolder(IFolder f) throws CoreException {
        IPythonPathNature nature = PythonNature.getPythonPathNature(f.getProject());
        if (nature != null) {
            String[] srcPaths = PythonNature.getStrAsStrItems(nature.getProjectSourcePath(true));
            String relFolder = f.getFullPath().toString() + "/";
            for (String src : srcPaths) {
                if (relFolder.startsWith(src + "/")) {
                    return src;
                }
View Full Code Here

        }
        IProject project = resource.getProject();
        if (project == null) {
            return "Unable to find the project related to the source folder.";
        }
        IPythonPathNature nature = PythonNature.getPythonPathNature(project);
        if (nature == null) {
            return "The pydev nature is not configured on the project: " + project.getName();
        }
        String full = resource.getFullPath().toString();
        String[] srcPaths = PythonNature.getStrAsStrItems(nature.getProjectSourcePath(true));
        for (String str : srcPaths) {
            if (str.equals(full)) {
                validatedSourceFolder = (IContainer) resource;
                return null;
            }
View Full Code Here

        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()) {
            folder.create(true, true, 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);
        }
        if (curr.length() > 0) {
            //there is already some path
            curr += "|" + newPath;
        } else {
            //there is still no other path
            curr = newPath;
        }
        pathNature.setProjectSourcePath(curr);
        PythonNature.getPythonNature(project).rebuildPath();
        return null;
    }
View Full Code Here

                IProject createdProject = appEngineWizard.getCreatedProject();
                PythonNature nature = PythonNature.getPythonNature(createdProject);
                Map<String, String> expected = new HashMap<String, String>();
                expected.put(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE, new File(
                        TestDependent.GOOGLE_APP_ENGINE_LOCATION).getAbsolutePath());
                IPythonPathNature pythonPathNature = nature.getPythonPathNature();
                try {
                    assertEquals(expected, pythonPathNature.getVariableSubstitution());

                    String projectExternalSourcePath = pythonPathNature.getProjectExternalSourcePath(false);
                    assertTrue(projectExternalSourcePath.indexOf(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE) != -1);
                    projectExternalSourcePath = pythonPathNature.getProjectExternalSourcePath(true);
                    assertTrue(projectExternalSourcePath.indexOf(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE) == -1);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
View Full Code Here

            if (nature == null) {
                MessageDialog.openError(PyAction.getShell(), "PyDev nature not found",
                        "Unable to perform action because the Pydev nature is not properly set.");
                return;
            }
            IPythonPathNature pythonPathNature = nature.getPythonPathNature();
            String settingsModule = null;
            Map<String, String> variableSubstitution = null;
            try {
                variableSubstitution = pythonPathNature.getVariableSubstitution();
                settingsModule = variableSubstitution.get(DjangoConstants.DJANGO_SETTINGS_MODULE);
            } catch (Exception e1) {
                throw new RuntimeException(e1);
            }
            if (settingsModule == null) {
                InputDialog d = new InputDialog(PyAction.getShell(), "Settings module",
                        "Please enter the settings module to be used.\n" + "\n"
                                + "Note that it can be edited later in:\np"
                                + "roject properties > pydev pythonpath > string substitution variables.",
                        selectedProject.getName() + ".settings", new IInputValidator() {

                            public String isValid(String newText) {
                                if (newText.length() == 0) {
                                    return "Text must be entered.";
                                }
                                for (char c : newText.toCharArray()) {
                                    if (c == ' ') {
                                        return "Whitespaces not accepted";
                                    }
                                    if (c != '.' && !Character.isJavaIdentifierPart(c)) {
                                        return "Invalid char: " + c;
                                    }
                                }
                                return null;
                            }
                        });

                int retCode = d.open();

                if (retCode == InputDialog.OK) {
                    settingsModule = d.getValue();
                    variableSubstitution.put(DjangoConstants.DJANGO_SETTINGS_MODULE, settingsModule);
                    try {
                        pythonPathNature.setVariableSubstitution(variableSubstitution);
                    } catch (Exception e) {
                        Log.log(e);
                    }

                }
View Full Code Here

TOP

Related Classes of org.python.pydev.core.IPythonPathNature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.