diff options
Diffstat (limited to 'server/src/com/vaadin/ui')
25 files changed, 270 insertions, 170 deletions
diff --git a/server/src/com/vaadin/ui/AbstractColorPicker.java b/server/src/com/vaadin/ui/AbstractColorPicker.java index db4239f8a6..acf3b2c042 100644 --- a/server/src/com/vaadin/ui/AbstractColorPicker.java +++ b/server/src/com/vaadin/ui/AbstractColorPicker.java @@ -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; } } diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index b6289e0b7d..9dbd9a093d 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -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 diff --git a/server/src/com/vaadin/ui/AbstractEmbedded.java b/server/src/com/vaadin/ui/AbstractEmbedded.java index 8c574fd59e..66752aa5d7 100644 --- a/server/src/com/vaadin/ui/AbstractEmbedded.java +++ b/server/src/com/vaadin/ui/AbstractEmbedded.java @@ -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; } } diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index a841aa672e..0bd8c3ea77 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -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. * @@ -141,7 +146,7 @@ public abstract class AbstractMedia extends AbstractComponent { */ public List<Resource> getSources() { ArrayList<Resource> sources = new ArrayList<Resource>(); - for (URLReference ref : getState().sources) { + for (URLReference ref : getState(false).sources) { sources.add(((ResourceReference) ref).getResource()); } return sources; @@ -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; } /** diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java index 039c87333e..27880db75f 100644 --- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java @@ -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); } /* diff --git a/server/src/com/vaadin/ui/AbstractSplitPanel.java b/server/src/com/vaadin/ui/AbstractSplitPanel.java index 3a1b7ca35a..1c69ebf87e 100644 --- a/server/src/com/vaadin/ui/AbstractSplitPanel.java +++ b/server/src/com/vaadin/ui/AbstractSplitPanel.java @@ -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; } } diff --git a/server/src/com/vaadin/ui/AbstractTextField.java b/server/src/com/vaadin/ui/AbstractTextField.java index 25b34ae19f..e0318ddf2b 100644 --- a/server/src/com/vaadin/ui/AbstractTextField.java +++ b/server/src/com/vaadin/ui/AbstractTextField.java @@ -96,6 +96,11 @@ public abstract class AbstractTextField extends AbstractField<String> implements } @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; } /** diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index 5a5d03a3ee..58b6f9de81 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -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; } } diff --git a/server/src/com/vaadin/ui/CustomLayout.java b/server/src/com/vaadin/ui/CustomLayout.java index fd56ed9219..7f1aa1ce46 100644 --- a/server/src/com/vaadin/ui/CustomLayout.java +++ b/server/src/com/vaadin/ui/CustomLayout.java @@ -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(); diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java index cb94a774a5..3d3356b338 100644 --- a/server/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java @@ -187,6 +187,10 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, private Set<String> sentIds = new HashSet<String>(); + private DragAndDropWrapper() { + super(); + } + /** * Wraps given component in a {@link DragAndDropWrapper}. * @@ -194,7 +198,8 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, * the component to be wrapped */ public DragAndDropWrapper(Component root) { - super(root); + this(); + setCompositionRoot(root); } /** diff --git a/server/src/com/vaadin/ui/Flash.java b/server/src/com/vaadin/ui/Flash.java index 791202f4a9..bbbd4e3285 100644 --- a/server/src/com/vaadin/ui/Flash.java +++ b/server/src/com/vaadin/ui/Flash.java @@ -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; } diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java index 5653a83cee..391ee45536 100644 --- a/server/src/com/vaadin/ui/Form.java +++ b/server/src/com/vaadin/ui/Form.java @@ -198,6 +198,11 @@ public class Form extends AbstractField<Object> implements Item.Editor, return (FormState) super.getState(); } + @Override + protected FormState getState(boolean markAsDirty) { + return (FormState) super.getState(markAsDirty); + } + /* Documented in interface */ @Override public void paintContent(PaintTarget target) throws PaintException { @@ -775,7 +780,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * @return the Layout of the form. */ public Layout getLayout() { - return (Layout) getState().layout; + return (Layout) getState(false).layout; } /** @@ -1054,8 +1059,9 @@ public class Form extends AbstractField<Object> implements Item.Editor, * @return the Field. */ private Field<?> getFirstFocusableField() { - if (getItemPropertyIds() != null) { - for (Object id : getItemPropertyIds()) { + Collection<?> itemPropertyIds = getItemPropertyIds(); + if (itemPropertyIds != null && itemPropertyIds.size() > 0) { + for (Object id : itemPropertyIds) { if (id != null) { Field<?> field = getField(id); if (field.isEnabled() && !field.isReadOnly()) { @@ -1065,7 +1071,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, } // fallback: first field if none of the fields is enabled and // writable - Object id = getItemPropertyIds().iterator().next(); + Object id = itemPropertyIds.iterator().next(); if (id != null) { return getField(id); } @@ -1214,7 +1220,7 @@ public class Form extends AbstractField<Object> implements Item.Editor, * is used */ public Layout getFooter() { - return (Layout) getState().footer; + return (Layout) getState(false).footer; } /** diff --git a/server/src/com/vaadin/ui/GridLayout.java b/server/src/com/vaadin/ui/GridLayout.java index 989f5efdea..0c097abc83 100644 --- a/server/src/com/vaadin/ui/GridLayout.java +++ b/server/src/com/vaadin/ui/GridLayout.java @@ -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); } /* diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index b4685adcea..c73840e6e9 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -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(); } diff --git a/server/src/com/vaadin/ui/MenuBar.java b/server/src/com/vaadin/ui/MenuBar.java index 17a2f8e391..6b6555c0a2 100644 --- a/server/src/com/vaadin/ui/MenuBar.java +++ b/server/src/com/vaadin/ui/MenuBar.java @@ -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; } /* diff --git a/server/src/com/vaadin/ui/Panel.java b/server/src/com/vaadin/ui/Panel.java index 34ff6ec112..9b1d8fd5fa 100644 --- a/server/src/com/vaadin/ui/Panel.java +++ b/server/src/com/vaadin/ui/Panel.java @@ -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); + } + } diff --git a/server/src/com/vaadin/ui/PopupDateField.java b/server/src/com/vaadin/ui/PopupDateField.java index 61aac16a97..f07ac84160 100644 --- a/server/src/com/vaadin/ui/PopupDateField.java +++ b/server/src/com/vaadin/ui/PopupDateField.java @@ -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; } } diff --git a/server/src/com/vaadin/ui/PopupView.java b/server/src/com/vaadin/ui/PopupView.java index b347576b22..90c60edc6e 100644 --- a/server/src/com/vaadin/ui/PopupView.java +++ b/server/src/com/vaadin/ui/PopupView.java @@ -61,6 +61,11 @@ public class PopupView extends AbstractComponent implements HasComponents { /* Constructors */ + private PopupView() { + registerRpc(rpc); + setHideOnMouseOut(true); + } + /** * A simple way to create a PopupPanel. Note that the minimal representation * may not be dynamically updated, in order to achieve this create your own @@ -94,9 +99,7 @@ public class PopupView extends AbstractComponent implements HasComponents { * the PopupView.Content that contains the information for this */ public PopupView(PopupView.Content content) { - super(); - registerRpc(rpc); - setHideOnMouseOut(true); + this(); setContent(content); } @@ -185,7 +188,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 +237,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 diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index e108c74ba2..ff6c955e47 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -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; } /** diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java index 56c97f58eb..e38be8ad3c 100644 --- a/server/src/com/vaadin/ui/TextArea.java +++ b/server/src/com/vaadin/ui/TextArea.java @@ -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; } } diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 562b30f81d..a72cbe5c30 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -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; } /** diff --git a/server/src/com/vaadin/ui/Window.java b/server/src/com/vaadin/ui/Window.java index 149fcd536f..35583c6052 100644 --- a/server/src/com/vaadin/ui/Window.java +++ b/server/src/com/vaadin/ui/Window.java @@ -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; } /** @@ -1034,7 +1034,7 @@ public class Window extends Panel implements FocusNotifier, BlurNotifier, * @return array of previously set components */ public Component[] getAssistiveDescription() { - Connector[] contentDescription = getState().contentDescription; + Connector[] contentDescription = getState(false).contentDescription; if (contentDescription == null) { return null; } @@ -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; } } diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java index 6147fcdd96..81b178e4f0 100644 --- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java +++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java @@ -56,7 +56,7 @@ public class ColorPickerGradient extends AbstractComponent implements }; /** The converter. */ - private final Coordinates2Color converter; + private Coordinates2Color converter; /** The foreground color. */ private Color color; @@ -67,6 +67,14 @@ public class ColorPickerGradient extends AbstractComponent implements /** The y-coordinate. */ private int y = 0; + private ColorPickerGradient() { + registerRpc(rpc); + // width and height must be set here instead of in theme, otherwise + // coordinate calculations fail + getState().width = "220px"; + getState().height = "220px"; + } + /** * Instantiates a new color picker gradient. * @@ -76,12 +84,8 @@ public class ColorPickerGradient extends AbstractComponent implements * the converter */ public ColorPickerGradient(String id, Coordinates2Color converter) { - registerRpc(rpc); + this(); addStyleName(id); - // width and height must be set here instead of in theme, otherwise - // coordinate calculations fail - getState().width = "220px"; - getState().height = "220px"; this.converter = converter; } diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java index e7b412f7eb..b9a8c001ce 100644 --- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java +++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java @@ -143,14 +143,7 @@ public class ColorPickerPopup extends Window implements ClickListener, */ private boolean updatingColors = false; - /** - * Instantiates a new color picker popup. - */ - public ColorPickerPopup(Color initialColor) { - super(); - - selectedColor = initialColor; - + private ColorPickerPopup() { // Set the layout layout = new VerticalLayout(); layout.setSpacing(false); @@ -162,15 +155,21 @@ public class ColorPickerPopup extends Window implements ClickListener, setStyleName(STYLENAME); setResizable(false); setImmediate(true); + // Create the history + history = new ColorPickerHistory(); + history.addColorChangeListener(this); + } + /** + * Instantiates a new color picker popup. + */ + public ColorPickerPopup(Color initialColor) { + this(); + selectedColor = initialColor; initContents(); } private void initContents() { - // Create the history - history = new ColorPickerHistory(); - history.addColorChangeListener(this); - // Create the preview on the rgb tab rgbPreview = new ColorPickerPreview(selectedColor); rgbPreview.setWidth("240px"); diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java index ae00b267ce..21a3630de2 100644 --- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java +++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java @@ -56,24 +56,23 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector, /** The old value. */ private String oldValue; - /** - * Instantiates a new color picker preview. - */ - public ColorPickerPreview(Color color) { + private ColorPickerPreview() { setStyleName("v-colorpicker-preview"); setImmediate(true); - - this.color = color; - field = new TextField(); field.setImmediate(true); field.setSizeFull(); field.setStyleName("v-colorpicker-preview-textfield"); field.setData(this); field.addValueChangeListener(this); - addComponent(field); + } + /** + * Instantiates a new color picker preview. + */ + public ColorPickerPreview(Color color) { + this(); setColor(color); } |