Subversion Repositories eFlore/Applications.coel

Rev

Rev 1780 | Rev 1802 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client;

import com.extjs.gxt.ui.client.GXT;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;

public class Coel implements EntryPoint {

        public void onModuleLoad() {
                
                // A décommenter + compiler en detailed dans le cas d'une erreur
                // survernant uniquement sur le serveur
                /*GWT.setUncaughtExceptionHandler(null);
                GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {    
                        @Override
                        public void onUncaughtException(Throwable e) {
                                        Window.alert("uncaught: " + e.getMessage());
                                        String s = buildStackTrace(e, "RuntimeException:\n");
                                        Window.alert(s);
                                        e.printStackTrace();
                        }
                });*/
                
                // Fermeture du panneau de chargement de l'appli
                GXT.hideLoadingPanel("loading");
                
                // Création du médiateur
                new Mediateur();
                
                // Si activation du mode débug
                if (Mediateur.DEBUG) {
                        System.out.println("");
                        System.out.println("-------------------------------------------------------------------");
                        System.out.println("");
                }
        }
        
        private String buildStackTrace(Throwable t, String log) {
            if (t != null) {
                     log += t.getClass().toString();
                     log += t.getMessage();
                     //
                     StackTraceElement[] stackTrace = t.getStackTrace();
                     if (stackTrace != null) {
                         StringBuffer trace = new StringBuffer();
                    
                             for (int i = 0; i < stackTrace.length; i++) {
                                 trace.append(stackTrace[i].getClassName() + "." + stackTrace[i].getMethodName() + "("
                                                 + stackTrace[i].getFileName() + ":" + stackTrace[i].getLineNumber());
                             }
                    
                             log += trace.toString();
                     }
                     //
                     Throwable cause = t.getCause();
                     if (cause != null && cause != t) {
                         log += buildStackTrace(cause, "CausedBy:\n");
                     }
            }
            return log;
        }

        public static native void  LogVersFirebug(String s) /*-{
                if (!!($wnd.console && $wnd.console.log)) {
                        console.log(s);
                }
        }-*/;
}