Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions eclipse-scout-core/src/form/fields/FieldStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class FieldStatus extends Widget implements FieldStatusModel {
position: FormFieldStatusPosition;
menus: Menu[];
tooltip: Tooltip;
tooltipHtmlEnabled: boolean;
contextMenu: ContextMenuPopup;
updating: boolean;

Expand All @@ -34,6 +35,7 @@ export class FieldStatus extends Widget implements FieldStatusModel {
constructor() {
super();
this.tooltip = null;
this.tooltipHtmlEnabled = false;
this.contextMenu = null;
this.status = null;
this.updating = false;
Expand Down Expand Up @@ -178,6 +180,10 @@ export class FieldStatus extends Widget implements FieldStatusModel {
this.invalidateLayoutTree();
}

setTooltipHtmlEnabled(tooltipHtmlEnabled: boolean) {
this.setProperty('tooltipHtmlEnabled', tooltipHtmlEnabled);
}

protected override _renderVisible() {
super._renderVisible();
if (!this.visible) {
Expand Down Expand Up @@ -278,13 +284,15 @@ export class FieldStatus extends Widget implements FieldStatusModel {
if (this.tooltip) {
// update existing tooltip
this.tooltip.setText(this.status.message);
this.tooltip.setHtmlEnabled(this.tooltipHtmlEnabled);
this.tooltip.setSeverity(this.status.severity);
this.tooltip.setMenus(this.menus);
} else {
this.tooltip = scout.create(Tooltip, {
parent: this,
$anchor: this.$container,
text: this.status.message,
htmlEnabled: this.tooltipHtmlEnabled,
severity: this.status.severity,
autoRemove: this.autoRemove,
menus: this.menus
Expand Down
15 changes: 14 additions & 1 deletion eclipse-scout-core/src/form/fields/FormField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class FormField extends Widget implements FormFieldModel {
/** If set to true, {@link saveNeeded} will return true as well, even if the value has not been changed. */
touched: boolean;
tooltipText: string;
tooltipHtmlEnabled: boolean;
font: string;
foregroundColor: string;
backgroundColor: string;
Expand Down Expand Up @@ -120,6 +121,7 @@ export class FormField extends Widget implements FormFieldModel {
this.suppressStatus = null;
this.touched = false;
this.tooltipText = null;
this.tooltipHtmlEnabled = false;
this.tooltipAnchor = FormField.TooltipAnchor.DEFAULT;
this.onFieldTooltipOptionsCreator = null;
this.validationResultProvider = this._createValidationResultProvider();
Expand Down Expand Up @@ -228,7 +230,8 @@ export class FormField extends Widget implements FormFieldModel {
protected _createFieldStatus(): FieldStatus {
return scout.create(FieldStatus, {
parent: this,
position: this.statusPosition
position: this.statusPosition,
tooltipHtmlEnabled: this.tooltipHtmlEnabled
});
}

Expand Down Expand Up @@ -495,6 +498,15 @@ export class FormField extends Widget implements FormFieldModel {
this._updateTooltip();
}

/** @see FormFieldModel.tooltipHtmlEnabled */
setTooltipHtmlEnabled(tooltipHtmlEnabled: boolean) {
this.setProperty('tooltipHtmlEnabled', tooltipHtmlEnabled);
}

protected _renderTooltipHtmlEnabled() {
this._updateTooltip();
}

/** @see FormFieldModel.tooltipAnchor */
setTooltipAnchor(tooltipAnchor: FormFieldTooltipAnchor) {
this.setProperty('tooltipAnchor', tooltipAnchor);
Expand Down Expand Up @@ -692,6 +704,7 @@ export class FormField extends Widget implements FormFieldModel {
let statusVisible = this._computeStatusVisible();
this.fieldStatus.setPosition(this.statusPosition);
this.fieldStatus.setVisible(statusVisible);
this.fieldStatus.setTooltipHtmlEnabled(this.tooltipHtmlEnabled);
if (!statusVisible) {
this.fieldStatus.setMenus(null);
this.fieldStatus.setStatus(null);
Expand Down
8 changes: 7 additions & 1 deletion eclipse-scout-core/src/form/fields/FormFieldModel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2025 BSI Business Systems Integration AG
* Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -144,6 +144,12 @@ export interface FormFieldModel extends WidgetModel {
* The text to be used in the {@link Tooltip} that is either displayed in the status area or when hovering over the field, depending on {@link tooltipAnchor}.
*/
tooltipText?: string;
/**
* Defines whether HTML code in the {@link tooltipText} property should be interpreted. If set to false, the HTML will be encoded.
*
* Default is false.
*/
tooltipHtmlEnabled?: boolean;
/**
* Defines where and how the tooltip configured by {@link tooltipText} should appear.
*
Expand Down
66 changes: 66 additions & 0 deletions eclipse-scout-core/test/form/fields/FormFieldSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,72 @@ describe('FormField', () => {

});

describe('property tooltipHtmlEnabled', () => {

it('if false, encodes html in tooltip', () => {
let field = scout.create(StringField, {
parent: session.desktop,
tooltipText: '<b>text</b>'
});
field.render();
field.fieldStatus.doAction();
expect(field.fieldStatus.tooltip.htmlEnabled).toBe(false);
expect(field.fieldStatus.tooltip.$content.html()).toBe('&lt;b&gt;text&lt;/b&gt;');
});

it('if true, does not encode html in tooltip', () => {
let field = scout.create(StringField, {
parent: session.desktop,
tooltipText: '<b>text</b>',
tooltipHtmlEnabled: true
});
field.render();
field.fieldStatus.doAction();
expect(field.fieldStatus.tooltip.htmlEnabled).toBe(true);
expect(field.fieldStatus.tooltip.$content.html()).toBe('<b>text</b>');
});

it('can be changed dynamically', () => {
let field = scout.create(StringField, {
parent: session.desktop,
tooltipText: '<b>text</b>'
});
field.render();
field.setTooltipHtmlEnabled(true);
field.fieldStatus.doAction();
expect(field.fieldStatus.tooltip.htmlEnabled).toBe(true);
expect(field.fieldStatus.tooltip.$content.html()).toBe('<b>text</b>');

field.setTooltipHtmlEnabled(false); // closes tooltip
field.fieldStatus.doAction();
expect(field.fieldStatus.tooltip.htmlEnabled).toBe(false);
expect(field.fieldStatus.tooltip.$content.html()).toBe('&lt;b&gt;text&lt;/b&gt;');
});

it('also affects error status tooltip', () => {
let field = scout.create(StringField, {
parent: session.desktop,
errorStatus: {
message: '<b>error</b>',
severity: Status.Severity.ERROR
},
tooltipHtmlEnabled: true
});
field.render();
// Tooltip is already open because tooltip.autoRemove is false on severity error
expect(field.fieldStatus.tooltip.htmlEnabled).toBe(true);
expect(field.fieldStatus.tooltip.$content.html()).toBe('<b>error</b>');

field.setTooltipHtmlEnabled(false);
expect(field.fieldStatus.tooltip.htmlEnabled).toBe(false);
expect(field.fieldStatus.tooltip.$content.html()).toBe('&lt;b&gt;error&lt;/b&gt;');

field.setTooltipHtmlEnabled(true);
expect(field.fieldStatus.tooltip.htmlEnabled).toBe(true);
expect(field.fieldStatus.tooltip.$content.html()).toBe('<b>error</b>');
});
});

describe('property menus', () => {
let formField, model;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2024 BSI Business Systems Integration AG
* Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -322,6 +322,12 @@ protected String getConfiguredTooltipText() {
return null;
}

@ConfigProperty(ConfigProperty.BOOLEAN)
@Order(52)
protected boolean getConfiguredTooltipHtmlEnabled() {
return false;
}

/**
* @return One of the <code>TOOLTIP_ANCHOR_*</code> constants. Default is {@link #TOOLTIP_ANCHOR_DEFAULT}.
*/
Expand Down Expand Up @@ -857,6 +863,7 @@ protected void initConfig() {
setMandatory(getConfiguredMandatory());
setOrder(calculateViewOrder());
setTooltipText(getConfiguredTooltipText());
setTooltipHtmlEnabled(getConfiguredTooltipHtmlEnabled());
setTooltipAnchor(getConfiguredTooltipAnchor());
setInitialLabel(getConfiguredLabel());
setLabel(getConfiguredLabel());
Expand Down Expand Up @@ -1833,6 +1840,16 @@ public String getTooltipText() {
return propertySupport.getPropertyString(PROP_TOOLTIP_TEXT);
}

@Override
public void setTooltipHtmlEnabled(boolean tooltipHtmlEnabled) {
propertySupport.setPropertyBool(PROP_TOOLTIP_HTML_ENABLED, tooltipHtmlEnabled);
}

@Override
public boolean isTooltipHtmlEnabled() {
return propertySupport.getPropertyBool(PROP_TOOLTIP_HTML_ENABLED);
}

@Override
public void setTooltipAnchor(String tooltipAnchor) {
propertySupport.setPropertyString(PROP_TOOLTIP_ANCHOR, tooltipAnchor);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2025 BSI Business Systems Integration AG
* Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -73,6 +73,7 @@ public interface IFormField extends IWidget, IOrdered, IStyleable, IVisibleDimen
String PROP_ORDER = "order";
String PROP_ERROR_STATUS = "errorStatus";
String PROP_TOOLTIP_TEXT = "tooltipText";
String PROP_TOOLTIP_HTML_ENABLED = "tooltipHtmlEnabled";
String PROP_TOOLTIP_ANCHOR = "tooltipAnchor";
String PROP_FOREGROUND_COLOR = "foregroundColor";
String PROP_BACKGROUND_COLOR = "backgroundColor";
Expand Down Expand Up @@ -465,6 +466,10 @@ public interface IFormField extends IWidget, IOrdered, IStyleable, IVisibleDimen

void setTooltipText(String text);

boolean isTooltipHtmlEnabled();

void setTooltipHtmlEnabled(boolean tooltipHtmlEnabled);

void setTooltipAnchor(String tooltipAnchor);

String getTooltipAnchor();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2023 BSI Business Systems Integration AG
* Copyright (c) 2010, 2026 BSI Business Systems Integration AG
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -101,6 +101,12 @@ protected String modelValue() {
return getModel().getTooltipText();
}
});
putJsonProperty(new JsonProperty<FORM_FIELD>(IFormField.PROP_TOOLTIP_HTML_ENABLED, model) {
@Override
protected Boolean modelValue() {
return getModel().isTooltipHtmlEnabled();
}
});
putJsonProperty(new JsonProperty<FORM_FIELD>(IFormField.PROP_TOOLTIP_ANCHOR, model) {
@Override
protected String modelValue() {
Expand Down
Loading