summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@itmill.com>2011-06-30 09:02:13 +0000
committerHenri Sara <henri.sara@itmill.com>2011-06-30 09:02:13 +0000
commitf34bba50065ffc65649a2e781c61aca79a9cabbf (patch)
tree64d24bbb9f1ee3a14b3d9111305661cd5a86eece /src
parent0499cf2f2b1daeb97f20e8aa7669d5edf2bd3789 (diff)
parentaca5cf66b46010ad4a1eb1e99be37f5708879006 (diff)
downloadvaadin-framework-f34bba50065ffc65649a2e781c61aca79a9cabbf.tar.gz
vaadin-framework-f34bba50065ffc65649a2e781c61aca79a9cabbf.zip
Merge changes from 6.6
svn changeset:19583/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/data/validator/AbstractValidator.java7
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java60
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTextArea.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VUpload.java6
-rw-r--r--src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java2
-rw-r--r--src/com/vaadin/ui/AbstractTextField.java48
6 files changed, 77 insertions, 52 deletions
diff --git a/src/com/vaadin/data/validator/AbstractValidator.java b/src/com/vaadin/data/validator/AbstractValidator.java
index 6ea2cae880..7d4f1c3a0d 100644
--- a/src/com/vaadin/data/validator/AbstractValidator.java
+++ b/src/com/vaadin/data/validator/AbstractValidator.java
@@ -43,12 +43,7 @@ public abstract class AbstractValidator implements Validator {
public void validate(Object value) throws InvalidValueException {
if (!isValid(value)) {
- String message;
- if (value == null) {
- message = errorMessage.replace("{0}", "null");
- } else {
- message = errorMessage.replace("{0}", value.toString());
- }
+ String message = errorMessage.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 cdf130d792..63e6cc8415 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VScrollTable.java
@@ -4766,54 +4766,40 @@ public class VScrollTable extends FlowPanel implements Table, ScrollHandler,
* target is this element or a child of it)
*/
private Element getEventTargetTdOrTr(Event event) {
- Element targetTdOrTr = null;
-
- final Element eventTarget = DOM.eventGetTarget(event);
- final Element eventTargetParent = DOM.getParent(eventTarget);
- final Element eventTargetGrandParent = DOM
- .getParent(eventTargetParent);
-
+ final Element eventTarget = event.getEventTarget().cast();
+ Widget widget = Util.findWidget(eventTarget, null);
final Element thisTrElement = getElement();
- if (eventTarget == thisTrElement) {
- // This was a click on the TR element
- targetTdOrTr = eventTarget;
- // rowTarget = true;
- } else if (thisTrElement == eventTargetParent) {
- // Target parent is the TR, so the actual target is the TD
- targetTdOrTr = eventTarget;
- } else if (thisTrElement == eventTargetGrandParent) {
- // Target grand parent is the TR, so the parent is the TD
- targetTdOrTr = eventTargetParent;
- } else {
+ if (widget != this) {
/*
* This is a workaround to make Labels, read only TextFields
* and Embedded in a Table clickable (see #2688). It is
* really not a fix as it does not work with a custom read
* only components (not extending VLabel/VEmbedded).
*/
- Widget widget = Util.findWidget(eventTarget, null);
- if (widget != this) {
- while (widget != null && widget.getParent() != this) {
- widget = widget.getParent();
- }
- if (widget != null) {
- // widget is now the closest widget to this row
- if (widget instanceof VLabel
- || widget instanceof VEmbedded
- || (widget instanceof VTextField && ((VTextField) widget)
- .isReadOnly())) {
- Element tdElement = eventTargetParent;
- while (DOM.getParent(tdElement) != thisTrElement) {
- tdElement = DOM.getParent(tdElement);
- }
- targetTdOrTr = tdElement;
- }
- }
+ while (widget != null && widget.getParent() != this) {
+ widget = widget.getParent();
+ }
+
+ if (!(widget instanceof VLabel)
+ && !(widget instanceof VEmbedded)
+ && !(widget instanceof VTextField && ((VTextField) widget)
+ .isReadOnly())) {
+ return null;
}
}
+ if (eventTarget == thisTrElement) {
+ // This was a click on the TR element
+ return thisTrElement;
+ }
- return targetTdOrTr;
+ // Iterate upwards until we find the TR element
+ Element element = eventTarget;
+ while (element != null
+ && element.getParentElement().cast() != thisTrElement) {
+ element = element.getParentElement().cast();
+ }
+ return element;
}
public void showContextMenu(Event event) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java
index 3e4724102d..842be7ce05 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextArea.java
@@ -1,4 +1,4 @@
-/*
+/*
@ITMillApache2LicenseForJavaFiles@
*/
@@ -39,7 +39,7 @@ public class VTextArea extends VTextField {
}
if (getMaxLength() >= 0) {
- sinkEvents(Event.ONKEYPRESS);
+ sinkEvents(Event.ONKEYUP);
}
}
@@ -57,7 +57,7 @@ public class VTextArea extends VTextField {
@Override
public void onBrowserEvent(Event event) {
- if (getMaxLength() >= 0 && event.getTypeInt() == Event.ONKEYPRESS) {
+ if (getMaxLength() >= 0 && event.getTypeInt() == Event.ONKEYUP) {
Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
if (getText().length() > getMaxLength()) {
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VUpload.java b/src/com/vaadin/terminal/gwt/client/ui/VUpload.java
index 206b89eb82..a49450e086 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VUpload.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VUpload.java
@@ -1,4 +1,4 @@
-/*
+/*
@ITMillApache2LicenseForJavaFiles@
*/
@@ -22,6 +22,7 @@ import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
+import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.VConsole;
@@ -44,7 +45,8 @@ public class VUpload extends SimplePanel implements Paintable {
&& !"".equals(fu.getFilename())) {
submit();
}
- } else if (event.getTypeInt() == Event.ONFOCUS) {
+ } else if (BrowserInfo.get().isIE()
+ && event.getTypeInt() == Event.ONFOCUS) {
// IE and user has clicked on hidden textarea part of upload
// field. Manually open file selector, other browsers do it by
// default.
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
index e3dd014dec..3a8ff9096f 100644
--- a/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
+++ b/src/com/vaadin/terminal/gwt/server/AbstractCommunicationManager.java
@@ -2192,7 +2192,7 @@ public abstract class AbstractCommunicationManager implements
public SimpleMultiPartInputStream(InputStream realInputStream,
String boundaryString) {
- boundary = (CRLF + DASHDASH + boundaryString + DASHDASH)
+ boundary = (CRLF + DASHDASH + boundaryString)
.toCharArray();
this.realInputStream = realInputStream;
}
diff --git a/src/com/vaadin/ui/AbstractTextField.java b/src/com/vaadin/ui/AbstractTextField.java
index 4ed76d367b..622b8d18d9 100644
--- a/src/com/vaadin/ui/AbstractTextField.java
+++ b/src/com/vaadin/ui/AbstractTextField.java
@@ -1,4 +1,4 @@
-/*
+/*
@ITMillApache2LicenseForJavaFiles@
*/
@@ -123,7 +123,20 @@ public abstract class AbstractTextField extends AbstractField implements
throw new IllegalStateException(
"Null values are not allowed if the null-representation is null");
}
- target.addVariable(this, "text", value);
+
+ if (requestRepaintInTextChangeEvent && !valueChangeInTextChangeEvent) {
+ /*
+ * If the repaint occurred in a text change event then we do not
+ * want to send back the old value since it will just overwrite the
+ * typed value so we send the last known value instead which is
+ * updated by the text change event.
+ */
+ target.addVariable(this, "text", lastKnownTextContent);
+ } else {
+ target.addVariable(this, "text", value);
+ }
+ requestRepaintInTextChangeEvent = false;
+ valueChangeInTextChangeEvent = false;
if (selectionPosition != -1) {
target.addAttribute("selpos", selectionPosition);
@@ -171,6 +184,22 @@ public abstract class AbstractTextField extends AbstractField implements
}
}
+ /**
+ * Flag for monitoring if a repaint gets requested in a text change event
+ */
+ private boolean requestRepaintInTextChangeEvent = false;
+
+ @Override
+ public void requestRepaint() {
+ if (textChangeEventPending) {
+ /*
+ * Textchange event listener triggered this repaint
+ */
+ requestRepaintInTextChangeEvent = true;
+ }
+ super.requestRepaint();
+ }
+
@Override
public void changeVariables(Object source, Map<String, Object> variables) {
changingVariables = true;
@@ -438,13 +467,26 @@ public abstract class AbstractTextField extends AbstractField implements
private void firePendingTextChangeEvent() {
if (textChangeEventPending) {
- textChangeEventPending = false;
fireEvent(new TextChangeEventImpl(this));
+ textChangeEventPending = false;
}
}
+ /**
+ * Flag for monitoring if the value got changed in a TextChangeEvent
+ * listener
+ */
+ protected boolean valueChangeInTextChangeEvent = false;
+
@Override
protected void setInternalValue(Object newValue) {
+ if (textChangeEventPending) {
+ /*
+ * Value changed in a TextChangeEvent listener
+ */
+ valueChangeInTextChangeEvent = true;
+ }
+
if (changingVariables && !textChangeEventPending) {
/*
* Fire a "simulated" text change event before value change event if