This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 28685 - unable to programmatically select node on runtime tab, even using common workaround
Summary: unable to programmatically select node on runtime tab, even using common work...
Status: VERIFIED WORKSFORME
Alias: None
Product: platform
Classification: Unclassified
Component: Explorer (show other bugs)
Version: 3.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jiri Rechtacek
URL:
Keywords:
Depends on: 7551
Blocks:
  Show dependency tree
 
Reported: 2002-11-12 20:12 UTC by Jeri Lockhart
Modified: 2008-12-22 20:31 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
source for test (1.74 KB, text/plain)
2002-11-14 12:39 UTC, Jiri Rechtacek
Details
test code put into an action class (3.19 KB, text/plain)
2002-11-14 18:17 UTC, Jeri Lockhart
Details
modified test code (correct file) (3.07 KB, text/plain)
2002-11-14 19:16 UTC, Jeri Lockhart
Details
ExplorerPanel workaround (5.34 KB, text/plain)
2002-11-19 18:41 UTC, Jeri Lockhart
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeri Lockhart 2002-11-12 20:12:11 UTC
Unable to select nodes on the Runtime tab.  Am
using stripped version of the prj40_prototype.  In
the UI, the Runtime tab looks like this:

Runtime
 - Server Registry
   - ServerA
     - ServerInstance
       - ServerTarget
 - Processes
   - (No processes running)


TopComponent.getRegistry().getActivated() returns
 class org.netbeans.core.NbMainExplorer$MainTab

This explorer objects implements
ExplorerManager.Provider so I use it to find the
ExplorerManager.

ExplorerManager getRootContext() returns
org.openide.nodes.AbstractNode@3d246[Name=,
displayName=]

The root node has no children. 

If I use the explorer object directly, I can get
the currently active node which is FilterNode.
Activated Node:
org.openide.nodes.FilterNode@470f32[Name=,
displayName=Sample JSR88 plugin]

This node has several children:
Child of Activated Node:
org.openide.nodes.FilterNode@411557[Name=,
displayName=Sample JSR88 plugin(123)]
Child of Activated Node:
org.openide.nodes.FilterNode@6023f7[Name=,
displayName=Sample JSR88 plugin(FooServerUrl)]
Child of Activated Node:
org.openide.nodes.FilterNode@595033[Name=,
displayName=Sample JSR88 plugin(qwerty)]
Child of Activated Node:
org.openide.nodes.FilterNode@20463e[Name=,
displayName=Sample JSR88 plugin(url6)]
Child of Activated Node:
org.openide.nodes.FilterNode@63a921[Name=,
displayName=Sample JSR88 plugin(BarServerUrl)]
Child of Activated Node:
org.openide.nodes.FilterNode@74c144[Name=,
displayName=Sample JSR88 plugin(url1)]
Child of Activated Node:
org.openide.nodes.FilterNode@3c765e[Name=,
displayName=Sample JSR88 plugin(fixedurl)]
Child of Activated Node:
org.openide.nodes.FilterNode@7f2036[Name=,
displayName=Sample JSR88 plugin(xyz)]
Child of Activated Node:
org.openide.nodes.FilterNode@1bd427[Name=,
displayName=Sample JSR88 plugin(Url4)]
Child of Activated Node:
org.openide.nodes.FilterNode@54f93[Name=,
displayName=Sample JSR88 plugin(Url3)]
Child of Activated Node:
org.openide.nodes.FilterNode@2b4292[Name=,
displayName=Sample JSR88 plugin(Url2)]
Child of Activated Node:
org.openide.nodes.FilterNode@1fac35[Name=,
displayName=Sample JSR88 plugin(url7)]

But if I try to select them using TopComponent
setActivatedNodes(Node[]), nothing happens.  If I
try to select them using ExplorerManager
setSelectedNodes(Node[]) I get an
IllegalArgumentException "A node selection cannot
contain nodes not underneath the root"
Comment 1 Jiri Rechtacek 2002-11-14 12:36:53 UTC
Jeri, I tried reproduce this issue and it worked for me. I attach a me
test code, could you run it? The test assume by run internally of
course and the Explorer/Runtime is activated. Send me please, how it
works for you. Thanks.
Comment 2 Jiri Rechtacek 2002-11-14 12:39:22 UTC
Created attachment 7947 [details]
source for test
Comment 3 Jeri Lockhart 2002-11-14 18:17:44 UTC
Created attachment 7950 [details]
test code put into an action class
Comment 4 Jeri Lockhart 2002-11-14 19:13:56 UTC
This is the output from the test run:   
     [exec] COMP:
org.netbeans.core.NbMainExplorer$MainTab[Runtime,2,2,369x431,layout=java.awt.BorderLayout,alignmentX=null,alignmentY=null,border=,fl
ags=1,maximumSize=,minimumSize=,preferredSize=]
     [exec] 0. activated node:
org.openide.nodes.FilterNode@6d06b0[Name=, displayName=Server Registry
(tools jsr version) (No default server)]
     [exec] root: org.openide.nodes.AbstractNode@4ce5eb[Name=,
displayName=]

I had to make some changes to your code because my module cannot have
a dependency on org.netbeans.core.NbMainExplorer.  I also put the code
into an action class for an action on one of the nodes on the runtime
tab. (See second attachment dated 2002-11-14) 

As you can see from the output, the ExplorerManager seems to be wrong,
it doesn't seem to match the TopComponent.  The root node returned by
the ExplorerManager is an AbstractNode with no name or display name,
and it has no children.

This was built and run on the projects (prj40_prototype) branch.

Please disregard the first attachment, its not the correct file.  The
second one sent 2002-11-14 is correct.

Comment 5 Jeri Lockhart 2002-11-14 19:16:31 UTC
Created attachment 7951 [details]
modified test code (correct file)
Comment 6 Jiri Rechtacek 2002-11-19 17:45:22 UTC
Hi Jeri,
I have some like as hot fix. Replace expMgr = ExplorerManager.find(tc)
with this code:
ExplorerPanel  expPanel = null;
if (tc instanceof ExplorerPanel) {
  expPanel = (ExplorerPanel)tc;
}
ExplorerManager expMgr = expPanel.getExplorerManager ();
It should work for you :) Is it accpetable?
-jiri
Comment 7 Jeri Lockhart 2002-11-19 18:37:53 UTC
Hi Jiri,
The workaround that you suggested didn't work.  I still get the
IllegalArgumentException.  I'll send you an attachment with the test
code that I used.  Have you tried this on the projects branch
(prj40_prototype)?
--Jeri


 [exec] java.lang.IllegalArgumentException: A node selection cannot
contain nodes (Sample JSR88 plugin(server3)) not underneath the root
(Runtime)

 [exec]     at
org.openide.explorer.ExplorerManager.setSelectedNodes(ExplorerManager.java:150)
 [exec]     at
org.netbeans.modules.j2ee.deployment.impl.ui.actions.FindDeploymentManagerAction$1.run(FindDeploymentManagerAction.java:98)
 [exec]     at
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:149)
 [exec]     at java.awt.EventQueue.dispatchEvent(EventQueue.java:332)
 [exec] [catch] at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:126)
 [exec]     at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:93)
 [exec]     at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:88)
 [exec]     at
java.awt.EventDispatchThread.run(EventDispatchThread.java:80)
Comment 8 Jeri Lockhart 2002-11-19 18:41:28 UTC
Created attachment 7993 [details]
ExplorerPanel workaround
Comment 9 Jiri Rechtacek 2002-11-20 17:52:54 UTC
I not tried it on projects branch but it should work on it because it
based on nb34. There wasn't any changes on this code. Make sure that
found node is from the root subtree. No other can be selected. If node
isn't from the root subtree, you should add it and then select it.
Comment 10 Jeri Lockhart 2002-11-20 18:11:09 UTC
You'll need to run the test on the projects branch to duplicate the
problem.  It is not working on this branch for some reason.  I am
working in the stripped version.

The ExplorerManager returns an Abstract Node for its root.  This node
has no name or display name and no children.  

The TopComponent returns the proper root and children.

So, for some reason, the ExplorerManager doesn't know about the nodes
that are in the TopComponent.

Here is some additional information:
TopComponent.setActivatedNodes() does nothing when passed an array of
children of the root of the TopComponent.  The nodes that I am trying
to activate do exist in the TopComponent.

Comment 11 Jiri Rechtacek 2003-01-06 14:06:31 UTC
This issue was reported on the prj40_prototype branch, so I set back
version 4.0 and mark with PROJECTS keyword.
Comment 12 Jiri Rechtacek 2003-04-03 14:34:56 UTC
Jeri, I assured the attached test worked on prj40_prototype branch.
Project's codeline was changes a lot, now it works for me. Ad your
FindDeploymentManagerAction.java: Make sure, that a root node given to
method findInstanceNode(root) comes from hierarchy of
ExplorerPanel.getExplorerManager().getRootContext(). Hope it works for
you too. Feel free to contact me (directly via mail or via this issue)
if any problem appears. Regards, Jiri
Comment 13 Marian Mirilovic 2003-07-31 10:44:33 UTC
verifying.