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

@@ -21,8 +21,9 @@ public class ComponentState extends SharedState {
private String style = "";
private boolean disabled = false;
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.
@@ -236,4 +237,31 @@ public class ComponentState extends SharedState {
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

@@ -10,6 +10,7 @@ import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTML;
import com.vaadin.terminal.gwt.client.ui.Icon;
import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
import com.vaadin.terminal.gwt.client.ui.VTabsheetBasePaintable;

public class VCaption extends HTML {

@@ -35,6 +36,10 @@ public class VCaption extends HTML {

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}.
*
@@ -81,6 +86,9 @@ public class VCaption extends HTML {
/**
* 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
* @return true if the position where the caption should be placed has
* changed
@@ -94,25 +102,20 @@ public class VCaption extends HTML {
// moves it above.
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
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON);
boolean hasText = uidl
.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION);
boolean showRequired = uidl
.getBooleanAttribute(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED);
boolean showError = uidl
@@ -125,10 +128,8 @@ public class VCaption extends HTML {
icon.setWidth("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
placedAfterComponent = false;
@@ -142,7 +143,7 @@ public class VCaption extends HTML {
icon = null;
}

if (hasText) {
if (owner.getState().getCaption() != 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.
@@ -151,15 +152,12 @@ public class VCaption extends HTML {
captionText = DOM.createDiv();
captionText.setClassName("v-captiontext");

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

// 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.
placedAfterComponent = false;
if (c == null || c.trim().equals("")) {
@@ -182,12 +180,10 @@ public class VCaption extends HTML {
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) {
@@ -197,10 +193,8 @@ public class VCaption extends HTML {
.setClassName("v-required-field-indicator");
DOM.setInnerText(requiredFieldIndicator, "*");

DOM.insertChild(
getElement(),
requiredFieldIndicator,
getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_REQUIRED));
DOM.insertChild(getElement(), requiredFieldIndicator,
getInsertPosition(InsertPosition.REQUIRED));
}
} else if (requiredFieldIndicator != null) {
// Remove existing
@@ -215,10 +209,8 @@ public class VCaption extends HTML {
DOM.setElementProperty(errorIndicatorElement, "className",
"v-errorindicator");

DOM.insertChild(
getElement(),
errorIndicatorElement,
getInsertPosition(VAbstractPaintableWidget.ATTRIBUTE_ERROR));
DOM.insertChild(getElement(), errorIndicatorElement,
getInsertPosition(InsertPosition.ERROR));
}
} else if (errorIndicatorElement != null) {
// Remove existing
@@ -235,16 +227,16 @@ public class VCaption extends HTML {
return (wasPlacedAfterComponent != placedAfterComponent);
}

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

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

@@ -252,26 +244,33 @@ public class VCaption extends HTML {
pos++;
}

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

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

}

@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
// 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;
if (disabled) {
style += " " + ApplicationConnection.DISABLED_CLASSNAME;
@@ -284,6 +283,90 @@ public class VCaption extends HTML {
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
@@ -323,9 +406,17 @@ public class VCaption extends HTML {
}
}

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)) {
return true;

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

@@ -52,7 +52,9 @@ public class JsonDecoder {
VPaintableMap idMapper) {
Object val = null;
// 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);
} else if (JsonEncoder.VTYPE_MAP.equals(variableType)) {
val = convertMap((JSONObject) value, idMapper);

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

@@ -195,7 +195,8 @@ public class VAbsoluteLayout extends ComplexPanel implements Container {

public void updateCaption(UIDL uidl) {

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

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

@@ -27,7 +27,6 @@ public abstract class VAbstractPaintableWidget implements VPaintableWidget {
// Not all references to the string literals have been converted to use
// these!
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_ERROR = "error";
public static final String ATTRIBUTE_HIDEERRORS = "hideErrors";

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

@@ -490,9 +490,10 @@ public class VAccordion extends VTabsheetBase implements
}

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(
uidl,
uidl.getStringAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_CAPTION),
uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DISABLED),
uidl.hasAttribute(VTabsheetBasePaintable.ATTRIBUTE_TAB_DESCRIPTION));
}

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

@@ -41,8 +41,7 @@ public class VButtonPaintable extends VAbstractPaintableWidget {
getWidgetForPaintable().paintableId = uidl.getId();

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

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


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

@@ -85,8 +85,7 @@ public class VCheckBoxPaintable extends VAbstractPaintableWidget {
}

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

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

@@ -208,7 +208,7 @@ public class VCssLayout extends SimplePanel implements Container {
public void updateCaption(VPaintableWidget paintable, UIDL uidl) {
Widget widget = paintable.getWidgetForPaintable();
VCaption caption = widgetToCaption.get(widget);
if (VCaption.isNeeded(uidl)) {
if (VCaption.isNeeded(uidl, paintable.getState())) {
if (caption == null) {
caption = new VCaption(paintable, client);
widgetToCaption.put(widget, caption);

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

@@ -332,7 +332,7 @@ public class VCustomLayout extends ComplexPanel implements Container,
public void updateCaption(VPaintableWidget paintable, UIDL uidl) {
VCaptionWrapper wrapper = paintableToCaptionWrapper.get(paintable);
Widget widget = paintable.getWidgetForPaintable();
if (VCaption.isNeeded(uidl)) {
if (VCaption.isNeeded(uidl, paintable.getState())) {
if (wrapper == null) {
// Add a wrapper between the layout and the child widget
final String loc = getLocation(widget);

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

@@ -365,14 +365,13 @@ public class VFormLayout extends SimplePanel implements Container {

}

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

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

@@ -31,9 +31,9 @@ public class VFormPaintable extends VAbstractPaintableWidgetContainer {
}

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;
} else {
getWidgetForPaintable().caption.setInnerText("");

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

@@ -61,8 +61,8 @@ public class VLinkPaintable extends VAbstractPaintableWidget {
.getIntAttribute("targetWidth") : -1;

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

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

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

@@ -41,8 +41,7 @@ public class VNativeButtonPaintable extends VAbstractPaintableWidget {
getWidgetForPaintable().paintableId = uidl.getId();

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

// handle error
if (uidl.hasAttribute("error")) {
@@ -100,4 +99,4 @@ public class VNativeButtonPaintable extends VAbstractPaintableWidget {
protected ComponentState createState() {
return GWT.create(ButtonState.class);
}
}
}

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

@@ -57,7 +57,7 @@ public class VNotification extends VOverlay {
private static final int TOUCH_DEVICE_IDLE_DELAY = 1000;

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_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;
public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position";

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

@@ -47,10 +47,9 @@ public class VPanelPaintable extends VAbstractPaintableWidgetContainer {
getWidgetForPaintable().captionNode.setClassName(VPanel.CLASSNAME
+ "-caption");
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;
} else {
getWidgetForPaintable().setCaption("");

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

@@ -80,7 +80,7 @@ public class VPopupViewPaintable extends VAbstractPaintableWidgetContainer {
}// updateFromUIDL

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

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

@@ -214,10 +214,11 @@ public class VTabsheet extends VTabsheetBase {
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_DESCRIPTION));


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

@@ -17,6 +17,7 @@ public abstract class VTabsheetBasePaintable extends

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

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

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

@@ -15,10 +15,10 @@ import com.vaadin.terminal.gwt.client.ui.VTree.TreeNode;
public class VTreePaintable extends VAbstractPaintableWidget {

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_ACTION_CAPTION = VAbstractPaintableWidget.ATTRIBUTE_CAPTION;
public static final String ATTRIBUTE_ACTION_CAPTION = "caption";
public static final String ATTRIBUTE_ACTION_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;

@Override

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

@@ -61,10 +61,9 @@ public class VViewPaintable extends VAbstractPaintableWidgetContainer {
clickEventHandler.handleEventHandlerRegistration(client);

if (!getWidgetForPaintable().isEmbedded()
&& uidl.hasAttribute(ATTRIBUTE_CAPTION)) {
&& getState().getCaption() != null) {
// 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

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

@@ -77,7 +77,7 @@ public class VWindowPaintable extends VAbstractPaintableWidgetContainer
// the caption attribute is missing the caption should be cleared.
getWidgetForPaintable()
.setCaption(
uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION),
getState().getCaption(),
uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON));
}


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

@@ -403,7 +403,7 @@ public class ChildComponentContainer extends Panel {
}

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

VCaption newCaption = caption;

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

@@ -771,13 +771,8 @@ public abstract class AbstractComponent implements Component, MethodEventSource
if (isVisible()) {
// 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) {
target.addAttribute(
VAbstractPaintableWidget.ATTRIBUTE_ICON, getIcon());
@@ -887,9 +882,9 @@ public abstract class AbstractComponent implements Component, MethodEventSource

sharedState.setStyle(getStyleName());

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

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

return sharedState;

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

@@ -399,7 +399,8 @@ public class TabSheet extends AbstractComponentContainer {
}
final String caption = tab.getCaption();
if (caption != null && caption.length() > 0) {
target.addAttribute("caption", caption);
target.addAttribute(
VTabsheetBasePaintable.ATTRIBUTE_TAB_CAPTION, caption);
}

final String description = tab.getDescription();

Loading…
Cancel
Save