Bug 54251 - Add tristate checkbox implementation
Add tristate checkbox implementation
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.8
All All
: P2 enhancement (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-12-05 16:34 UTC by Sebb
Modified: 2013-08-15 21:33 UTC (History)
1 user (show)



Attachments
Sample screenshot in Linux env (11.96 KB, image/png)
2012-12-06 08:05 UTC, Milamber
Details
TristateCheckBoxTest - Win7/Java7(with javax.swing.plaf.synth.SynthUI) (8.93 KB, image/png)
2012-12-06 09:16 UTC, Kurt Hong
Details
WinXP Java 6 disabled (9.41 KB, image/png)
2012-12-06 09:28 UTC, Sebb
Details
WinXP Java 6 enabled (8.78 KB, image/png)
2012-12-06 09:28 UTC, Sebb
Details
WinXP Java 6 disabled (icon/original) (15.22 KB, image/png)
2012-12-06 10:10 UTC, Sebb
Details
WinXP Java 6 enabled (icon/original) (12.63 KB, image/png)
2012-12-06 10:10 UTC, Sebb
Details
WinXP Java 6 enabled (icon/original) - Bar (15.05 KB, image/png)
2012-12-06 19:58 UTC, Sebb
Details
WinXP Java 6 disabled (icon/original) - Bar (15.05 KB, image/png)
2012-12-06 19:58 UTC, Sebb
Details
WinXP Java 6 enabled (icon/original) - Bar (12.44 KB, image/png)
2012-12-06 20:00 UTC, Sebb
Details
Current in linux (22.26 KB, image/png)
2012-12-06 20:42 UTC, Milamber
Details
round third state (15.17 KB, image/png)
2012-12-06 20:43 UTC, Milamber
Details
Mac OSX look (28.10 KB, image/png)
2012-12-06 20:46 UTC, Philippe Mouawad
Details
MacOs Underterminate (8.91 KB, image/png)
2012-12-06 20:51 UTC, Philippe Mouawad
Details
enabled (28.10 KB, image/png)
2012-12-06 20:52 UTC, Philippe Mouawad
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebb 2012-12-05 16:34:29 UTC
A tri-state checkbox would have three states:
- unselected
- selected
- indeterminate (i.e. neither)

The indeterminate state would be useful for handling defaults - e.g. if the sampler checkbox is indeterminate, use the setting from the configuration.

There don't seem to be any existing implementations with a suitable license.

The following implementation is neat and simple:

[1] http://stackoverflow.com/questions/1263323/tristate-checkboxes-in-java

However, testing shows that it does not support ItemListener properly, as the processing causes an additional item change. It also relies on its ActionListener being processed first.

However, it does provide a useful hint - using a icon for the indeterminate state.

Another implementation is at

[2] http://www.javaspecialists.eu/archive/Issue145.html

This works well, however the indeterminate state is not very obvious on the display, particularly in the Motif LAF.

Another TriState implementation is here:

[3] http://www.coderanch.com/t/342563/GUI/java/TriState-CheckBox

It does not support ActionListener, however it does have a useful Icon implementation which can be used to improve implementation [2].

Code and test case will be added shortly.
Comment 1 Sebb 2012-12-06 01:45:32 UTC
Added initial implementation.

It needs a bit of work on the Nimbus UI.

Please try running 

test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java

to see what how the UI behaves.


URL: http://svn.apache.org/viewvc?rev=1417726&view=rev
Log:
Add tristate checkbox implementation
Bugzilla Id: 54251

Added:
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateCheckBox.java   (with props)
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateState.java   (with props)
    jmeter/trunk/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java   (with props)
Modified:
    jmeter/trunk/xdocs/changes.xml
Comment 2 Milamber 2012-12-06 08:05:24 UTC
Created attachment 29713 [details]
Sample screenshot in Linux env
Comment 3 Kurt Hong 2012-12-06 09:16:35 UTC
Created attachment 29714 [details]
TristateCheckBoxTest - Win7/Java7(with javax.swing.plaf.synth.SynthUI)

looks good for me except Nimbus. But it's using javax.swing.plaf.synth.SynthUI.

Thank you!
Comment 4 Sebb 2012-12-06 09:28:19 UTC
Created attachment 29715 [details]
WinXP Java 6 disabled
Comment 5 Sebb 2012-12-06 09:28:52 UTC
Created attachment 29716 [details]
WinXP Java 6 enabled
Comment 6 Sebb 2012-12-06 10:10:08 UTC
Created attachment 29717 [details]
WinXP Java 6 disabled (icon/original)
Comment 7 Sebb 2012-12-06 10:10:46 UTC
Created attachment 29718 [details]
WinXP Java 6 enabled (icon/original)
Comment 8 Sebb 2012-12-06 10:11:54 UTC
Show how original design (no special icon) looked.

URL: http://svn.apache.org/viewvc?rev=1417789&view=rev
Log:
Add tests for original code - which did not use a special icon - for comparison
Bugzilla Id: 54251

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateCheckBox.java
    jmeter/trunk/test/src/org/apache/jmeter/gui/util/TristateCheckBoxTest.java
Comment 9 Sebb 2012-12-06 11:08:59 UTC
URL: http://svn.apache.org/viewvc?rev=1417803&view=rev
Log:
Fix up so Nimbus calls paint when disabling the button
Bugzilla Id: 54251

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateCheckBox.java
Comment 10 Sebb 2012-12-06 19:58:05 UTC
Created attachment 29720 [details]
WinXP Java 6 enabled (icon/original) - Bar
Comment 11 Sebb 2012-12-06 19:58:41 UTC
Created attachment 29721 [details]
WinXP Java 6 disabled (icon/original) - Bar
Comment 12 Sebb 2012-12-06 20:00:06 UTC
Created attachment 29722 [details]
WinXP Java 6 enabled (icon/original) - Bar
Comment 13 Sebb 2012-12-06 20:06:37 UTC
This should fix the compilation issues:

URL: http://svn.apache.org/viewvc?rev=1418045&view=rev
Log:
Fix up so does not use private Sun class; we get the icon size from the UIManager defaults
Also change from cross to horizontal line
Bugzilla Id: 54251

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/TristateCheckBox.java


Also changed the icon to a horizontal bar.
This is what GMail uses when some (but not all) mails in a list are selected, so hopefully would be more obvious / less confusing than a cross.

Also, the code should now pick up the actual icon size, even if it varies from the default.

Not yet sure if we need to allow for LAF changes or whether those will be handled by recreating the relevant classes.
Comment 14 Milamber 2012-12-06 20:42:50 UTC
Created attachment 29723 [details]
Current in linux
Comment 15 Milamber 2012-12-06 20:43:15 UTC
Created attachment 29724 [details]
round third state
Comment 16 Philippe Mouawad 2012-12-06 20:46:25 UTC
Created attachment 29725 [details]
Mac OSX look
Comment 17 Philippe Mouawad 2012-12-06 20:51:20 UTC
Under MacOS X:
- icon look is clear 
- but "Tristate checkbox (original)" is not. There is no real difference between indeterminate and checked.

Thank you sebb.
Comment 18 Philippe Mouawad 2012-12-06 20:51:47 UTC
Created attachment 29726 [details]
MacOs Underterminate
Comment 19 Philippe Mouawad 2012-12-06 20:52:05 UTC
Created attachment 29727 [details]
enabled
Comment 20 Sebb 2012-12-07 10:02:22 UTC
(In reply to comment #17)
> Under MacOS X:
> - icon look is clear 
> - but "Tristate checkbox (original)" is not. There is no real difference
> between indeterminate and checked.

That is also the case for WinXP, which is why the icon solution attracted my attention.
Comment 21 Sebb 2012-12-07 10:12:17 UTC
(In reply to comment #14)
> Created attachment 29723 [details]
> Current in linux

The left shift is odd, because the code uses the supplied x,y coordinates. Maybe a bug in the JVM? Also, the unix Nimbus look is very different from MacOS and Windows.

It would be nice to fix these problems, but I don't think they are show-stoppers.
If necessary they can be fixed later.