package ch.asynk.helloworld; import com.vaadin.Application; import com.vaadin.terminal.Terminal; import com.vaadin.terminal.UserError; import com.vaadin.terminal.SystemError; import com.vaadin.terminal.ErrorMessage; import com.vaadin.terminal.VariableOwner; import com.vaadin.terminal.URIHandler; import com.vaadin.terminal.ParameterHandler; import com.vaadin.terminal.gwt.server.ChangeVariablesErrorEvent; import com.vaadin.ui.Window; import com.vaadin.ui.AbstractComponent; public class HelloWorldApp extends Application { private static final long serialVersionUID = 1L; @Override public void init() { setTheme("asynk"); final Window mainWindow = new Window("Hello World Application"); mainWindow.setContent( new MainLayout() ); setMainWindow(mainWindow); setLogoutURL("http://asynk.ch"); } @Override public void terminalError(Terminal.ErrorEvent event) { // Call the default implementation. //super.terminalError(event); // http://dev.vaadin.com/browser/releases/6.6.6/src/com/vaadin/Application.java#L1190 final Throwable t = event.getThrowable(); Object owner = null; if (event instanceof VariableOwner.ErrorEvent) { owner = ((VariableOwner.ErrorEvent) event).getVariableOwner(); } else if (event instanceof URIHandler.ErrorEvent) { owner = ((URIHandler.ErrorEvent) event).getURIHandler(); } else if (event instanceof ParameterHandler.ErrorEvent) { owner = ((ParameterHandler.ErrorEvent) event).getParameterHandler(); } else if (event instanceof ChangeVariablesErrorEvent) { owner = ((ChangeVariablesErrorEvent) event).getComponent(); } if (owner instanceof AbstractComponent) { if (t instanceof ErrorMessage) { ((AbstractComponent) owner).setComponentError((ErrorMessage)t); } else { //((AbstractComponent) owner).setComponentError(new SystemError(t)); ((AbstractComponent) owner).setComponentError(new UserError("User Error!")); } } // Some custom behaviour. if (getMainWindow() != null) { getMainWindow().showNotification("An unchecked exception occured!", event.getThrowable().toString(), Window.Notification.TYPE_ERROR_MESSAGE); } } }