I'm also curious about this.

It seems to me the API is somewhat incomplete, specifically in the async area. 
We have no Future to listen to and react. So, it's all fire-and-forget when 
often times you want to do something after the node has been created / shown.

In your case you control the beanTreeView so as a last resort I guess you could 
subclass the view and listen on the JTree directly (it's a protected field). 
Still... it's ugly.

Not really sure if there's some other way. If you do find it, please come back 
on the mailing list and let us know.

--emi

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On 13 April 2018 12:28 PM, Marco Rossi <ma...@markreds.it> wrote:

> Hi there,
> 
> can someone tell me how to programmatically select a node in my beanTreeView 
> (backed up by an explorerManager) after being created in my data model? I 
> tried to do this in parent node, by adding a NodeListener like this:
> 
> parentNode.addNodeListener(new NodeAdapter() {
> 
> @Override
> 
> public void childrenAdded(NodeMemberEvent ev) {
> 
> if (ev.isAddEvent()) {
> 
> final Node node = ev.getNode();
> 
> SwingUtilities.invokeLater(new Runnable() {
> 
> @Override
> 
> public void run() {
> 
> try {
> 
> LibraryViewerTopComponent.findInstance().getExplorerManager().setSelectedNodes(new
>  Node[] { node });
> 
> } catch (PropertyVetoException ex) {
> 
> MessageBox.error(ex);
> 
> }
> 
> }
> 
> });
> 
> }
> 
> }
> 
> });
> 
> When I create a new item in my data model, the ChildFactory refreshes 
> asynchronously itself and creates a new node representing the data. 
> Unfortunately this does’t work because the child node may be not exists yet 
> in the explorer manager. Any suggestions?
> 
> 
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> 
> To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
> 
> For additional commands, e-mail: users-h...@netbeans.apache.org
> 
> For further information about the NetBeans mailing lists, visit:
> 
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to