diff options
Diffstat (limited to 'src/com')
8 files changed, 84 insertions, 36 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); } |