summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml4
-rw-r--r--src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java9
-rw-r--r--src/com/vaadin/terminal/gwt/client/Console.java4
-rw-r--r--src/com/vaadin/terminal/gwt/client/NullConsole.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTextField.java36
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VWindow.java4
-rw-r--r--src/com/vaadin/terminal/gwt/server/WebBrowser.java41
-rw-r--r--src/com/vaadin/ui/AbstractTextField.java16
-rw-r--r--tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.html31
-rw-r--r--tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.java45
-rw-r--r--tests/testbench/com/vaadin/tests/application/WebBrowserTest.html30
-rw-r--r--tests/testbench/com/vaadin/tests/application/WebBrowserTest.java2
12 files changed, 176 insertions, 52 deletions
diff --git a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml
index a3245830f9..9bc05dee2e 100644
--- a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml
+++ b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml
@@ -17,6 +17,10 @@
<replace-with class="com.vaadin.terminal.gwt.client.VSchedulerImpl">
<when-type-is class="com.google.gwt.core.client.impl.SchedulerImpl" />
</replace-with>
+
+ <replace-with class="com.vaadin.terminal.gwt.client.VDebugConsole">
+ <when-type-is class="com.vaadin.terminal.gwt.client.Console" />
+ </replace-with>
<generate-with
class="com.vaadin.terminal.gwt.widgetsetutils.WidgetMapGenerator">
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
index 51a620cf27..f4f3643169 100644
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
@@ -530,7 +530,7 @@ public class ApplicationConfiguration implements EntryPoint {
// Prepare VConsole for debugging
if (isDebugMode()) {
- VDebugConsole console = GWT.create(VDebugConsole.class);
+ Console console = GWT.create(Console.class);
console.setQuietMode(isQuietDebugMode());
console.init();
VConsole.setImplementation(console);
@@ -588,7 +588,12 @@ public class ApplicationConfiguration implements EntryPoint {
}
}-*/;
- private native static boolean isQuietDebugMode()
+ /**
+ * Checks whether debug logging should be quiet
+ *
+ * @return <code>true</code> if debug logging should be quiet
+ */
+ public native static boolean isQuietDebugMode()
/*-{
var uri = $wnd.location;
var re = /debug=q[^\/]*$/;
diff --git a/src/com/vaadin/terminal/gwt/client/Console.java b/src/com/vaadin/terminal/gwt/client/Console.java
index ebf4b07e5d..483ab8e0fd 100644
--- a/src/com/vaadin/terminal/gwt/client/Console.java
+++ b/src/com/vaadin/terminal/gwt/client/Console.java
@@ -25,4 +25,8 @@ public interface Console {
Set<Paintable> zeroHeightComponents,
Set<Paintable> zeroWidthComponents);
+ public abstract void setQuietMode(boolean quietDebugMode);
+
+ public abstract void init();
+
} \ No newline at end of file
diff --git a/src/com/vaadin/terminal/gwt/client/NullConsole.java b/src/com/vaadin/terminal/gwt/client/NullConsole.java
index 8f907e5aef..12df4b323b 100644
--- a/src/com/vaadin/terminal/gwt/client/NullConsole.java
+++ b/src/com/vaadin/terminal/gwt/client/NullConsole.java
@@ -44,4 +44,10 @@ public class NullConsole implements Console {
GWT.log(e.getMessage(), e);
}
+ public void setQuietMode(boolean quietDebugMode) {
+ }
+
+ public void init() {
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java
index b4a73bbada..9861222355 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java
@@ -138,18 +138,28 @@ public class VTextField extends TextBoxBase implements Paintable, Field,
return lastTextChangeString;
}
- private boolean communicateTextValueToServer() {
+ private void communicateTextValueToServer() {
String text = getText();
if (prompting) {
// Input prompt visible, text is actually ""
text = "";
}
if (!text.equals(getLastCommunicatedString())) {
+ if (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.
+ */
+ client.sendPendingVariableChanges();
+ } else {
+ // Default case - just send an immediate text change message
+ client.updateVariable(id, VAR_CUR_TEXT, text, true);
+ }
lastTextChangeString = text;
- client.updateVariable(id, VAR_CUR_TEXT, text, true);
- return true;
}
- return false;
}
private Timer textChangeEventTrigger = new Timer() {
@@ -158,10 +168,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field,
public void run() {
if (isAttached()) {
updateCursorPosition();
- boolean textChanged = communicateTextValueToServer();
- if (textChanged) {
- client.sendPendingVariableChanges();
- }
+ communicateTextValueToServer();
scheduled = false;
}
}
@@ -554,20 +561,7 @@ public class VTextField extends TextBoxBase implements Paintable, Field,
}
public void onBeforeShortcutAction(Event e) {
- // Remember current value to detect changes
- String oldValue = valueBeforeEdit;
-
valueChange(false);
-
- /*
- * The valueChange method updates valueBeforeEdit when a "text" variable
- * is sent. This will cause a text change event to be simulated on the
- * server. In that case, we should avoid sending the same text as a
- * normal text change event. (#8035)
- */
- if (oldValue != valueBeforeEdit) {
- lastTextChangeString = valueBeforeEdit;
- }
}
// Here for backward compatibility; to be moved to TextArea
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
index 9645aebb2e..6ac594bc96 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java
@@ -33,6 +33,7 @@ import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
+import com.vaadin.terminal.gwt.client.Console;
import com.vaadin.terminal.gwt.client.Container;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.Focusable;
@@ -40,7 +41,6 @@ import com.vaadin.terminal.gwt.client.Paintable;
import com.vaadin.terminal.gwt.client.RenderSpace;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
-import com.vaadin.terminal.gwt.client.VDebugConsole;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner;
@@ -1134,7 +1134,7 @@ public class VWindow extends VOverlay implements Container,
// debug window
Widget w = Util.findWidget(target, null);
while (w != null) {
- if (w instanceof VDebugConsole) {
+ if (w instanceof Console) {
return true; // allow debug-window clicks
} else if (w instanceof Paintable) {
return false;
diff --git a/src/com/vaadin/terminal/gwt/server/WebBrowser.java b/src/com/vaadin/terminal/gwt/server/WebBrowser.java
index 8257bfae87..0a743fcf96 100644
--- a/src/com/vaadin/terminal/gwt/server/WebBrowser.java
+++ b/src/com/vaadin/terminal/gwt/server/WebBrowser.java
@@ -23,6 +23,8 @@ public class WebBrowser implements Terminal {
private int screenHeight = 0;
private int screenWidth = 0;
+ private int clientHeight = 0;
+ private int clientWidth = 0;
private String browserApplication = null;
private Locale locale;
private String address;
@@ -64,6 +66,24 @@ public class WebBrowser implements Terminal {
}
/**
+ * Gets the height of the client (browser window)
+ *
+ * @return The height of the client or 0 if unknown.
+ */
+ public int getClientHeight() {
+ return clientHeight;
+ }
+
+ /**
+ * Gets the width of the client (browser window)
+ *
+ * @return The width of the client or 0 if unknown.
+ */
+ public int getClientWidth() {
+ return clientWidth;
+ }
+
+ /**
* Get the browser user-agent string.
*
* @return The raw browser userAgent string
@@ -313,6 +333,10 @@ public class WebBrowser implements Terminal {
* Screen width
* @param sh
* Screen height
+ * @param cw
+ * Client width
+ * @param ch
+ * Client height
* @param tzo
* TimeZone offset in minutes from GMT
* @param rtzo
@@ -325,9 +349,9 @@ public class WebBrowser implements Terminal {
* the current date in milliseconds since the epoch
* @param touchDevice
*/
- private void updateClientSideDetails(String sw, String sh, String tzo,
- String rtzo, String dstSavings, String dstInEffect, String curDate,
- boolean touchDevice) {
+ void updateClientSideDetails(String sw, String sh, String cw, String ch,
+ String tzo, String rtzo, String dstSavings, String dstInEffect,
+ String curDate, boolean touchDevice) {
if (sw != null) {
try {
screenHeight = Integer.parseInt(sh);
@@ -336,6 +360,14 @@ public class WebBrowser implements Terminal {
screenHeight = screenWidth = 0;
}
}
+ if (cw != null) {
+ try {
+ clientHeight = Integer.parseInt(ch);
+ clientWidth = Integer.parseInt(cw);
+ } catch (final NumberFormatException e) {
+ clientHeight = clientWidth = 0;
+ }
+ }
if (tzo != null) {
try {
// browser->java conversion: min->ms, reverse sign
@@ -396,7 +428,8 @@ public class WebBrowser implements Terminal {
if (request.getParameter("sw") != null) {
updateClientSideDetails(request.getParameter("sw"),
- request.getParameter("sh"), request.getParameter("tzo"),
+ request.getParameter("sh"), request.getParameter("cw"),
+ request.getParameter("ch"), request.getParameter("tzo"),
request.getParameter("rtzo"), request.getParameter("dstd"),
request.getParameter("dston"),
request.getParameter("curdate"),
diff --git a/src/com/vaadin/ui/AbstractTextField.java b/src/com/vaadin/ui/AbstractTextField.java
index e843cf43b4..a958b61c2f 100644
--- a/src/com/vaadin/ui/AbstractTextField.java
+++ b/src/com/vaadin/ui/AbstractTextField.java
@@ -70,6 +70,8 @@ public abstract class AbstractTextField extends AbstractField<String> implements
*/
private boolean textChangeEventPending;
+ private boolean isFiringTextChangeEvent = false;
+
private TextChangeEventMode textChangeEventMode = TextChangeEventMode.LAZY;
private final int DEFAULT_TEXTCHANGE_TIMEOUT = 400;
@@ -449,9 +451,14 @@ public abstract class AbstractTextField extends AbstractField<String> implements
/* ** Text Change Events ** */
private void firePendingTextChangeEvent() {
- if (textChangeEventPending) {
+ if (textChangeEventPending && !isFiringTextChangeEvent) {
+ isFiringTextChangeEvent = true;
textChangeEventPending = false;
- fireEvent(new TextChangeEventImpl(this));
+ try {
+ fireEvent(new TextChangeEventImpl(this));
+ } finally {
+ isFiringTextChangeEvent = false;
+ }
}
}
@@ -494,11 +501,6 @@ public abstract class AbstractTextField extends AbstractField<String> implements
firePendingTextChangeEvent();
}
- /*
- * Reset lastKnownTextContent field on value change. We know the value
- * now.
- */
- lastKnownTextContent = null;
super.setInternalValue(newValue);
}
diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.html b/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.html
new file mode 100644
index 0000000000..3c59c7a953
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.html
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.application.WebBrowserSizeTest?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserSizeTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>screenCapture</td>
+ <td></td>
+ <td>size</td>
+</tr>
+</tbody></table>
+</body>
+</html> \ No newline at end of file
diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.java b/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.java
new file mode 100644
index 0000000000..f2726118d4
--- /dev/null
+++ b/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.java
@@ -0,0 +1,45 @@
+package com.vaadin.tests.application;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+
+public class WebBrowserSizeTest extends TestBase {
+
+ @Override
+ protected void setup() {
+
+ final Label screenSizeLabel = new Label("n/a");
+ screenSizeLabel.setCaption("Screen size");
+
+ final Label browserSizeLabel = new Label("n/a");
+ browserSizeLabel.setCaption("Client (browser window) size");
+
+ final Button update = new Button("Refresh", new Button.ClickListener() {
+
+ public void buttonClick(ClickEvent event) {
+ screenSizeLabel.setValue(getBrowser().getScreenWidth() + " x "
+ + getBrowser().getScreenHeight());
+ browserSizeLabel.setValue(getBrowser().getClientWidth() + " x "
+ + getBrowser().getClientHeight());
+ }
+ });
+
+ addComponent(update);
+ addComponent(screenSizeLabel);
+ addComponent(browserSizeLabel);
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Verifies that browser sizes are reported correctly. Note that client width differs depending on browser decorations.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 5655;
+ }
+
+}
diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html
index 04bdec4d48..f04dd564bf 100644
--- a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html
+++ b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html
@@ -12,32 +12,32 @@
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.application.WebBrowserTest?restartApplication</td>
- <td></td>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.application.WebBrowserTest?restartApplication</td>
+ <td></td>
</tr>
<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
</tr>
<!-- Raw offset -->
<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0]</td>
- <td>7200000</td>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0]</td>
+ <td>7200000</td>
</tr>
<!-- offset to Helsinki -->
<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VLabel[0]</td>
- <td>0</td>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VLabel[0]</td>
+ <td>0</td>
</tr>
<!-- in Helsinki? -->
<tr>
- <td>assertText</td>
- <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VLabel[0]</td>
- <td>Yes</td>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VLabel[0]</td>
+ <td>Yes</td>
</tr>
</tbody></table>
</body>
diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
index 08c9061d45..31e7534042 100644
--- a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
+++ b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java
@@ -71,6 +71,7 @@ public class WebBrowserTest extends TestBase {
curDateLabel.setValue(getBrowser().getCurrentDate()
.toString());
+
}
});
@@ -82,7 +83,6 @@ public class WebBrowserTest extends TestBase {
addComponent(curDateLabel);
addComponent(diffLabel);
addComponent(containsLabel);
-
}
@Override