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 30598 - Focus is lost when hierarchy event listener is add to Toolkit
Summary: Focus is lost when hierarchy event listener is add to Toolkit
Status: CLOSED WORKSFORME
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 3.x
Hardware: Sun SunOS
: P3 blocker (vote)
Assignee: Peter Zavadsky
URL:
Keywords: T9Y
Depends on:
Blocks:
 
Reported: 2003-02-03 14:18 UTC by Jiri Skrivanek
Modified: 2008-12-23 09:28 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Test case (431 bytes, text/plain)
2003-02-03 14:19 UTC, Jiri Skrivanek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Skrivanek 2003-02-03 14:18:21 UTC
It has the same symtoms like 30274 and 30510 but
different way how to achieve such behaviour. In
automated tests we used to add AWTEventListener to
default Toolkit and wait for 'quiet' period
without events. If a listener with
AWTEvent.HIERARCHY_EVENT_MASK is added, it causes
unwanted switching of tabs in editor.
To reproduce:

- run IDE in MDI
- open 2 or more files in editor
- execute attached class by internal executor
- double-click file already open in editor but not
focused. It is focused for a while but focus is
moved back to the last open file
- double-click to open a file not open in editor
=> it is OK

Tested in build 200302030100, Solaris, JDK1.4.1_01.
Comment 1 Jiri Skrivanek 2003-02-03 14:19:28 UTC
Created attachment 8765 [details]
Test case
Comment 2 mslama 2003-02-05 11:33:35 UTC
This is really mess caused by adding componentShowing(). -> to make
sure component is visible there is a bunch of
TopComponent.setVisible(false/true) from our focus event dispatcher.
Call of setVisible() causes creating another focus event from
processing of previous one - it is really ugly practice. 

Fix of this issue is relatively easy: Just do not call
TopComponent.setVisible(true) from
SplitContainerImpl.componentSelected(). But this fixed issue #24485.
It is magic circle.

I spent already 2 days on investigation but still no idea why adding
another listener to Toolkit causes this change of behaviour. Perhaps
it could be that setVisible() also generates hierarchy events.

Current Winsys API is not suitable for componentShowing() approach
when we want to initialize only GUI of TopComponent added in the end.
Current implementation calls TopComponent.setVisible() everywhere just
to be sure that proper TopComponent is/is not visible.

Winsys redesign should solve this but I do not what solution shoudl be
aplied now. Peter any idea?
Comment 3 mslama 2003-02-05 11:34:43 UTC
Actually focus is not lost it is assigned to toolbar of visible top
component in Editor.
Comment 4 mslama 2003-02-05 15:06:43 UTC
I removed fix of #24422, #24485. These issues are not reproducible for
me when I removed original fix. Please Marian can you verify on
Solaris? This issue is fixed too by removing of above fixes. If there
will be problem with component visibility we will have to find some
other solution. I tested on JDK 1.4.1_01.

Modified:
core/src/org/netbeans/core/windows/frames/SplitContainerImpl.java r.1.98
Comment 5 Jiri Skrivanek 2003-02-06 12:27:34 UTC
Verified in 20030206-0100. Thanks.
Comment 6 Peter Zavadsky 2003-02-25 09:31:41 UTC
The fix was reverted, because it has caused regression of issue
#24422, see issue #31427.
Comment 7 Peter Zavadsky 2003-02-25 09:33:04 UTC
Btw. why is this P2? Decreasing it doesn't correspond to the guide
which explains which kind of issues are P2's
Comment 8 Jiri Skrivanek 2003-02-25 13:52:30 UTC
It is P2 when we apply a rule "product feature"="testability":

P2

    * product feature is significantly affected, a workaround may
exist bug is difficult to use or impractical
    * intermittent crash or deadlock, happens fairly often
    * critical usability problem
    * severe performance problem
    * affects another developer's progress

Please, fix ASAP.
Comment 9 Peter Zavadsky 2003-02-26 10:29:59 UTC
Well now it seems to be working, also Jiri confirmed it.

So there had to be made some change between Marek commit and my
rollback which in fact made the difference. 
Closing as worksforme.
Comment 10 Jiri Skrivanek 2003-02-26 10:31:08 UTC
Verified in build 200302260100.