From be0495ba589b4b843f5a19bb4d8dfba8e713f34e Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 9 Dec 2011 11:05:55 +0000 Subject: #7354 IT Mill -> Vaadin find and replace svn changeset:22341/svn branch:6.8 --- src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/com') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java index 0032b1a5dc..ce4a19462f 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VDragAndDropWrapperIE.java @@ -1,5 +1,5 @@ /* -@ITMillApache2LicenseForJavaFiles@ +@VaadinApache2LicenseForJavaFiles@ */ package com.vaadin.terminal.gwt.client.ui; -- cgit v1.2.3 From 54aac82d4e87af786a4b8d29a83291ab350f1643 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 9 Dec 2011 13:31:08 +0000 Subject: #8035 - More generic fix based on review Don't send a text change message in cases where a value change has already been sent or is about to get sent svn changeset:22359/svn branch:6.7 --- .../vaadin/terminal/gwt/client/ui/VTextField.java | 36 +++++++++------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'src/com') diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextField.java b/src/com/vaadin/terminal/gwt/client/ui/VTextField.java index a4038b67ac..f059e0cea5 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; } } @@ -587,20 +594,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 -- cgit v1.2.3 From d4b3dcfd0fc12b8069c61ef725b30ee54a79348a Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 9 Dec 2011 13:38:41 +0000 Subject: #8089 Don't fire TextChangeEvent inside TextChangeEvent svn changeset:22361/svn branch:6.7 --- src/com/vaadin/ui/AbstractTextField.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/com') diff --git a/src/com/vaadin/ui/AbstractTextField.java b/src/com/vaadin/ui/AbstractTextField.java index 3bfeabd33f..346d370bd5 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 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 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 implements firePendingTextChangeEvent(); } - /* - * Reset lastKnownTextContent field on value change. We know the value - * now. - */ - lastKnownTextContent = null; super.setInternalValue(newValue); } -- cgit v1.2.3 From 83ae145f53fed1bd45250f69918454371f43c73a Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Fri, 16 Dec 2011 12:04:04 +0000 Subject: Merge #8143 to 6.8 and add missing methods to the Console interface svn changeset:22423/svn branch:6.8 --- src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml | 4 ++++ src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java | 9 +++++++-- src/com/vaadin/terminal/gwt/client/Console.java | 4 ++++ src/com/vaadin/terminal/gwt/client/NullConsole.java | 6 ++++++ src/com/vaadin/terminal/gwt/client/ui/VWindow.java | 4 ++-- 5 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src/com') diff --git a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml index 1c9b459512..7844ccecf1 100644 --- a/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml +++ b/src/com/vaadin/terminal/gwt/DefaultWidgetSet.gwt.xml @@ -17,6 +17,10 @@ + + + + diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java index 2871ab8ba4..fce5b4206c 100644 --- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java +++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java @@ -449,7 +449,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); @@ -506,7 +506,12 @@ public class ApplicationConfiguration implements EntryPoint { } }-*/; - private native static boolean isQuietDebugMode() + /** + * Checks whether debug logging should be quiet + * + * @return true 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 zeroHeightComponents, Set 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/VWindow.java b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java index 867e187070..9302be29df 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VWindow.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VWindow.java @@ -34,6 +34,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; @@ -41,7 +42,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; @@ -1218,7 +1218,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; -- cgit v1.2.3 From 4e9bd2a49142d3dd87f380b1f6e458734c566f7d Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 20 Dec 2011 10:11:58 +0000 Subject: #5655 Added getClientWidth() and getClientHeight() to WebBrowser and updated test svn changeset:22453/svn branch:6.8 --- .../gwt/server/AbstractApplicationPortlet.java | 2 ++ .../gwt/server/AbstractApplicationServlet.java | 3 +- src/com/vaadin/terminal/gwt/server/WebBrowser.java | 38 ++++++++++++++++++++-- .../vaadin/tests/application/WebBrowserTest.html | 35 +++++++++++--------- .../vaadin/tests/application/WebBrowserTest.java | 13 ++++++++ 5 files changed, 72 insertions(+), 19 deletions(-) (limited to 'src/com') diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java index 22f5cba1e6..acae039e8b 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationPortlet.java @@ -567,6 +567,8 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet browser.updateClientSideDetails( getHTTPRequestParameter(request, "sw"), getHTTPRequestParameter(request, "sh"), + getHTTPRequestParameter(request, "cw"), + getHTTPRequestParameter(request, "ch"), getHTTPRequestParameter(request, "tzo"), getHTTPRequestParameter(request, "rtzo"), getHTTPRequestParameter(request, "dstd"), diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 17b92db617..3957c84a71 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -595,7 +595,8 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements request.getHeader("user-agent")); if (request.getParameter("repaintAll") != null) { browser.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/terminal/gwt/server/WebBrowser.java b/src/com/vaadin/terminal/gwt/server/WebBrowser.java index 9182ebdc03..cb83d93a72 100644 --- a/src/com/vaadin/terminal/gwt/server/WebBrowser.java +++ b/src/com/vaadin/terminal/gwt/server/WebBrowser.java @@ -22,6 +22,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; @@ -62,6 +64,24 @@ public class WebBrowser implements Terminal { return screenWidth; } + /** + * 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. * @@ -312,6 +332,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 @@ -324,9 +348,9 @@ public class WebBrowser implements Terminal { * the current date in milliseconds since the epoch * @param touchDevice */ - 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); @@ -335,6 +359,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 diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html index 04bdec4d48..f4dd48f6d0 100644 --- a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html +++ b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.html @@ -12,32 +12,37 @@ New Test - open - /run/com.vaadin.tests.application.WebBrowserTest?restartApplication - + open + /run/com.vaadin.tests.application.WebBrowserTest?restartApplication + - click - vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0] - + click + vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0] + - assertText - vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0] - 7200000 + assertText + vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VLabel[0] + 7200000 - assertText - vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VLabel[0] - 0 + assertText + vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[6]/VLabel[0] + 0 - assertText - vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VLabel[0] - Yes + assertText + vaadin=runcomvaadintestsapplicationWebBrowserTest::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[7]/VLabel[0] + Yes + + + screenCapture + + browserinfo diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java index 08c9061d45..33a70a942c 100644 --- a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java +++ b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java @@ -35,6 +35,12 @@ public class WebBrowserTest extends TestBase { final Label containsLabel = new Label("n/a"); containsLabel.setCaption("Browser could be in Helsinki"); + 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("Get TimeZone from browser", new Button.ClickListener() { @@ -71,6 +77,11 @@ public class WebBrowserTest extends TestBase { curDateLabel.setValue(getBrowser().getCurrentDate() .toString()); + + screenSizeLabel.setValue(getBrowser().getScreenWidth() + + " x " + getBrowser().getScreenHeight()); + browserSizeLabel.setValue(getBrowser().getClientWidth() + + " x " + getBrowser().getClientHeight()); } }); @@ -82,6 +93,8 @@ public class WebBrowserTest extends TestBase { addComponent(curDateLabel); addComponent(diffLabel); addComponent(containsLabel); + addComponent(screenSizeLabel); + addComponent(browserSizeLabel); } -- cgit v1.2.3