Bläddra i källkod

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 år sedan
förälder
incheckning
0c229ae914

+ 3
- 2
server/src/com/vaadin/server/AbstractClientConnector.java Visa fil

@@ -243,7 +243,7 @@ public abstract class AbstractClientConnector implements ClientConnector,

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

/**
@@ -666,7 +666,8 @@ public abstract class AbstractClientConnector implements ClientConnector,
* @see #setResource(String, Resource)
*/
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 Visa fil

@@ -147,7 +147,7 @@ public class BrowserWindowOpener extends AbstractExtension {
* @return the window target string
*/
public String getWindowName() {
return getState().target;
return getState(false).target;
}

// Avoid breaking url to multiple lines
@@ -171,7 +171,7 @@ public class BrowserWindowOpener extends AbstractExtension {
* @return
*/
public String getFeatures() {
return getState().features;
return getState(false).features;
}

@Override
@@ -179,6 +179,11 @@ public class BrowserWindowOpener extends AbstractExtension {
return (BrowserWindowOpenerState) super.getState();
}

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

@Override
public void attach() {
super.attach();
@@ -226,7 +231,7 @@ public class BrowserWindowOpener extends AbstractExtension {
* @see #setUriFragment(String)
*/
public String getUriFragment() {
return getState().uriFragment;
return getState(false).uriFragment;
}

/**
@@ -301,7 +306,7 @@ public class BrowserWindowOpener extends AbstractExtension {
if (name == null) {
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 Visa fil

@@ -189,7 +189,7 @@ public abstract class AbstractColorPicker extends AbstractComponent implements
* currently selected color, e.g. #ffffff) if no other caption is available.
*/
public boolean isDefaultCaptionEnabled() {
return getState().showDefaultCaption;
return getState(false).showDefaultCaption;
}

/**
@@ -358,6 +358,11 @@ public abstract class AbstractColorPicker extends AbstractComponent implements
return (ColorPickerState) super.getState();
}

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

/**
* Sets the default styles of the component
*
@@ -462,6 +467,6 @@ public abstract class AbstractColorPicker extends AbstractComponent implements
* <code>false</code> otherwise
*/
public boolean isHtmlContentAllowed() {
return getState().htmlContentAllowed;
return getState(false).htmlContentAllowed;
}
}

+ 3
- 3
server/src/com/vaadin/ui/AbstractComponent.java Visa fil

@@ -151,8 +151,8 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public String getStyleName() {
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();) {
s += it.next();
if (it.hasNext()) {
@@ -191,7 +191,7 @@ public abstract class AbstractComponent extends AbstractClientConnector

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

@Override

+ 6
- 1
server/src/com/vaadin/ui/AbstractEmbedded.java Visa fil

@@ -34,6 +34,11 @@ public abstract class AbstractEmbedded extends AbstractComponent {
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.
* The type is guessed from resource.
@@ -73,7 +78,7 @@ public abstract class AbstractEmbedded extends AbstractComponent {
* @returns Alternate text
*/
public String getAlternateText() {
return getState().alternateText;
return getState(false).alternateText;
}

}

+ 10
- 5
server/src/com/vaadin/ui/AbstractMedia.java Visa fil

@@ -47,6 +47,11 @@ public abstract class AbstractMedia extends AbstractComponent {
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.
*
@@ -160,7 +165,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* @return true if the browser is to show native media controls.
*/
public boolean isShowControls() {
return getState().showControls;
return getState(false).showControls;
}

/**
@@ -183,7 +188,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* HTML5.
*/
public String getAltText() {
return getState().altText;
return getState(false).altText;
}

/**
@@ -201,7 +206,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* be rendered as HTML.
*/
public boolean isHtmlContentAllowed() {
return getState().htmlContentAllowed;
return getState(false).htmlContentAllowed;
}

/**
@@ -218,7 +223,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* @return true if the media is set to automatically start playback.
*/
public boolean isAutoplay() {
return getState().autoplay;
return getState(false).autoplay;
}

/**
@@ -234,7 +239,7 @@ public abstract class AbstractMedia extends AbstractComponent {
* @return true if the audio is muted.
*/
public boolean isMuted() {
return getState().muted;
return getState(false).muted;
}

/**

+ 8
- 3
server/src/com/vaadin/ui/AbstractOrderedLayout.java Visa fil

@@ -69,6 +69,11 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
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
* or under the previous component.
@@ -285,7 +290,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
*/
@Override
public boolean isSpacing() {
return getState().spacing;
return getState(false).spacing;
}

/**
@@ -335,7 +340,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
* @return expand ratio of given component, 0.0f by default.
*/
public float getExpandRatio(Component component) {
ChildComponentData childData = getState().childData.get(component);
ChildComponentData childData = getState(false).childData.get(component);
if (childData == null) {
throw new IllegalArgumentException(
"The given component is not a child of this layout");
@@ -413,7 +418,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
*/
@Override
public MarginInfo getMargin() {
return new MarginInfo(getState().marginsBitmask);
return new MarginInfo(getState(false).marginsBitmask);
}

/*

+ 8
- 3
server/src/com/vaadin/ui/AbstractSplitPanel.java Visa fil

@@ -186,7 +186,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return the first component of this split panel
*/
public Component getFirstComponent() {
return (Component) getState().firstChild;
return (Component) getState(false).firstChild;
}

/**
@@ -196,7 +196,7 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
* @return the second component of this split panel
*/
public Component getSecondComponent() {
return (Component) getState().secondChild;
return (Component) getState(false).secondChild;
}

/**
@@ -534,7 +534,12 @@ public abstract class AbstractSplitPanel extends AbstractComponentContainer {
return (AbstractSplitPanelState) super.getState();
}

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

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

+ 8
- 3
server/src/com/vaadin/ui/AbstractTextField.java Visa fil

@@ -95,6 +95,11 @@ public abstract class AbstractTextField extends AbstractField<String> implements
return (AbstractTextFieldState) super.getState();
}

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

@Override
public void beforeClientResponse(boolean initial) {
super.beforeClientResponse(initial);
@@ -311,7 +316,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the maxLength
*/
public int getMaxLength() {
return getState().maxLength;
return getState(false).maxLength;
}

/**
@@ -333,7 +338,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the number of columns in the editor.
*/
public int getColumns() {
return getState().columns;
return getState(false).columns;
}

/**
@@ -358,7 +363,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements
* @return the current input prompt, or null if not enabled
*/
public String getInputPrompt() {
return getState().inputPrompt;
return getState(false).inputPrompt;
}

/**

+ 9
- 4
server/src/com/vaadin/ui/Button.java Visa fil

@@ -556,7 +556,7 @@ public class Button extends AbstractComponent implements
* @return true if the button is disabled when clicked, false otherwise
*/
public boolean isDisableOnClick() {
return getState().disableOnClick;
return getState(false).disableOnClick;
}

/**
@@ -582,7 +582,7 @@ public class Button extends AbstractComponent implements
*/
@Override
public int getTabIndex() {
return getState().tabIndex;
return getState(false).tabIndex;
}

/*
@@ -606,6 +606,11 @@ public class Button extends AbstractComponent implements
return (ButtonState) super.getState();
}

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

/**
* Sets the component's icon and alt text.
*
@@ -628,7 +633,7 @@ public class Button extends AbstractComponent implements
* @return String with the alt text
*/
public String getIconAlternateText() {
return getState().iconAltText;
return getState(false).iconAltText;
}

public void setIconAlternateText(String iconAltText) {
@@ -658,7 +663,7 @@ public class Button extends AbstractComponent implements
* <code>false</code> otherwise
*/
public boolean isHtmlContentAllowed() {
return getState().htmlContentAllowed;
return getState(false).htmlContentAllowed;
}

}

+ 8
- 3
server/src/com/vaadin/ui/CustomLayout.java Visa fil

@@ -124,6 +124,11 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
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
* is already populated, the old component is removed.
@@ -251,12 +256,12 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {

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

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

/**
@@ -292,7 +297,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent {
public void paintContent(PaintTarget target) throws PaintException {
// Workaround to make the CommunicationManager read the template file
// and send it to the client
String templateName = getState().templateName;
String templateName = getState(false).templateName;
if (templateName != null && templateName.length() != 0) {
Set<Object> usedResources = ((JsonPaintTarget) target)
.getUsedResources();

+ 6
- 1
server/src/com/vaadin/ui/Flash.java Visa fil

@@ -67,6 +67,11 @@ public class Flash extends AbstractEmbedded {
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
* specified by the classid, data, and archive attributes. When absent, its
@@ -156,7 +161,7 @@ public class Flash extends AbstractEmbedded {
* @return the Value of parameter or null if not found.
*/
public String getParameter(String name) {
return getState().embedParams != null ? getState().embedParams
return getState(false).embedParams != null ? getState(false).embedParams
.get(name) : null;
}


+ 78
- 73
server/src/com/vaadin/ui/GridLayout.java Visa fil

@@ -39,12 +39,12 @@ import com.vaadin.shared.ui.gridlayout.GridLayoutState.ChildComponentData;

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

/**
* 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
* components outside its area.
*
*
* @param columns
* Number of columns in the grid.
* @param rows
@@ -121,9 +121,9 @@ public class GridLayout extends AbstractLayout implements
/**
* Constructs a GridLayout of given size (number of columns and rows) and
* adds the given components in order to the grid.
*
*
* @see #addComponents(Component...)
*
*
* @param columns
* Number of columns in the grid.
* @param rows
@@ -141,19 +141,24 @@ public class GridLayout extends AbstractLayout implements
return (GridLayoutState) super.getState();
}

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

/**
* <p>
* 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
* corner (column2, row2) of the area. The coordinates are zero-based.
* </p>
*
*
* <p>
* If the area overlaps with any of the existing components already present
* in the grid, the operation will fail and an {@link OverlapsException} is
* thrown.
* </p>
*
*
* @param component
* the component to be added, not <code>null</code>.
* @param column1
@@ -257,7 +262,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Tests if the given area overlaps with any of the items already on the
* grid.
*
*
* @param area
* the Area to be checked for overlapping.
* @throws OverlapsException
@@ -279,7 +284,7 @@ public class GridLayout extends AbstractLayout implements
* the area.) End coordinates (SouthEast corner of the area) are the same as
* column1,row1. The coordinates are zero-based. Component width and height
* is 1.
*
*
* @param component
* the component to be added, not <code>null</code>.
* @param column
@@ -299,16 +304,16 @@ public class GridLayout extends AbstractLayout implements

/**
* Forces the next component to be added at the beginning of the next line.
*
*
* <p>
* Sets the cursor column to 0 and increments the cursor row by one.
* </p>
*
*
* <p>
* By calling this function you can ensure that no more components are added
* right of the previous component.
* </p>
*
*
* @see #space()
*/
public void newLine() {
@@ -319,7 +324,7 @@ public class GridLayout extends AbstractLayout implements
/**
* 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.
*
*
* @see #newLine()
*/
public void space() {
@@ -335,7 +340,7 @@ public class GridLayout extends AbstractLayout implements
* 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
* grid is automatically extended.
*
*
* @param component
* the component to be added, not <code>null</code>.
*/
@@ -371,7 +376,7 @@ public class GridLayout extends AbstractLayout implements

/**
* Removes the specified component from the layout.
*
*
* @param component
* the component to be removed.
*/
@@ -391,7 +396,7 @@ public class GridLayout extends AbstractLayout implements

/**
* Removes the component specified by its cell coordinates.
*
*
* @param column
* the component's column, starting from 0.
* @param row
@@ -414,7 +419,7 @@ public class GridLayout extends AbstractLayout implements
/**
* 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.
*
*
* @return the Iterator of the components inside the layout.
*/
@Override
@@ -425,7 +430,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Gets the number of components contained in the layout. Consistent with
* the iterator returned by {@link #getComponentIterator()}.
*
*
* @return the number of contained components
*/
@Override
@@ -440,7 +445,7 @@ public class GridLayout extends AbstractLayout implements

/**
* Paints the contents of this component.
*
*
* @param target
* the Paint Event.
* @throws PaintException
@@ -519,7 +524,7 @@ public class GridLayout extends AbstractLayout implements
*/
@Override
public Alignment getComponentAlignment(Component childComponent) {
ChildComponentData childComponentData = getState().childData
ChildComponentData childComponentData = getState(false).childData
.get(childComponent);
if (childComponentData == null) {
throw new IllegalArgumentException(
@@ -531,17 +536,17 @@ public class GridLayout extends AbstractLayout implements

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

/**
* Tests if this Area overlaps with another Area.
*
*
* @param other
* the other Area that is to be tested for overlap with this
* area
@@ -600,7 +605,7 @@ public class GridLayout extends AbstractLayout implements

/**
* Gets the component connected to the area.
*
*
* @return the Component.
*/
public Component getComponent() {
@@ -609,7 +614,7 @@ public class GridLayout extends AbstractLayout implements

/**
* Gets the column of the top-left corner cell.
*
*
* @return the column of the top-left corner cell.
*/
public int getColumn1() {
@@ -618,7 +623,7 @@ public class GridLayout extends AbstractLayout implements

/**
* Gets the column of the bottom-right corner cell.
*
*
* @return the column of the bottom-right corner cell.
*/
public int getColumn2() {
@@ -627,7 +632,7 @@ public class GridLayout extends AbstractLayout implements

/**
* Gets the row of the top-left corner cell.
*
*
* @return the row of the top-left corner cell.
*/
public int getRow1() {
@@ -636,7 +641,7 @@ public class GridLayout extends AbstractLayout implements

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

/**
* Constructs an <code>OverlapsException</code>.
*
*
* @param existingArea
*/
public OverlapsException(Area existingArea) {
@@ -700,7 +705,7 @@ public class GridLayout extends AbstractLayout implements

/**
* Gets the area .
*
*
* @return the existing area.
*/
public Area getArea() {
@@ -711,7 +716,7 @@ public class GridLayout extends AbstractLayout implements
/**
* An <code>Exception</code> object which is thrown when an area exceeds the
* bounds of the grid.
*
*
* @author Vaadin Ltd.
* @since 3.0
*/
@@ -722,7 +727,7 @@ public class GridLayout extends AbstractLayout implements
/**
* Constructs an <code>OoutOfBoundsException</code> with the specified
* detail message.
*
*
* @param areaOutOfBounds
*/
public OutOfBoundsException(Area areaOutOfBounds) {
@@ -731,7 +736,7 @@ public class GridLayout extends AbstractLayout implements

/**
* Gets the area that is out of bounds.
*
*
* @return the area out of Bound.
*/
public Area getArea() {
@@ -742,7 +747,7 @@ public class GridLayout extends AbstractLayout implements
/**
* 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.
*
*
* @param columns
* the new number of columns in the grid.
*/
@@ -776,17 +781,17 @@ public class GridLayout extends AbstractLayout implements

/**
* Get the number of columns in the grid.
*
*
* @return the number of columns in the grid.
*/
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
* reduced if there are any areas that would be outside of the shrunk grid.
*
*
* @param rows
* the new number of rows in the grid.
*/
@@ -820,23 +825,23 @@ public class GridLayout extends AbstractLayout implements

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

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

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

/**
* Inserts an empty row at the specified position in the grid.
*
*
* @param row
* Index of the row before which the new row will be inserted.
* The leftmost row has index 0.
@@ -990,18 +995,18 @@ public class GridLayout extends AbstractLayout implements

/**
* Removes a row and all the components in the row.
*
*
* <p>
* Components which span over several rows are removed if the selected row
* is on the first row of such a component.
* </p>
*
*
* <p>
* 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
* upper left cell of the grid.
* </p>
*
*
* @param row
* Index of the row to remove. The leftmost row has index 0.
*/
@@ -1048,20 +1053,20 @@ public class GridLayout extends AbstractLayout implements

/**
* Sets the expand ratio of given column.
*
*
* <p>
* The expand ratio defines how excess space is distributed among columns.
* Excess space means space that is left over from components that are not
* sized relatively. By default, the excess space is distributed evenly.
* </p>
*
*
* <p>
* 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.
* </p>
*
*
* @see #setWidth(float, int)
*
*
* @param columnIndex
* @param ratio
*/
@@ -1073,9 +1078,9 @@ public class GridLayout extends AbstractLayout implements

/**
* Returns the expand ratio of given column
*
*
* @see #setColumnExpandRatio(int, float)
*
*
* @param columnIndex
* @return the expand ratio, 0.0f by default
*/
@@ -1086,20 +1091,20 @@ public class GridLayout extends AbstractLayout implements

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

/**
* Returns the expand ratio of given row.
*
*
* @see #setRowExpandRatio(int, float)
*
*
* @param rowIndex
* The row index, starting from 0 for the topmost row.
* @return the expand ratio, 0.0f by default
@@ -1126,7 +1131,7 @@ public class GridLayout extends AbstractLayout implements

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

/*

+ 9
- 5
server/src/com/vaadin/ui/Label.java Visa fil

@@ -155,6 +155,11 @@ public class Label extends AbstractComponent implements Property<String>,
return (LabelState) super.getState();
}

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

/**
* Gets the value of the label.
* <p>
@@ -168,7 +173,7 @@ public class Label extends AbstractComponent implements Property<String>,
public String getValue() {
if (getPropertyDataSource() == null) {
// Use internal value if we are running without a data source
return getState().text;
return getState(false).text;
}
return getDataSourceValue();
}
@@ -196,7 +201,7 @@ public class Label extends AbstractComponent implements Property<String>,
public void setValue(String newStringValue) {
if (getPropertyDataSource() == null) {

LabelState state = (LabelState) getState(false);
LabelState state = getState(false);
String oldTextValue = state.text;
if (!SharedUtil.equals(oldTextValue, newStringValue)) {
getState().text = newStringValue;
@@ -281,7 +286,7 @@ public class Label extends AbstractComponent implements Property<String>,
* @see ContentMode
*/
public ContentMode getContentMode() {
return getState().contentMode;
return getState(false).contentMode;
}

/**
@@ -412,8 +417,7 @@ public class Label extends AbstractComponent implements Property<String>,
private void updateValueFromDataSource() {
// Update the internal value from the data source
String newConvertedValue = getDataSourceValue();
if (!SharedUtil.equals(newConvertedValue,
((LabelState) getState(false)).text)) {
if (!SharedUtil.equals(newConvertedValue, getState(false).text)) {
getState().text = newConvertedValue;
fireValueChange();
}

+ 6
- 1
server/src/com/vaadin/ui/MenuBar.java Visa fil

@@ -57,6 +57,11 @@ public class MenuBar extends AbstractComponent implements LegacyComponent,
return (MenuBarState) super.getState();
}

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

/** Paint (serialise) the component for the client. */
@Override
public void paintContent(PaintTarget target) throws PaintException {
@@ -396,7 +401,7 @@ public class MenuBar extends AbstractComponent implements LegacyComponent,

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

/*

+ 8
- 3
server/src/com/vaadin/ui/Panel.java Visa fil

@@ -171,7 +171,7 @@ public class Panel extends AbstractSingleComponentContainer implements
*/
@Override
public int getScrollLeft() {
return getState().scrollLeft;
return getState(false).scrollLeft;
}

/*
@@ -181,7 +181,7 @@ public class Panel extends AbstractSingleComponentContainer implements
*/
@Override
public int getScrollTop() {
return getState().scrollTop;
return getState(false).scrollTop;
}

/*
@@ -309,7 +309,7 @@ public class Panel extends AbstractSingleComponentContainer implements
*/
@Override
public int getTabIndex() {
return getState().tabIndex;
return getState(false).tabIndex;
}

/**
@@ -334,4 +334,9 @@ public class Panel extends AbstractSingleComponentContainer implements
return (PanelState) super.getState();
}

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

}

+ 7
- 2
server/src/com/vaadin/ui/PopupDateField.java Visa fil

@@ -93,6 +93,11 @@ public class PopupDateField extends DateField {
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.
*
@@ -101,7 +106,7 @@ public class PopupDateField extends DateField {
* @return <b>true</b> if the text field is enabled, <b>false</b> otherwise.
*/
public boolean isTextFieldEnabled() {
return getState().textFieldEnabled;
return getState(false).textFieldEnabled;
}

/**
@@ -136,6 +141,6 @@ public class PopupDateField extends DateField {
* @return String with the description
*/
public String getAssistiveText() {
return getState().descriptionForAssistiveDevices;
return getState(false).descriptionForAssistiveDevices;
}
}

+ 6
- 1
server/src/com/vaadin/ui/PopupView.java Visa fil

@@ -185,7 +185,7 @@ public class PopupView extends AbstractComponent implements HasComponents {
* @return true if the popup is hidden on mouse out, false otherwise
*/
public boolean isHideOnMouseOut() {
return getState().hideOnMouseOut;
return getState(false).hideOnMouseOut;
}

/**
@@ -234,6 +234,11 @@ public class PopupView extends AbstractComponent implements HasComponents {
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
* dynamically loaded when they are redrawn. The user must take care that

+ 9
- 4
server/src/com/vaadin/ui/Slider.java Visa fil

@@ -144,13 +144,18 @@ public class Slider extends AbstractField<Double> {
return (SliderState) super.getState();
}

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

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

/**
@@ -173,7 +178,7 @@ public class Slider extends AbstractField<Double> {
* @return the smallest value the slider can have
*/
public double getMin() {
return getState().minValue;
return getState(false).minValue;
}

/**
@@ -197,7 +202,7 @@ public class Slider extends AbstractField<Double> {
* {@link SliderOrientation#VERTICAL}
*/
public SliderOrientation getOrientation() {
return getState().orientation;
return getState(false).orientation;
}

/**
@@ -219,7 +224,7 @@ public class Slider extends AbstractField<Double> {
* @return resolution
*/
public int getResolution() {
return getState().resolution;
return getState(false).resolution;
}

/**

+ 7
- 2
server/src/com/vaadin/ui/TextArea.java Visa fil

@@ -85,6 +85,11 @@ public class TextArea extends AbstractTextField {
return (TextAreaState) super.getState();
}

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

/**
* Sets the number of rows in the text area.
*
@@ -104,7 +109,7 @@ public class TextArea extends AbstractTextField {
* @return number of explicitly set rows.
*/
public int getRows() {
return getState().rows;
return getState(false).rows;
}

/**
@@ -125,7 +130,7 @@ public class TextArea extends AbstractTextField {
* <code>false</code> if not.
*/
public boolean isWordwrap() {
return getState().wordwrap;
return getState(false).wordwrap;
}

}

+ 1
- 1
server/src/com/vaadin/ui/UI.java Visa fil

@@ -1581,7 +1581,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements
* @return the label of the container
*/
public String getOverlayContainerLabel() {
return getState().overlayContainerLabel;
return getState(false).overlayContainerLabel;
}

/**

+ 13
- 13
server/src/com/vaadin/ui/Window.java Visa fil

@@ -36,9 +36,9 @@ import com.vaadin.server.PaintTarget;
import com.vaadin.shared.Connector;
import com.vaadin.shared.MouseEventDetails;
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.WindowState;
import com.vaadin.shared.ui.window.WindowRole;
import com.vaadin.util.ReflectTools;

/**
@@ -254,7 +254,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public int getPositionX() {
return getState().positionX;
return getState(false).positionX;
}

/**
@@ -283,7 +283,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @since 4.0.0
*/
public int getPositionY() {
return getState().positionY;
return getState(false).positionY;
}

/**
@@ -661,7 +661,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return true if this window is modal.
*/
public boolean isModal() {
return getState().modal;
return getState(false).modal;
}

/**
@@ -679,7 +679,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return true if window is resizable by the end-user, otherwise false.
*/
public boolean isResizable() {
return getState().resizable;
return getState(false).resizable;
}

/**
@@ -688,7 +688,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* sizes are recalculated immediately.
*/
public boolean isResizeLazy() {
return getState().resizeLazy;
return getState(false).resizeLazy;
}

/**
@@ -764,7 +764,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* true if the window can be dragged by the user
*/
public boolean isDraggable() {
return getState().draggable;
return getState(false).draggable;
}

/**
@@ -1068,7 +1068,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return The accessibility prefix
*/
public String getAssistivePrefix() {
return getState().assistivePrefix;
return getState(false).assistivePrefix;
}

/**
@@ -1093,7 +1093,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return The accessibility postfix
*/
public String getAssistivePostfix() {
return getState().assistivePostfix;
return getState(false).assistivePostfix;
}

/**
@@ -1124,7 +1124,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return WAI-ARIA role set for the window
*/
public WindowRole getAssistiveRole() {
return getState().role;
return getState(false).role;
}

/**
@@ -1152,7 +1152,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* focus can leave the window
*/
public boolean isTabStopEnabled() {
return getState().assistiveTabStop;
return getState(false).assistiveTabStop;
}

/**
@@ -1193,7 +1193,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return the top message
*/
public String getTabStopTopAssistiveText() {
return getState().assistiveTabStopTopText;
return getState(false).assistiveTabStopTopText;
}

/**
@@ -1204,6 +1204,6 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier,
* @return the bottom message
*/
public String getTabStopBottomAssistiveText() {
return getState().assistiveTabStopBottomText;
return getState(false).assistiveTabStopBottomText;
}
}

Laddar…
Avbryt
Spara