Example usage for com.google.gwt.user.client.ui HTMLPanel HTMLPanel

List of usage examples for com.google.gwt.user.client.ui HTMLPanel HTMLPanel

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui HTMLPanel HTMLPanel.

Prototype

private HTMLPanel(Element elem) 

Source Link

Document

Construct a new HTMLPanel with the specified element.

Usage

From source file:net.scran24.user.client.survey.WelcomePage.java

License:Apache License

@Override
public SimpleSurveyStageInterface getInterface(final Callback1<Survey> onComplete,
        Callback2<Survey, Boolean> onIntermediateStateChange) {
    final Button startButton = WidgetFactory.createGreenButton(surveyMessages.welcomePage_ready(),
            new ClickHandler() {
                public void onClick(ClickEvent event) {
                    onComplete.call(initialData.withFlag(FLAG_WELCOME_PAGE_SHOWN));
                }/*ww  w  .  ja v a 2 s .c o m*/
            });

    HTMLPanel tutorialVideo = new HTMLPanel(SafeHtmlUtils.fromSafeConstant(TutorialVideo.embedHTML));

    FlowPanel contents = new FlowPanel();
    contents.getElement().addClassName("intake24-survey-content-container");
    contents.add(tutorialVideo);
    HTMLPanel htmlPanel = new HTMLPanel(SafeHtmlUtils.fromSafeConstant(welcomeHtml));

    contents.add(htmlPanel);
    contents.add(startButton);

    return new SimpleSurveyStageInterface(contents);
}

From source file:net.scran24.user.client.surveyscheme.ucljan15.ConsentPage.java

@Override
public SimpleSurveyStageInterface getInterface(final Callback1<Survey> onComplete,
        Callback2<Survey, Boolean> onIntermediateStateChange) {
    final Button startButton = WidgetFactory
            .createGreenButton("I agree to take part. Continue to part 1 of the survey.", new ClickHandler() {
                public void onClick(ClickEvent event) {
                    onComplete.call(data.withFlag(FLAG_CONSENT_GIVEN));
                }/*from   ww w  .j  a  va 2s  .c o m*/
            });

    HTMLPanel welcomePage = new HTMLPanel(HtmlResources.INSTANCE.getConsentHtml().getText());
    welcomePage.addStyleName("intake24-survey-content-container");

    welcomePage.addAndReplaceElement(startButton, "startButton");

    return new SimpleSurveyStageInterface(welcomePage);
}

From source file:net.scran24.user.client.surveyscheme.ucljan15.WelcomePage.java

@Override
public SimpleSurveyStageInterface getInterface(final Callback1<Survey> onComplete,
        Callback2<Survey, Boolean> onIntermediateStateChange) {
    final Button startButton = WidgetFactory.createGreenButton("Continue to information page",
            new ClickHandler() {
                public void onClick(ClickEvent event) {
                    onComplete.call(initialData.withFlag(FLAG_WELCOME_PAGE_SHOWN));
                }//from  w  w w . j a v a2s  .c o m
            });

    HTMLPanel welcomePage = new HTMLPanel(HtmlResources.INSTANCE.getWelcomeHtml().getText());
    welcomePage.addStyleName("intake24-survey-content-container");

    welcomePage.addAndReplaceElement(startButton, "startButton");

    return new SimpleSurveyStageInterface(welcomePage);
}

From source file:net.scran24.user.client.surveyscheme.UserDataQuestion.java

@Override
public SimpleSurveyStageInterface getInterface(final Callback1<Survey> onComplete,
        Callback2<Survey, Boolean> onIntermediateStateChange) {
    final FlowPanel content = new FlowPanel();
    content.addStyleName("intake24-survey-content-container");

    content.add(new HTMLPanel("<p>Before you continue, please answer a few questions about yourself.</p>"));

    final PVector<String> ageOptions = TreePVector.<String>empty().plus("11").plus("12").plus("13").plus("14")
            .plus("15").plus("16").plus("17").plus("18");

    final PVector<String> genderOptions = TreePVector.<String>empty().plus("Male").plus("Female");

    final RadioButtonQuestion ageBlock = new RadioButtonQuestion(
            SafeHtmlUtils.fromSafeConstant("<p>What age are you?</p>"), ageOptions, "ageGroup",
            Option.<String>none());
    content.add(ageBlock);/*  w w w  .j a v a 2s . com*/
    final RadioButtonQuestion genderBlock = new RadioButtonQuestion(
            SafeHtmlUtils.fromSafeConstant("<p>Are you...</p>"), genderOptions, "genderGroup",
            Option.<String>none());
    content.add(genderBlock);

    final TextBoxQuestion postCode = new TextBoxQuestion(
            SafeHtmlUtils.fromSafeConstant("<p>What is your post code?</p>"));

    content.add(postCode);

    final TextBoxQuestion schoolName = new TextBoxQuestion(
            SafeHtmlUtils.fromSafeConstant("<p>What is the name of the School you go to?</p>"));

    content.add(schoolName);

    final TextBoxQuestion townName = new TextBoxQuestion(
            SafeHtmlUtils.fromSafeConstant("<p>What is the name of your town?</p>"));

    content.add(townName);

    final Button accept = WidgetFactory.createButton("Continue");

    accept.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            Option<String> ageChoice = ageBlock.getChoice();

            if (ageChoice.isEmpty()) {
                ageBlock.showWarning();
                return;
            } else
                ageBlock.clearWarning();

            Option<String> genderChoice = genderBlock.getChoice();

            if (genderChoice.isEmpty()) {
                genderBlock.showWarning();
                return;
            } else
                genderBlock.clearWarning();

            if (postCode.textBox.getText().isEmpty()) {
                postCode.showWarning();
                return;
            } else
                postCode.clearWarning();

            if (schoolName.textBox.getText().isEmpty()) {
                schoolName.showWarning();
                return;
            } else
                schoolName.clearWarning();

            if (townName.textBox.getText().isEmpty()) {
                townName.showWarning();
                return;
            } else
                townName.clearWarning();

            final HashMap<String, String> data = new HashMap<String, String>();
            data.put("age", ageChoice.getOrDie());
            data.put("gender", genderChoice.getOrDie());
            data.put("postCode", postCode.textBox.getText());
            data.put("schoolName", schoolName.textBox.getText());
            data.put("townName", townName.textBox.getText());

            accept.setEnabled(false);

            AsyncRequestAuthHandler.execute(new AsyncRequest<Void>() {
                @Override
                public void execute(AsyncCallback<Void> callback) {
                    userDataService.submit(data, callback);
                }
            }, new AsyncCallback<Void>() {
                @Override
                public void onFailure(Throwable caught) {
                    onComplete.call(state.withFlag(FLAG_SKIP_USERDATA_UPLOAD));
                }

                @Override
                public void onSuccess(Void result) {
                    UserInfo userInfo = CurrentUser.getUserInfo();
                    CurrentUser.setUserInfo(new UserInfo(userInfo.userName, userInfo.surveyId,
                            userInfo.surveyParameters, data));
                    onComplete.call(state);
                }
            });

            userDataService.submit(data, new AsyncCallback<Void>() {
                @Override
                public void onSuccess(Void result) {
                }

                @Override
                public void onFailure(Throwable caught) {
                    Window.alert(caught.getMessage());
                }
            });
        }
    });

    content.add(WidgetFactory.createButtonsPanel(accept));

    return new SimpleSurveyStageInterface(content);
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.kin.KinDocumentGwt.java

License:Open Source License

@Override
public void readDocument(String uri, String templateXml) throws IOException {
    htmlDoc = new HTMLPanel(templateXml);
}

From source file:nl.mpi.tg.eg.experiment.client.view.TimedStimulusView.java

License:Open Source License

@Deprecated
public void addTimedImage(final TimedEventMonitor timedEventMonitor, SafeUri imagePath, int percentOfPage,
        int maxHeight, int maxWidth, final String animateStyle, final Integer fixedPositionY,
        final int postLoadMs, final CancelableStimulusListener shownStimulusListener,
        final CancelableStimulusListener loadedStimulusListener,
        final CancelableStimulusListener failedStimulusListener,
        final CancelableStimulusListener clickedStimulusListener) {
    cancelableListnerList.add(shownStimulusListener);
    cancelableListnerList.add(loadedStimulusListener);
    cancelableListnerList.add(failedStimulusListener);
    cancelableListnerList.add(clickedStimulusListener);
    if (timedEventMonitor != null) {
        timedEventMonitor.registerEvent("addTimedImage");
    }/*from  w w w. j  ava 2  s.c  om*/
    final Image image = new Image(imagePath);
    if (animateStyle != null && !animateStyle.isEmpty()) {
        image.addStyleName(animateStyle);
        if (fixedPositionY != null) {
            image.getElement().getStyle().setLeft(fixedPositionY, Style.Unit.PCT);
        }
    }
    addSizeAttributes(image.getElement(), percentOfPage, maxHeight, maxWidth);
    image.addErrorHandler(new ErrorHandler() {
        @Override
        public void onError(ErrorEvent event) {
            if (timedEventMonitor != null) {
                timedEventMonitor.registerEvent("onError");
            }
            if (failedStimulusListener != null) {
                failedStimulusListener.postLoadTimerFired();
            }
        }
    });
    image.addLoadHandler(new LoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {
            if (timedEventMonitor != null) {
                timedEventMonitor.registerEvent("onLoad");
            }
            if (shownStimulusListener != null) {
                shownStimulusListener.postLoadTimerFired();
            }
            Timer timer = new Timer() {
                @Override
                public void run() {
                    loadedStimulusListener.postLoadTimerFired();
                }
            };
            timerList.add(timer);
            timer.schedule(postLoadMs);
        }
    });
    if (clickedStimulusListener != null) {
        final SingleShotEventListner singleShotEventListner = new SingleShotEventListner() {

            @Override
            protected void singleShotFired() {
                clickedStimulusListener.postLoadTimerFired();
                resetSingleShot();
            }
        };
        image.addClickHandler(singleShotEventListner);
        image.addTouchStartHandler(singleShotEventListner);
        image.addTouchMoveHandler(singleShotEventListner);
        image.addTouchEndHandler(singleShotEventListner);
    }
    final HTMLPanel htmlPanel = new HTMLPanel("");
    htmlPanel.setStylePrimaryName("gridCell");
    htmlPanel.add(image);
    getActivePanel().add(htmlPanel);
}

From source file:nl.mpi.tg.eg.experiment.client.view.TimedStimulusView.java

License:Open Source License

public void addSvgImage(String svgContent, int percentWidth) {
    final HTMLPanel htmlPanel = new HTMLPanel(svgContent);
    htmlPanel.setWidth(percentWidth + "%");
    getActivePanel().add(htmlPanel);/*from  www  . j a v  a2  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//from ww  w. ja  v  a  2 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 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/* w  ww .  j  a  va2 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//from ww w.  ja v a  2 s  .  c om
        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);
                }
            }
        }
    });

}