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 134910 - The return of "Aggressive focus grabbing by the editor"
Summary: The return of "Aggressive focus grabbing by the editor"
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: mslama
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-13 04:44 UTC by ivan
Modified: 2008-12-22 10:03 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ivan 2008-05-13 04:44:16 UTC
IZ 108834 described how the editor would aggressively grab focus 
when Line.SHOW_SHOW was used by sunstudios dbx gui.

It seems that a variation of this problem is back in the 6.x codebase.
Line.SHOW_SHOW, if it opens a new edito tab will cause focus to
get grabbed away.

I've submitted a standalone reproducible testcase project as part of IZ 132671.
Please familiarize yourself with it first and then consider the following
commands:

Issue "edit A". The editor will open file A.
Issue "line 10" and see the editor line hilite move to line 10.
Issue "edit B". Observe how the focus moves away from ReadEvalPrint.
Issue "edit A" again. Now the focus doesn't move away. Ergo it's only
the opning of new files which causes focus to shift.
Comment 1 Lukas Hasik 2008-05-28 16:12:33 UTC
it seems that there were no changes in the EditorSupportLineSet.java from the fix for the issue 108834 that you verified...
http://hg.netbeans.org/main/log/tip/openide.text/src/org/openide/text/EditorSupportLineSet.java
Comment 2 ivan 2008-05-28 22:16:16 UTC
This new behaviour does not have to have anything to do with EditorSupportLineSet.java.
SHOW_SHOW of a previously unopened file would not steal focus in 5.x.
It does so in 6.x.

The first attachment in IZ 132671 was empty. I've added a filled one.
Comment 3 mslama 2008-06-18 13:56:12 UTC
Problem is in window system. CloneableEditor calls TopComponent.requestVisible. It should not focus newly selected TC if
given mode is not active but winsys activates mode and focuses newly selected TC.
Comment 4 mslama 2008-06-18 18:49:25 UTC
Correction: This was introduced by Jarda as http://hg.netbeans.org/main/rev/237f35dacb17. There is no explanation for
this ie. why it was done. Generally it is wrong. Opening TC should not focus it. If there is need to focus it
TopComponent.requestActive() should be called. Normal usage is:
TopComponent tc = ...
tc.open()
tc.requestActive()

Jarda please could you explain why you added  call of requestFocusInWindow() into CloneableEditor? In addition
requestFocusInWindow should be only overriden but not called. requestActive should be used instead. It is to set all
winsys internals (like active mode) correctly.

Fixed as 7489fd8218d8.
Comment 5 Quality Engineering 2008-06-19 04:30:50 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #268 build
Changeset: http://hg.netbeans.org/main/rev/7489fd8218d8
User: Marek Slama <mslama@netbeans.org>
Log: #134910: Fix grabbing focus by editor when new CloneableEditor is opened.
Comment 6 Jesse Glick 2008-06-20 16:51:59 UTC
I think the fix is bad. In 080620, when I create a new Java class, the caret is not visible. Irritating regression.
Comment 7 mslama 2008-06-24 11:40:26 UTC
Fixed 4c3a265cbc40.

Problem is that in some cases TC.requestFocus is called BEFORE CloneableEditor.DoInitialize.initVisual so editor pane is
added later. So current fix transfers focus to added subcomponent ONLY when editor is already activated ie. compare
editor (CloneableEditor.this) and getRegistry().getActivated(). If they are equals call requestFocusInWindow().

I tested test module from issue #132671 and it works as expected ie. focus is not changed.
Comment 8 mslama 2008-06-25 09:41:25 UTC
Fixed in release65_m1 39fb9c7844b1
Comment 9 Quality Engineering 2008-06-27 16:28:25 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #285 build
Changeset: http://hg.netbeans.org/main/rev/4c3a265cbc40
User: Marek Slama <mslama@netbeans.org>
Log: #134910: Transfer focus to added subcomponent when TC is already activated only.
Comment 10 rbalada 2008-08-04 15:53:43 UTC
Please note that NetBeans 6.1 Patch3 cut-off is going to happen on close of
business August 5th. If you would like to have bugfix for this issue as part of
NetBeans 6.1 Patch3, then this issue must have information about bugfix' trunk
changeset and it's status must be "VERIFIED".
Comment 11 mslama 2008-08-04 16:21:55 UTC
Marian added 61fixes2 to issue. Marian/Ivan shall we put this fix to patch3?
Comment 12 Lukas Hasik 2008-08-04 17:41:23 UTC
ivan, can you mark as verified if it works for you?
Comment 13 ivan 2008-08-04 22:33:00 UTC
verified in trunk.
Comment 14 rbalada 2008-08-05 09:19:19 UTC
I've ported those two changesets http://hg.netbeans.org/main/rev/7489fd8218d8 and
http://hg.netbeans.org/main/rev/4c3a265cbc40 into release61_fixes repository as
http://hg.netbeans.org/release61_fixes/rev/345f57e4a0aa
Comment 15 mslama 2008-08-05 09:31:12 UTC
Yes it is correct. I checked diff http://hg.netbeans.org/release61_fixes/rev/345f57e4a0aa
Comment 16 Thomas Preisler 2008-09-15 16:50:13 UTC
delivered to SS