Browse Source

Reading properties of components should not set state to dirty (#14060).

Many core vaadin components did incorrectly mark the state as dirty when
reading from them. This patch fixes the problem, which should reduce the
amount of server->client state updates significantly.

Change-Id: I342d74129e2985a7f407e9b53a802dc0146d9992
tags/7.3.0.beta1
Fabian Lange 10 years ago
parent
commit
0c229ae914

+ 3
- 2
server/src/com/vaadin/server/AbstractClientConnector.java View File



@Override @Override
public JSONObject encodeState() throws JSONException { public JSONObject encodeState() throws JSONException {
return LegacyCommunicationManager.encodeState(this, getState());
return LegacyCommunicationManager.encodeState(this, getState(false));
} }


/** /**
* @see #setResource(String, Resource) * @see #setResource(String, Resource)
*/ */
protected Resource getResource(String key) { protected Resource getResource(String key) {
return ResourceReference.getResource(getState().resources.get(key));
return ResourceReference
.getResource(getState(false).resources.get(key));
} }


/** /**

+ 9
- 4
server/src/com/vaadin/server/BrowserWindowOpener.java View File

* @return the window target string * @return the window target string
*/ */
public String getWindowName() { public String getWindowName() {
return getState().target;
return getState(false).target;
} }


// Avoid breaking url to multiple lines // Avoid breaking url to multiple lines
* @return * @return
*/ */
public String getFeatures() { public String getFeatures() {
return getState().features;
return getState(false).features;
} }


@Override @Override
return (BrowserWindowOpenerState) super.getState(); return (BrowserWindowOpenerState) super.getState();
} }


@Override
protected BrowserWindowOpenerState getState(boolean markAsDirty) {
return (BrowserWindowOpenerState) super.getState(markAsDirty);
}

@Override @Override
public void attach() { public void attach() {
super.attach(); super.attach();
* @see #setUriFragment(String) * @see #setUriFragment(String)
*/ */
public String getUriFragment() { public String getUriFragment() {
return getState().uriFragment;
return getState(false).uriFragment;
} }


/** /**
if (name == null) { if (name == null) {
throw new IllegalArgumentException("Null not allowed"); throw new IllegalArgumentException("Null not allowed");
} }
return getState().parameters.get(name);
return getState(false).parameters.get(name);
} }


} }

+ 7
- 2
server/src/com/vaadin/ui/AbstractColorPicker.java View File

* currently selected color, e.g. #ffffff) if no other caption is available. * currently selected color, e.g. #ffffff) if no other caption is available.
*/ */
public boolean isDefaultCaptionEnabled() { public boolean isDefaultCaptionEnabled() {
return getState().showDefaultCaption;
return getState(false).showDefaultCaption;
} }


/** /**
return (ColorPickerState) super.getState(); return (ColorPickerState) super.getState();
} }


@Override
protected ColorPickerState getState(boolean markAsDirty) {
return (ColorPickerState) super.getState(markAsDirty);
}

/** /**
* Sets the default styles of the component * Sets the default styles of the component
* *
* <code>false</code> otherwise * <code>false</code> otherwise
*/ */
public boolean isHtmlContentAllowed() { public boolean isHtmlContentAllowed() {
return getState().htmlContentAllowed;
return getState(false).htmlContentAllowed;
} }
} }

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

@Override @Override
public String getStyleName() { public String getStyleName() {
String s = ""; String s = "";
if (ComponentStateUtil.hasStyles(getState())) {
for (final Iterator<String> it = getState().styles.iterator(); it
if (ComponentStateUtil.hasStyles(getState(false))) {
for (final Iterator<String> it = getState(false).styles.iterator(); it
.hasNext();) { .hasNext();) {
s += it.next(); s += it.next();
if (it.hasNext()) { if (it.hasNext()) {


@Override @Override
public String getPrimaryStyleName() { public String getPrimaryStyleName() {
return getState().primaryStyleName;
return getState(false).primaryStyleName;
} }


@Override @Override

+ 6
- 1
server/src/com/vaadin/ui/AbstractEmbedded.java View File

return (AbstractEmbeddedState) super.getState(); return (AbstractEmbeddedState) super.getState();
} }


@Override
protected AbstractEmbeddedState getState(boolean markAsDirty) {
return (AbstractEmbeddedState) super.getState(markAsDirty);
}

/** /**
* Sets the object source resource. The dimensions are assumed if possible. * Sets the object source resource. The dimensions are assumed if possible.
* The type is guessed from resource. * The type is guessed from resource.
* @returns Alternate text * @returns Alternate text
*/ */
public String getAlternateText() { public String getAlternateText() {
return getState().alternateText;
return getState(false).alternateText;
} }


} }

+ 10
- 5
server/src/com/vaadin/ui/AbstractMedia.java View File

return (AbstractMediaState) super.getState(); return (AbstractMediaState) super.getState();
} }


@Override
protected AbstractMediaState getState(boolean markAsDirty) {
return (AbstractMediaState) super.getState(markAsDirty);
}

/** /**
* Sets a single media file as the source of the media component. * Sets a single media file as the source of the media component.
* *
* @return true if the browser is to show native media controls. * @return true if the browser is to show native media controls.
*/ */
public boolean isShowControls() { public boolean isShowControls() {
return getState().showControls;
return getState(false).showControls;
} }


/** /**
* HTML5. * HTML5.
*/ */
public String getAltText() { public String getAltText() {
return getState().altText;
return getState(false).altText;
} }


/** /**
* be rendered as HTML. * be rendered as HTML.
*/ */
public boolean isHtmlContentAllowed() { public boolean isHtmlContentAllowed() {
return getState().htmlContentAllowed;
return getState(false).htmlContentAllowed;
} }


/** /**
* @return true if the media is set to automatically start playback. * @return true if the media is set to automatically start playback.
*/ */
public boolean isAutoplay() { public boolean isAutoplay() {
return getState().autoplay;
return getState(false).autoplay;
} }


/** /**
* @return true if the audio is muted. * @return true if the audio is muted.
*/ */
public boolean isMuted() { public boolean isMuted() {
return getState().muted;
return getState(false).muted;
} }


/** /**

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

return (AbstractOrderedLayoutState) super.getState(); return (AbstractOrderedLayoutState) super.getState();
} }


@Override
protected AbstractOrderedLayoutState getState(boolean markAsDirty) {
return (AbstractOrderedLayoutState) super.getState(markAsDirty);
}

/** /**
* Add a component into this container. The component is added to the right * Add a component into this container. The component is added to the right
* or under the previous component. * or under the previous component.
*/ */
@Override @Override
public boolean isSpacing() { public boolean isSpacing() {
return getState().spacing;
return getState(false).spacing;
} }


/** /**
* @return expand ratio of given component, 0.0f by default. * @return expand ratio of given component, 0.0f by default.
*/ */
public float getExpandRatio(Component component) { public float getExpandRatio(Component component) {
ChildComponentData childData = getState().childData.get(component);
ChildComponentData childData = getState(false).childData.get(component);
if (childData == null) { if (childData == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"The given component is not a child of this layout"); "The given component is not a child of this layout");
*/ */
@Override @Override
public MarginInfo getMargin() { public MarginInfo getMargin() {
return new MarginInfo(getState().marginsBitmask);
return new MarginInfo(getState(false).marginsBitmask);
} }


/* /*

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

* @return the first component of this split panel * @return the first component of this split panel
*/ */
public Component getFirstComponent() { public Component getFirstComponent() {
return (Component) getState().firstChild;
return (Component) getState(false).firstChild;
} }


/** /**
* @return the second component of this split panel * @return the second component of this split panel
*/ */
public Component getSecondComponent() { public Component getSecondComponent() {
return (Component) getState().secondChild;
return (Component) getState(false).secondChild;
} }


/** /**
return (AbstractSplitPanelState) super.getState(); return (AbstractSplitPanelState) super.getState();
} }


@Override
protected AbstractSplitPanelState getState(boolean markAsDirty) {
return (AbstractSplitPanelState) super.getState(markAsDirty);
}

private SplitterState getSplitterState() { private SplitterState getSplitterState() {
return getState().splitterState;
return getState(false).splitterState;
} }
} }

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

return (AbstractTextFieldState) super.getState(); return (AbstractTextFieldState) super.getState();
} }


@Override
protected AbstractTextFieldState getState(boolean markAsDirty) {
return (AbstractTextFieldState) super.getState(markAsDirty);
}

@Override @Override
public void beforeClientResponse(boolean initial) { public void beforeClientResponse(boolean initial) {
super.beforeClientResponse(initial); super.beforeClientResponse(initial);
* @return the maxLength * @return the maxLength
*/ */
public int getMaxLength() { public int getMaxLength() {
return getState().maxLength;
return getState(false).maxLength;
} }


/** /**
* @return the number of columns in the editor. * @return the number of columns in the editor.
*/ */
public int getColumns() { public int getColumns() {
return getState().columns;
return getState(false).columns;
} }


/** /**
* @return the current input prompt, or null if not enabled * @return the current input prompt, or null if not enabled
*/ */
public String getInputPrompt() { public String getInputPrompt() {
return getState().inputPrompt;
return getState(false).inputPrompt;
} }


/** /**

+ 9
- 4
server/src/com/vaadin/ui/Button.java View File

* @return true if the button is disabled when clicked, false otherwise * @return true if the button is disabled when clicked, false otherwise
*/ */
public boolean isDisableOnClick() { public boolean isDisableOnClick() {
return getState().disableOnClick;
return getState(false).disableOnClick;
} }


/** /**
*/ */
@Override @Override
public int getTabIndex() { public int getTabIndex() {
return getState().tabIndex;
return getState(false).tabIndex;
} }


/* /*
return (ButtonState) super.getState(); return (ButtonState) super.getState();
} }


@Override
protected ButtonState getState(boolean markAsDirty) {
return (ButtonState) super.getState(markAsDirty);
}

/** /**
* Sets the component's icon and alt text. * Sets the component's icon and alt text.
* *
* @return String with the alt text * @return String with the alt text
*/ */
public String getIconAlternateText() { public String getIconAlternateText() {
return getState().iconAltText;
return getState(false).iconAltText;
} }


public void setIconAlternateText(String iconAltText) { public void setIconAlternateText(String iconAltText) {
* <code>false</code> otherwise * <code>false</code> otherwise
*/ */
public boolean isHtmlContentAllowed() { public boolean isHtmlContentAllowed() {
return getState().htmlContentAllowed;
return getState(false).htmlContentAllowed;
} }


} }

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

return (CustomLayoutState) super.getState(); return (CustomLayoutState) super.getState();
} }


@Override
protected CustomLayoutState getState(boolean markAsDirty) {
return (CustomLayoutState) super.getState(markAsDirty);
}

/** /**
* Adds the component into this container to given location. If the location * Adds the component into this container to given location. If the location
* is already populated, the old component is removed. * is already populated, the old component is removed.


/** Get the name of the template */ /** Get the name of the template */
public String getTemplateName() { public String getTemplateName() {
return getState().templateName;
return getState(false).templateName;
} }


/** Get the contents of the template */ /** Get the contents of the template */
public String getTemplateContents() { public String getTemplateContents() {
return getState().templateContents;
return getState(false).templateContents;
} }


/** /**
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {
// Workaround to make the CommunicationManager read the template file // Workaround to make the CommunicationManager read the template file
// and send it to the client // and send it to the client
String templateName = getState().templateName;
String templateName = getState(false).templateName;
if (templateName != null && templateName.length() != 0) { if (templateName != null && templateName.length() != 0) {
Set<Object> usedResources = ((JsonPaintTarget) target) Set<Object> usedResources = ((JsonPaintTarget) target)
.getUsedResources(); .getUsedResources();

+ 6
- 1
server/src/com/vaadin/ui/Flash.java View File

return (FlashState) super.getState(); return (FlashState) super.getState();
} }


@Override
protected FlashState getState(boolean markAsDirty) {
return (FlashState) super.getState(markAsDirty);
}

/** /**
* This attribute specifies the base path used to resolve relative URIs * This attribute specifies the base path used to resolve relative URIs
* specified by the classid, data, and archive attributes. When absent, its * specified by the classid, data, and archive attributes. When absent, its
* @return the Value of parameter or null if not found. * @return the Value of parameter or null if not found.
*/ */
public String getParameter(String name) { public String getParameter(String name) {
return getState().embedParams != null ? getState().embedParams
return getState(false).embedParams != null ? getState(false).embedParams
.get(name) : null; .get(name) : null;
} }



+ 78
- 73
server/src/com/vaadin/ui/GridLayout.java View File



/** /**
* A layout where the components are laid out on a grid using cell coordinates. * A layout where the components are laid out on a grid using cell coordinates.
*
*
* <p> * <p>
* The GridLayout also maintains a cursor for adding components in * The GridLayout also maintains a cursor for adding components in
* left-to-right, top-to-bottom order. * left-to-right, top-to-bottom order.
* </p> * </p>
*
*
* <p> * <p>
* Each component in a <code>GridLayout</code> uses a defined * Each component in a <code>GridLayout</code> uses a defined
* {@link GridLayout.Area area} (column1,row1,column2,row2) from the grid. The * {@link GridLayout.Area area} (column1,row1,column2,row2) from the grid. The
* you will get an {@link OverlapsException}. Adding a component with cursor * you will get an {@link OverlapsException}. Adding a component with cursor
* automatically extends the grid by increasing the grid height. * automatically extends the grid by increasing the grid height.
* </p> * </p>
*
*
* <p> * <p>
* The grid coordinates, which are specified by a row and column index, always * The grid coordinates, which are specified by a row and column index, always
* start from 0 for the topmost row and the leftmost column. * start from 0 for the topmost row and the leftmost column.
* </p> * </p>
*
*
* @author Vaadin Ltd. * @author Vaadin Ltd.
* @since 3.0 * @since 3.0
*/ */


/** /**
* Constructor for a grid of given size (number of columns and rows). * Constructor for a grid of given size (number of columns and rows).
*
*
* The grid may grow or shrink later. Grid grows automatically if you add * The grid may grow or shrink later. Grid grows automatically if you add
* components outside its area. * components outside its area.
*
*
* @param columns * @param columns
* Number of columns in the grid. * Number of columns in the grid.
* @param rows * @param rows
/** /**
* Constructs a GridLayout of given size (number of columns and rows) and * Constructs a GridLayout of given size (number of columns and rows) and
* adds the given components in order to the grid. * adds the given components in order to the grid.
*
*
* @see #addComponents(Component...) * @see #addComponents(Component...)
*
*
* @param columns * @param columns
* Number of columns in the grid. * Number of columns in the grid.
* @param rows * @param rows
return (GridLayoutState) super.getState(); return (GridLayoutState) super.getState();
} }


@Override
protected GridLayoutState getState(boolean markAsDirty) {
return (GridLayoutState) super.getState(markAsDirty);
}

/** /**
* <p> * <p>
* Adds a component to the grid in the specified area. The area is defined * Adds a component to the grid in the specified area. The area is defined
* by specifying the upper left corner (column1, row1) and the lower right * by specifying the upper left corner (column1, row1) and the lower right
* corner (column2, row2) of the area. The coordinates are zero-based. * corner (column2, row2) of the area. The coordinates are zero-based.
* </p> * </p>
*
*
* <p> * <p>
* If the area overlaps with any of the existing components already present * If the area overlaps with any of the existing components already present
* in the grid, the operation will fail and an {@link OverlapsException} is * in the grid, the operation will fail and an {@link OverlapsException} is
* thrown. * thrown.
* </p> * </p>
*
*
* @param component * @param component
* the component to be added, not <code>null</code>. * the component to be added, not <code>null</code>.
* @param column1 * @param column1
/** /**
* Tests if the given area overlaps with any of the items already on the * Tests if the given area overlaps with any of the items already on the
* grid. * grid.
*
*
* @param area * @param area
* the Area to be checked for overlapping. * the Area to be checked for overlapping.
* @throws OverlapsException * @throws OverlapsException
* the area.) End coordinates (SouthEast corner of the area) are the same as * the area.) End coordinates (SouthEast corner of the area) are the same as
* column1,row1. The coordinates are zero-based. Component width and height * column1,row1. The coordinates are zero-based. Component width and height
* is 1. * is 1.
*
*
* @param component * @param component
* the component to be added, not <code>null</code>. * the component to be added, not <code>null</code>.
* @param column * @param column


/** /**
* Forces the next component to be added at the beginning of the next line. * Forces the next component to be added at the beginning of the next line.
*
*
* <p> * <p>
* Sets the cursor column to 0 and increments the cursor row by one. * Sets the cursor column to 0 and increments the cursor row by one.
* </p> * </p>
*
*
* <p> * <p>
* By calling this function you can ensure that no more components are added * By calling this function you can ensure that no more components are added
* right of the previous component. * right of the previous component.
* </p> * </p>
*
*
* @see #space() * @see #space()
*/ */
public void newLine() { public void newLine() {
/** /**
* Moves the cursor forward by one. If the cursor goes out of the right grid * Moves the cursor forward by one. If the cursor goes out of the right grid
* border, it is moved to the first column of the next row. * border, it is moved to the first column of the next row.
*
*
* @see #newLine() * @see #newLine()
*/ */
public void space() { public void space() {
* cursor position is already occupied, the cursor is moved forwards to find * cursor position is already occupied, the cursor is moved forwards to find
* free position. If the cursor goes out from the bottom of the grid, the * free position. If the cursor goes out from the bottom of the grid, the
* grid is automatically extended. * grid is automatically extended.
*
*
* @param component * @param component
* the component to be added, not <code>null</code>. * the component to be added, not <code>null</code>.
*/ */


/** /**
* Removes the specified component from the layout. * Removes the specified component from the layout.
*
*
* @param component * @param component
* the component to be removed. * the component to be removed.
*/ */


/** /**
* Removes the component specified by its cell coordinates. * Removes the component specified by its cell coordinates.
*
*
* @param column * @param column
* the component's column, starting from 0. * the component's column, starting from 0.
* @param row * @param row
/** /**
* Gets an Iterator for the components contained in the layout. By using the * Gets an Iterator for the components contained in the layout. By using the
* Iterator it is possible to step through the contents of the layout. * Iterator it is possible to step through the contents of the layout.
*
*
* @return the Iterator of the components inside the layout. * @return the Iterator of the components inside the layout.
*/ */
@Override @Override
/** /**
* Gets the number of components contained in the layout. Consistent with * Gets the number of components contained in the layout. Consistent with
* the iterator returned by {@link #getComponentIterator()}. * the iterator returned by {@link #getComponentIterator()}.
*
*
* @return the number of contained components * @return the number of contained components
*/ */
@Override @Override


/** /**
* Paints the contents of this component. * Paints the contents of this component.
*
*
* @param target * @param target
* the Paint Event. * the Paint Event.
* @throws PaintException * @throws PaintException
*/ */
@Override @Override
public Alignment getComponentAlignment(Component childComponent) { public Alignment getComponentAlignment(Component childComponent) {
ChildComponentData childComponentData = getState().childData
ChildComponentData childComponentData = getState(false).childData
.get(childComponent); .get(childComponent);
if (childComponentData == null) { if (childComponentData == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(


/** /**
* Defines a rectangular area of cells in a GridLayout. * Defines a rectangular area of cells in a GridLayout.
*
*
* <p> * <p>
* Also maintains a reference to the component contained in the area. * Also maintains a reference to the component contained in the area.
* </p> * </p>
*
*
* <p> * <p>
* The area is specified by the cell coordinates of its upper left corner * The area is specified by the cell coordinates of its upper left corner
* (column1,row1) and lower right corner (column2,row2). As otherwise with * (column1,row1) and lower right corner (column2,row2). As otherwise with
* GridLayout, the column and row coordinates start from zero. * GridLayout, the column and row coordinates start from zero.
* </p> * </p>
*
*
* @author Vaadin Ltd. * @author Vaadin Ltd.
* @since 3.0 * @since 3.0
*/ */
* <p> * <p>
* Construct a new area on a grid. * Construct a new area on a grid.
* </p> * </p>
*
*
* @param component * @param component
* the component connected to the area. * the component connected to the area.
* @param column1 * @param column1


/** /**
* Tests if this Area overlaps with another Area. * Tests if this Area overlaps with another Area.
*
*
* @param other * @param other
* the other Area that is to be tested for overlap with this * the other Area that is to be tested for overlap with this
* area * area


/** /**
* Gets the component connected to the area. * Gets the component connected to the area.
*
*
* @return the Component. * @return the Component.
*/ */
public Component getComponent() { public Component getComponent() {


/** /**
* Gets the column of the top-left corner cell. * Gets the column of the top-left corner cell.
*
*
* @return the column of the top-left corner cell. * @return the column of the top-left corner cell.
*/ */
public int getColumn1() { public int getColumn1() {


/** /**
* Gets the column of the bottom-right corner cell. * Gets the column of the bottom-right corner cell.
*
*
* @return the column of the bottom-right corner cell. * @return the column of the bottom-right corner cell.
*/ */
public int getColumn2() { public int getColumn2() {


/** /**
* Gets the row of the top-left corner cell. * Gets the row of the top-left corner cell.
*
*
* @return the row of the top-left corner cell. * @return the row of the top-left corner cell.
*/ */
public int getRow1() { public int getRow1() {


/** /**
* Gets the row of the bottom-right corner cell. * Gets the row of the bottom-right corner cell.
*
*
* @return the row of the bottom-right corner cell. * @return the row of the bottom-right corner cell.
*/ */
public int getRow2() { public int getRow2() {
* Gridlayout does not support laying components on top of each other. An * Gridlayout does not support laying components on top of each other. An
* <code>OverlapsException</code> is thrown when a component already exists * <code>OverlapsException</code> is thrown when a component already exists
* (even partly) at the same space on a grid with the new component. * (even partly) at the same space on a grid with the new component.
*
*
* @author Vaadin Ltd. * @author Vaadin Ltd.
* @since 3.0 * @since 3.0
*/ */


/** /**
* Constructs an <code>OverlapsException</code>. * Constructs an <code>OverlapsException</code>.
*
*
* @param existingArea * @param existingArea
*/ */
public OverlapsException(Area existingArea) { public OverlapsException(Area existingArea) {


/** /**
* Gets the area . * Gets the area .
*
*
* @return the existing area. * @return the existing area.
*/ */
public Area getArea() { public Area getArea() {
/** /**
* An <code>Exception</code> object which is thrown when an area exceeds the * An <code>Exception</code> object which is thrown when an area exceeds the
* bounds of the grid. * bounds of the grid.
*
*
* @author Vaadin Ltd. * @author Vaadin Ltd.
* @since 3.0 * @since 3.0
*/ */
/** /**
* Constructs an <code>OoutOfBoundsException</code> with the specified * Constructs an <code>OoutOfBoundsException</code> with the specified
* detail message. * detail message.
*
*
* @param areaOutOfBounds * @param areaOutOfBounds
*/ */
public OutOfBoundsException(Area areaOutOfBounds) { public OutOfBoundsException(Area areaOutOfBounds) {


/** /**
* Gets the area that is out of bounds. * Gets the area that is out of bounds.
*
*
* @return the area out of Bound. * @return the area out of Bound.
*/ */
public Area getArea() { public Area getArea() {
/** /**
* Sets the number of columns in the grid. The column count can not be * Sets the number of columns in the grid. The column count can not be
* reduced if there are any areas that would be outside of the shrunk grid. * reduced if there are any areas that would be outside of the shrunk grid.
*
*
* @param columns * @param columns
* the new number of columns in the grid. * the new number of columns in the grid.
*/ */


/** /**
* Get the number of columns in the grid. * Get the number of columns in the grid.
*
*
* @return the number of columns in the grid. * @return the number of columns in the grid.
*/ */
public int getColumns() { public int getColumns() {
return getState().columns;
return getState(false).columns;
} }


/** /**
* Sets the number of rows in the grid. The number of rows can not be * Sets the number of rows in the grid. The number of rows can not be
* reduced if there are any areas that would be outside of the shrunk grid. * reduced if there are any areas that would be outside of the shrunk grid.
*
*
* @param rows * @param rows
* the new number of rows in the grid. * the new number of rows in the grid.
*/ */


/** /**
* Get the number of rows in the grid. * Get the number of rows in the grid.
*
*
* @return the number of rows in the grid. * @return the number of rows in the grid.
*/ */
public int getRows() { public int getRows() {
return getState().rows;
return getState(false).rows;
} }


/** /**
* Gets the current x-position (column) of the cursor. * Gets the current x-position (column) of the cursor.
*
*
* <p> * <p>
* The cursor position points the position for the next component that is * The cursor position points the position for the next component that is
* added without specifying its coordinates (grid cell). When the cursor * added without specifying its coordinates (grid cell). When the cursor
* position is occupied, the next component will be added to first free * position is occupied, the next component will be added to first free
* position after the cursor. * position after the cursor.
* </p> * </p>
*
*
* @return the grid column the cursor is on, starting from 0. * @return the grid column the cursor is on, starting from 0.
*/ */
public int getCursorX() { public int getCursorX() {
/** /**
* Sets the current cursor x-position. This is usually handled automatically * Sets the current cursor x-position. This is usually handled automatically
* by GridLayout. * by GridLayout.
*
*
* @param cursorX * @param cursorX
*/ */
public void setCursorX(int cursorX) { public void setCursorX(int cursorX) {


/** /**
* Gets the current y-position (row) of the cursor. * Gets the current y-position (row) of the cursor.
*
*
* <p> * <p>
* The cursor position points the position for the next component that is * The cursor position points the position for the next component that is
* added without specifying its coordinates (grid cell). When the cursor * added without specifying its coordinates (grid cell). When the cursor
* position is occupied, the next component will be added to the first free * position is occupied, the next component will be added to the first free
* position after the cursor. * position after the cursor.
* </p> * </p>
*
*
* @return the grid row the Cursor is on. * @return the grid row the Cursor is on.
*/ */
public int getCursorY() { public int getCursorY() {
/** /**
* Sets the current y-coordinate (row) of the cursor. This is usually * Sets the current y-coordinate (row) of the cursor. This is usually
* handled automatically by GridLayout. * handled automatically by GridLayout.
*
*
* @param cursorY * @param cursorY
* the row number, starting from 0 for the topmost row. * the row number, starting from 0 for the topmost row.
*/ */
*/ */
@Override @Override
public boolean isSpacing() { public boolean isSpacing() {
return getState().spacing;
return getState(false).spacing;
} }


/** /**
* Inserts an empty row at the specified position in the grid. * Inserts an empty row at the specified position in the grid.
*
*
* @param row * @param row
* Index of the row before which the new row will be inserted. * Index of the row before which the new row will be inserted.
* The leftmost row has index 0. * The leftmost row has index 0.


/** /**
* Removes a row and all the components in the row. * Removes a row and all the components in the row.
*
*
* <p> * <p>
* Components which span over several rows are removed if the selected row * Components which span over several rows are removed if the selected row
* is on the first row of such a component. * is on the first row of such a component.
* </p> * </p>
*
*
* <p> * <p>
* If the last row is removed then all remaining components will be removed * If the last row is removed then all remaining components will be removed
* and the grid will be reduced to one row. The cursor will be moved to the * and the grid will be reduced to one row. The cursor will be moved to the
* upper left cell of the grid. * upper left cell of the grid.
* </p> * </p>
*
*
* @param row * @param row
* Index of the row to remove. The leftmost row has index 0. * Index of the row to remove. The leftmost row has index 0.
*/ */


/** /**
* Sets the expand ratio of given column. * Sets the expand ratio of given column.
*
*
* <p> * <p>
* The expand ratio defines how excess space is distributed among columns. * The expand ratio defines how excess space is distributed among columns.
* Excess space means space that is left over from components that are not * Excess space means space that is left over from components that are not
* sized relatively. By default, the excess space is distributed evenly. * sized relatively. By default, the excess space is distributed evenly.
* </p> * </p>
*
*
* <p> * <p>
* Note that the component width of the GridLayout must be defined (fixed or * Note that the component width of the GridLayout must be defined (fixed or
* relative, as opposed to undefined) for this method to have any effect. * relative, as opposed to undefined) for this method to have any effect.
* </p> * </p>
*
*
* @see #setWidth(float, int) * @see #setWidth(float, int)
*
*
* @param columnIndex * @param columnIndex
* @param ratio * @param ratio
*/ */


/** /**
* Returns the expand ratio of given column * Returns the expand ratio of given column
*
*
* @see #setColumnExpandRatio(int, float) * @see #setColumnExpandRatio(int, float)
*
*
* @param columnIndex * @param columnIndex
* @return the expand ratio, 0.0f by default * @return the expand ratio, 0.0f by default
*/ */


/** /**
* Sets the expand ratio of given row. * Sets the expand ratio of given row.
*
*
* <p> * <p>
* Expand ratio defines how excess space is distributed among rows. Excess * Expand ratio defines how excess space is distributed among rows. Excess
* space means the space left over from components that are not sized * space means the space left over from components that are not sized
* relatively. By default, the excess space is distributed evenly. * relatively. By default, the excess space is distributed evenly.
* </p> * </p>
*
*
* <p> * <p>
* Note, that height needs to be defined (fixed or relative, as opposed to * Note, that height needs to be defined (fixed or relative, as opposed to
* undefined height) for this method to have any effect. * undefined height) for this method to have any effect.
* </p> * </p>
*
*
* @see #setHeight(float, int) * @see #setHeight(float, int)
*
*
* @param rowIndex * @param rowIndex
* The row index, starting from 0 for the topmost row. * The row index, starting from 0 for the topmost row.
* @param ratio * @param ratio


/** /**
* Returns the expand ratio of given row. * Returns the expand ratio of given row.
*
*
* @see #setRowExpandRatio(int, float) * @see #setRowExpandRatio(int, float)
*
*
* @param rowIndex * @param rowIndex
* The row index, starting from 0 for the topmost row. * The row index, starting from 0 for the topmost row.
* @return the expand ratio, 0.0f by default * @return the expand ratio, 0.0f by default


/** /**
* Gets the Component at given index. * Gets the Component at given index.
*
*
* @param x * @param x
* The column index, starting from 0 for the leftmost column. * The column index, starting from 0 for the leftmost column.
* @param y * @param y
* @return Component in given cell or null if empty * @return Component in given cell or null if empty
*/ */
public Component getComponent(int x, int y) { public Component getComponent(int x, int y) {
for (Entry<Connector, ChildComponentData> entry : getState().childData
for (Entry<Connector, ChildComponentData> entry : getState(false).childData
.entrySet()) { .entrySet()) {
ChildComponentData childData = entry.getValue(); ChildComponentData childData = entry.getValue();
if (childData.column1 <= x && x <= childData.column2 if (childData.column1 <= x && x <= childData.column2
/** /**
* Returns information about the area where given component is laid in the * Returns information about the area where given component is laid in the
* GridLayout. * GridLayout.
*
*
* @param component * @param component
* the component whose area information is requested. * the component whose area information is requested.
* @return an Area object that contains information how component is laid in * @return an Area object that contains information how component is laid in
* the grid * the grid
*/ */
public Area getComponentArea(Component component) { public Area getComponentArea(Component component) {
ChildComponentData childComponentData = getState().childData
ChildComponentData childComponentData = getState(false).childData
.get(component); .get(component);
if (childComponentData == null) { if (childComponentData == null) {
return null; return null;
*/ */
@Override @Override
public MarginInfo getMargin() { public MarginInfo getMargin() {
return new MarginInfo(getState().marginsBitmask);
return new MarginInfo(getState(false).marginsBitmask);
} }


/* /*

+ 9
- 5
server/src/com/vaadin/ui/Label.java View File

return (LabelState) super.getState(); return (LabelState) super.getState();
} }


@Override
protected LabelState getState(boolean markAsDirty) {
return (LabelState) super.getState(markAsDirty);
}

/** /**
* Gets the value of the label. * Gets the value of the label.
* <p> * <p>
public String getValue() { public String getValue() {
if (getPropertyDataSource() == null) { if (getPropertyDataSource() == null) {
// Use internal value if we are running without a data source // Use internal value if we are running without a data source
return getState().text;
return getState(false).text;
} }
return getDataSourceValue(); return getDataSourceValue();
} }
public void setValue(String newStringValue) { public void setValue(String newStringValue) {
if (getPropertyDataSource() == null) { if (getPropertyDataSource() == null) {


LabelState state = (LabelState) getState(false);
LabelState state = getState(false);
String oldTextValue = state.text; String oldTextValue = state.text;
if (!SharedUtil.equals(oldTextValue, newStringValue)) { if (!SharedUtil.equals(oldTextValue, newStringValue)) {
getState().text = newStringValue; getState().text = newStringValue;
* @see ContentMode * @see ContentMode
*/ */
public ContentMode getContentMode() { public ContentMode getContentMode() {
return getState().contentMode;
return getState(false).contentMode;
} }


/** /**
private void updateValueFromDataSource() { private void updateValueFromDataSource() {
// Update the internal value from the data source // Update the internal value from the data source
String newConvertedValue = getDataSourceValue(); String newConvertedValue = getDataSourceValue();
if (!SharedUtil.equals(newConvertedValue,
((LabelState) getState(false)).text)) {
if (!SharedUtil.equals(newConvertedValue, getState(false).text)) {
getState().text = newConvertedValue; getState().text = newConvertedValue;
fireValueChange(); fireValueChange();
} }

+ 6
- 1
server/src/com/vaadin/ui/MenuBar.java View File

return (MenuBarState) super.getState(); return (MenuBarState) super.getState();
} }


@Override
protected MenuBarState getState(boolean markAsDirty) {
return (MenuBarState) super.getState(markAsDirty);
}

/** Paint (serialise) the component for the client. */ /** Paint (serialise) the component for the client. */
@Override @Override
public void paintContent(PaintTarget target) throws PaintException { public void paintContent(PaintTarget target) throws PaintException {


@Override @Override
public int getTabIndex() { public int getTabIndex() {
return getState().tabIndex;
return getState(false).tabIndex;
} }


/* /*

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

*/ */
@Override @Override
public int getScrollLeft() { public int getScrollLeft() {
return getState().scrollLeft;
return getState(false).scrollLeft;
} }


/* /*
*/ */
@Override @Override
public int getScrollTop() { public int getScrollTop() {
return getState().scrollTop;
return getState(false).scrollTop;
} }


/* /*
*/ */
@Override @Override
public int getTabIndex() { public int getTabIndex() {
return getState().tabIndex;
return getState(false).tabIndex;
} }


/** /**
return (PanelState) super.getState(); return (PanelState) super.getState();
} }


@Override
protected PanelState getState(boolean markAsDirty) {
return (PanelState) super.getState(markAsDirty);
}

} }

+ 7
- 2
server/src/com/vaadin/ui/PopupDateField.java View File

return (PopupDateFieldState) super.getState(); return (PopupDateFieldState) super.getState();
} }


@Override
protected PopupDateFieldState getState(boolean markAsDirty) {
return (PopupDateFieldState) super.getState(markAsDirty);
}

/** /**
* Checks whether the text field is enabled (default) or not. * Checks whether the text field is enabled (default) or not.
* *
* @return <b>true</b> if the text field is enabled, <b>false</b> otherwise. * @return <b>true</b> if the text field is enabled, <b>false</b> otherwise.
*/ */
public boolean isTextFieldEnabled() { public boolean isTextFieldEnabled() {
return getState().textFieldEnabled;
return getState(false).textFieldEnabled;
} }


/** /**
* @return String with the description * @return String with the description
*/ */
public String getAssistiveText() { public String getAssistiveText() {
return getState().descriptionForAssistiveDevices;
return getState(false).descriptionForAssistiveDevices;
} }
} }

+ 6
- 1
server/src/com/vaadin/ui/PopupView.java View File

* @return true if the popup is hidden on mouse out, false otherwise * @return true if the popup is hidden on mouse out, false otherwise
*/ */
public boolean isHideOnMouseOut() { public boolean isHideOnMouseOut() {
return getState().hideOnMouseOut;
return getState(false).hideOnMouseOut;
} }


/** /**
return (PopupViewState) super.getState(); return (PopupViewState) super.getState();
} }


@Override
protected PopupViewState getState(boolean markAsDirty) {
return (PopupViewState) super.getState(markAsDirty);
}

/** /**
* Used to deliver customized content-packages to the PopupView. These are * Used to deliver customized content-packages to the PopupView. These are
* dynamically loaded when they are redrawn. The user must take care that * dynamically loaded when they are redrawn. The user must take care that

+ 9
- 4
server/src/com/vaadin/ui/Slider.java View File

return (SliderState) super.getState(); return (SliderState) super.getState();
} }


@Override
public SliderState getState(boolean markAsDirty) {
return (SliderState) super.getState(markAsDirty);
}

/** /**
* Gets the maximum slider value * Gets the maximum slider value
* *
* @return the largest value the slider can have * @return the largest value the slider can have
*/ */
public double getMax() { public double getMax() {
return getState().maxValue;
return getState(false).maxValue;
} }


/** /**
* @return the smallest value the slider can have * @return the smallest value the slider can have
*/ */
public double getMin() { public double getMin() {
return getState().minValue;
return getState(false).minValue;
} }


/** /**
* {@link SliderOrientation#VERTICAL} * {@link SliderOrientation#VERTICAL}
*/ */
public SliderOrientation getOrientation() { public SliderOrientation getOrientation() {
return getState().orientation;
return getState(false).orientation;
} }


/** /**
* @return resolution * @return resolution
*/ */
public int getResolution() { public int getResolution() {
return getState().resolution;
return getState(false).resolution;
} }


/** /**

+ 7
- 2
server/src/com/vaadin/ui/TextArea.java View File

return (TextAreaState) super.getState(); return (TextAreaState) super.getState();
} }


@Override
protected TextAreaState getState(boolean markAsDirty) {
return (TextAreaState) super.getState(markAsDirty);
}

/** /**
* Sets the number of rows in the text area. * Sets the number of rows in the text area.
* *
* @return number of explicitly set rows. * @return number of explicitly set rows.
*/ */
public int getRows() { public int getRows() {
return getState().rows;
return getState(false).rows;
} }


/** /**
* <code>false</code> if not. * <code>false</code> if not.
*/ */
public boolean isWordwrap() { public boolean isWordwrap() {
return getState().wordwrap;
return getState(false).wordwrap;
} }


} }

+ 1
- 1
server/src/com/vaadin/ui/UI.java View File

* @return the label of the container * @return the label of the container
*/ */
public String getOverlayContainerLabel() { public String getOverlayContainerLabel() {
return getState().overlayContainerLabel;
return getState(false).overlayContainerLabel;
} }


/** /**

+ 13
- 13
server/src/com/vaadin/ui/Window.java View File

import com.vaadin.shared.Connector; import com.vaadin.shared.Connector;
import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.window.WindowMode; import com.vaadin.shared.ui.window.WindowMode;
import com.vaadin.shared.ui.window.WindowRole;
import com.vaadin.shared.ui.window.WindowServerRpc; import com.vaadin.shared.ui.window.WindowServerRpc;
import com.vaadin.shared.ui.window.WindowState; import com.vaadin.shared.ui.window.WindowState;
import com.vaadin.shared.ui.window.WindowRole;
import com.vaadin.util.ReflectTools; import com.vaadin.util.ReflectTools;


/** /**
* @since 4.0.0 * @since 4.0.0
*/ */
public int getPositionX() { public int getPositionX() {
return getState().positionX;
return getState(false).positionX;
} }


/** /**
* @since 4.0.0 * @since 4.0.0
*/ */
public int getPositionY() { public int getPositionY() {
return getState().positionY;
return getState(false).positionY;
} }


/** /**
* @return true if this window is modal. * @return true if this window is modal.
*/ */
public boolean isModal() { public boolean isModal() {
return getState().modal;
return getState(false).modal;
} }


/** /**
* @return true if window is resizable by the end-user, otherwise false. * @return true if window is resizable by the end-user, otherwise false.
*/ */
public boolean isResizable() { public boolean isResizable() {
return getState().resizable;
return getState(false).resizable;
} }


/** /**
* sizes are recalculated immediately. * sizes are recalculated immediately.
*/ */
public boolean isResizeLazy() { public boolean isResizeLazy() {
return getState().resizeLazy;
return getState(false).resizeLazy;
} }


/** /**
* true if the window can be dragged by the user * true if the window can be dragged by the user
*/ */
public boolean isDraggable() { public boolean isDraggable() {
return getState().draggable;
return getState(false).draggable;
} }


/** /**
* @return The accessibility prefix * @return The accessibility prefix
*/ */
public String getAssistivePrefix() { public String getAssistivePrefix() {
return getState().assistivePrefix;
return getState(false).assistivePrefix;
} }


/** /**
* @return The accessibility postfix * @return The accessibility postfix
*/ */
public String getAssistivePostfix() { public String getAssistivePostfix() {
return getState().assistivePostfix;
return getState(false).assistivePostfix;
} }


/** /**
* @return WAI-ARIA role set for the window * @return WAI-ARIA role set for the window
*/ */
public WindowRole getAssistiveRole() { public WindowRole getAssistiveRole() {
return getState().role;
return getState(false).role;
} }


/** /**
* focus can leave the window * focus can leave the window
*/ */
public boolean isTabStopEnabled() { public boolean isTabStopEnabled() {
return getState().assistiveTabStop;
return getState(false).assistiveTabStop;
} }


/** /**
* @return the top message * @return the top message
*/ */
public String getTabStopTopAssistiveText() { public String getTabStopTopAssistiveText() {
return getState().assistiveTabStopTopText;
return getState(false).assistiveTabStopTopText;
} }


/** /**
* @return the bottom message * @return the bottom message
*/ */
public String getTabStopBottomAssistiveText() { public String getTabStopBottomAssistiveText() {
return getState().assistiveTabStopBottomText;
return getState(false).assistiveTabStopBottomText;
} }
} }

Loading…
Cancel
Save