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

Summary: Problems with handling tooltips in o.o.awt.Actions.ButtonBridge
Product: platform Reporter: Jan Lahoda <jlahoda>
Component: ActionsAssignee: Jan Lahoda <jlahoda>
Status: VERIFIED FIXED    
Severity: blocker CC: apireviews
Priority: P3 Keywords: API, API_REVIEW_FAST
Version: 5.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 54851    
Attachments: The patch.
Refined patch using runInEQ for tests.

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
o.o.awt.Actions.ButtonBridge:
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
as-designed?
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 
IllegalStateException(e.getMessage()); 
+                         
+                        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
Committed:
Checking in openide-spec-vers.properties;
/cvs/openide/openide-spec-vers.properties,v  <--  openide-spec-vers.properties
new revision: 1.173; previous revision: 1.172
done
Checking in awt/apichanges.xml;
/cvs/openide/awt/apichanges.xml,v  <--  apichanges.xml
new revision: 1.3; previous revision: 1.2
done
Checking in awt/manifest.mf;
/cvs/openide/awt/manifest.mf,v  <--  manifest.mf
new revision: 1.4; previous revision: 1.3
done
Checking in awt/src/org/openide/awt/Actions.java;
/cvs/openide/awt/src/org/openide/awt/Actions.java,v  <--  Actions.java
new revision: 1.2; previous revision: 1.1
done
Checking in test/unit/src/org/openide/awt/ActionsTest.java;
/cvs/openide/test/unit/src/org/openide/awt/ActionsTest.java,v  <--  ActionsTest.java
new revision: 1.11; previous revision: 1.10
done
Comment 12 Jaromir Uhrik 2005-07-14 16:18:53 UTC
Verified.