Search in sources :

Example 16 with DataAndImageTreeNode

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

the class HierarchyLabelProvider method getStyledText.

// not there on all versions of eclipse...
@Override
public StyledString getStyledText(Object element) {
    if (element instanceof DataAndImageTreeNode) {
        @SuppressWarnings("rawtypes") DataAndImageTreeNode treeNode = (DataAndImageTreeNode) element;
        Object data = treeNode.data;
        if (data instanceof HierarchyNodeModel) {
            HierarchyNodeModel model = (HierarchyNodeModel) data;
            String spaces = "     ";
            StyledString styledString = new StyledString(model.name + spaces);
            if (model.moduleName != null && model.moduleName.trim().length() > 0) {
                Styler styler = StyledString.createColorRegistryStyler(JFacePreferences.DECORATIONS_COLOR, null);
                styledString.append("(" + model.moduleName + ")", styler);
            }
            return styledString;
        }
        return new StyledString(data.toString());
    }
    return new StyledString(element == null ? "" : element.toString());
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) StyledString(org.eclipse.jface.viewers.StyledString) DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) Styler(org.eclipse.jface.viewers.StyledString.Styler) HierarchyNodeModel(org.python.pydev.ast.refactoring.HierarchyNodeModel)

Example 17 with DataAndImageTreeNode

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

the class HierarchyLabelProvider method getText.

@Override
public String getText(Object element) {
    if (element instanceof DataAndImageTreeNode) {
        @SuppressWarnings("rawtypes") DataAndImageTreeNode treeNode = (DataAndImageTreeNode) element;
        Object data = treeNode.data;
        if (data instanceof HierarchyNodeModel) {
            HierarchyNodeModel model = (HierarchyNodeModel) data;
            String spaces = "     ";
            if (model.moduleName != null && model.moduleName.trim().length() > 0) {
                return model.name + spaces + "(" + model.moduleName + ")";
            }
            return model.name;
        }
        return data.toString();
    }
    return super.getText(element);
}
Also used : StyledString(org.eclipse.jface.viewers.StyledString) DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) HierarchyNodeModel(org.python.pydev.ast.refactoring.HierarchyNodeModel)

Example 18 with DataAndImageTreeNode

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

the class HierarchyViewer method setHierarchy.

public void setHierarchy(HierarchyNodeModel model) {
    if (classImage == null) {
        classImage = SharedUiPlugin.getImageCache().get(UIConstants.CLASS_ICON);
    }
    DataAndImageTreeNode root = new DataAndImageTreeNode(null, null, null);
    DataAndImageTreeNode item = new DataAndImageTreeNode(root, model, classImage);
    DataAndImageTreeNode base = item;
    recursivelyAdd(model, base, true, new HashSet<HierarchyNodeModel>());
    if (parentsImage == null) {
        parentsImage = SharedUiPlugin.getImageCache().get("icons/class_hi.gif");
    }
    DataAndImageTreeNode parents = new DataAndImageTreeNode(root, "Parents", parentsImage);
    recursivelyAdd(model, parents, false, new HashSet<HierarchyNodeModel>());
    treeClassesViewer.setInput(root);
    onClick(model, 1);
}
Also used : DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) HierarchyNodeModel(org.python.pydev.ast.refactoring.HierarchyNodeModel)

Example 19 with DataAndImageTreeNode

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

the class HierarchyViewer method recursivelyAdd.

private void recursivelyAdd(HierarchyNodeModel model, DataAndImageTreeNode base, boolean addChildren, HashSet<HierarchyNodeModel> memo) {
    List<HierarchyNodeModel> items = addChildren ? model.children : model.parents;
    if (items != null) {
        for (HierarchyNodeModel modelNode : items) {
            if (memo.contains(modelNode)) {
                new DataAndImageTreeNode(base, modelNode.name + " already added.", classImage);
                continue;
            }
            memo.add(modelNode);
            DataAndImageTreeNode item = new DataAndImageTreeNode(base, modelNode, classImage);
            recursivelyAdd(modelNode, item, addChildren, memo);
        }
    }
}
Also used : DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) HierarchyNodeModel(org.python.pydev.ast.refactoring.HierarchyNodeModel)

Example 20 with DataAndImageTreeNode

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

the class HierarchyViewer method handleSelection.

private void handleSelection(ISelection selection, int clickCount) {
    HierarchyNodeModel model = null;
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection iStructuredSelection = (IStructuredSelection) selection;
        Object firstElement = iStructuredSelection.getFirstElement();
        if (firstElement instanceof DataAndImageTreeNode) {
            DataAndImageTreeNode treeNode = (DataAndImageTreeNode) firstElement;
            Object data = treeNode.data;
            if (data instanceof HierarchyNodeModel) {
                model = (HierarchyNodeModel) data;
            }
        } else if (firstElement instanceof HierarchyNodeModel) {
            model = (HierarchyNodeModel) firstElement;
        }
    }
    onClick(model, clickCount);
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DataAndImageTreeNode(org.python.pydev.shared_core.structure.DataAndImageTreeNode) HierarchyNodeModel(org.python.pydev.ast.refactoring.HierarchyNodeModel)

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