]> source.dussan.org Git - vaadin-framework.git/commitdiff
Made #1642 fix more generic by moving implementation to AbstractComponent
authorArtur Signell <artur.signell@itmill.com>
Mon, 25 Aug 2008 05:59:54 +0000 (05:59 +0000)
committerArtur Signell <artur.signell@itmill.com>
Mon, 25 Aug 2008 05:59:54 +0000 (05:59 +0000)
svn changeset:5250/svn branch:trunk

src/com/itmill/toolkit/Application.java
src/com/itmill/toolkit/terminal/gwt/server/ChangeVariablesErrorEvent.java
src/com/itmill/toolkit/ui/AbstractComponent.java
src/com/itmill/toolkit/ui/AbstractField.java

index 1196891014d94b0bba836d6c14a4f0d93f4cd53d..d2067b32ffc00194663e541e855b5c8bc22a850d 100644 (file)
@@ -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();
+
         }
     }
 
index 08182b715510d91a20c04a36303bed7b35d748a6..76bd1822c04798dd235daca6b0c5d21d9e8c0a6e 100644 (file)
@@ -3,7 +3,7 @@ package com.itmill.toolkit.terminal.gwt.server;
 import java.util.Map;\r
 \r
 import com.itmill.toolkit.ui.Component;\r
-import com.itmill.toolkit.ui.AbstractField.ComponentErrorEvent;\r
+import com.itmill.toolkit.ui.AbstractComponent.ComponentErrorEvent;\r
 \r
 public class ChangeVariablesErrorEvent implements ComponentErrorEvent {\r
 \r
index 83502aa40c85e39876b4bce6482c88a064339203..634f58dbac512df5b0c2bbe0da2648f54f54fc87 100644 (file)
@@ -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
index 70b17ad41aa5658f016965090690e6487f4fec7a..98a001dd5752672a971b33d77ac5282954dec4a0 100644 (file)
@@ -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;
 
 /**
  * <p>
@@ -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