Search in sources :

Example 11 with DataAndImageTreeNode

use of org.python.pydev.shared_core.structure.DataAndImageTreeNode in project Pydev by fabioz.

the class PyOutlineSelectionDialog method fillHierarchy.

@SuppressWarnings({ "unchecked", "rawtypes" })
private void fillHierarchy(DataAndImageTreeNode<Object> entry) {
    ArrayList<DataAndImageTreeNode<Object>> copy = new ArrayList(entry.getChildren());
    for (DataAndImageTreeNode<Object> nextEntry : copy) {
        HierarchyNodeModel model = this.nodeToModel.get(((OutlineEntry) nextEntry.data).node);
        addMethods(nextEntry, model);
        fillHierarchy(nextEntry);
    }
}
Also used : ArrayList(java.util.ArrayList) DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) HierarchyNodeModel(org.python.pydev.ast.refactoring.HierarchyNodeModel)

Example 12 with DataAndImageTreeNode

use of org.python.pydev.shared_core.structure.DataAndImageTreeNode in project Pydev by fabioz.

the class PyOutlineSelectionDialog method open.

/* (non-Javadoc)
     * @see org.eclipse.ui.dialogs.ElementTreeSelectionDialog#open()
     */
@Override
public int open() {
    int ret = super.open();
    if (ret == OK) {
        Object[] result = getResult();
        if (result != null && result.length > 0) {
            @SuppressWarnings("unchecked") DataAndImageTreeNode<Object> n = (DataAndImageTreeNode<Object>) result[0];
            OutlineEntry outlineEntry = (OutlineEntry) n.data;
            if (outlineEntry.model == null) {
                Location location = new Location(NodeUtils.getNameLineDefinition(outlineEntry.node) - 1, NodeUtils.getNameColDefinition(outlineEntry.node) - 1);
                EditorUtils.showInEditor(pyEdit, location, location);
            } else {
                PyOpenAction pyOpenAction = new PyOpenAction();
                IModule m = outlineEntry.model.module;
                if (m instanceof SourceModule) {
                    SourceModule sourceModule = (SourceModule) m;
                    File file = sourceModule.getFile();
                    if (file != null) {
                        ItemPointer p = new ItemPointer(file, outlineEntry.node);
                        pyOpenAction.run(p);
                    }
                }
            }
        }
    }
    return ret;
}
Also used : SourceModule(org.python.pydev.ast.codecompletion.revisited.modules.SourceModule) IModule(org.python.pydev.core.IModule) PyOpenAction(org.python.pydev.editor.actions.PyOpenAction) DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) File(java.io.File) Location(org.python.pydev.shared_core.structure.Location) ItemPointer(org.python.pydev.ast.item_pointer.ItemPointer)

Example 13 with DataAndImageTreeNode

use of org.python.pydev.shared_core.structure.DataAndImageTreeNode in project Pydev by fabioz.

the class ShowOutlineLabelProvider method getText.

@Override
public String getText(Object element) {
    if (element instanceof DataAndImageTreeNode) {
        @SuppressWarnings("rawtypes") DataAndImageTreeNode treeNode = (DataAndImageTreeNode) element;
        element = treeNode.data;
    }
    if (element instanceof OutlineEntry) {
        OutlineEntry entry = (OutlineEntry) element;
        String start = NodeUtils.getFullRepresentationString(entry.node);
        if (entry.model != null) {
            FastStringBuffer suffix = new FastStringBuffer("  (", entry.model.name.length() + 50).append(entry.model.name);
            if (entry.model.moduleName != null && entry.model.moduleName.length() > 0) {
                suffix.append(" - ").append(entry.model.moduleName);
            }
            suffix.append(')');
            return start + suffix.toString();
        }
        return start;
    }
    if (element instanceof ASTEntry) {
        return NodeUtils.getFullRepresentationString(((ASTEntry) element).node);
    }
    return element.toString();
}
Also used : FastStringBuffer(org.python.pydev.shared_core.string.FastStringBuffer) ASTEntry(org.python.pydev.parser.visitors.scope.ASTEntry) StyledString(org.eclipse.jface.viewers.StyledString) DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode)

Example 14 with DataAndImageTreeNode

use of org.python.pydev.shared_core.structure.DataAndImageTreeNode in project Pydev by fabioz.

the class ShowOutlineLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    SimpleNode n = null;
    if (element instanceof DataAndImageTreeNode) {
        @SuppressWarnings("rawtypes") DataAndImageTreeNode treeNode = (DataAndImageTreeNode) element;
        element = treeNode.data;
    }
    if (element instanceof OutlineEntry) {
        n = ((OutlineEntry) element).node;
    }
    if (element instanceof ASTEntry) {
        n = ((ASTEntry) element).node;
    }
    if (n != null) {
        IImageCache imageCache = SharedUiPlugin.getImageCache();
        if (imageCache == null) {
            return null;
        }
        return ParsedItem.getImageForNode(imageCache, n, null);
    }
    return null;
}
Also used : IImageCache(org.python.pydev.shared_core.image.IImageCache) ASTEntry(org.python.pydev.parser.visitors.scope.ASTEntry) DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) SimpleNode(org.python.pydev.parser.jython.SimpleNode)

Example 15 with DataAndImageTreeNode

use of org.python.pydev.shared_core.structure.DataAndImageTreeNode in project Pydev by fabioz.

the class Counter method isBig.

@SuppressWarnings("rawtypes")
@Override
public boolean isBig(Object input) {
    final Counter counter = new Counter();
    if (input == null) {
        return false;
    }
    // We consider a tree with a size of 400 items to be big.
    int SIZE_TO_CONSIDER_BIG = 400;
    DataAndImageTreeNode m = (DataAndImageTreeNode) input;
    m.traverse((DataAndImageTreeNode c) -> {
        counter.increment(c.childrenCount());
        if (counter.count > SIZE_TO_CONSIDER_BIG) {
            return false;
        }
        return true;
    });
    return counter.count > SIZE_TO_CONSIDER_BIG;
}
Also used : DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode)

Aggregations

DataAndImageTreeNode (org.python.pydev.shared_core.structure.DataAndImageTreeNode)22 ArrayList (java.util.ArrayList)9 IInterpreterInfo (org.python.pydev.core.IInterpreterInfo)8 HierarchyNodeModel (org.python.pydev.ast.refactoring.HierarchyNodeModel)7 TreeNode (org.python.pydev.shared_core.structure.TreeNode)7 HashSet (java.util.HashSet)5 InterpreterInfo (org.python.pydev.ast.interpreter_managers.InterpreterInfo)5 ASTEntry (org.python.pydev.parser.visitors.scope.ASTEntry)5 HashMap (java.util.HashMap)4 List (java.util.List)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 StyledString (org.eclipse.jface.viewers.StyledString)4 SyncSystemModulesManager (org.python.pydev.ast.codecompletion.revisited.SyncSystemModulesManager)4 IInterpreterManager (org.python.pydev.core.IInterpreterManager)4 AdditionalSystemInterpreterInfo (com.python.pydev.analysis.additionalinfo.AdditionalSystemInterpreterInfo)3 File (java.io.File)3 Collection (java.util.Collection)3 Map (java.util.Map)3 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)2 BackingStoreException (org.osgi.service.prefs.BackingStoreException)2