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