Examples of PythonNature


Examples of org.python.pydev.plugin.nature.PythonNature

        topComp.setLayoutData(gd);

        if (project != null) {
            try {
                IPythonPathNature pathNature = PythonNature.getPythonPathNature(project);
                final PythonNature nature = PythonNature.getPythonNature(project);

                Map<String, String> variableSubstitution = pathNature.getVariableSubstitution(false);

                Label label = new Label(topComp, SWT.None);
                label.setText("Django manage.py");

                Text text = new Text(topComp, SWT.BORDER);
                textDjangoManage = text;
                textDjangoManage
                        .setToolTipText("This is the name of the project-relative location of manage.py (i.e.: src/myapp/manage.py)");

                label = new Label(topComp, SWT.None);
                labelErrorManage = new Label(topComp, SWT.None);
                labelErrorManage.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

                ModifyListener manageValidator = new ModifyListener() {

                    public void modifyText(ModifyEvent e) {
                        try {
                            String path = textDjangoManage.getText().trim();
                            if (path.trim().length() == 0) {
                                labelErrorSettings
                                        .setText("Please specify the manage.py relative name (i.e.: src/myapp/manage.py)");
                                return;
                            }

                            IFile file = project.getFile(new Path(path));
                            if (!file.exists()) {
                                labelErrorManage.setText(com.aptana.shared_core.string.StringUtils.format("File: %s could not be found.", path));
                            } else {
                                labelErrorManage.setText("");
                            }
                        } catch (Exception e1) {
                            Log.log(e1);
                        }
                    }
                };
                text.addModifyListener(manageValidator);

                text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
                String string = variableSubstitution.get(DjangoConstants.DJANGO_MANAGE_VARIABLE);
                if (string != null) {
                    text.setText(string);
                } else {
                    text.setText("");
                }

                // Settings
                label = new Label(topComp, SWT.None);
                label.setText("Django settings module");
                text = new Text(topComp, SWT.BORDER);
                textDjangoSettings = text;
                textDjangoSettings
                        .setToolTipText("This is the name of the django settings module (i.e.: myapp.settings)");

                label = new Label(topComp, SWT.None);
                labelErrorSettings = new Label(topComp, SWT.None);
                labelErrorSettings.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
                ModifyListener settingsValidator = new ModifyListener() {

                    public void modifyText(ModifyEvent e) {
                        try {
                            String moduleName = textDjangoSettings.getText().trim();
                            if (moduleName.trim().length() == 0) {
                                labelErrorSettings
                                        .setText("Please specify the name of the module (i.e.: myapp.settings)");
                                return;
                            }

                            ICodeCompletionASTManager astManager = nature.getAstManager();
                            ProjectModulesManager modulesManager = (ProjectModulesManager) astManager
                                    .getModulesManager();
                            IModule moduleInDirectManager = modulesManager.getModuleInDirectManager(moduleName, nature,
                                    true);
                            if (moduleInDirectManager == null) {
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

            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);
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    private static ILaunchConfigurationWorkingCopy getLaunchConfiguration(IFile resource, String programArguments)
            throws CoreException, MisconfigurationException, PythonNatureWithoutProjectException {
        String vmargs = ""; // Not sure if it should be a parameter or not
        IProject project = resource.getProject();
        PythonNature nature = PythonNature.getPythonNature(project);
        ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
        String launchConfigurationType = configurationFor(nature.getInterpreterType());
        ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigurationType);
        if (type == null) {
            throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, "Python launch configuration not found",
                    null));
        }

        String location = resource.getRawLocation().toString();
        String name = manager.generateUniqueLaunchConfigurationNameFrom(resource.getName());
        String baseDirectory = new File(location).getParent();
        int resourceType = IResource.FILE;

        ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, name);
        // Python Main Tab Arguments       
        workingCopy.setAttribute(Constants.ATTR_PROJECT, project.getName());
        workingCopy.setAttribute(Constants.ATTR_RESOURCE_TYPE, resourceType);
        workingCopy.setAttribute(Constants.ATTR_INTERPRETER, nature.getProjectInterpreter().getExecutableOrJar());
        workingCopy.setAttribute(Constants.ATTR_LOCATION, location);
        workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY, baseDirectory);
        workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, programArguments);
        workingCopy.setAttribute(Constants.ATTR_VM_ARGUMENTS, vmargs);
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

public class DjangoLaunchConfigurationDelegate extends AbstractLaunchConfigurationDelegate {

    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");
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    }

    public void testNullElements() throws Exception {
        final HashSet<String> pythonPathSet = new HashSet<String>();
        pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"); //root is the source
        PythonNature nature = createNature(pythonPathSet);

        WorkspaceRootStub workspaceRootStub = new WorkspaceRootStub();
        project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature);
        workspaceRootStub.addChild(project);
        project.setParent(workspaceRootStub);
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

        if (f.exists()) {
            f.delete();
        }

        pythonPathSet.add(source2Folder); //still not created!
        PythonNature nature = createNature(pythonPathSet);

        project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature, false);
        provider = new PythonModelProvider();
        Object[] children1 = provider.getChildren(project);
        assertEquals(1, children1.length);
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

        if (f.exists()) {
            f.delete();
        }

        pythonPathSet.add(source2Folder); //still not created!
        PythonNature nature = createNature(pythonPathSet);

        project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature, false);
        provider = new PythonModelProvider();
        Object[] children1 = provider.getChildren(project);
        assertEquals(1, children1.length);
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

        if (f.exists()) {
            f.delete();
        }

        pythonPathSet.add(source2Folder); //still not created!
        PythonNature nature = createNature(pythonPathSet);

        project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature, false);
        provider = new PythonModelProvider();
        Object[] children1 = provider.getChildren(project);
        assertEquals(1, children1.length);
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    }

    public void testWorkingSetsTopLevel() throws Exception {
        final HashSet<String> pythonPathSet = new HashSet<String>();
        pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"); //root is the source
        PythonNature nature = createNature(pythonPathSet);

        WorkspaceRootStub workspaceRootStub = new WorkspaceRootStub();
        project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature);
        workspaceRootStub.addChild(project);
        project.setParent(workspaceRootStub);
View Full Code Here

Examples of org.python.pydev.plugin.nature.PythonNature

    @Override
    protected void calculateChildren() {
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        IProject[] projects = root.getProjects();
        for (IProject iProject : projects) {
            PythonNature nature = PythonNature.getPythonNature(iProject);
            if (nature != null) {
                addChild(new NatureGroup(this, nature));
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.