private void onClick(final HierarchyNodeModel model, int clickCount) {
if (clickCount == 2) {
if (model != null) {
IModule m = model.module;
if (m != null && model.ast != null) {
ItemPointer pointer = new ItemPointer(m.getFile(), model.ast.name);
new PyOpenAction().run(pointer);
}
}
} else {
Runnable r = new Runnable() {
public void run() {
synchronized (lock) {
if (treeMembers.getItemCount() > 0) {
treeMembers.removeAll();
}
if (model == null) {
return;
}
ClassDef ast = model.ast;
if (ast != null && treeMembers != null) {
DefinitionsASTIteratorVisitor visitor = DefinitionsASTIteratorVisitor.create(ast);
Iterator<ASTEntry> outline = visitor.getOutline();
HashMap<SimpleNode, TreeItem> c = new HashMap<SimpleNode, TreeItem>();
boolean first = true;
while (outline.hasNext()) {
ASTEntry entry = outline.next();
if (first) {
//Don't add the class itself.
first = false;
continue;
}
TreeItem item = null;
if (entry.node instanceof FunctionDef) {
item = createTreeItem(c, entry);
item.setImage(PydevPlugin.getImageCache().get(UIConstants.METHOD_ICON));
if (model.module != null) {
item.setData(new ItemPointer(model.module.getFile(),
((FunctionDef) entry.node).name));
}
} else if (entry.node instanceof ClassDef) {
item = createTreeItem(c, entry);
item.setImage(PydevPlugin.getImageCache().get(UIConstants.CLASS_ICON));
if (model.module != null) {
item.setData(new ItemPointer(model.module.getFile(),
((ClassDef) entry.node).name));
}
} else {
item = createTreeItem(c, entry);
item.setImage(PydevPlugin.getImageCache().get(UIConstants.PUBLIC_ATTR_ICON));
if (model.module != null) {
item.setData(new ItemPointer(model.module.getFile(), entry.node));
}
}
item.setText(entry.getName());
item.setExpanded(true);
}