import com.google.gwt.user.client.ui.HTML;
import com.vaadin.terminal.gwt.client.ui.AbstractFieldConnector;
import com.vaadin.terminal.gwt.client.ui.Icon;
-import com.vaadin.terminal.gwt.client.ui.TabsheetBaseConnector;
public class VCaption extends HTML {
@Deprecated
public boolean updateCaptionWithoutOwner(String caption, boolean disabled,
- boolean hasDescription, String iconURL) {
+ boolean hasDescription, boolean hasError, String iconURL) {
boolean wasPlacedAfterComponent = placedAfterComponent;
// Caption is placed after component unless there is some part which
// browsers when it is set to the empty string. If there is an
// icon, error indicator or required indicator they will ensure
// that space is reserved.
- if (!hasIcon) {
+ if (!hasIcon && !hasError) {
captionText.setInnerHTML(" ");
}
} else {
captionText = null;
}
+ if (hasError) {
+ if (errorIndicatorElement == null) {
+ errorIndicatorElement = DOM.createDiv();
+ DOM.setInnerHTML(errorIndicatorElement, " ");
+ DOM.setElementProperty(errorIndicatorElement, "className",
+ "v-errorindicator");
+
+ DOM.insertChild(getElement(), errorIndicatorElement,
+ getInsertPosition(InsertPosition.ERROR));
+ }
+ } else if (errorIndicatorElement != null) {
+ // Remove existing
+ getElement().removeChild(errorIndicatorElement);
+ errorIndicatorElement = null;
+ }
+
return (wasPlacedAfterComponent != placedAfterComponent);
}
}
}
- @Deprecated
- public static boolean isNeeded(UIDL uidl) {
- // TODO fallback for cases where the caption has no owner (Tabsheet,
- // Accordion)
- if (uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_CAPTION) != null) {
- return true;
- }
- if (uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_ICON)) {
- return true;
- }
-
- return false;
- }
-
public static boolean isNeeded(ComponentState state) {
if (state.getCaption() != null) {
return true;
tooltipInfo
.setTitle(uidl
.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DESCRIPTION));
- // TODO currently, there is no error indicator and message for a
- // tab
+ tooltipInfo
+ .setErrorMessage(uidl
+ .getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_ERROR_MESSAGE));
client.registerTooltip(getTabsheet(), getElement(), tooltipInfo);
} else {
client.registerTooltip(getTabsheet(), getElement(), null);
uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_CAPTION),
uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DISABLED),
uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_DESCRIPTION),
+ uidl.hasAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_ERROR_MESSAGE),
uidl.getStringAttribute(TabsheetBaseConnector.ATTRIBUTE_TAB_ICON));
setClosable(uidl.hasAttribute("closable"));
target.addAttribute(
TabsheetBaseConnector.ATTRIBUTE_TAB_CAPTION, caption);
}
-
+ ErrorMessage tabError = tab.getComponentError();
+ if (tabError != null) {
+ target.addAttribute(
+ TabsheetBaseConnector.ATTRIBUTE_TAB_ERROR_MESSAGE,
+ tabError.getFormattedHtmlMessage());
+ }
final String description = tab.getDescription();
if (description != null) {
target.addAttribute(