Bug 259952 - [Preferences] Duplicated text when using tooltip in BooleanFieldEditor
Summary: [Preferences] Duplicated text when using tooltip in BooleanFieldEditor
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2009-01-05 09:28 EST by Fabiano Castro Pereira CLA
Modified: 2009-03-06 20:16 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabiano Castro Pereira CLA 2009-01-05 09:28:26 EST
Build ID: M20080911-1700

Steps To Reproduce:
1. Set a tooltip to the field: bfe.getLabelControl(parent).setToolTipText(tooltipText);
2. When the preference page is shown, the text that describes the preference being edited appears duplicated.

More information:
The usual way to set the tool tip to a field editor is calling "getLabelControl(parent).setToolTipText(tooltipText)", but in the BooleanFieldEditor this creates a Label that is not needed (when using the BooleanFieldEditor.DEFAULT style), which makes the textual description be shown twice, in the Checkbox control, and in the (unnecessary) Label control.

One solution for this issue would be to turn the method "BooleanFieldEditor.getChangeControl()" to be public instead of protected. This way one could set the tool tip directly in the checkbox Button control.
Comment 1 Eric Moffatt CLA 2009-01-08 15:46:48 EST
Boris, do you see any problem with making the method public? A quick look at its use showed at least two different ways folks are doing this for themselves:

org.eclipse.debug.internal.ui.preferences.BooleanFieldEditor2 is a subclass that makes it public

org.eclipse.team.internal.ccvs.ui.ComparePreferencePage.createFieldEditors() locally overrides the method to allow adding Help hooks.

If you agree I'll make it happen...
Comment 2 Boris Bokowski CLA 2009-01-12 12:34:58 EST
Making the method public may break clients (but only when they recompile, the change would still be binary compatible). Are there any other options for solving this?
Comment 3 Fabiano Castro Pereira CLA 2009-01-12 13:25:52 EST
Another option to solve this is to create the method getDescriptionControl() in BooleanFieldEditor that returns the Control responsible to show the field editor description (which is provided in the constructor parameter "labelText"). It would return a Button control (if using BooleanFieldEditor.DEFAULT style) or a Label control (if using BooleanFieldEditor.SEPARATE_LABEL style).

This way the client can set the tool tip (and other info) in the correct control, the one that the user actually hovers to get the tip.
Comment 4 Eric Moffatt CLA 2009-01-13 15:51:39 EST
Giving to Boris since it's API-related.
Comment 5 Boris Bokowski CLA 2009-03-06 20:16:33 EST
/**
 * Returns the control responsible for displaying this field editor's label.
 * This method can be used to set a tooltip for a
 * <code>BooleanFieldEditor</code>. Note that the normal pattern of
 * <code>getLabelControl(parent).setToolTipText(tooltipText)</code> does not
 * work for boolean field editors, as it can lead to duplicate text (see bug
 * 259952).
 * 
 * @param parent
 *            the parent composite
 * @return the control responsible for displaying the label
 * 
 * @since 3.5
 */
public Control getDescriptionControl(Composite parent) {
	if (style == SEPARATE_LABEL) {
		return getLabelControl(parent);
	}
	return getChangeControl(parent);
}