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 57974 - Problems with handling tooltips in o.o.awt.Actions.ButtonBridge
Summary: Problems with handling tooltips in o.o.awt.Actions.ButtonBridge
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jan Lahoda
Depends on:
Blocks: 54851
  Show dependency tree
Reported: 2005-04-18 09:50 UTC by Jan Lahoda
Modified: 2008-12-22 22:10 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:

The patch. (11.34 KB, patch)
2005-04-19 17:02 UTC, Jan Lahoda
Details | Diff
Refined patch using runInEQ for tests. (9.69 KB, patch)
2005-04-20 13:43 UTC, Jan Lahoda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Lahoda 2005-04-18 09:50:46 UTC
o.o.awt.Actions.ButtonBridge revision 1.110.

It seems to me that there are two problems with handling tooltips in
1. If an action sets a tooltip and than changes value of property
ACCELERATOR_KEY (or NAME), the tooltip of the button is set to action's
name+accelerator, ignoring the tooltip set in the action. This seems to me like
a bug.
2. If an action sets a tooltip, the tooltip is not automatically augmented with
accelerator key (eg. if the action's NAME is "Test" and accelerator is "Alt-K",
the default button's tooltip is "Test (Alt-K)", but if the action's tooltip is
"Test", the button's tooltip is only "Test", not "Test (Alt-K)"). Is this
Comment 1 David Simonek 2005-04-18 10:36:46 UTC
Passing to actions subcomponent.
Comment 2 Jan Lahoda 2005-04-19 17:01:24 UTC
I propose the following behavior:
1. if an action has a tooltip, it is always prefered over the name when the
button's tooltip is created
2. the button's tooltip is automatically augmented with a shortcut even in case
the action specifies the tooltip

As the later is an incompatible change (actions which already augment the
tooltip with the shortcut will have the shortcut doubled), I am asking for a
fasttrack API review.

I am attaching a diff that does the change in Actions, adds three tests to test
the behavior, adds a note to apichanges.xml and increments spec version.
Comment 3 Jan Lahoda 2005-04-19 17:02:59 UTC
Created attachment 21729 [details]
The patch.
Comment 4 Jesse Glick 2005-04-19 18:21:20 UTC
Suggestion: if there is an existing tooltip, look for something that appears to
be shortcut info - "(something)" where "something" could be produced by
Actions.findKey - and if there is one, leave the tooltip along but log a warning
to console giving the action class name and requesting that any keystroke info
be removed from its tooltip.
Comment 5 Jaroslav Tulach 2005-04-20 11:44:54 UTC
Should not 
+        if (!SwingUtilities.isEventDispatchThread()) { 
+            SwingUtilities.invokeAndWait(new Runnable() { 
+                public void run() { 
+                    try { 
+                        testTooltipsContainAccelerator(); 
+                    } catch (Exception e) { 
+                        IllegalStateException exc = new 
+                        exc.initCause(e); 
+                        throw exc; 
+                    } 
+                } 
+            }); 
+            return ; 
+        } 
be replaced with  
protected boolean runInEQ () { 
  return true; 
That would automatically switch to AWT event thread. 
Comment 6 Jan Lahoda 2005-04-20 13:41:53 UTC
Re: runInEQ, yes, the tests should use this. I am attaching corrected patch
(using this method).
Comment 7 Jan Lahoda 2005-04-20 13:43:17 UTC
Created attachment 21758 [details]
Refined patch using runInEQ for tests.
Comment 8 Jan Lahoda 2005-04-20 18:12:18 UTC
Regarding inspecting the tooltip for potential shortcut: I am a bit afraid that
this may unpredictably fail (not provide shortcut info in cases where it should
be provided). If the tooltip is not inspected, the worst case is that the user
sees two shortcut infos in the tooltip, which is not a big problem in my opinion.

I have grepped the 4.1 codebase, and I did not find any action that would
augment the tooltip with the shortcut info (some actions provide a custom
tooltip, like JUnit/Open Test, and these are shown without the shortcut info).

But, I can implement the tooltip inspection if it is a requirement.
Comment 9 Jesse Glick 2005-04-20 19:02:42 UTC
I don't think it's a requirement, given your comments. Was just checking if it
had been considered.
Comment 10 Jan Lahoda 2005-04-27 09:25:47 UTC
Unless there are any objections, I will commit this change tomorrow.
Comment 11 Jan Lahoda 2005-04-29 09:05:43 UTC
Checking in;
/cvs/openide/,v  <--
new revision: 1.173; previous revision: 1.172
Checking in awt/apichanges.xml;
/cvs/openide/awt/apichanges.xml,v  <--  apichanges.xml
new revision: 1.3; previous revision: 1.2
Checking in awt/;
/cvs/openide/awt/,v  <--
new revision: 1.4; previous revision: 1.3
Checking in awt/src/org/openide/awt/;
/cvs/openide/awt/src/org/openide/awt/,v  <--
new revision: 1.2; previous revision: 1.1
Checking in test/unit/src/org/openide/awt/;
/cvs/openide/test/unit/src/org/openide/awt/,v  <--
new revision: 1.11; previous revision: 1.10
Comment 12 Jaromir Uhrik 2005-07-14 16:18:53 UTC