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 78896 - Add tooltip for close button on editor tab
Summary: Add tooltip for close button on editor tab
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords: NETFIX, SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2006-06-22 11:35 UTC by David Simonek
Modified: 2009-09-02 19:50 UTC (History)
4 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Patch for the requested issue (4.09 KB, patch)
2009-08-12 07:10 UTC, tusharvjoshi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Simonek 2006-06-22 11:35:44 UTC
Small close button on editor tab is interestingly powerful, but functionality
isn't discoverable:

click = close this document
Shift + click = Close All Documents
Alt + click = Close other documents

Therefore, add following tooltip on close button: 
"Shift + click to close all documents, Alt + click to close other documents"
Comment 1 David Simonek 2008-10-16 15:19:31 UTC
Easy to do, TM to 7.0
Comment 2 Jiri Kovalsky 2009-03-30 14:55:06 UTC
David Simonek agreed that he would review and integrate a patch for this issue contributed by the NetFIX [1] team.

[1] http://wiki.netbeans.org/NetFIX
Comment 3 amelongo 2009-04-09 05:13:54 UTC
I'm working on this issue and I was just wondering about the shortcuts; In my version 'close All Documents' as a
shortcut of 'Ctrl+Shift+W' and 'close other Documents' has no shortcut at all. If I should implement this issue, I guess
I have to go by the default shortcuts. Don't you think? Please let me know.
Comment 4 David Simonek 2009-04-09 10:00:33 UTC
Well, I'm not sure I understand - it seems like you extended feature request and you would like to mention also
shortcuts in tooltip, is that right?
Personally I'd stick with simple solution and don't include shortcuts in tooltip, as shortcuts can be discovered in
popup menu of editor tab.

....but if you feel shortcuts should be mentioned in tooltip, then go for it - but it's not that easy. You shouldn't
hardcode shortcuts as they may vary across platforms etc. You will need:
1) Get access to action instance
2) retrieve shortcut from action's ACCELERATOR_KEY property (see javax.swing.Action)
3) convert KeyStroke to meaningful text -- see in spi.quicksearch module, class SearchResultRender, method
getKeyStrokeAsText(...) for example how this can be done.

...or did you mean something different? :)

Btw thanks for you help to make NetBeans better.

Comment 5 amelongo 2009-04-10 06:30:13 UTC
I think you didn't understand what I meant. The requirement says, put a tooltip to the close button that will say:
"Shift + click to close all documents, Alt + click to close other documents" whenever the mouse is over that button. Now
my question is, 'close all documents' has a shortcut of 'Ctrl+Shift+W' NOT 'Shift+Click' and 'close other documents' has
no shortcut at all. The reason of my post was that I was just wondering whether the 'Shift+click' shortcut was
mistakenly mentioned; if that's the case, then my tooltip will be 'Ctrl+Shift+W to close all documents' and I will not
put any tooltip for 'close other documents' since that option, by default, doesn't have a shortcut. However, if it's the
case that the requirement had no mistake, then my question will be should I have to create, on top of displaying the
tooltip, shortcuts for 'close all documents'(Shift+Click) and 'close other documents'(Alt+Click)?
Comment 6 David Simonek 2009-04-10 08:38:56 UTC
I see, sorry for misunderstanding.

Situation is actually quite simple: request has no mistake and you should *not* create new shortcuts. Alt + clicking on
close button and Shift + clicking on close button is just another way to close documents, tied directly to close button.
Shortcuts are intended to be keyboard only, not keyboard + mouse mixture.

Meaning of this enhancement is purely to raise discoverability, as said in first comment. I doubt anybody knows about
this hidden functionality.
Comment 7 amelongo 2009-04-22 00:47:18 UTC
Simonek,
Can you please tell me which module in the NB code deal with this issue? Thanks.
Comment 8 David Simonek 2009-04-22 08:42:37 UTC
Yes, it is o.n.swing.tabcontrol. Namely packages org.netbeans.swing.tabcontrol and org.netbeans.swing.tabcontrol.plaf.

I wanted to give you some more pointers and I found out that fix will not be trivial as I thought. Sadly, implementation
of close button on editor tabs is strange and complicated. There is no JButton for close "button", it is just image
drawn. Therefore, you'll need to watch mouse position and return tooltip for close button only when mouse is hovering
above the area of close button image.

Perhaps it could be done in this (little bit ugly, but the easiest) way: 
- TabDisplayer.getToolTipText will need to recognize if mouse is in close button area. For that, you'll probably need
- add public method to BasicTabDisplayerUI, that will ask its tab renderer - use AbstractTabCellRenderer.inCloseButton()

Hope this helped.
Comment 9 amelongo 2009-04-22 23:18:42 UTC
Thank you for the pointers. If I have more questions, I'll let you know.
Comment 10 tusharvjoshi 2009-08-12 07:10:27 UTC
Created attachment 86137 [details]
Patch for the requested issue
Comment 11 tusharvjoshi 2009-08-12 07:14:47 UTC
Hi,

I have attached the patch for the implementation of the requested feature.  
I had to change the visibility of two methods from protected to public for this fix.  
AbstractTabCellRenderer::inCloseButton and BasicTabDisplayerUI::getTabCellRenderer.  Are these type of access mode 
changes allowed for this API?  If not then I can introduce new methods in those classes doing the same thing, but those 
methods are needed for this solution.

The solution works as expected for all editor tab close buttons.
Please review

with regards
Tushar Joshi, Nagpur
NetFIX Team
Comment 12 Jiri Kovalsky 2009-08-12 08:08:23 UTC
Dafe, will you please review and integrate Tushar's patch in case his implementation looks good to you? Thanks!
Comment 13 Stanislav Aubrecht 2009-08-12 09:54:26 UTC
dafe doesn't work on window system any more
Comment 14 Stanislav Aubrecht 2009-08-12 09:55:52 UTC
i've committed a slightly modified patch to core-main e4953f712809
Comment 15 Quality Engineering 2009-08-13 06:05:05 UTC
Integrated into 'main-golden', will be available in build *200908130201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e4953f712809
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #78896 - Add tooltip for close button on editor tab
Comment 16 Michel Graciano 2009-09-02 19:50:31 UTC
v. 200909010201