Package org.python.pydev.navigator.elements

Examples of org.python.pydev.navigator.elements.PythonSourceFolder


            set.add(source2FolderChild);
            provider.interceptAdd(new PipelinedShapeModification(source2FolderFile, set));

            assertEquals(1, set.size());
            PythonFolder c = (PythonFolder) set.iterator().next();
            PythonSourceFolder sourceFolder = c.getSourceFolder();
            assertTrue(sourceFolder instanceof PythonSourceFolder);

            set.clear();
            set.add(source2FolderChild);
            provider.interceptAdd(new PipelinedShapeModification(source2FolderFile, set));
View Full Code Here


            set.add(source2FolderReChild);
            provider.interceptAdd(new PipelinedShapeModification(source2FolderChild, set));

            assertEquals(1, set.size());
            PythonFolder c = (PythonFolder) set.iterator().next();
            PythonSourceFolder sourceFolder = c.getSourceFolder();
            assertTrue(sourceFolder instanceof PythonSourceFolder);

            set.clear();
            set.add(source2FolderChild);
            provider.interceptRemove(new PipelinedShapeModification(source2FolderFile, set));
View Full Code Here

        if (DEBUG) {
            System.out.println("Getting resource in python model:" + object);
        }
        Set<PythonSourceFolder> sourceFolders = getProjectSourceFolders(object.getProject());
        Object f = null;
        PythonSourceFolder sourceFolder = null;

        for (Iterator<PythonSourceFolder> it = sourceFolders.iterator(); f == null && it.hasNext();) {
            sourceFolder = it.next();
            if (sourceFolder.getActualObject().equals(object)) {
                f = sourceFolder;
            } else {
                f = sourceFolder.getChild(object);
            }
        }
        if (f == null) {
            if (returnNullIfNotFound) {
                return null;
            } else {
                return object;
            }
        } else {
            if (removeFoundResource) {
                if (f == sourceFolder) {
                    sourceFolders.remove(f);
                } else {
                    sourceFolder.removeChild(object);
                }
            }
        }
        return f;
    }
View Full Code Here

                    }

                    Set<String> sourcePathSet = localNature.getPythonPathNature().getProjectSourcePathSet(true);
                    IPath fullPath = container.getFullPath();
                    if (sourcePathSet.contains(fullPath.toString())) {
                        PythonSourceFolder createdSourceFolder;
                        if (container instanceof IFolder) {
                            createdSourceFolder = new PythonSourceFolder(parentElement, (IFolder) container);
                        } else if (container instanceof IProject) {
                            createdSourceFolder = new PythonProjectSourceFolder(parentElement, (IProject) container);
                        } else {
                            throw new RuntimeException("Should not get here.");
                        }
View Full Code Here

            PythonNode node = (PythonNode) element;
            return node.entry.toString();
        }

        if (element instanceof PythonSourceFolder) {
            PythonSourceFolder sourceFolder = (PythonSourceFolder) element;
            return provider.getText(sourceFolder.container);
        }

        if (element instanceof IWrappedResource) {
            IWrappedResource resource = (IWrappedResource) element;
View Full Code Here

                wrapChildren(parentResource, parentResource.getSourceFolder(), modification.getChildren(), isAdd);

            } else if (pythonParent == null) {

                Object parentInWrap = parentContainer;
                PythonSourceFolder sourceFolderInWrap = null;

                //this may happen when a source folder is added or some element that still doesn't have it's parent in the model...
                //so, we have to get the parent's parent until we actually 'know' that it is not in the model (or until we run
                //out of parents to try)
                //the case in which we reproduce this is Test 1 (described in the class)
                FastStack<Object> found = new FastStack<Object>(20);
                while (true) {

                    //add the current to the found
                    if (parentContainer == null) {
                        break;
                    }

                    found.push(parentContainer);
                    if (parentContainer instanceof IProject) {
                        //we got to the project without finding any part of a python model already there, so, let's see
                        //if any of the parts was actually a source folder (that was still not added)
                        tryCreateModelFromProject((IProject) parentContainer, found);
                        //and now, if it was created, try to convert it to the python model (without any further add)
                        convertToPythonElementsUpdateOrRefresh(modification.getChildren());
                        return;
                    }

                    Object p = getResourceInPythonModel(parentContainer, true);

                    if (p instanceof IWrappedResource) {
                        IWrappedResource wrappedResource = (IWrappedResource) p;
                        sourceFolderInWrap = wrappedResource.getSourceFolder();

                        while (found.size() > 0) {
                            Object f = found.pop();
                            if (f instanceof IResource) {
                                //no need to create it if it's already in the model!
                                Object child = sourceFolderInWrap.getChild((IResource) f);
                                if (child != null && child instanceof IWrappedResource) {
                                    wrappedResource = (IWrappedResource) child;
                                    continue;
                                }
                            }
View Full Code Here

        } catch (CoreException e) {
            Log.log(e);
        }

        Object currentParent = project;
        PythonSourceFolder pythonSourceFolder = null;
        for (Iterator<Object> it = found.topDownIterator(); it.hasNext();) {
            Object child = it.next();
            if (child instanceof IFolder || child instanceof IProject) {
                if (pythonSourceFolder == null) {
                    pythonSourceFolder = tryWrapSourceFolder(currentParent, (IContainer) child, sourcePathSet);
View Full Code Here

     */
    protected IWrappedResource doWrap(Object parent, PythonSourceFolder pythonSourceFolder, Object child) {
        if (child instanceof IProject) {
            //ok, let's see if the child is a source folder (as the default project can be the actual source folder)
            if (pythonSourceFolder == null && parent != null) {
                PythonSourceFolder f = doWrapPossibleSourceFolder(parent, (IProject) child);
                if (f != null) {
                    return f;
                }
            }

        } else if (child instanceof IFolder) {
            IFolder folder = (IFolder) child;

            //it may be a PythonSourceFolder
            if (pythonSourceFolder == null && parent != null) {
                PythonSourceFolder f = doWrapPossibleSourceFolder(parent, folder);
                if (f != null) {
                    return f;
                }
            }
            if (pythonSourceFolder != null) {
View Full Code Here

            }
            PythonNature nature = PythonNature.getPythonNature(project);
            if (nature != null) {
                //check for source folder
                Set<String> sourcePathSet = nature.getPythonPathNature().getProjectSourcePathSet(true);
                PythonSourceFolder newSourceFolder = tryWrapSourceFolder(parent, container, sourcePathSet);
                if (newSourceFolder != null) {
                    return newSourceFolder;
                }
            }
        } catch (CoreException e) {
View Full Code Here

     * @return a created source folder or null if it couldn't be created.
     */
    private PythonSourceFolder tryWrapSourceFolder(Object parent, IContainer container, Set<String> sourcePathSet) {
        IPath fullPath = container.getFullPath();
        if (sourcePathSet.contains(fullPath.toString())) {
            PythonSourceFolder sourceFolder;
            if (container instanceof IFolder) {
                sourceFolder = new PythonSourceFolder(parent, (IFolder) container);
            } else if (container instanceof IProject) {
                sourceFolder = new PythonProjectSourceFolder(parent, (IProject) container);
            } else {
                return null; //some other container we don't know how to treat!
            }
View Full Code Here

TOP

Related Classes of org.python.pydev.navigator.elements.PythonSourceFolder

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.