# HG changeset patch # User Ingo Weinzierl # Date 1308820974 0 # Node ID 9e30c776cbef815bb940ed61b239ffa8bb405d46 # Parent 84d3c5fde5bb8b0bd48bae1f7995e396bd3f7298 Improved the exception handling. flys-client/trunk@2212 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 84d3c5fde5bb -r 9e30c776cbef flys-client/ChangeLog --- a/flys-client/ChangeLog Thu Jun 23 09:11:54 2011 +0000 +++ b/flys-client/ChangeLog Thu Jun 23 09:22:54 2011 +0000 @@ -1,3 +1,16 @@ +2011-06-23 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants.java: + Added more i18n strings for the project list and error messages. + + * src/main/java/de/intevation/flys/client/client/FLYS.java: Added a + handler that catches uncaught exceptions. Those exceptions are displayed + using a new method showWarning(Throwable t). This method brings up a + Window that displays the stacktrace of the exceptions. + 2011-06-23 Sascha L. Teichmann * pom.xml: Added dependency to Apache Commons Lang 2.6 http://commons.apache.org/lang/ diff -r 84d3c5fde5bb -r 9e30c776cbef flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Thu Jun 23 09:11:54 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java Thu Jun 23 09:22:54 2011 +0000 @@ -2,14 +2,18 @@ import java.util.ArrayList; import java.util.List; +import java.util.Set; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.shared.UmbrellaException; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.xml.client.XMLParser; import com.smartgwt.client.util.SC; +import com.smartgwt.client.widgets.Window; +import com.smartgwt.client.widgets.HTMLPane; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.events.CloseClickHandler; @@ -100,6 +104,12 @@ public void onModuleLoad() { openProjects = new ArrayList(); + GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { + public void onUncaughtException(Throwable e) { + showWarning(e); + } + }); + VLayout vertical = new VLayout(); vertical.setLayoutMargin(1); vertical.setWidth100(); @@ -153,6 +163,40 @@ } + public void showWarning(Throwable e) { + StringBuilder sb = new StringBuilder(); + sb.append(""); + + if (e instanceof UmbrellaException) { + UmbrellaException u = (UmbrellaException) e; + Set throwables = u.getCauses(); + + for (Throwable t: throwables) { + sb.append(t.getLocalizedMessage()); + sb.append("
"); + } + } + else { + sb.append(e.getLocalizedMessage()); + } + + sb.append("
"); + + Window w = new Window(); + w.setTitle(MSG.unexpected_exception()); + w.setWidth(550); + w.setHeight(300); + w.centerInPage(); + w.setCanDragResize(true); + + HTMLPane p = new HTMLPane(); + p.setContents(sb.toString()); + + w.addItem(p); + w.show(); + } + + /** * This method should be called at system start. It initialzes the client * configuration. diff -r 84d3c5fde5bb -r 9e30c776cbef flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Jun 23 09:11:54 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Thu Jun 23 09:22:54 2011 +0000 @@ -8,6 +8,8 @@ */ public interface FLYSConstants extends ConstantsWithLookup { + String unexpected_exception(); + String title(); String fullname(); @@ -26,6 +28,18 @@ String manage_projects(); + String favorite_tooltip(); + + String favorite_tooltip_meaning(); + + String projectlist_creationTime(); + + String projectlist_title(); + + String projectlist_favorite(); + + String really_delete(); + String logout(); String switch_language(); diff -r 84d3c5fde5bb -r 9e30c776cbef flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Jun 23 09:11:54 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Thu Jun 23 09:22:54 2011 +0000 @@ -8,6 +8,12 @@ delete_project = Delete Project rename_project = Rename Project manage_projects = Manage Projects +favorite_tooltip = Permanently store? +favorite_tooltip_meaning = Golden star: stored +projectlist_creationTime = Creation time +projectlist_title = Title +projectlist_favorite = Permanent +really_delete = Do you really want to delete this project? switch_language = German info = Info warning = Attention @@ -100,6 +106,7 @@ wst = WST chart_themepanel_header_themes = Theme +unexpected_exception = There occured an unexpected exception error_read_minmax_values = Error while reading min/max values for the location input. error_validate_range = The value $1 needs to be smaller than $3 and bigger than $2. error_validate_lower_range = The lower value $1 needs to be bigger than $2. diff -r 84d3c5fde5bb -r 9e30c776cbef flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Jun 23 09:11:54 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Thu Jun 23 09:22:54 2011 +0000 @@ -8,6 +8,12 @@ delete_project = Projekt l\u00f6schen rename_project = Projekt umbenennen manage_projects = Projekte verwalten +favorite_tooltip = Dauerhaft speichern? +favorite_tooltip_meaning = Goldener Stern: gespeichert +projectlist_creationTime = Anlegezeitpunkt +projectlist_title = Titel +projectlist_favorite = Dauerhaft +really_delete = Wollen Sie dieses Projekt wirklich l\u00f6schen? switch_language = Englisch info = Info warning = Achtung @@ -100,6 +106,7 @@ wst = WST chart_themepanel_header_themes = Thema +unexpected_exception = Ein unerwarteter Fehler ist aufgetreten error_read_minmax_values = Fehler beim Lesen der min/max Werte. Es kann keine Validierung der eingegebenen Strecke durchgef\u00fchrt werden. error_validate_range = Der Wert $1 muss kleiner als $3 und gr\u00f6\u00dfer als $2 sein. error_validate_lower_range = Der untere Wert $1 muss gr\u00f6\u00dfer sein als $2. diff -r 84d3c5fde5bb -r 9e30c776cbef flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu Jun 23 09:11:54 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Thu Jun 23 09:22:54 2011 +0000 @@ -8,6 +8,12 @@ delete_project = Delete Project rename_project = Rename Project manage_projects = Manage Projects +favorite_tooltip = Permanently store? +favorite_tooltip_meaning = Golden star: stored +projectlist_creationTime = Creation time +projectlist_title = Title +projectlist_favorite = Permanent +really_delete = Do you really want to delete this project? switch_language = German info = Info warning = Attention @@ -98,6 +104,7 @@ wst = WST chart_themepanel_header_themes = Theme +unexpected_exception = There occured an unexpected exception error_read_minmax_values = Error while reading min/max values for the location input. error_validate_range = The value $1 needs to be smaller than $3 and bigger than $2. error_validate_lower_range = The lower value $1 needs to be bigger than $2.