Example usage for com.google.gwt.logging.client HasWidgetsLogHandler HasWidgetsLogHandler

List of usage examples for com.google.gwt.logging.client HasWidgetsLogHandler HasWidgetsLogHandler

Introduction

In this page you can find the example usage for com.google.gwt.logging.client HasWidgetsLogHandler HasWidgetsLogHandler.

Prototype

public HasWidgetsLogHandler(HasWidgets container) 

Source Link

Usage

From source file:client.net.sf.saxon.ce.LogController.java

License:Mozilla Public License

public static void addRequiredLogHanders(LogRecord record) {
    jsLogHandler = new JsLogHandler();
    mainLogger.addHandler(jsLogHandler);
    jsLogHandler.publish(record);/*  w w w  .j a v a 2 s .co m*/

    GenericLogHandler gHandler = new GenericLogHandler();

    // popup & firebug must be disabled using Saxonce.gwt.xml and enabled
    // below - if required
    if (gHandler.isSupported()) {
        mainLogger.addHandler(gHandler);
        gHandler.publish(record);
    } else if (!SaxonceApi.isLogHandlerExternal()) {
        HasWidgets loggingWidget = new LoggingPopup();
        HasWidgetsLogHandler hw = new HasWidgetsLogHandler(loggingWidget);
        mainLogger.addHandler(hw);
        hw.publish(record);
    }
}

From source file:com.google.gwt.sample.logexample.client.CustomLogArea.java

License:Apache License

public CustomLogArea(Logger logger) {
    panel = uiBinder.createAndBindUi(this);

    // An example of adding our own custom logging area.  Since VerticalPanel
    // extends HasWidgets, and handles multiple calls to add(widget) gracefully
    // we simply create a new HasWidgetsLogHandler with it, and add that
    // handler to a logger. In this case, we add it to a particular logger in
    // order to demonstrate how the logger hierarchy works, but adding it to the
    // root logger would be fine. Note that we guard this code with a call to
    // LogConfiguration.loggingIsEnabled(). Although this code will compile out
    // without this check in web mode, the guard will ensure that the handler
    // does not show up in development mode.
    if (LogConfiguration.loggingIsEnabled()) {
        logger.addHandler(new HasWidgetsLogHandler(customLogArea));
    }/* w w  w  .j a  v a  2  s  .c o  m*/
}

From source file:org.atmosphere.samples.client.GwtJerseyDemo.java

License:Apache License

@Override
public void onModuleLoad() {

    GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
        @Override/* w w  w .j a v a2s  .c  o  m*/
        public void onUncaughtException(Throwable e) {
            logger.log(Level.SEVERE, "Uncaught exception", e);
        }
    });

    HorizontalPanel buttons = new HorizontalPanel();
    final TextBox messageInput = new TextBox();
    buttons.add(messageInput);

    Button sendRPC = new Button("send (GWT-RPC)");
    buttons.add(sendRPC);

    RootPanel.get("buttonbar").add(buttons);

    HTMLPanel logPanel = new HTMLPanel("") {
        @Override
        public void add(Widget widget) {
            super.add(widget);
            widget.getElement().scrollIntoView();
        }
    };
    RootPanel.get("logger").add(logPanel);
    Logger.getLogger("").addHandler(new HasWidgetsLogHandler(logPanel));

    RPCSerializer rpc_serializer = GWT.create(RPCSerializer.class);

    AtmosphereRequestConfig jerseyRpcRequestConfig = AtmosphereRequestConfig.create(rpc_serializer);
    jerseyRpcRequestConfig.setUrl(GWT.getHostPageBaseURL() + "atmo/jersey/rpc");
    jerseyRpcRequestConfig.setTransport(AtmosphereRequestConfig.Transport.WEBSOCKET);
    jerseyRpcRequestConfig.setFallbackTransport(AtmosphereRequestConfig.Transport.STREAMING);
    jerseyRpcRequestConfig.setOpenHandler(new AtmosphereOpenHandler() {
        @Override
        public void onOpen(AtmosphereResponse response) {
            logger.info("Jersey RPC Connection opened");
        }
    });
    jerseyRpcRequestConfig.setCloseHandler(new AtmosphereCloseHandler() {
        @Override
        public void onClose(AtmosphereResponse response) {
            logger.info("Jersey RPC Connection closed");
        }
    });
    jerseyRpcRequestConfig.setMessageHandler(new AtmosphereMessageHandler() {
        @Override
        public void onMessage(AtmosphereResponse response) {
            List<RPCEvent> events = response.getMessages();
            for (RPCEvent event : events) {
                logger.info("received message through Jersey RPC: " + event.getData());
            }
        }
    });

    // trackMessageLength is not required but makes the connection more robust, does not seem to work with 
    // unicode characters
    //        rpcRequestConfig.setFlags(Flags.trackMessageLength);
    jerseyRpcRequestConfig.clearFlags(Flags.dropAtmosphereHeaders);

    Atmosphere atmosphere = Atmosphere.create();
    final AtmosphereRequest jerseyRpcRequest = atmosphere.subscribe(jerseyRpcRequestConfig);

    sendRPC.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (messageInput.getText().trim().length() > 0) {
                try {
                    //              service.sendEvent(new Event(messageInput.getText()), callback);
                    RPCEvent myevent = new RPCEvent();
                    myevent.setData(messageInput.getText());
                    jerseyRpcRequest.push(myevent);
                } catch (SerializationException ex) {
                    logger.log(Level.SEVERE, "Failed to serialize message", ex);
                }
            }
        }
    });

}

From source file:org.atmosphere.samples.client.GwtJsonDemo.java

License:Apache License

@Override
public void onModuleLoad() {

    GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
        @Override//from w ww. java  2  s. co m
        public void onUncaughtException(Throwable e) {
            logger.log(Level.SEVERE, "Uncaught exception", e);
        }
    });

    HorizontalPanel buttons = new HorizontalPanel();
    final TextBox messageInput = new TextBox();
    buttons.add(messageInput);

    Button sendJSON = new Button("send (JSON)");
    buttons.add(sendJSON);

    RootPanel.get("buttonbar").add(buttons);

    HTMLPanel logPanel = new HTMLPanel("") {
        @Override
        public void add(Widget widget) {
            super.add(widget);
            widget.getElement().scrollIntoView();
        }
    };
    RootPanel.get("logger").add(logPanel);
    Logger.getLogger("").addHandler(new HasWidgetsLogHandler(logPanel));

    AutoBeanClientSerializer json_serializer = new AutoBeanClientSerializer();
    json_serializer.registerBeanFactory(beanFactory, Event.class);

    // setup JSON Atmosphere connection
    AtmosphereRequestConfig jsonRequestConfig = AtmosphereRequestConfig.create(json_serializer);
    jsonRequestConfig.setUrl(GWT.getModuleBaseURL() + "atmosphere/json");
    jsonRequestConfig.setContentType("application/json; charset=UTF-8");
    jsonRequestConfig.setTransport(AtmosphereRequestConfig.Transport.STREAMING);
    jsonRequestConfig.setFallbackTransport(AtmosphereRequestConfig.Transport.LONG_POLLING);
    jsonRequestConfig.setOpenHandler(new AtmosphereOpenHandler() {
        @Override
        public void onOpen(AtmosphereResponse response) {
            logger.info("JSON Connection opened");
        }
    });
    jsonRequestConfig.setCloseHandler(new AtmosphereCloseHandler() {
        @Override
        public void onClose(AtmosphereResponse response) {
            logger.info("JSON Connection closed");
        }
    });
    jsonRequestConfig.setMessageHandler(new AtmosphereMessageHandler() {
        @Override
        public void onMessage(AtmosphereResponse response) {
            List<Event> events = response.getMessages();
            for (Event event : events) {
                logger.info("received message through JSON: " + event.getData());
            }
        }
    });

    Atmosphere atmosphere = Atmosphere.create();
    final AtmosphereRequest jsonRequest = atmosphere.subscribe(jsonRequestConfig);

    sendJSON.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (messageInput.getText().trim().length() > 0) {
                try {
                    //              service.sendEvent(new Event(messageInput.getText()), callback);
                    Event myevent = beanFactory.create(Event.class).as();
                    myevent.setData(messageInput.getText());
                    jsonRequest.push(myevent);
                } catch (SerializationException ex) {
                    logger.log(Level.SEVERE, "Failed to serialize message", ex);
                }
            }
        }
    });

}

From source file:org.atmosphere.samples.client.GwtRpcDemo.java

License:Apache License

@Override
public void onModuleLoad() {

    GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
        @Override/* w  w  w. ja v a2  s. c  o m*/
        public void onUncaughtException(Throwable e) {
            logger.log(Level.SEVERE, "Uncaught exception", e);
        }
    });

    HorizontalPanel buttons = new HorizontalPanel();
    final TextBox messageInput = new TextBox();
    buttons.add(messageInput);

    Button sendRPC = new Button("send (GWT-RPC)");
    buttons.add(sendRPC);

    RootPanel.get("buttonbar").add(buttons);

    HTMLPanel logPanel = new HTMLPanel("") {
        @Override
        public void add(Widget widget) {
            super.add(widget);
            widget.getElement().scrollIntoView();
        }
    };
    RootPanel.get("logger").add(logPanel);
    Logger.getLogger("").addHandler(new HasWidgetsLogHandler(logPanel));

    RPCSerializer rpc_serializer = GWT.create(RPCSerializer.class);

    AtmosphereRequestConfig rpcRequestConfig = AtmosphereRequestConfig.create(rpc_serializer);
    rpcRequestConfig.setUrl(GWT.getModuleBaseURL() + "atmosphere/rpc");
    rpcRequestConfig.setTransport(AtmosphereRequestConfig.Transport.STREAMING);
    rpcRequestConfig.setFallbackTransport(AtmosphereRequestConfig.Transport.LONG_POLLING);
    rpcRequestConfig.setOpenHandler(new AtmosphereOpenHandler() {
        @Override
        public void onOpen(AtmosphereResponse response) {
            logger.info("RPC Connection opened");
        }
    });
    rpcRequestConfig.setReopenHandler(new AtmosphereReopenHandler() {
        @Override
        public void onReopen(AtmosphereResponse response) {
            logger.info("RPC Connection reopened");
        }
    });
    rpcRequestConfig.setCloseHandler(new AtmosphereCloseHandler() {
        @Override
        public void onClose(AtmosphereResponse response) {
            logger.info("RPC Connection closed");
        }
    });
    rpcRequestConfig.setMessageHandler(new AtmosphereMessageHandler() {
        @Override
        public void onMessage(AtmosphereResponse response) {
            List<BaseEvent> messages = response.getMessages();
            for (BaseEvent event : messages) {
                logger.info("received message through RPC: " + event.toString());
                messageInput.setText(event.toString());
            }
        }
    });

    // trackMessageLength is not required but makes the connection more
    // robust, does not seem to work with
    // unicode characters
    // rpcRequestConfig.setFlags(Flags.trackMessageLength);

    Atmosphere atmosphere = Atmosphere.create();
    final AtmosphereRequest rpcRequest = atmosphere.subscribe(rpcRequestConfig);

    sendRPC.addClickHandler(new ClickHandler() {
        private boolean bToogle = false;

        @Override
        public void onClick(ClickEvent event) {
            if (messageInput.getText().trim().length() > 0) {
                try {
                    if (bToogle) {
                        EventFoo myevent2 = new EventFoo();
                        myevent2.setData1(messageInput.getText());
                        myevent2.setData2(messageInput.getText());
                        rpcRequest.push(myevent2);
                        bToogle = false;

                    } else {
                        EventBar myevent2 = new EventBar();
                        myevent2.setData1(messageInput.getText());
                        myevent2.setData2(messageInput.getText());
                        rpcRequest.push(myevent2);
                        bToogle = true;

                    }
                } catch (SerializationException ex) {
                    logger.log(Level.SEVERE, "Failed to serialize message", ex);
                }
            }
        }
    });

}

From source file:org.eclipse.kura.web.client.ui.EntryClassUi.java

License:Open Source License

public EntryClassUi() {
    logger.log(Level.FINER, "Initiating UiBinder");
    this.ui = this;
    initWidget(uiBinder.createAndBindUi(this));

    // TODO : standardize the URL?
    // header.setUrl("eclipse/kura/icons/kura_logo_small.png");
    this.header.setStyleName("headerLogo");
    Date now = new Date();
    @SuppressWarnings("deprecation")
    int year = now.getYear() + 1900;
    this.footerLeft.setText(MSGS.copyright(String.valueOf(year)));
    this.footerLeft.setStyleName("copyright");
    this.contentPanel.setVisible(false);

    // Set client side logging
    errorLogger.addHandler(new HasWidgetsLogHandler(this.errorLogArea));
    this.errorPopup.addHideHandler(new ModalHideHandler() {

        @Override/*from  w w w  .  j  ava  2s.co  m*/
        public void onHide(ModalHideEvent evt) {
            EntryClassUi.this.errorLogArea.clear();
        }
    });

    //
    dragDropInit(this);

    FailureHandler.setPopup(this.errorPopup);
}