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);
}
}
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;
}
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();
}
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;
}
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;
}
Aggregations