Browse Source

Communicate caption of components in shared state (#8304).

tags/7.0.0.alpha2
Henri Sara 12 years ago
parent
commit
6c0662316c
25 changed files with 216 additions and 102 deletions
  1. 30
    2
      src/com/vaadin/terminal/gwt/client/ComponentState.java
  2. 143
    52
      src/com/vaadin/terminal/gwt/client/VCaption.java
  3. 3
    1
      src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java
  4. 2
    1
      src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java
  5. 0
    1
      src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java
  6. 3
    2
      src/com/vaadin/terminal/gwt/client/ui/VAccordion.java
  7. 1
    2
      src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java
  8. 1
    2
      src/com/vaadin/terminal/gwt/client/ui/VCheckBoxPaintable.java
  9. 1
    1
      src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java
  10. 1
    1
      src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java
  11. 2
    3
      src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java
  12. 3
    3
      src/com/vaadin/terminal/gwt/client/ui/VFormPaintable.java
  13. 2
    2
      src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java
  14. 2
    3
      src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java
  15. 1
    1
      src/com/vaadin/terminal/gwt/client/ui/VNotification.java
  16. 3
    4
      src/com/vaadin/terminal/gwt/client/ui/VPanelPaintable.java
  17. 1
    1
      src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java
  18. 5
    4
      src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java
  19. 1
    0
      src/com/vaadin/terminal/gwt/client/ui/VTabsheetBasePaintable.java
  20. 2
    2
      src/com/vaadin/terminal/gwt/client/ui/VTreePaintable.java
  21. 2
    3
      src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java
  22. 1
    1
      src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java
  23. 1
    1
      src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java
  24. 3
    8
      src/com/vaadin/ui/AbstractComponent.java
  25. 2
    1
      src/com/vaadin/ui/TabSheet.java

+ 30
- 2
src/com/vaadin/terminal/gwt/client/ComponentState.java View File

private String style = ""; private String style = "";
private boolean disabled = false; private boolean disabled = false;
private String description = ""; private String description = "";

// TODO more fields to move here: caption
// Note: for the caption, there is a difference between null and an empty
// string!
private String caption = null;


/** /**
* Returns the component height as set by the server. * Returns the component height as set by the server.
return !"".equals(getDescription()); return !"".equals(getDescription());
} }


/**
* Gets the caption of the component (typically shown by the containing
* layout).
*
* @see com.vaadin.ui.Component#getCaption()
*
* @return component caption - can be null (no caption) or empty string
* (reserve space for an empty caption)
*/
public String getCaption() {
return caption;
}

/**
* Sets the caption of the component (typically shown by the containing
* layout).
*
* @see com.vaadin.ui.Component#setCaption(String)
*
* @param caption
* new component caption - can be null (no caption) or empty
* string (reserve space for an empty caption)
*/
public void setCaption(String caption) {
this.caption = caption;
}

} }

+ 143
- 52
src/com/vaadin/terminal/gwt/client/VCaption.java View File

import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.vaadin.terminal.gwt.client.ui.Icon; import com.vaadin.terminal.gwt.client.ui.Icon;
import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget; import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
import com.vaadin.terminal.gwt.client.ui.VTabsheetBasePaintable;


public class VCaption extends HTML { public class VCaption extends HTML {




private static final String CLASSNAME_CLEAR = CLASSNAME + "-clearelem"; private static final String CLASSNAME_CLEAR = CLASSNAME + "-clearelem";


private enum InsertPosition {
ICON, CAPTION, REQUIRED, ERROR
}

/** /**
* Creates a caption that is not linked to a {@link VPaintableWidget}. * Creates a caption that is not linked to a {@link VPaintableWidget}.
* *
/** /**
* Updates the caption from UIDL. * Updates the caption from UIDL.
* *
* This method may only be called when the caption has an owner - otherwise,
* use {@link #updateCaptionWithoutOwner(UIDL, String, boolean, boolean)}.
*
* @param uidl * @param uidl
* @return true if the position where the caption should be placed has * @return true if the position where the caption should be placed has
* changed * changed
// moves it above. // moves it above.
placedAfterComponent = true; placedAfterComponent = true;


// TODO otherwise, the user should also call updateCaptionWithoutOwner()
if (null != owner) {
String style = CLASSNAME;
if (owner.getState().hasStyles()) {
final String[] styles = owner.getState().getStyle().split(" ");
for (int i = 0; i < styles.length; i++) {
style += " " + CLASSNAME + "-" + styles[i];
}
String style = CLASSNAME;
if (owner.getState().hasStyles()) {
final String[] styles = owner.getState().getStyle().split(" ");
for (int i = 0; i < styles.length; i++) {
style += " " + CLASSNAME + "-" + styles[i];
} }
if (owner.getState().isDisabled()) {
style += " " + ApplicationConnection.DISABLED_CLASSNAME;
}
setStyleName(style);
} }
if (owner.getState().isDisabled()) {
style += " " + ApplicationConnection.DISABLED_CLASSNAME;
}
setStyleName(style);


boolean hasIcon = uidl boolean hasIcon = uidl
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON); .hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON);
boolean hasText = uidl
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION);
boolean showRequired = uidl boolean showRequired = uidl
.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED); .getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED);
boolean showError = uidl boolean showError = uidl
icon.setWidth("0"); icon.setWidth("0");
icon.setHeight("0"); icon.setHeight("0");


DOM.insertChild(
getElement(),
icon.getElement(),
getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_ICON));
DOM.insertChild(getElement(), icon.getElement(),
getInsertPosition(InsertPosition.ICON));
} }
// Icon forces the caption to be above the component // Icon forces the caption to be above the component
placedAfterComponent = false; placedAfterComponent = false;
icon = null; icon = null;
} }


if (hasText) {
if (owner.getState().getCaption() != null) {
// A caption text should be shown if the attribute is set // A caption text should be shown if the attribute is set
// If the caption is null the ATTRIBUTE_CAPTION should not be set to // If the caption is null the ATTRIBUTE_CAPTION should not be set to
// avoid ending up here. // avoid ending up here.
captionText = DOM.createDiv(); captionText = DOM.createDiv();
captionText.setClassName("v-captiontext"); captionText.setClassName("v-captiontext");


DOM.insertChild(
getElement(),
captionText,
getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_CAPTION));
DOM.insertChild(getElement(), captionText,
getInsertPosition(InsertPosition.CAPTION));
} }


// Update caption text // Update caption text
String c = uidl
.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION);
String c = owner.getState().getCaption();
// A text forces the caption to be above the component. // A text forces the caption to be above the component.
placedAfterComponent = false; placedAfterComponent = false;
if (c == null || c.trim().equals("")) { if (c == null || c.trim().equals("")) {
captionText = null; captionText = null;
} }


if (null != owner) {
if (owner.getState().hasDescription() && captionText != null) {
addStyleDependentName("hasdescription");
} else {
removeStyleDependentName("hasdescription");
}
if (owner.getState().hasDescription() && captionText != null) {
addStyleDependentName("hasdescription");
} else {
removeStyleDependentName("hasdescription");
} }


if (showRequired) { if (showRequired) {
.setClassName("v-required-field-indicator"); .setClassName("v-required-field-indicator");
DOM.setInnerText(requiredFieldIndicator, "*"); DOM.setInnerText(requiredFieldIndicator, "*");


DOM.insertChild(
getElement(),
requiredFieldIndicator,
getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED));
DOM.insertChild(getElement(), requiredFieldIndicator,
getInsertPosition(InsertPosition.REQUIRED));
} }
} else if (requiredFieldIndicator != null) { } else if (requiredFieldIndicator != null) {
// Remove existing // Remove existing
DOM.setElementProperty(errorIndicatorElement, "className", DOM.setElementProperty(errorIndicatorElement, "className",
"v-errorindicator"); "v-errorindicator");


DOM.insertChild(
getElement(),
errorIndicatorElement,
getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_ERROR));
DOM.insertChild(getElement(), errorIndicatorElement,
getInsertPosition(InsertPosition.ERROR));
} }
} else if (errorIndicatorElement != null) { } else if (errorIndicatorElement != null) {
// Remove existing // Remove existing
return (wasPlacedAfterComponent != placedAfterComponent); return (wasPlacedAfterComponent != placedAfterComponent);
} }


private int getInsertPosition(String element) {
private int getInsertPosition(InsertPosition element) {
int pos = 0; int pos = 0;
if (element.equals(VAbstractPaintableWidget.ATTRIBUTE_ICON)) {
if (InsertPosition.ICON.equals(element)) {
return pos; return pos;
} }
if (icon != null) { if (icon != null) {
pos++; pos++;
} }


if (element.equals(VAbstractPaintableWidget.ATTRIBUTE_CAPTION)) {
if (InsertPosition.CAPTION.equals(element)) {
return pos; return pos;
} }


pos++; pos++;
} }


if (element.equals(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED)) {
if (InsertPosition.REQUIRED.equals(element)) {
return pos; return pos;
} }
if (requiredFieldIndicator != null) { if (requiredFieldIndicator != null) {
pos++; pos++;
} }


// if (element.equals(ATTRIBUTE_ERROR)) {
// if (InsertPosition.ERROR.equals(element)) {
// } // }
return pos; return pos;


} }


@Deprecated @Deprecated
public void updateCaptionWithoutOwner(boolean disabled,
boolean hasDescription) {
public boolean updateCaptionWithoutOwner(UIDL uidl, String caption,
boolean disabled, boolean hasDescription) {
// TODO temporary method, needed because some tabsheet and accordion // TODO temporary method, needed because some tabsheet and accordion
// internal captions do not have an owner or shared state.
// Remaining such cases do not use the "style" attribute - see
// Tabsheet.paintContent().
// internal captions do not have an owner or shared state. Simplified to
// only support those cases
setVisible(!uidl.getBooleanAttribute("invisible"));

boolean wasPlacedAfterComponent = placedAfterComponent;

// Caption is placed after component unless there is some part which
// moves it above.
placedAfterComponent = true;

String style = VCaption.CLASSNAME; String style = VCaption.CLASSNAME;
if (disabled) { if (disabled) {
style += " " + ApplicationConnection.DISABLED_CLASSNAME; style += " " + ApplicationConnection.DISABLED_CLASSNAME;
removeStyleDependentName("hasdescription"); removeStyleDependentName("hasdescription");
} }
} }
boolean hasIcon = uidl
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON);
boolean showError = uidl
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)
&& !uidl.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_HIDEERRORS);

if (hasIcon) {
if (icon == null) {
icon = new Icon(client);
icon.setWidth("0");
icon.setHeight("0");

DOM.insertChild(getElement(), icon.getElement(),
getInsertPosition(InsertPosition.ICON));
}
// Icon forces the caption to be above the component
placedAfterComponent = false;

icon.setUri(uidl
.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON));

} else if (icon != null) {
// Remove existing
DOM.removeChild(getElement(), icon.getElement());
icon = null;
}

if (caption != null) {
// A caption text should be shown if the attribute is set
// If the caption is null the ATTRIBUTE_CAPTION should not be set to
// avoid ending up here.

if (captionText == null) {
captionText = DOM.createDiv();
captionText.setClassName("v-captiontext");

DOM.insertChild(getElement(), captionText,
getInsertPosition(InsertPosition.CAPTION));
}

// Update caption text
// A text forces the caption to be above the component.
placedAfterComponent = false;
if (caption.trim().equals("")) {
// This is required to ensure that the caption uses space in all
// 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 && !showError) {
captionText.setInnerHTML("&nbsp;");
}
} else {
DOM.setInnerText(captionText, caption);
}

} else if (captionText != null) {
// Remove existing
DOM.removeChild(getElement(), captionText);
captionText = null;
}

if (showError) {
if (errorIndicatorElement == null) {
errorIndicatorElement = DOM.createDiv();
DOM.setInnerHTML(errorIndicatorElement, "&nbsp;");
DOM.setElementProperty(errorIndicatorElement, "className",
"v-errorindicator");

DOM.insertChild(getElement(), errorIndicatorElement,
getInsertPosition(InsertPosition.ERROR));
}
} else if (errorIndicatorElement != null) {
// Remove existing
getElement().removeChild(errorIndicatorElement);
errorIndicatorElement = null;
}

if (clearElement == null) {
clearElement = DOM.createDiv();
clearElement.setClassName(CLASSNAME_CLEAR);
getElement().appendChild(clearElement);
}

return (wasPlacedAfterComponent != placedAfterComponent);
} }


@Override @Override
} }
} }


public static boolean isNeeded(UIDL uidl) {
if (uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION) != null) {
return true;
public static boolean isNeeded(UIDL uidl, ComponentState state) {
if (state != null) {
if (state.getCaption() != null) {
return true;
}
} else {
// TODO fallback for cases where the caption has no owner (Tabsheet,
// Accordion)
if (uidl.getStringAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_CAPTION) != null) {
return true;
}
} }
if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)) { if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ERROR)) {
return true; return true;

+ 3
- 1
src/com/vaadin/terminal/gwt/client/communication/JsonDecoder.java View File

VPaintableMap idMapper) { VPaintableMap idMapper) {
Object val = null; Object val = null;
// TODO type checks etc. // TODO type checks etc.
if (JsonEncoder.VTYPE_ARRAY.equals(variableType)) {
if (JsonEncoder.VTYPE_UNDEFINED.equals(variableType)) {
val = null;
} else if (JsonEncoder.VTYPE_ARRAY.equals(variableType)) {
val = convertArray((JSONArray) value, idMapper); val = convertArray((JSONArray) value, idMapper);
} else if (JsonEncoder.VTYPE_MAP.equals(variableType)) { } else if (JsonEncoder.VTYPE_MAP.equals(variableType)) {
val = convertMap((JSONObject) value, idMapper); val = convertMap((JSONObject) value, idMapper);

+ 2
- 1
src/com/vaadin/terminal/gwt/client/ui/VAbsoluteLayout.java View File



public void updateCaption(UIDL uidl) { public void updateCaption(UIDL uidl) {


boolean captionIsNeeded = VCaption.isNeeded(uidl);
boolean captionIsNeeded = VCaption.isNeeded(uidl,
paintable.getState());
if (captionIsNeeded) { if (captionIsNeeded) {
if (caption == null) { if (caption == null) {
caption = new VCaption(paintable, client); caption = new VCaption(paintable, client);

+ 0
- 1
src/com/vaadin/terminal/gwt/client/ui/VAbstractPaintableWidget.java View File

// Not all references to the string literals have been converted to use // Not all references to the string literals have been converted to use
// these! // these!
public static final String ATTRIBUTE_ICON = "icon"; public static final String ATTRIBUTE_ICON = "icon";
public static final String ATTRIBUTE_CAPTION = "caption";
public static final String ATTRIBUTE_REQUIRED = "required"; public static final String ATTRIBUTE_REQUIRED = "required";
public static final String ATTRIBUTE_ERROR = "error"; public static final String ATTRIBUTE_ERROR = "error";
public static final String ATTRIBUTE_HIDEERRORS = "hideErrors"; public static final String ATTRIBUTE_HIDEERRORS = "hideErrors";

+ 3
- 2
src/com/vaadin/terminal/gwt/client/ui/VAccordion.java View File

} }


public void updateCaption(UIDL uidl) { public void updateCaption(UIDL uidl) {
caption.updateCaption(uidl);
// TODO required because the caption does not have an owner
// TODO need to call this because the caption does not have an owner
caption.updateCaptionWithoutOwner( caption.updateCaptionWithoutOwner(
uidl,
uidl.getStringAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_CAPTION),
uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DISABLED), uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DISABLED),
uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DESCRIPTION)); uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DESCRIPTION));
} }

+ 1
- 2
src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java View File

getWidgetForPaintable().paintableId = uidl.getId(); getWidgetForPaintable().paintableId = uidl.getId();


// Set text // Set text
getWidgetForPaintable().setText(
uidl.getStringAttribute(ATTRIBUTE_CAPTION));
getWidgetForPaintable().setText(getState().getCaption());


getWidgetForPaintable().disableOnClick = getState().isDisableOnClick(); getWidgetForPaintable().disableOnClick = getState().isDisableOnClick();



+ 1
- 2
src/com/vaadin/terminal/gwt/client/ui/VCheckBoxPaintable.java View File

} }


// Set text // Set text
getWidgetForPaintable().setText(
uidl.getStringAttribute(ATTRIBUTE_CAPTION));
getWidgetForPaintable().setText(getState().getCaption());
getWidgetForPaintable() getWidgetForPaintable()
.setValue( .setValue(
uidl.getBooleanVariable(getWidgetForPaintable().VARIABLE_STATE)); uidl.getBooleanVariable(getWidgetForPaintable().VARIABLE_STATE));

+ 1
- 1
src/com/vaadin/terminal/gwt/client/ui/VCssLayout.java View File

public void updateCaption(VPaintableWidget paintable, UIDL uidl) { public void updateCaption(VPaintableWidget paintable, UIDL uidl) {
Widget widget = paintable.getWidgetForPaintable(); Widget widget = paintable.getWidgetForPaintable();
VCaption caption = widgetToCaption.get(widget); VCaption caption = widgetToCaption.get(widget);
if (VCaption.isNeeded(uidl)) {
if (VCaption.isNeeded(uidl, paintable.getState())) {
if (caption == null) { if (caption == null) {
caption = new VCaption(paintable, client); caption = new VCaption(paintable, client);
widgetToCaption.put(widget, caption); widgetToCaption.put(widget, caption);

+ 1
- 1
src/com/vaadin/terminal/gwt/client/ui/VCustomLayout.java View File

public void updateCaption(VPaintableWidget paintable, UIDL uidl) { public void updateCaption(VPaintableWidget paintable, UIDL uidl) {
VCaptionWrapper wrapper = paintableToCaptionWrapper.get(paintable); VCaptionWrapper wrapper = paintableToCaptionWrapper.get(paintable);
Widget widget = paintable.getWidgetForPaintable(); Widget widget = paintable.getWidgetForPaintable();
if (VCaption.isNeeded(uidl)) {
if (VCaption.isNeeded(uidl, paintable.getState())) {
if (wrapper == null) { if (wrapper == null) {
// Add a wrapper between the layout and the child widget // Add a wrapper between the layout and the child widget
final String loc = getLocation(widget); final String loc = getLocation(widget);

+ 2
- 3
src/com/vaadin/terminal/gwt/client/ui/VFormLayout.java View File



} }


if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION)) {
if (state.getCaption() != null) {
if (captionText == null) { if (captionText == null) {
captionText = DOM.createSpan(); captionText = DOM.createSpan();
DOM.insertChild(getElement(), captionText, icon == null ? 0 DOM.insertChild(getElement(), captionText, icon == null ? 0
: 1); : 1);
} }
String c = uidl
.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION);
String c = state.getCaption();
if (c == null) { if (c == null) {
c = ""; c = "";
} else { } else {

+ 3
- 3
src/com/vaadin/terminal/gwt/client/ui/VFormPaintable.java View File

} }


boolean legendEmpty = true; boolean legendEmpty = true;
if (uidl.hasAttribute(ATTRIBUTE_CAPTION)) {
getWidgetForPaintable().caption.setInnerText(uidl
.getStringAttribute(ATTRIBUTE_CAPTION));
if (getState().getCaption() != null) {
getWidgetForPaintable().caption.setInnerText(getState()
.getCaption());
legendEmpty = false; legendEmpty = false;
} else { } else {
getWidgetForPaintable().caption.setInnerText(""); getWidgetForPaintable().caption.setInnerText("");

+ 2
- 2
src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java View File

.getIntAttribute("targetWidth") : -1; .getIntAttribute("targetWidth") : -1;


// Set link caption // Set link caption
getWidgetForPaintable().captionElement.setInnerText(uidl
.getStringAttribute(ATTRIBUTE_CAPTION));
getWidgetForPaintable().captionElement.setInnerText(getState()
.getCaption());


// handle error // handle error
if (uidl.hasAttribute("error")) { if (uidl.hasAttribute("error")) {

+ 2
- 3
src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java View File

getWidgetForPaintable().paintableId = uidl.getId(); getWidgetForPaintable().paintableId = uidl.getId();


// Set text // Set text
getWidgetForPaintable().setText(
uidl.getStringAttribute(ATTRIBUTE_CAPTION));
getWidgetForPaintable().setText(getState().getCaption());


// handle error // handle error
if (uidl.hasAttribute("error")) { if (uidl.hasAttribute("error")) {
protected ComponentState createState() { protected ComponentState createState() {
return GWT.create(ButtonState.class); return GWT.create(ButtonState.class);
} }
}
}

+ 1
- 1
src/com/vaadin/terminal/gwt/client/ui/VNotification.java View File

private static final int TOUCH_DEVICE_IDLE_DELAY = 1000; private static final int TOUCH_DEVICE_IDLE_DELAY = 1000;


public static final String ATTRIBUTE_NOTIFICATION_STYLE = "style"; public static final String ATTRIBUTE_NOTIFICATION_STYLE = "style";
public static final String ATTRIBUTE_NOTIFICATION_CAPTION = VAbstractPaintableWidget.ATTRIBUTE_CAPTION;
public static final String ATTRIBUTE_NOTIFICATION_CAPTION = "caption";
public static final String ATTRIBUTE_NOTIFICATION_MESSAGE = "message"; public static final String ATTRIBUTE_NOTIFICATION_MESSAGE = "message";
public static final String ATTRIBUTE_NOTIFICATION_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON; public static final String ATTRIBUTE_NOTIFICATION_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;
public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position"; public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position";

+ 3
- 4
src/com/vaadin/terminal/gwt/client/ui/VPanelPaintable.java View File

getWidgetForPaintable().captionNode.setClassName(VPanel.CLASSNAME getWidgetForPaintable().captionNode.setClassName(VPanel.CLASSNAME
+ "-caption"); + "-caption");
boolean hasCaption = false; boolean hasCaption = false;
if (uidl.hasAttribute(ATTRIBUTE_CAPTION)
&& !uidl.getStringAttribute(ATTRIBUTE_CAPTION).equals("")) {
getWidgetForPaintable().setCaption(
uidl.getStringAttribute(ATTRIBUTE_CAPTION));
if (getState().getCaption() != null
&& !"".equals(getState().getCaption())) {
getWidgetForPaintable().setCaption(getState().getCaption());
hasCaption = true; hasCaption = true;
} else { } else {
getWidgetForPaintable().setCaption(""); getWidgetForPaintable().setCaption("");

+ 1
- 1
src/com/vaadin/terminal/gwt/client/ui/VPopupViewPaintable.java View File

}// updateFromUIDL }// updateFromUIDL


public void updateCaption(VPaintableWidget component, UIDL uidl) { public void updateCaption(VPaintableWidget component, UIDL uidl) {
if (VCaption.isNeeded(uidl)) {
if (VCaption.isNeeded(uidl, component.getState())) {
if (getWidgetForPaintable().popup.captionWrapper != null) { if (getWidgetForPaintable().popup.captionWrapper != null) {
getWidgetForPaintable().popup.captionWrapper getWidgetForPaintable().popup.captionWrapper
.updateCaption(uidl); .updateCaption(uidl);

+ 5
- 4
src/com/vaadin/terminal/gwt/client/ui/VTabsheet.java View File

client.registerWidgetTooltip(getTabsheet(), getElement(), null); client.registerWidgetTooltip(getTabsheet(), getElement(), null);
} }


boolean ret = super.updateCaption(uidl);

// TODO required because the caption does not have an owner
updateCaptionWithoutOwner(
// TODO need to call this instead of super because the caption does
// not have an owner
boolean ret = updateCaptionWithoutOwner(
uidl,
uidl.getStringAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_CAPTION),
uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DISABLED), uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DISABLED),
uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DESCRIPTION)); uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DESCRIPTION));



+ 1
- 0
src/com/vaadin/terminal/gwt/client/ui/VTabsheetBasePaintable.java View File



public static final String ATTRIBUTE_TAB_DISABLED = "disabled"; public static final String ATTRIBUTE_TAB_DISABLED = "disabled";
public static final String ATTRIBUTE_TAB_DESCRIPTION = "description"; public static final String ATTRIBUTE_TAB_DESCRIPTION = "description";
public static final String ATTRIBUTE_TAB_CAPTION = "caption";


@Override @Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) { public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

+ 2
- 2
src/com/vaadin/terminal/gwt/client/ui/VTreePaintable.java View File

public class VTreePaintable extends VAbstractPaintableWidget { public class VTreePaintable extends VAbstractPaintableWidget {


public static final String ATTRIBUTE_NODE_STYLE = "style"; public static final String ATTRIBUTE_NODE_STYLE = "style";
public static final String ATTRIBUTE_NODE_CAPTION = VAbstractPaintableWidget.ATTRIBUTE_CAPTION;
public static final String ATTRIBUTE_NODE_CAPTION = "caption";
public static final String ATTRIBUTE_NODE_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON; public static final String ATTRIBUTE_NODE_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;


public static final String ATTRIBUTE_ACTION_CAPTION = VAbstractPaintableWidget.ATTRIBUTE_CAPTION;
public static final String ATTRIBUTE_ACTION_CAPTION = "caption";
public static final String ATTRIBUTE_ACTION_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON; public static final String ATTRIBUTE_ACTION_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;


@Override @Override

+ 2
- 3
src/com/vaadin/terminal/gwt/client/ui/VViewPaintable.java View File

clickEventHandler.handleEventHandlerRegistration(client); clickEventHandler.handleEventHandlerRegistration(client);


if (!getWidgetForPaintable().isEmbedded() if (!getWidgetForPaintable().isEmbedded()
&& uidl.hasAttribute(ATTRIBUTE_CAPTION)) {
&& getState().getCaption() != null) {
// only change window title if we're in charge of the whole page // only change window title if we're in charge of the whole page
com.google.gwt.user.client.Window.setTitle(uidl
.getStringAttribute(ATTRIBUTE_CAPTION));
com.google.gwt.user.client.Window.setTitle(getState().getCaption());
} }


// Process children // Process children

+ 1
- 1
src/com/vaadin/terminal/gwt/client/ui/VWindowPaintable.java View File

// the caption attribute is missing the caption should be cleared. // the caption attribute is missing the caption should be cleared.
getWidgetForPaintable() getWidgetForPaintable()
.setCaption( .setCaption(
uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION),
getState().getCaption(),
uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON)); uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON));
} }



+ 1
- 1
src/com/vaadin/terminal/gwt/client/ui/layout/ChildComponentContainer.java View File

} }


public void updateCaption(UIDL uidl, ApplicationConnection client) { public void updateCaption(UIDL uidl, ApplicationConnection client) {
if (VCaption.isNeeded(uidl)) {
if (VCaption.isNeeded(uidl, paintable.getState())) {
// We need a caption // We need a caption


VCaption newCaption = caption; VCaption newCaption = caption;

+ 3
- 8
src/com/vaadin/ui/AbstractComponent.java View File

if (isVisible()) { if (isVisible()) {
// width and height are only in shared state // width and height are only in shared state


// TODO probably can remove some of these (caption, icon, ...)
// once all the VCaption related code has been updated
if (getCaption() != null) {
target.addAttribute(
VAbstractPaintableWidget.ATTRIBUTE_CAPTION,
getCaption());
}
// TODO probably can remove also icon once all the VCaption
// related code has been updated
if (getIcon() != null) { if (getIcon() != null) {
target.addAttribute( target.addAttribute(
VAbstractPaintableWidget.ATTRIBUTE_ICON, getIcon()); VAbstractPaintableWidget.ATTRIBUTE_ICON, getIcon());


sharedState.setStyle(getStyleName()); sharedState.setStyle(getStyleName());


sharedState.setCaption(getCaption());
sharedState.setDescription(getDescription()); sharedState.setDescription(getDescription());


// TODO sharedState.setCaption(getCaption());
// TODO icon also in shared state - how to convert Resource? // TODO icon also in shared state - how to convert Resource?


return sharedState; return sharedState;

+ 2
- 1
src/com/vaadin/ui/TabSheet.java View File

} }
final String caption = tab.getCaption(); final String caption = tab.getCaption();
if (caption != null && caption.length() > 0) { if (caption != null && caption.length() > 0) {
target.addAttribute("caption", caption);
target.addAttribute(
VTabsheetBasePaintable.ATTRIBUTE_TAB_CAPTION, caption);
} }


final String description = tab.getDescription(); final String description = tab.getDescription();

Loading…
Cancel
Save