comparison flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java @ 605:9e30c776cbef

Improved the exception handling. flys-client/trunk@2212 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 23 Jun 2011 09:22:54 +0000
parents 347cf4a5a486
children 854312c0528c
comparison
equal deleted inserted replaced
604:84d3c5fde5bb 605:9e30c776cbef
1 package de.intevation.flys.client.client; 1 package de.intevation.flys.client.client;
2 2
3 import java.util.ArrayList; 3 import java.util.ArrayList;
4 import java.util.List; 4 import java.util.List;
5 import java.util.Set;
5 6
6 import com.google.gwt.core.client.EntryPoint; 7 import com.google.gwt.core.client.EntryPoint;
7 import com.google.gwt.core.client.GWT; 8 import com.google.gwt.core.client.GWT;
9 import com.google.gwt.event.shared.UmbrellaException;
8 import com.google.gwt.user.client.rpc.AsyncCallback; 10 import com.google.gwt.user.client.rpc.AsyncCallback;
9 import com.google.gwt.user.client.ui.RootPanel; 11 import com.google.gwt.user.client.ui.RootPanel;
10 import com.google.gwt.xml.client.XMLParser; 12 import com.google.gwt.xml.client.XMLParser;
11 13
12 import com.smartgwt.client.util.SC; 14 import com.smartgwt.client.util.SC;
15 import com.smartgwt.client.widgets.Window;
16 import com.smartgwt.client.widgets.HTMLPane;
13 import com.smartgwt.client.widgets.layout.VLayout; 17 import com.smartgwt.client.widgets.layout.VLayout;
14 import com.smartgwt.client.widgets.layout.HLayout; 18 import com.smartgwt.client.widgets.layout.HLayout;
15 import com.smartgwt.client.widgets.events.CloseClickHandler; 19 import com.smartgwt.client.widgets.events.CloseClickHandler;
16 import com.smartgwt.client.widgets.events.CloseClientEvent; 20 import com.smartgwt.client.widgets.events.CloseClientEvent;
17 21
98 * This is the entry point method. 102 * This is the entry point method.
99 */ 103 */
100 public void onModuleLoad() { 104 public void onModuleLoad() {
101 openProjects = new ArrayList<String>(); 105 openProjects = new ArrayList<String>();
102 106
107 GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
108 public void onUncaughtException(Throwable e) {
109 showWarning(e);
110 }
111 });
112
103 VLayout vertical = new VLayout(); 113 VLayout vertical = new VLayout();
104 vertical.setLayoutMargin(1); 114 vertical.setLayoutMargin(1);
105 vertical.setWidth100(); 115 vertical.setWidth100();
106 vertical.setHeight100(); 116 vertical.setHeight100();
107 117
148 view.setFLYSWorkspace(workspace); 158 view.setFLYSWorkspace(workspace);
149 159
150 readRivers(); 160 readRivers();
151 } 161 }
152 }); 162 });
163 }
164
165
166 public void showWarning(Throwable e) {
167 StringBuilder sb = new StringBuilder();
168 sb.append("<tt>");
169
170 if (e instanceof UmbrellaException) {
171 UmbrellaException u = (UmbrellaException) e;
172 Set<Throwable> throwables = u.getCauses();
173
174 for (Throwable t: throwables) {
175 sb.append(t.getLocalizedMessage());
176 sb.append("<br>");
177 }
178 }
179 else {
180 sb.append(e.getLocalizedMessage());
181 }
182
183 sb.append("</tt>");
184
185 Window w = new Window();
186 w.setTitle(MSG.unexpected_exception());
187 w.setWidth(550);
188 w.setHeight(300);
189 w.centerInPage();
190 w.setCanDragResize(true);
191
192 HTMLPane p = new HTMLPane();
193 p.setContents(sb.toString());
194
195 w.addItem(p);
196 w.show();
153 } 197 }
154 198
155 199
156 /** 200 /**
157 * This method should be called at system start. It initialzes the client 201 * This method should be called at system start. It initialzes the client

http://dive4elements.wald.intevation.org