diff options
author | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2011-12-30 12:51:56 +0000 |
---|---|---|
committer | Johannes Dahlström <johannes.dahlstrom@vaadin.com> | 2011-12-30 12:51:56 +0000 |
commit | dd786ffd3554828e91d4398bc9a3ce6e498f74b2 (patch) | |
tree | b95585606d711c925477cdaea23b4e31fcf68c97 /src | |
parent | 02daee926e0bb40bcd8a321a2a27570da5c9c928 (diff) | |
download | vaadin-framework-dd786ffd3554828e91d4398bc9a3ce6e498f74b2.tar.gz vaadin-framework-dd786ffd3554828e91d4398bc9a3ce6e498f74b2.zip |
Merged changes from 6.7
svn changeset:22500/svn branch:6.8
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/data/validator/AbstractValidator.java | 2 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java | 13 | ||||
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VTextField.java | 25 | ||||
-rw-r--r-- | src/com/vaadin/ui/Window.java | 24 |
4 files changed, 53 insertions, 11 deletions
diff --git a/src/com/vaadin/data/validator/AbstractValidator.java b/src/com/vaadin/data/validator/AbstractValidator.java index e0c63b1565..5c8dd9b31a 100644 --- a/src/com/vaadin/data/validator/AbstractValidator.java +++ b/src/com/vaadin/data/validator/AbstractValidator.java @@ -49,7 +49,7 @@ public abstract class AbstractValidator implements Validator { public void validate(Object value) throws InvalidValueException { if (!isValid(value)) { - String message = errorMessage.replace("{0}", String.valueOf(value)); + String message = getErrorMessage().replace("{0}", String.valueOf(value)); throw new InvalidValueException(message); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java index 3120aa3cdb..f1c1927b26 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java @@ -3936,7 +3936,6 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, Element table = DOM.createTable(); private int firstRendered; - private int lastRendered; private char[] aligns; @@ -4045,6 +4044,11 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, ensureCacheFilled(); } + /** + * Ensure we have the correct set of rows on client side, e.g. if the + * content on the server side has changed, or the client scroll position + * has changed since the last request. + */ protected void ensureCacheFilled() { int reactFirstRow = (int) (firstRowInViewPort - pageLength * cache_react_rate); @@ -4074,7 +4078,7 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, rowRequestHandler.setReqFirstRow(lastRendered + 1); rowRequestHandler.setReqRows(reactLastRow - lastRendered); rowRequestHandler.deferRowFetch(1); - } else if (scrollBody.getFirstRendered() > reactFirstRow) { + } else if (firstRendered > reactFirstRow) { /* * Branch for fetching cache above visible area. * @@ -6116,17 +6120,18 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler, final int firstRendered = scrollBody.getFirstRendered(); if (postLimit <= lastRendered && preLimit >= firstRendered) { + // we're within no-react area, no need to request more rows // remember which firstvisible we requested, in case the server has // a differing opinion lastRequestedFirstvisible = firstRowInViewPort; client.updateVariable(paintableId, "firstvisible", firstRowInViewPort, false); - return; // scrolled withing "non-react area" + return; } if (firstRowInViewPort - pageLength * cache_rate > lastRendered || firstRowInViewPort + pageLength + pageLength * cache_rate < firstRendered) { - // need a totally new set + // need a totally new set of rows rowRequestHandler .setReqFirstRow((firstRowInViewPort - (int) (pageLength * cache_rate))); int last = firstRowInViewPort + (int) (cache_rate * pageLength) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java index f059e0cea5..44ee7c11df 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java @@ -58,6 +58,13 @@ public class VTextField extends TextBoxBase implements Paintable, Field, private String valueBeforeEdit = null; + /** + * Set to false if a text change event has been sent since the last value + * change event. This means that {@link #valueBeforeEdit} should not be + * trusted when determining whether a text change even should be sent. + */ + private boolean valueBeforeEditIsSynced = true; + private boolean immediate = false; private int extraHorizontalPixels = -1; private int extraVerticalPixels = -1; @@ -145,18 +152,22 @@ public class VTextField extends TextBoxBase implements Paintable, Field, text = ""; } if (!text.equals(getLastCommunicatedString())) { - if (text.equals(valueBeforeEdit)) { + if (valueBeforeEditIsSynced && text.equals(valueBeforeEdit)) { /* - * Value change for the current text has been enqueued, but we - * can't know that it has been sent to the server. Ensure that - * all pending changes are sent now. Sending a value change - * without a text change will simulate a TextChangeEvent on the - * server. + * Value change for the current text has been enqueued since the + * last text change event was sent, but we can't know that it + * has been sent to the server. Ensure that all pending changes + * are sent now. Sending a value change without a text change + * will simulate a TextChangeEvent on the server. */ client.sendPendingVariableChanges(); } else { // Default case - just send an immediate text change message client.updateVariable(id, VAR_CUR_TEXT, text, true); + + // Shouldn't investigate valueBeforeEdit to avoid duplicate text + // change events as the states are not in sync any more + valueBeforeEditIsSynced = false; } lastTextChangeString = text; } @@ -334,6 +345,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field, } lastTextChangeString = valueBeforeEdit = text; + valueBeforeEditIsSynced = true; } protected void onCut() { @@ -423,6 +435,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field, sendValueChange = immediate; client.updateVariable(id, "text", getText(), false); valueBeforeEdit = newText; + valueBeforeEditIsSynced = true; } /* diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index 1e0172d60f..5f6c29f182 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -2356,4 +2356,28 @@ public class Window extends Panel implements URIHandler, ParameterHandler, } } + /** + * Notifies the child components and subwindows that the window is attached + * to the application. + */ + @Override + public void attach() { + super.attach(); + for (Window w : subwindows) { + w.attach(); + } + } + + /** + * Notifies the child components and subwindows that the window is detached + * from the application. + */ + @Override + public void detach() { + super.detach(); + for (Window w : subwindows) { + w.detach(); + } + } + } |