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 30758 - Unnecessary TopComponent activation after mouse click
Summary: Unnecessary TopComponent activation after mouse click
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 3.x
Hardware: All All
: P3 blocker (vote)
Assignee: mslama
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-06 11:54 UTC by mslama
Modified: 2008-12-23 09:32 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
shortest testcase for internal execution (1.17 KB, application/octet-stream)
2003-02-06 23:36 UTC, andrew
Details
Patch (34.94 KB, application/octet-stream)
2003-02-07 16:17 UTC, mslama
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mslama 2003-02-06 11:54:44 UTC
There is strange TopComponent activation:
1.Add to bottom of Explorer some focusable
TopComponent.
2.Filesystem tab should be selected at center area
(ExplorerPanel).
3.Open anything in Source Editor.
4.Select your TopComponent at bottom of Explorer
5.Select TopComponent in Source Editor by mouse click.
6.Click on test TopComponent at bottom of Explorer.
7.Sometimes first Filesystem is activated
(receives focus) first and then test TopComponent
is activated. You can see it at frame title it
shortly displays "Explorer [Filesystems]".
Comment 1 andrew 2003-02-06 12:54:23 UTC
Some additinal info is in a thread with this message:


http://www.netbeans.org/servlets/ReadMsg?msgId=460183&listNa
me=nbdev




I (original reporter :-) have the issue on win XP, so 
changing OS


from Linux to All




Andrew
Comment 2 _ leonchiver 2003-02-06 12:57:06 UTC
Here's the bug from a user's perspective:

1) open netbeans,  close all editor windows, leave only the explorer
and the output window open
2) Activate an explorer tab, lets say "Filesystems"
3) Click in the output window
4) Now click on then "Runtime" tab from the explorer window.

You can see that it's activated for a very short time, than the
"Filesystems" tab is activated again. I have to click again on the
"Runtime" tab to activate it. Very annoying. That's why I'm increasing
priority :)
Comment 3 mslama 2003-02-06 14:42:16 UTC
I removed call of requestDefaultFocus() from
ExplorerPanel.requestFocus(). Subclasses of ExplorerPanel should
overwrite requestFocus() and set focus to desired subcomponent after
super.requestFocus() is called. Also NbMainExplorer$ExplorerTab now
overwrites TopComponent.requestFocus() instead of overwriting it in
ExplorerPanel. (Issue #29848.)

Modified:
openide/src/org/openide/explorer/ExplorerPanel.java r.1.40
Comment 4 andrew 2003-02-06 17:06:00 UTC
Marek,

unfortunately, can not verify the fix. 
Try this sequence:

Filesystems - Editor - TC under testing

This listener's code (without any extra 
code in the listener)

TopComponent tc = 
   TopComponent.getRegistry().getActivated();
if(tc == null)
    return;
if(tc.equals(this)) {
    System.err.println("Self-selected");
    return;
}
System.err.println(tc.getName());

gives this output after clicking on TC under 
testing:

...
Filesystems
Self-selected
Filesystems
Self-selected
...

You see, there are four(!) activations now.
Comment 5 mslama 2003-02-06 17:31:38 UTC
I had your component at bottom of Explorer, some text in Source
Editor. Now I click on your component and component in source editor.
I have log in RegistryImpl.topComponentActivated(). Before there was
call with Filesystems. But not now. Only your top component is
activated. Can you verify this? Or could you send me your module with
log? And possibly one call stack Thread.dumpStack(). I will check your
sequence. Thanks. BTW what JDK do you use? I have JDK 1.4.1_01. There
is diff between JDK 1.3 and 1.4 in focus area.
Comment 6 mslama 2003-02-06 17:34:44 UTC
I forgot I was clicking alternatively on your TC and source editor
more than once. Click and see what events are comming (activation and
focus events).
Comment 7 mslama 2003-02-06 17:42:17 UTC
One more note you should add 
requestFocus() {
super.requestFocus();
beanTreeView.requestFocus();
} to your top component. It will make sure that focus is set correctly.
Comment 8 andrew 2003-02-06 17:47:40 UTC
Marek,

Yes, seq. TC-Editor-TC-Editor-... works now without
any problems.
Try FS-Editor-TC-FS-Editor-TC-... here 4 events take
place after clicking on TC.

_All_ code of the listener was included in my prev.
commit. For testing purpose all other code was commented.
Comment 9 andrew 2003-02-06 17:49:19 UTC
Yes, I have tried with requestFocus() 
with the same result.
Comment 10 andrew 2003-02-06 17:53:36 UTC
Well, env. was reported in our mail thread:
win XP, j2se 1.4.1_01
I have tried to switch to "All" OS instead
of "Linux", but you have switched back to "Linux" :-)
Comment 11 andrew 2003-02-06 23:36:08 UTC
Created attachment 8837 [details]
shortest testcase for internal execution
Comment 12 andrew 2003-02-06 23:40:15 UTC
Marek,

I have created very short and clear testcase (I think :-). It is main() for internal execution. Hope, will help.

Andrew
Comment 13 mslama 2003-02-07 12:29:17 UTC
Yes you are right. Problem is caused by changes in
DefaultContainerImpl made by Peter (new actions implementation). We
also activate TopComponent when frame is activated - in this case
originally selected component is activated first and then we process
FOCUS_GAINED for your component which is selected then. Before there
was delayed activation ie. when more activation requests was required
only last one was performed. Now it doe snot work this way. I think
that functionality should be returned back. Peter what do you think?
Other solution (not activate top component when only frame is selected
eg when you just click on frame title bar is not possible - it would
change behaviour) is not possible.
Comment 14 mslama 2003-02-07 16:16:05 UTC
I created patch: Activation of TopComponent comming from
frameActivated() is delayed to make sure that proper TopComponent is
set before. Please check that.

I observed one strange thing: When I start IDE. Source Editor selected
and then click on Filesystem on some class node you component is
updated and takes focus from Filesystems. Is it correct behaviour?

I will attach patch. Put it to lib/patches and test it please.
Comment 15 mslama 2003-02-07 16:17:24 UTC
Created attachment 8844 [details]
Patch
Comment 16 andrew 2003-02-07 16:50:30 UTC
Marek,

It is difficult to test because of periodic frequent
exception:

java.lang.NullPointerException
	at org.netbeans.core.windows.frames.DefaultContainerImpl.reactivateSelectedComponent(DefaultContainerImpl.java:1077)
[catch] at org.netbeans.core.windows.frames.DefaultContainerImpl$2.run(DefaultContainerImpl.java:1135)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:448)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

Andrew
Comment 17 andrew 2003-02-07 17:03:00 UTC
>>...then click on Filesystem on some class node 
>>you component is updated and takes focus from 
>> Filesystems. Is it correct behaviour?

This is a goal - to show expanded java file tree
when appropriate node (in explorer, search result,
editor, ...) is activated. This TC is some (and 
first :-) kind of outline panel.

The module try to wait java node parsing,
creates FilterNode and expands it.
Comment 18 andrew 2003-02-07 17:14:12 UTC
Marek,

Patched path seems to work well, - at least, during
few minutes clicking :-) Thanks!

My suggestion is: I'll test overall the IDE behaviour
during upcoming weekends.
Comment 19 mslama 2003-02-07 17:16:36 UTC
I have no problem with your component updating but with stealing focus
:). Ok good to hear I will test it too and probably on Monday commit
fix to trunk.
Comment 20 andrew 2003-02-10 11:32:44 UTC
Marek,

During last weekends I have not noticed any
side-effects of your patch.

BTW, how does focus stealing become apparent?
Comment 21 mslama 2003-02-10 11:51:23 UTC
Second part of fix. TopComponent activation is delayed when called
from frameActivated(). I also tested that issue #29939 does not appear
again.

Modified:
core/src/org/netbeans/core/windows/frames/DefaultContainerImpl.java r.1.71

Regarding focus stealing: Focus is moved to your TopComponent ie.
focus is not in FS.
Comment 22 Marian Mirilovic 2003-04-01 14:39:50 UTC
verified in [s1s5](030331)