From 3a6e5a11210f1560a3b14b29803eac5386dacf98 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 25 Aug 2008 05:59:54 +0000 Subject: [PATCH] Made #1642 fix more generic by moving implementation to AbstractComponent svn changeset:5250/svn branch:trunk --- src/com/itmill/toolkit/Application.java | 12 +++-- .../gwt/server/ChangeVariablesErrorEvent.java | 2 +- .../itmill/toolkit/ui/AbstractComponent.java | 52 +++++++++++++++++++ src/com/itmill/toolkit/ui/AbstractField.java | 52 ------------------- 4 files changed, 61 insertions(+), 57 deletions(-) diff --git a/src/com/itmill/toolkit/Application.java b/src/com/itmill/toolkit/Application.java index 1196891014..d2067b32ff 100644 --- a/src/com/itmill/toolkit/Application.java +++ b/src/com/itmill/toolkit/Application.java @@ -1088,10 +1088,7 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener System.err .println("Warning: SocketException in CommunicationManager." + " Most likely client (browser) closed socket."); - - } else { - // throw it to standard error stream too - t.printStackTrace(); + return; } // Finds the original source of the error/exception @@ -1115,6 +1112,13 @@ public abstract class Application implements URIHandler, Terminal.ErrorListener ((AbstractComponent) owner) .setComponentError(new SystemError(e)); } + } else { + /* + * Can't show it to the user in any way so we print to standard + * error + */ + t.printStackTrace(); + } } diff --git a/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java b/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java index 08182b7155..76bd1822c0 100644 --- a/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java +++ b/src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java @@ -3,7 +3,7 @@ package com.itmill.toolkit.terminal.gwt.server; import java.util.Map; import com.itmill.toolkit.ui.Component; -import com.itmill.toolkit.ui.AbstractField.ComponentErrorEvent; +import com.itmill.toolkit.ui.AbstractComponent.ComponentErrorEvent; public class ChangeVariablesErrorEvent implements ComponentErrorEvent { diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java index 83502aa40c..634f58dbac 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponent.java +++ b/src/com/itmill/toolkit/ui/AbstractComponent.java @@ -19,6 +19,7 @@ import com.itmill.toolkit.terminal.ErrorMessage; import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; import com.itmill.toolkit.terminal.Resource; +import com.itmill.toolkit.terminal.Terminal; /** * An abstract class that defines default implementation for the @@ -121,6 +122,8 @@ public abstract class AbstractComponent implements Component, MethodEventSource private int widthUnit = UNITS_PIXELS; private int heightUnit = UNITS_PIXELS; + private ComponentErrorHandler errorHandler = null; + /* Constructor */ /** @@ -1170,4 +1173,53 @@ public abstract class AbstractComponent implements Component, MethodEventSource return values; } + public interface ComponentErrorEvent extends Terminal.ErrorEvent { + } + + public interface ComponentErrorHandler { + /** + * Handle the component error + * + * @param event + * @return True if the error has been handled False, otherwise + */ + public boolean handleComponentError(ComponentErrorEvent event); + } + + /** + * Gets the error handler for the component. + * + * The error handler is dispatched whenever there is an error processing the + * data coming from the client. + * + * @return + */ + public ComponentErrorHandler getErrorHandler() { + return errorHandler; + } + + /** + * Sets the error handler for the component. + * + * The error handler is dispatched whenever there is an error processing the + * data coming from the client. + * + * If the error handler is not set, the application error handler is used to + * handle the exception. + * + * @param errorHandler + * AbstractField specific error handler + */ + public void setErrorHandler(ComponentErrorHandler errorHandler) { + this.errorHandler = errorHandler; + } + + public boolean handleError(ComponentErrorEvent error) { + if (errorHandler != null) { + return errorHandler.handleComponentError(error); + } + return false; + + } + } \ No newline at end of file diff --git a/src/com/itmill/toolkit/ui/AbstractField.java b/src/com/itmill/toolkit/ui/AbstractField.java index 70b17ad41a..98a001dd57 100644 --- a/src/com/itmill/toolkit/ui/AbstractField.java +++ b/src/com/itmill/toolkit/ui/AbstractField.java @@ -21,7 +21,6 @@ import com.itmill.toolkit.terminal.CompositeErrorMessage; import com.itmill.toolkit.terminal.ErrorMessage; import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; -import com.itmill.toolkit.terminal.Terminal; /** *

@@ -122,8 +121,6 @@ public abstract class AbstractField extends AbstractComponent implements Field, */ private boolean validationVisible = true; - private ComponentErrorHandler errorHandler = null; - /* Component basics ************************************************ */ /* @@ -1085,52 +1082,6 @@ public abstract class AbstractField extends AbstractComponent implements Field, } } - public interface ComponentErrorHandler { - /** - * Handle the component error - * - * @param event - * @return True if the error has been handled False, otherwise - */ - public boolean handleComponentError(ComponentErrorEvent event); - } - - /** - * Gets the error handler for the component. - * - * The error handler is dispatched whenever there is an error processing the - * data coming from the client. - * - * @return - */ - public ComponentErrorHandler getErrorHandler() { - return errorHandler; - } - - /** - * Sets the error handler for the component. - * - * The error handler is dispatched whenever there is an error processing the - * data coming from the client. - * - * If the error handler is not set, the application error handler is used to - * handle the exception. - * - * @param errorHandler - * AbstractField specific error handler - */ - public void setErrorHandler(ComponentErrorHandler errorHandler) { - this.errorHandler = errorHandler; - } - - public boolean handleError(ComponentErrorEvent error) { - if (errorHandler != null) { - return errorHandler.handleComponentError(error); - } - return false; - - } - /** * Sets the current buffered source exception. * @@ -1142,7 +1093,4 @@ public abstract class AbstractField extends AbstractComponent implements Field, requestRepaint(); } - public interface ComponentErrorEvent extends Terminal.ErrorEvent { - } - } \ No newline at end of file -- 2.39.5