How to use BeanTreeView?
Posted
by joseph
on Stack Overflow
See other posts from Stack Overflow
or by joseph
Published on 2010-03-23T18:57:38Z
Indexed on
2010/03/23
19:03 UTC
Read the original article
Hit count: 526
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);
}
}
© Stack Overflow or respective owner