summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java60
-rwxr-xr-xsrc/com/vaadin/terminal/gwt/client/ApplicationConnection.java179
-rw-r--r--src/com/vaadin/terminal/gwt/client/BrowserInfo.java16
-rw-r--r--src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java3
-rw-r--r--src/com/vaadin/terminal/gwt/client/Console.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/DateTimeService.java44
-rw-r--r--src/com/vaadin/terminal/gwt/client/NullConsole.java8
-rw-r--r--src/com/vaadin/terminal/gwt/client/Util.java7
-rw-r--r--src/com/vaadin/terminal/gwt/client/VConsole.java88
-rwxr-xr-xsrc/com/vaadin/terminal/gwt/client/VDebugConsole.java260
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VDateField.java6
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java7
12 files changed, 404 insertions, 280 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
index 9834a40487..c71ebb78e9 100644
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConfiguration.java
@@ -11,6 +11,7 @@ import java.util.List;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.GWT.UncaughtExceptionHandler;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayString;
import com.google.gwt.user.client.Command;
@@ -19,6 +20,20 @@ import com.vaadin.terminal.gwt.client.ui.VUnknownComponent;
public class ApplicationConfiguration implements EntryPoint {
+ /**
+ * Builds number. For example 0-custom_tag in 5.0.0-custom_tag.
+ */
+ public static final String VERSION;
+
+ /* Initialize version numbers from string replaced by build-script. */
+ static {
+ if ("@VERSION@".equals("@" + "VERSION" + "@")) {
+ VERSION = "9.9.9.INTERNAL-DEBUG-BUILD";
+ } else {
+ VERSION = "@VERSION@";
+ }
+ }
+
private static WidgetSet widgetSet = GWT.create(WidgetSet.class);
private String id;
@@ -361,7 +376,52 @@ public class ApplicationConfiguration implements EntryPoint {
};
public void onModuleLoad() {
+ // display some sort of error of exceptions in web mode to debug console
+ GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+ public void onUncaughtException(Throwable e) {
+ Console console = ApplicationConnection.getConsole();
+ if (console != null) {
+ console.error(e.getMessage());
+ }
+ }
+ });
+
+ // Prepare VConsole for debugging
+ if (isDebugMode()) {
+ VDebugConsole console = GWT.create(VDebugConsole.class);
+ console.setQuietMode(isQuietDebugMode());
+ console.init();
+ VConsole.setImplementation(console);
+ } else {
+ VConsole.setImplementation((Console) GWT.create(NullConsole.class));
+ }
+
initConfigurations();
startNextApplication();
}
+
+ /**
+ * Checks if client side is in debug mode. Practically this is invoked by
+ * adding ?debug parameter to URI.
+ *
+ * @return true if client side is currently been debugged
+ */
+ public native static boolean isDebugMode()
+ /*-{
+ if($wnd.vaadin.debug) {
+ var parameters = $wnd.location.search;
+ var re = /debug[^\/]*$/;
+ return re.test(parameters);
+ } else {
+ return false;
+ }
+ }-*/;
+
+ private native static boolean isQuietDebugMode()
+ /*-{
+ var uri = $wnd.location;
+ var re = /debug=q[^\/]*$/;
+ return re.test(uri);
+ }-*/;
+
}
diff --git a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
index 1ddbd9bdd0..9cf14b4ec0 100755
--- a/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
+++ b/src/com/vaadin/terminal/gwt/client/ApplicationConnection.java
@@ -93,8 +93,6 @@ public class ApplicationConnection {
private final HashMap<String, String> resourcesMap = new HashMap<String, String>();
- private static Console console;
-
private final ArrayList<String> pendingVariables = new ArrayList<String>();
private final ComponentDetailMap idToPaintableDetail = ComponentDetailMap
@@ -147,14 +145,22 @@ public class ApplicationConnection {
public ApplicationConnection(WidgetSet widgetSet,
ApplicationConfiguration cnf) {
+
+ VConsole.log("Starting application " + cnf.getRootPanelId());
+
+ VConsole.log("Vaadin application servlet version: "
+ + cnf.getServletVersion());
+ VConsole.log("Application version: " + cnf.getApplicationVersion());
+
+ if (!cnf.getServletVersion().equals(ApplicationConfiguration.VERSION)) {
+ VConsole.error("Warning: your widget set seems to be built with a different "
+ + "version than the one used on server. Unexpected "
+ + "behavior may occur.");
+ }
+
this.widgetSet = widgetSet;
configuration = cnf;
windowName = configuration.getInitialWindowName();
- if (isDebugMode()) {
- console = new VDebugConsole(this, cnf, !isQuietDebugMode());
- } else {
- console = new NullConsole();
- }
ComponentLocator componentLocator = new ComponentLocator(this);
@@ -291,35 +297,27 @@ public class ApplicationConnection {
* Get the active Console for writing debug messages. May return an actual
* logging console, or the NullConsole if debugging is not turned on.
*
+ * @deprecated Developers should use {@link VConsole} since 6.4.5
+ *
* @return the active Console
*/
+ @Deprecated
public static Console getConsole() {
- return console;
+ return VConsole.getImplementation();
}
/**
* Checks if client side is in debug mode. Practically this is invoked by
* adding ?debug parameter to URI.
*
+ * @deprecated use ApplicationConfiguration isDebugMode instead.
+ *
* @return true if client side is currently been debugged
*/
- public native static boolean isDebugMode()
- /*-{
- if($wnd.vaadin.debug) {
- var parameters = $wnd.location.search;
- var re = /debug[^\/]*$/;
- return re.test(parameters);
- } else {
- return false;
- }
- }-*/;
-
- private native static boolean isQuietDebugMode()
- /*-{
- var uri = $wnd.location;
- var re = /debug=q[^\/]*$/;
- return re.test(uri);
- }-*/;
+ @Deprecated
+ public static boolean isDebugMode() {
+ return ApplicationConfiguration.isDebugMode();
+ }
/**
* Gets the application base URI. Using this other than as the download
@@ -349,7 +347,7 @@ public class ApplicationConnection {
// Security: double cookie submission pattern
final String rd = uidl_security_key + VAR_BURST_SEPARATOR + requestData;
- console.log("Making UIDL Request with params: " + rd);
+ VConsole.log("Making UIDL Request with params: " + rd);
String uri;
if (configuration.usePortletURLs()) {
uri = configuration.getPortletUidlURLBase();
@@ -410,7 +408,7 @@ public class ApplicationConnection {
public void onResponseReceived(Request request,
Response response) {
- console.log("Server visit took "
+ VConsole.log("Server visit took "
+ String.valueOf((new Date()).getTime()
- requestStartTime.getTime()) + "ms");
@@ -436,7 +434,7 @@ public class ApplicationConnection {
// We'll assume msec instead of the usual seconds
int delay = Integer.parseInt(response
.getHeader("Retry-After"));
- console.log("503, retrying in " + delay + "msec");
+ VConsole.log("503, retrying in " + delay + "msec");
(new Timer() {
@Override
public void run() {
@@ -481,22 +479,22 @@ public class ApplicationConnection {
handleWhenCSSLoaded(response);
}
}).schedule(50);
- console.log("Assuming CSS loading is not complete, "
+ VConsole.log("Assuming CSS loading is not complete, "
+ "postponing render phase. "
+ "(.v-loading-indicator height == 0)");
cssWaits++;
} else {
handleReceivedJSONMessage(response);
if (cssWaits >= MAX_CSS_WAITS) {
- console.error("CSS files may have not loaded properly.");
+ VConsole.error("CSS files may have not loaded properly.");
}
}
}
});
- } catch (final RequestException e) {
- ClientExceptionHandler.displayError(e);
+ } catch (RequestException e) {
+ VConsole.error(e);
endRequest();
}
} else {
@@ -518,7 +516,7 @@ public class ApplicationConnection {
* Optional details for debugging.
*/
private void showCommunicationError(String details) {
- console.error("Communication error: " + details);
+ VConsole.error("Communication error: " + details);
showError(details, configuration.getCommunicationErrorCaption(),
configuration.getCommunicationErrorMessage(),
configuration.getCommunicationErrorUrl());
@@ -531,7 +529,7 @@ public class ApplicationConnection {
* Optional details for debugging.
*/
private void showAuthenticationError(String details) {
- console.error("Authentication error: " + details);
+ VConsole.error("Authentication error: " + details);
showError(details, configuration.getAuthorizationErrorCaption(),
configuration.getAuthorizationErrorMessage(),
configuration.getAuthorizationErrorUrl());
@@ -666,8 +664,7 @@ public class ApplicationConnection {
variableBurst.remove(i - 1);
variableBurst.remove(i - 1);
i -= 2;
- ApplicationConnection.getConsole().log(
- "Removed variable from removed component: " + id);
+ VConsole.log("Removed variable from removed component: " + id);
}
}
}
@@ -678,7 +675,7 @@ public class ApplicationConnection {
loadElement = DOM.createDiv();
DOM.setStyleAttribute(loadElement, "position", "absolute");
DOM.appendChild(view.getElement(), loadElement);
- ApplicationConnection.getConsole().log("inserting load indicator");
+ VConsole.log("inserting load indicator");
}
DOM.setElementProperty(loadElement, "className", "v-loading-indicator");
DOM.setStyleAttribute(loadElement, "display", "block");
@@ -774,13 +771,12 @@ public class ApplicationConnection {
return;
}
- ApplicationConnection.getConsole().log(
- "JSON parsing took " + (new Date().getTime() - start.getTime())
- + "ms");
+ VConsole.log("JSON parsing took "
+ + (new Date().getTime() - start.getTime()) + "ms");
// Handle redirect
if (json.containsKey("redirect")) {
String url = json.getValueMap("redirect").getString("url");
- console.log("redirecting to " + url);
+ VConsole.log("redirecting to " + url);
redirect(url);
return;
}
@@ -856,15 +852,7 @@ public class ApplicationConnection {
for (int i = 0; i < length; i++) {
try {
final UIDL change = changes.get(i).cast();
- try {
- console.dirUIDL(change);
- } catch (final Exception e) {
- ClientExceptionHandler.displayError(e);
- // TODO: dir doesn't work in any browser although it
- // should
- // work (works in hosted mode)
- // it partially did at some part but now broken.
- }
+ VConsole.dirUIDL(change, configuration);
final UIDL uidl = change.getChildUIDL(0);
// TODO optimize
final Paintable paintable = getPaintable(uidl.getId());
@@ -880,11 +868,10 @@ public class ApplicationConnection {
} else {
if (!uidl.getTag().equals(
configuration.getEncodedWindowTag())) {
- ClientExceptionHandler
- .displayError("Received update for "
- + uidl.getTag()
- + ", but there is no such paintable ("
- + uidl.getId() + ") rendered.");
+ VConsole.error("Received update for "
+ + uidl.getTag()
+ + ", but there is no such paintable ("
+ + uidl.getId() + ") rendered.");
} else {
String pid = uidl.getId();
if (!idToPaintableDetail.containsKey(pid)) {
@@ -902,7 +889,7 @@ public class ApplicationConnection {
}
}
} catch (final Throwable e) {
- ClientExceptionHandler.displayError(e);
+ VConsole.error(e);
}
}
@@ -966,7 +953,7 @@ public class ApplicationConnection {
applicationRunning = false;
}
if (validatingLayouts) {
- getConsole().printLayoutProblems(meta,
+ VConsole.printLayoutProblems(meta,
ApplicationConnection.this,
zeroHeightComponents, zeroWidthComponents);
zeroHeightComponents = null;
@@ -980,10 +967,10 @@ public class ApplicationConnection {
final long prosessingTime = (new Date().getTime())
- start.getTime();
- console.log(" Processing time was "
+ VConsole.log(" Processing time was "
+ String.valueOf(prosessingTime) + "ms for "
+ jsonText.length() + " characters of JSON");
- console.log("Referenced paintables: "
+ VConsole.log("Referenced paintables: "
+ idToPaintableDetail.size());
endRequest();
@@ -1082,8 +1069,7 @@ public class ApplicationConnection {
*/
public void unregisterPaintable(Paintable p) {
if (p == null) {
- ApplicationConnection.getConsole().error(
- "WARN: Trying to unregister null paintable");
+ VConsole.error("WARN: Trying to unregister null paintable");
return;
}
String id = getPid(p);
@@ -1562,19 +1548,17 @@ public class ApplicationConnection {
boolean manageCaption) {
String pid = getPid(component.getElement());
if (pid == null) {
- getConsole().error(
- "Trying to update an unregistered component: "
- + Util.getSimpleName(component));
+ VConsole.error("Trying to update an unregistered component: "
+ + Util.getSimpleName(component));
return true;
}
ComponentDetail componentDetail = idToPaintableDetail.get(pid);
if (componentDetail == null) {
- getConsole().error(
- "ComponentDetail not found for "
- + Util.getSimpleName(component) + " with PID "
- + pid + ". This should not happen.");
+ VConsole.error("ComponentDetail not found for "
+ + Util.getSimpleName(component) + " with PID " + pid
+ + ". This should not happen.");
return true;
}
@@ -1899,29 +1883,21 @@ public class ApplicationConnection {
}
if (debugSizes) {
- getConsole()
- .log("Widget "
- + Util.getSimpleName(widget)
- + "/"
- + getPid(widget.getElement())
- + " relative height "
- + relativeSize.getHeight()
- + "% of "
- + renderSpace.getHeight()
- + "px (reported by "
-
- + Util.getSimpleName(parent)
- + "/"
- + (parent == null ? "?" : parent.hashCode())
- + ") : " + height + "px");
+ VConsole.log("Widget " + Util.getSimpleName(widget) + "/"
+ + getPid(widget.getElement()) + " relative height "
+ + relativeSize.getHeight() + "% of "
+ + renderSpace.getHeight() + "px (reported by "
+
+ + Util.getSimpleName(parent) + "/"
+ + (parent == null ? "?" : parent.hashCode())
+ + ") : " + height + "px");
}
widget.setHeight(height + "px");
} else {
widget.setHeight(relativeSize.getHeight() + "%");
- ApplicationConnection.getConsole().error(
- Util.getLayout(widget).getClass().getName()
- + " did not produce allocatedSpace for "
- + widget.getClass().getName());
+ VConsole.error(Util.getLayout(widget).getClass().getName()
+ + " did not produce allocatedSpace for "
+ + widget.getClass().getName());
}
}
@@ -1956,24 +1932,20 @@ public class ApplicationConnection {
}
if (debugSizes) {
- getConsole().log(
- "Widget " + Util.getSimpleName(widget) + "/"
- + getPid(widget.getElement())
- + " relative width "
- + relativeSize.getWidth() + "% of "
- + renderSpace.getWidth()
- + "px (reported by "
- + Util.getSimpleName(parent) + "/"
- + (parent == null ? "?" : getPid(parent))
- + ") : " + width + "px");
+ VConsole.log("Widget " + Util.getSimpleName(widget) + "/"
+ + getPid(widget.getElement()) + " relative width "
+ + relativeSize.getWidth() + "% of "
+ + renderSpace.getWidth() + "px (reported by "
+ + Util.getSimpleName(parent) + "/"
+ + (parent == null ? "?" : getPid(parent)) + ") : "
+ + width + "px");
}
widget.setWidth(width + "px");
} else {
widget.setWidth(relativeSize.getWidth() + "%");
- ApplicationConnection.getConsole().error(
- Util.getLayout(widget).getClass().getName()
- + " did not produce allocatedSpace for "
- + widget.getClass().getName());
+ VConsole.error(Util.getLayout(widget).getClass().getName()
+ + " did not produce allocatedSpace for "
+ + widget.getClass().getName());
}
}
@@ -2081,7 +2053,7 @@ public class ApplicationConnection {
if (uidlUri.startsWith("theme://")) {
final String themeUri = configuration.getThemeUri();
if (themeUri == null) {
- console.error("Theme not set: ThemeResource will not be found. ("
+ VConsole.error("Theme not set: ThemeResource will not be found. ("
+ uidlUri + ")");
}
uidlUri = themeUri + uidlUri.substring(7);
@@ -2204,8 +2176,7 @@ public class ApplicationConnection {
@Override
public void run() {
- getConsole().log(
- "Running re-layout of " + view.getClass().getName());
+ VConsole.log("Running re-layout of " + view.getClass().getName());
runDescendentsLayout(view);
isPending = false;
}
diff --git a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
index 988396a793..7578d104b8 100644
--- a/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
+++ b/src/com/vaadin/terminal/gwt/client/BrowserInfo.java
@@ -54,17 +54,13 @@ public class BrowserInfo {
private VBrowserDetails browserDetails;
private BrowserInfo() {
- try {
- browserDetails = new VBrowserDetails(getBrowserString());
- if (browserDetails.isIE()
- && browserDetails.getBrowserMajorVersion() == 8
- && isIE8InIE7CompatibilityMode()) {
- browserDetails.setIE8InCompatibilityMode();
- }
-
- } catch (Exception e) {
- ClientExceptionHandler.displayError(e);
+ browserDetails = new VBrowserDetails(getBrowserString());
+ if (browserDetails.isIE()
+ && browserDetails.getBrowserMajorVersion() == 8
+ && isIE8InIE7CompatibilityMode()) {
+ browserDetails.setIE8InCompatibilityMode();
}
+
}
private native boolean isIE8InIE7CompatibilityMode()
diff --git a/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java b/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java
index 97b3e07c06..b30ff1f843 100644
--- a/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java
+++ b/src/com/vaadin/terminal/gwt/client/ClientExceptionHandler.java
@@ -5,6 +5,7 @@ package com.vaadin.terminal.gwt.client;
import com.google.gwt.core.client.GWT;
+@Deprecated
public class ClientExceptionHandler {
public static void displayError(Throwable e) {
@@ -13,6 +14,7 @@ public class ClientExceptionHandler {
GWT.log(e.getMessage(), e);
}
+ @Deprecated
public static void displayError(String msg) {
Console console = ApplicationConnection.getConsole();
@@ -23,6 +25,7 @@ public class ClientExceptionHandler {
}
}
+ @Deprecated
public static void displayError(String msg, Throwable e) {
displayError(msg);
displayError(e);
diff --git a/src/com/vaadin/terminal/gwt/client/Console.java b/src/com/vaadin/terminal/gwt/client/Console.java
index 048b5fb0b7..301418dc10 100644
--- a/src/com/vaadin/terminal/gwt/client/Console.java
+++ b/src/com/vaadin/terminal/gwt/client/Console.java
@@ -10,11 +10,15 @@ public interface Console {
public abstract void log(String msg);
+ public abstract void log(Throwable e);
+
+ public abstract void error(Throwable e);
+
public abstract void error(String msg);
public abstract void printObject(Object msg);
- public abstract void dirUIDL(UIDL u);
+ public abstract void dirUIDL(UIDL u, ApplicationConfiguration cnf);
public abstract void printLayoutProblems(ValueMap meta,
ApplicationConnection applicationConnection,
diff --git a/src/com/vaadin/terminal/gwt/client/DateTimeService.java b/src/com/vaadin/terminal/gwt/client/DateTimeService.java
index dffe2a9a53..449dae73db 100644
--- a/src/com/vaadin/terminal/gwt/client/DateTimeService.java
+++ b/src/com/vaadin/terminal/gwt/client/DateTimeService.java
@@ -59,75 +59,77 @@ public class DateTimeService {
try {
return LocaleService.getMonthNames(currentLocale)[month];
} catch (final LocaleNotLoadedException e) {
- ClientExceptionHandler.displayError(e);
+ ApplicationConnection.getConsole().error(e);
+ return null;
}
- return null;
}
public String getShortMonth(int month) {
try {
return LocaleService.getShortMonthNames(currentLocale)[month];
} catch (final LocaleNotLoadedException e) {
- ClientExceptionHandler.displayError(e);
+ ApplicationConnection.getConsole().error(e);
+ return null;
}
- return null;
}
public String getDay(int day) {
try {
return LocaleService.getDayNames(currentLocale)[day];
} catch (final LocaleNotLoadedException e) {
- ClientExceptionHandler.displayError(e);
+ ApplicationConnection.getConsole().error(e);
+ return null;
}
- return null;
}
public String getShortDay(int day) {
try {
return LocaleService.getShortDayNames(currentLocale)[day];
} catch (final LocaleNotLoadedException e) {
- ClientExceptionHandler.displayError(e);
+ ApplicationConnection.getConsole().error(e);
+ return null;
}
- return null;
}
public int getFirstDayOfWeek() {
try {
return LocaleService.getFirstDayOfWeek(currentLocale);
} catch (final LocaleNotLoadedException e) {
- ClientExceptionHandler.displayError(e);
+ ApplicationConnection.getConsole().error(e);
+ return 0;
}
- return 0;
}
public boolean isTwelveHourClock() {
try {
return LocaleService.isTwelveHourClock(currentLocale);
} catch (final LocaleNotLoadedException e) {
- ClientExceptionHandler.displayError(e);
+ ApplicationConnection.getConsole().error(e);
+ return false;
}
- return false;
}
public String getClockDelimeter() {
try {
return LocaleService.getClockDelimiter(currentLocale);
} catch (final LocaleNotLoadedException e) {
- ClientExceptionHandler.displayError(e);
+ ApplicationConnection.getConsole().error(e);
+ return ":";
}
- return ":";
}
+ private static final String[] DEFAULT_AMPM_STRINGS = { "AM", "PM" };
+
public String[] getAmPmStrings() {
try {
return LocaleService.getAmPmStrings(currentLocale);
} catch (final LocaleNotLoadedException e) {
- ClientExceptionHandler.displayError(e);
+ // TODO can this practically even happen? Should die instead?
+ ApplicationConnection.getConsole().error(
+ "Locale not loaded, using fallback : AM/PM");
+ ApplicationConnection.getConsole().error(e);
+ return DEFAULT_AMPM_STRINGS;
}
- final String[] temp = new String[2];
- temp[0] = "AM";
- temp[1] = "PM";
- return temp;
}
public int getStartWeekDay(Date date) {
@@ -137,8 +139,10 @@ public class DateTimeService {
try {
firstDay = LocaleService.getFirstDayOfWeek(currentLocale);
} catch (final LocaleNotLoadedException e) {
+ ApplicationConnection.getConsole().error(
+ "Locale not loaded, using fallback 0");
+ ApplicationConnection.getConsole().error(e);
firstDay = 0;
- ClientExceptionHandler.displayError(e);
}
int start = dateForFirstOfThisMonth.getDay() - firstDay;
if (start < 0) {
diff --git a/src/com/vaadin/terminal/gwt/client/NullConsole.java b/src/com/vaadin/terminal/gwt/client/NullConsole.java
index efcd201d3f..9d66b1f20d 100644
--- a/src/com/vaadin/terminal/gwt/client/NullConsole.java
+++ b/src/com/vaadin/terminal/gwt/client/NullConsole.java
@@ -13,7 +13,7 @@ import java.util.Set;
*/
public class NullConsole implements Console {
- public void dirUIDL(UIDL u) {
+ public void dirUIDL(UIDL u, ApplicationConfiguration cnf) {
}
public void error(String msg) {
@@ -31,4 +31,10 @@ public class NullConsole implements Console {
Set<Paintable> zeroWidthComponents) {
}
+ public void log(Throwable e) {
+ }
+
+ public void error(Throwable e) {
+ }
+
}
diff --git a/src/com/vaadin/terminal/gwt/client/Util.java b/src/com/vaadin/terminal/gwt/client/Util.java
index 19ba535bef..e94f9b4bcb 100644
--- a/src/com/vaadin/terminal/gwt/client/Util.java
+++ b/src/com/vaadin/terminal/gwt/client/Util.java
@@ -158,11 +158,10 @@ public class Util {
try {
return Float.parseFloat(size.substring(0, size.length() - 1));
} catch (Exception e) {
- ClientExceptionHandler.displayError(
- "Unable to parse relative size", e);
+ ApplicationConnection.getConsole().log(
+ "Unable to parse relative size");
+ return -1;
}
-
- return -1;
}
/**
diff --git a/src/com/vaadin/terminal/gwt/client/VConsole.java b/src/com/vaadin/terminal/gwt/client/VConsole.java
new file mode 100644
index 0000000000..ca3a4fa4dc
--- /dev/null
+++ b/src/com/vaadin/terminal/gwt/client/VConsole.java
@@ -0,0 +1,88 @@
+package com.vaadin.terminal.gwt.client;
+
+import java.util.Set;
+
+import com.google.gwt.core.client.GWT;
+
+/**
+ * A helper class to do some client side logging.
+ * <p>
+ * This class replaces previously used loggin style:
+ * ApplicationConnection.getConsole().log("foo").
+ * <p>
+ * The default widgetset provides three modes for debugging:
+ * <ul>
+ * <li>NullConsole (Default, displays no errors at all)
+ * <li>VDebugConsole ( Enabled by appending ?debug to url. Displays a floating
+ * console in the browser and also prints to browsers internal console (builtin
+ * or Firebug) and GWT's development mode console if available.)
+ * <li>VDebugConsole in quiet mode (Enabled by appending ?debug=quiet. Same as
+ * previous but without the console floating over application).
+ * </ul>
+ * <p>
+ * Implementations can be customized with GWT deferred binding by overriding
+ * NullConsole.class or VDebugConsole.class. This way developer can for example
+ * build mechanism to send client side logging data to a server.
+ * <p>
+ * Note that logging in client side is not fully optimized away even in
+ * production mode. Use logging moderately in production code to keep the size
+ * of client side engine small. An exception is {@link GWT#log(String)} style
+ * logging, which is available only in GWT development mode, but optimized away
+ * when compiled to web mode.
+ *
+ *
+ * TODO improve javadocs of individual methods
+ *
+ */
+public class VConsole {
+ private static Console impl;
+
+ /**
+ * Used by ApplicationConfiguration to initialize VConsole.
+ *
+ * @param console
+ */
+ static void setImplementation(Console console) {
+ impl = console;
+ }
+
+ /**
+ * Used by ApplicationConnection to support deprecated getConsole() api.
+ */
+ static Console getImplementation() {
+ return impl;
+ }
+
+ public static void log(String msg) {
+ impl.log(msg);
+ }
+
+ public static void log(Throwable e) {
+ impl.log(e);
+ }
+
+ public static void error(Throwable e) {
+ impl.error(e);
+ }
+
+ public static void error(String msg) {
+ impl.error(msg);
+ }
+
+ public static void printObject(Object msg) {
+ impl.printObject(msg);
+ }
+
+ public static void dirUIDL(UIDL u, ApplicationConfiguration cnf) {
+ impl.dirUIDL(u, cnf);
+ }
+
+ public static void printLayoutProblems(ValueMap meta,
+ ApplicationConnection applicationConnection,
+ Set<Paintable> zeroHeightComponents,
+ Set<Paintable> zeroWidthComponents) {
+ impl.printLayoutProblems(meta, applicationConnection,
+ zeroHeightComponents, zeroWidthComponents);
+ }
+
+}
diff --git a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
index 9a1f2c9644..369ad5e428 100755
--- a/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
+++ b/src/com/vaadin/terminal/gwt/client/VDebugConsole.java
@@ -7,6 +7,7 @@ package com.vaadin.terminal.gwt.client;
import java.util.List;
import java.util.Set;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.dom.client.Style.FontWeight;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -32,20 +33,6 @@ import com.vaadin.terminal.gwt.client.ui.VOverlay;
public final class VDebugConsole extends VOverlay implements Console {
- /**
- * Builds number. For example 0-custom_tag in 5.0.0-custom_tag.
- */
- public static final String VERSION;
-
- /* Initialize version numbers from string replaced by build-script. */
- static {
- if ("@VERSION@".equals("@" + "VERSION" + "@")) {
- VERSION = "9.9.9.INTERNAL-DEBUG-BUILD";
- } else {
- VERSION = "@VERSION@";
- }
- }
-
Element caption = DOM.createDiv();
private Panel panel;
@@ -69,127 +56,11 @@ public final class VDebugConsole extends VOverlay implements Console {
private int origLeft;
- private ApplicationConnection client;
-
- private ApplicationConfiguration conf;
-
private static final String help = "Drag=move, shift-drag=resize, doubleclick=min/max."
+ "Use debug=quiet to log only to browser console.";
- public VDebugConsole(ApplicationConnection client,
- ApplicationConfiguration cnf, boolean showWindow) {
+ public VDebugConsole() {
super(false, false);
-
- this.client = client;
- conf = cnf;
-
- panel = new FlowPanel();
- if (showWindow) {
- DOM.appendChild(getContainerElement(), caption);
- setWidget(panel);
- caption.setClassName("v-debug-console-caption");
- setStyleName("v-debug-console");
- DOM.setStyleAttribute(getElement(), "zIndex", 20000 + "");
- DOM.setStyleAttribute(getElement(), "overflow", "hidden");
-
- sinkEvents(Event.ONDBLCLICK);
-
- sinkEvents(Event.MOUSEEVENTS);
-
- panel.setStyleName("v-debug-console-content");
-
- caption.setInnerHTML("Debug window");
- caption.setTitle(help);
-
- show();
- minimize();
-
- actions = new HorizontalPanel();
- actions.add(clear);
- actions.add(restart);
- actions.add(forceLayout);
- actions.add(analyzeLayout);
-
- panel.add(actions);
-
- panel.add(new HTML("<i>" + help + "</i>"));
-
- clear.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent event) {
- int width = panel.getOffsetWidth();
- int height = panel.getOffsetHeight();
- panel = new FlowPanel();
- panel.setPixelSize(width, height);
- panel.setStyleName("v-debug-console-content");
- panel.add(actions);
- setWidget(panel);
- }
- });
-
- restart.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent event) {
-
- String queryString = Window.Location.getQueryString();
- if (queryString != null
- && queryString.contains("restartApplications")) {
- Window.Location.reload();
- } else {
- String url = Location.getHref();
- String separator = "?";
- if (url.contains("?")) {
- separator = "&";
- }
- if (!url.contains("restartApplication")) {
- url += separator;
- url += "restartApplication";
- }
- if (!"".equals(Location.getHash())) {
- String hash = Location.getHash();
- url = url.replace(hash, "") + hash;
- }
- Window.Location.replace(url);
- }
-
- }
- });
-
- forceLayout.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent event) {
- VDebugConsole.this.client.forceLayout();
- }
- });
-
- analyzeLayout.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent event) {
- List<ApplicationConnection> runningApplications = ApplicationConfiguration
- .getRunningApplications();
- for (ApplicationConnection applicationConnection : runningApplications) {
- applicationConnection.analyzeLayouts();
- }
- }
- });
- analyzeLayout
- .setTitle("Analyzes currently rendered view and "
- + "reports possible common problems in usage of relative sizes."
- + "Will cause server visit/rendering of whole screen and loss of"
- + " all non committed variables form client side.");
-
- }
-
- log("Vaadin application servlet version: " + cnf.getServletVersion());
- log("Widget set is built on version: " + VERSION);
- log("Application version: " + cnf.getApplicationVersion());
-
- if (!cnf.getServletVersion().equals(VERSION)) {
- error("Warning: your widget set seems to be built with a different "
- + "version than the one used on server. Unexpected "
- + "behavior may occur.");
- }
-
- logToDebugWindow("<div class=\"v-theme-version v-theme-version-"
- + VERSION.replaceAll("\\.", "_")
- + "\">Warning: widgetset version " + VERSION
- + " does not seem to match theme version </div>", true);
}
private EventPreview dragpreview = new EventPreview() {
@@ -200,6 +71,8 @@ public final class VDebugConsole extends VOverlay implements Console {
}
};
+ private boolean quietMode;
+
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
@@ -310,7 +183,7 @@ public final class VDebugConsole extends VOverlay implements Console {
}
logToDebugWindow(msg, false);
- System.out.println(msg);
+ GWT.log(msg);
consoleLog(msg);
}
@@ -347,7 +220,7 @@ public final class VDebugConsole extends VOverlay implements Console {
logToDebugWindow(msg, true);
- System.err.println(msg);
+ GWT.log(msg);
consoleErr(msg);
}
@@ -374,7 +247,7 @@ public final class VDebugConsole extends VOverlay implements Console {
* @see com.vaadin.terminal.gwt.client.Console#dirUIDL(com.vaadin
* .terminal.gwt.client.UIDL)
*/
- public void dirUIDL(UIDL u) {
+ public void dirUIDL(UIDL u, ApplicationConfiguration conf) {
if (panel.isAttached()) {
panel.add(new VUIDLBrowser(u, conf));
}
@@ -521,4 +394,123 @@ public final class VDebugConsole extends VOverlay implements Console {
}
parent.addItem(errorNode);
}
+
+ public void log(Throwable e) {
+ log(e.getMessage());
+ GWT.log(e.getMessage(), e);
+ }
+
+ public void error(Throwable e) {
+ error(e.getMessage());
+ GWT.log(e.getMessage(), e);
+ }
+
+ public void init() {
+ panel = new FlowPanel();
+ if (!quietMode) {
+ DOM.appendChild(getContainerElement(), caption);
+ setWidget(panel);
+ caption.setClassName("v-debug-console-caption");
+ setStyleName("v-debug-console");
+ DOM.setStyleAttribute(getElement(), "zIndex", 20000 + "");
+ DOM.setStyleAttribute(getElement(), "overflow", "hidden");
+
+ sinkEvents(Event.ONDBLCLICK);
+
+ sinkEvents(Event.MOUSEEVENTS);
+
+ panel.setStyleName("v-debug-console-content");
+
+ caption.setInnerHTML("Debug window");
+ caption.setTitle(help);
+
+ show();
+ minimize();
+
+ actions = new HorizontalPanel();
+ actions.add(clear);
+ actions.add(restart);
+ actions.add(forceLayout);
+ actions.add(analyzeLayout);
+
+ panel.add(actions);
+
+ panel.add(new HTML("<i>" + help + "</i>"));
+
+ clear.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ int width = panel.getOffsetWidth();
+ int height = panel.getOffsetHeight();
+ panel = new FlowPanel();
+ panel.setPixelSize(width, height);
+ panel.setStyleName("v-debug-console-content");
+ panel.add(actions);
+ setWidget(panel);
+ }
+ });
+
+ restart.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+
+ String queryString = Window.Location.getQueryString();
+ if (queryString != null
+ && queryString.contains("restartApplications")) {
+ Window.Location.reload();
+ } else {
+ String url = Location.getHref();
+ String separator = "?";
+ if (url.contains("?")) {
+ separator = "&";
+ }
+ if (!url.contains("restartApplication")) {
+ url += separator;
+ url += "restartApplication";
+ }
+ if (!"".equals(Location.getHash())) {
+ String hash = Location.getHash();
+ url = url.replace(hash, "") + hash;
+ }
+ Window.Location.replace(url);
+ }
+
+ }
+ });
+
+ forceLayout.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ // TODO for each client in appconf force layout
+ // VDebugConsole.this.client.forceLayout();
+ }
+ });
+
+ analyzeLayout.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ List<ApplicationConnection> runningApplications = ApplicationConfiguration
+ .getRunningApplications();
+ for (ApplicationConnection applicationConnection : runningApplications) {
+ applicationConnection.analyzeLayouts();
+ }
+ }
+ });
+ analyzeLayout
+ .setTitle("Analyzes currently rendered view and "
+ + "reports possible common problems in usage of relative sizes."
+ + "Will cause server visit/rendering of whole screen and loss of"
+ + " all non committed variables form client side.");
+
+ }
+ log("Widget set is built on version: "
+ + ApplicationConfiguration.VERSION);
+
+ logToDebugWindow("<div class=\"v-theme-version v-theme-version-"
+ + ApplicationConfiguration.VERSION.replaceAll("\\.", "_")
+ + "\">Warning: widgetset version "
+ + ApplicationConfiguration.VERSION
+ + " does not seem to match theme version </div>", true);
+
+ }
+
+ public void setQuietMode(boolean quietDebugMode) {
+ quietMode = quietDebugMode;
+ }
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VDateField.java b/src/com/vaadin/terminal/gwt/client/ui/VDateField.java
index 9de31af52d..bbd1da5080 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VDateField.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VDateField.java
@@ -9,7 +9,6 @@ import java.util.Date;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FlowPanel;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
-import com.vaadin.terminal.gwt.client.ClientExceptionHandler;
import com.vaadin.terminal.gwt.client.DateTimeService;
import com.vaadin.terminal.gwt.client.LocaleNotLoadedException;
import com.vaadin.terminal.gwt.client.Paintable;
@@ -102,10 +101,11 @@ public class VDateField extends FlowPanel implements Paintable, Field {
currentLocale = locale;
} catch (final LocaleNotLoadedException e) {
currentLocale = dts.getLocale();
- ClientExceptionHandler.displayError(
+ ApplicationConnection.getConsole().error(
"Tried to use an unloaded locale \"" + locale
+ "\". Using default locale (" + currentLocale
- + ").", e);
+ + ").");
+ ApplicationConnection.getConsole().error(e);
}
}
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
index b9b4e22c69..134678e864 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
@@ -16,7 +16,6 @@ import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.TextBox;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
-import com.vaadin.terminal.gwt.client.ClientExceptionHandler;
import com.vaadin.terminal.gwt.client.ContainerResizedListener;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.Focusable;
@@ -160,7 +159,9 @@ public class VTextualDate extends VDateField implements Paintable, Field,
formatStr = frmString;
} catch (LocaleNotLoadedException e) {
- ClientExceptionHandler.displayError(e);
+ // TODO should die instead? Can the component survive
+ // without format string?
+ ApplicationConnection.getConsole().error(e);
}
}
}
@@ -229,7 +230,7 @@ public class VTextualDate extends VDateField implements Paintable, Field,
// remove possibly added invalid value indication
removeStyleName(PARSE_ERROR_CLASSNAME);
} catch (final Exception e) {
- ClientExceptionHandler.displayError(e.getMessage());
+ ApplicationConnection.getConsole().log(e);
addStyleName(PARSE_ERROR_CLASSNAME);
// this is a hack that may eventually be removed