Community
Participate
Working Groups
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.
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...
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?
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.
Giving to Boris since it's API-related.
/** * 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); }