How to use BeanTreeView?
- by joseph
Hello. I have read through whole platform.netbeans.org
and I do not find how to add some instance to existing children. I can add static array of diagrams(created in addNotify()), but how to add new Diagram object to the Children? I want to add it from an action that I will create(not included in code). See the code:
public class ExploirerTopComponent extends TopComponent implements ExplorerManager.Provider {
...
...
...
public ExploirerTopComponent() {
...
...
associateLookup (ExplorerUtils.createLookup(mgr, getActionMap()));
mgr.setRootContext(new MyProjects());//
setDisplayName ("Projects explorer");
}
public class MyProjects extends AbstractNode {
public MyProjects(MainProject obj) {
super (new ProjectsChildren(), Lookups.singleton(obj));
setDisplayName ( obj.getName());
}
public MyProjects() {
super (new ProjectsChildren());
setDisplayName ("My projects");
}
}
.
public class ProjectsChildren extends Children.Keys{
public ProjectsChildren() { }
@Override
protected Node[] createNodes(Object o) {
MainProject obj = (MainProject) o;
return new Node[] { new MyDiagrams() };
}
@Override
protected void addNotify() {
Diagram[] d = new Diagram[3];
for (int i = 0; i < pr.length; i++) {
pr[i] = new Diagram("digram");
}
setKeys (pr);
}
}