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.common.client.WidgetFactory.java

License:Apache License

public static FlowPanel createPromptPanel(SafeHtml promptText) {
    FlowPanel result = new FlowPanel();
    HTMLPanel promptPanel = new HTMLPanel(promptText);
    promptPanel.addStyleName("intake24-prompt-text");
    result.add(promptPanel);/*from www  .  ja va2s .c om*/
    return result;
}

From source file:net.scran24.common.client.WidgetFactory.java

License:Apache License

public static Panel createLoadingPanelText(SafeHtml text) {
    HTMLPanel result = new HTMLPanel(text);
    result.addStyleName("intake24-loading-panel-text");
    return result;
}

From source file:net.scran24.common.client.WidgetFactory.java

License:Apache License

public static Panel createFoodPlaceholder(SafeHtml text) {
    HTMLPanel result = new HTMLPanel(text);
    result.addStyleName("scran24-food-list-text");
    return result;
}

From source file:net.scran24.common.client.WidgetFactory.java

License:Apache License

public static Panel createDefaultErrorMessage() {
    FlowPanel result = new FlowPanel();
    result.add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant(messages.serverError())));
    return result;
}

From source file:net.scran24.frontpage.client.FrontPage.java

License:Apache License

public void onModuleLoad() {
    if (Location.getParameter("genUser") != null) {
        genUserService.autoCreateUser(EmbeddedData.surveyId(), new AsyncCallback<UserRecord>() {
            @Override/*from  w ww. j av a2  s . co  m*/
            public void onSuccess(final UserRecord userRecord) {
                loginService.login(EmbeddedData.surveyId(), userRecord.username, userRecord.password,
                        new AsyncCallback<UserInfo>() {
                            @Override
                            public void onSuccess(UserInfo arg0) {
                                RootPanel.get("loading").getElement().removeFromParent();

                                final String url = Location.createUrlBuilder().removeParameter("genUser")
                                        .buildString();

                                FlowPanel userInfo = new FlowPanel();
                                userInfo.addStyleName("intake24-user-info-panel");

                                userInfo.add(new HTMLPanel(
                                        SafeHtmlUtils.fromSafeConstant(commonMessages.genUserWelcome())));
                                userInfo.add(new HTMLPanel(
                                        SafeHtmlUtils.fromSafeConstant(commonMessages.genUserSaveInfo())));

                                String surveyUrl = Location.getProtocol() + "//" + Location.getHost()
                                        + Location.getPath().replace("/login/", "/");

                                Grid userInfoTable = new Grid(2, 2);
                                userInfoTable.addStyleName("intake24-user-info-table");

                                userInfoTable.setWidget(0, 0,
                                        new Label(commonMessages.loginForm_userNameLabel()));
                                userInfoTable.setWidget(0, 1, new Label(userRecord.username));
                                userInfoTable.setWidget(1, 0,
                                        new Label(commonMessages.loginForm_passwordLabel()));
                                userInfoTable.setWidget(1, 1, new Label(userRecord.password));

                                userInfo.add(userInfoTable);

                                userInfo.add(new HTMLPanel(
                                        SafeHtmlUtils.fromSafeConstant(commonMessages.genUserSurveyLink())));

                                FlowPanel urlDiv = new FlowPanel();
                                urlDiv.add(new Anchor(surveyUrl, surveyUrl));
                                userInfo.add(urlDiv);

                                userInfo.add(new HTMLPanel(
                                        SafeHtmlUtils.fromSafeConstant(commonMessages.genUserOneSitting())));

                                Button cont = WidgetFactory.createGreenButton(commonMessages.genUserContinue(),
                                        new ClickHandler() {
                                            @Override
                                            public void onClick(ClickEvent event) {
                                                Location.replace(url);
                                            }
                                        });

                                userInfo.add(WidgetFactory.createButtonsPanel(cont));

                                replaceHeader();

                                RootPanel.get("loginForm").add(userInfo);
                            }

                            @Override
                            public void onFailure(Throwable arg0) {
                                RootPanel.get("loading").getElement().removeFromParent();

                                FlowPanel errorPanel = new FlowPanel();
                                errorPanel.addStyleName("intake24-error-panel");

                                errorPanel.add(new HTMLPanel(
                                        SafeHtmlUtils.fromSafeConstant(commonMessages.serverError())));

                                RootPanel.get("loginForm").add(errorPanel);
                            }
                        });
            }

            @Override
            public void onFailure(Throwable arg0) {
                RootPanel.get("loading").getElement().removeFromParent();

                FlowPanel errorPanel = new FlowPanel();
                errorPanel.addStyleName("intake24-error-panel");

                errorPanel.add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant(commonMessages.serverError())));

                RootPanel.get("loginForm").add(errorPanel);
            }
        });
    } else {
        RootPanel.get("loading").getElement().removeFromParent();

        LoginForm login = new LoginForm(new Callback1<UserInfo>() {
            @Override
            public void call(UserInfo info) {
                Location.reload();
            }
        }, SafeHtmlUtils.fromSafeConstant(commonMessages.loginForm_logInToContinue()));

        replaceHeader();
        RootPanel.get("loginForm").add(login);
    }

    initComplete();
}

From source file:net.scran24.staff.client.StaffPage.java

private void showSurveyStatus() {
    content.clear();//from ww  w .j a  v a  2  s  .  c  o  m

    switch (parameters.state) {
    case SUSPENDED:
        content.add(new HTMLPanel("<h1>Survey is suspended</h1>"));
        content.add(new HTMLPanel(
                "<h2>Reason</h2><p>" + SafeHtmlUtils.htmlEscape(parameters.suspensionReason) + "</p>"));

        Button resumeButton = WidgetFactory.createButton("Resume", new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                surveyControl.setParameters(parameters.withState(SurveyState.ACTIVE).withSuspensionReason(""),
                        new AsyncCallback<Void>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                content.clear();
                                content.add(new HTMLPanel("<p>Server error: </p>" + caught.getMessage()));
                            }

                            @Override
                            public void onSuccess(Void result) {
                                Location.reload();
                            }
                        });
            }
        });

        resumeButton.getElement().addClassName("scran24-admin-button");

        content.add(resumeButton);
        break;
    case NOT_INITIALISED:
        content.add(new HTMLPanel("<h1>Survey has not yet been activated</h1>"));
        content.add(new HTMLPanel("<p>Follow the instructions below to activate the survey."));

        FlowPanel initDiv = new FlowPanel();
        content.add(initDiv);

        initStage1(initDiv);
        break;
    case ACTIVE:
        Date now = new Date();

        boolean showSuspend = true;

        if (now.getTime() < parameters.startDate)
            content.add(new HTMLPanel("<h1>Survey is active, but not yet started</h1>"));
        else if (now.getTime() > parameters.endDate) {
            content.add(new HTMLPanel("<h1>Survey is finished</h1>"));
            showSuspend = false;
        } else
            content.add(new HTMLPanel("<h1>Survey is running</h1>"));

        content.add(new HTMLPanel("<h2>Start date (inclusive)</h2>"));
        content.add(new HTMLPanel(
                "<p>" + DateTimeFormat.getFormat("EEE, MMMM d, yyyy").format(new Date(parameters.startDate))
                        + "</p>"));

        content.add(new HTMLPanel("<h2>End date (exclusive)</h2>"));
        content.add(new HTMLPanel("<p>"
                + DateTimeFormat.getFormat("EEE, MMMM d, yyyy").format(new Date(parameters.endDate)) + "</p>"));

        if (showSuspend) {

            content.add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant("<h3>Suspend survey</h3>")));
            content.add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant("<p>Reason for suspension:</p>")));
            final TextBox reason = new TextBox();
            reason.getElement().getStyle().setWidth(600, Unit.PX);

            Button suspend = WidgetFactory.createButton("Suspend", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    if (reason.getText().isEmpty()) {
                        Window.alert("Please give a reason for suspension.");
                    } else {
                        surveyControl.setParameters(parameters.withSuspensionReason(reason.getText())
                                .withState(SurveyState.SUSPENDED), new AsyncCallback<Void>() {
                                    @Override
                                    public void onSuccess(Void result) {
                                        Location.reload();
                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        Window.alert("Server error: " + caught.getMessage());
                                    }
                                });
                    }
                }
            });

            suspend.getElement().addClassName("scran24-admin-button");

            content.add(reason);
            content.add(new HTMLPanel("<p></p>"));
            content.add(suspend);
        }
        break;
    }
}

From source file:net.scran24.staff.client.StaffPage.java

private void downloadData() {
    content.clear();//from www .j  a  v  a2  s .c  om
    content.add(new HTMLPanel("<h1>Download data</h1>"));
    final DownloadData download = new DownloadData();

    switch (parameters.state) {
    case SUSPENDED:
    case ACTIVE:
        download.dateFrom.setValue(new Date(parameters.startDate), true);
        download.dateTo.setValue(new Date(parameters.endDate), true);
        break;
    case NOT_INITIALISED:
        break;
    }
    content.add(download);
}

From source file:net.scran24.staff.client.StaffPage.java

private void updateUsers() {
    content.clear();//from w ww . j  a v a  2  s  . c  om
    content.add(new HTMLPanel("<h2>Upload participant accounts from CSV</h2>"));
    content.add(new HTMLPanel(
            "<p><strong>Note:</strong> participant records from CSV files you upload using this page will be appended to the existing user list, which means that you can only add new accounts or update the passwords and custom fields for existing participants.</p><p>You <strong>cannot delete</strong> participant accounts from this page; if you need to delete existing participants please contact support.</p>"));

    final FlowPanel messageDiv = new FlowPanel();

    List<String> permissions = Arrays.asList(new String[] { "processSurvey:" + surveyId });

    final UserInfoUpload userUpload = new UserInfoUpload(surveyId, "respondent", permissions,
            new Callback1<Option<String>>() {
                @Override
                public void call(Option<String> res) {
                    res.accept(new Option.SideEffectVisitor<String>() {
                        @Override
                        public void visitSome(String error) {
                            messageDiv.clear();
                            messageDiv.getElement().getStyle().setColor("#d00");
                            messageDiv.add(new HTMLPanel(SafeHtmlUtils.fromString(error)));
                        }

                        @Override
                        public void visitNone() {
                            messageDiv.clear();
                            messageDiv.getElement().getStyle().setColor("#0d0");
                            messageDiv.add(new HTMLPanel(
                                    SafeHtmlUtils.fromString("Respondent accounts uploaded successfully")));
                        }
                    });
                }
            });

    content.add(messageDiv);
    content.add(userUpload);
}

From source file:net.scran24.staff.client.StaffPage.java

private void updateSchedule() {
    content.clear();//from w  w w .  j a va 2s  . c om
    content.add(new HTMLPanel("<h1>Update schedule</h1>"));
    HorizontalPanel hpanel = new HorizontalPanel();

    hpanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
    hpanel.setSpacing(10);

    final DatePicker dateFrom = new DatePicker();
    final DatePicker dateTo = new DatePicker();

    final Button update = WidgetFactory.createButton("Update", new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final long twelveHours = 12 * 60 * 60 * 1000;
            final long timeFrom = dateFrom.getValue().getTime() - twelveHours;
            final long timeTo = dateTo.getValue().getTime() + twelveHours;

            surveyControl.getParameters(new AsyncCallback<SurveyParameters>() {
                @Override
                public void onFailure(Throwable caught) {
                    content.clear();
                    content.add(new HTMLPanel("<p>Server error: </p>" + caught.getMessage()));
                }

                @Override
                public void onSuccess(SurveyParameters result) {
                    surveyControl.setParameters(result.withDates(timeFrom, timeTo), new AsyncCallback<Void>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            content.clear();
                            content.add(new HTMLPanel("<p>Server error: </p>" + caught.getMessage()));
                        }

                        @Override
                        public void onSuccess(Void result) {
                            Location.reload();
                        }
                    });
                }
            });
        }
    });

    update.getElement().addClassName("scran24-admin-button");

    dateFrom.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateTo.getValue() != null) {
                update.setEnabled(true);
            }
        }
    });

    dateTo.addValueChangeHandler(new ValueChangeHandler<Date>() {
        @Override
        public void onValueChange(ValueChangeEvent<Date> event) {
            if (event.getValue() != null && dateFrom.getValue() != null) {
                update.setEnabled(true);
            }
        }
    });

    update.setEnabled(false);

    switch (parameters.state) {
    case SUSPENDED:
    case ACTIVE:
        dateFrom.setValue(new Date(parameters.startDate), true);
        dateTo.setValue(new Date(parameters.endDate), true);
        break;
    case NOT_INITIALISED:
        break;
    }

    hpanel.add(new Label("Start date:"));
    hpanel.add(dateFrom);
    hpanel.add(new Label("End date:"));
    hpanel.add(dateTo);

    content.add(hpanel);
    content.add(update);
}

From source file:net.scran24.staff.client.StaffPage.java

@Override
public void onModuleLoad() {
    final Element loading = Document.get().getElementById("loading");
    links = RootPanel.get("navigation-bar");

    RootPanel contentDiv = RootPanel.get("main-content");
    content = new FlowPanel();
    content.addStyleName("intake24-staff-ui-container");
    contentDiv.add(content);//from ww  w  .j ava  2 s .com

    surveyControl.getParameters(new AsyncCallback<SurveyParameters>() {
        @Override
        public void onSuccess(SurveyParameters result) {
            parameters = result;

            final Anchor downloadData = new Anchor("Download data");
            downloadData.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    downloadData();
                }
            });

            final Anchor surveyCtl = new Anchor("Survey control");
            surveyCtl.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    showSurveyStatus();
                }
            });

            final Anchor updateUsers = new Anchor("Create participant accounts");
            updateUsers.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    updateUsers();
                }
            });

            final Anchor updateSchedule = new Anchor("Update schedule");
            updateSchedule.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    updateSchedule();
                }
            });

            links.clear();
            links.add(new NavigationBar(downloadData, surveyCtl, updateUsers, updateSchedule,
                    new Anchor("Log out", "../../../common/logout" + Location.getQueryString())));

            showSurveyStatus();
            loading.removeFromParent();
        }

        @Override
        public void onFailure(Throwable caught) {
            content.clear();
            content.add(new HTMLPanel("<p>Server error</p?" + caught.getMessage()));
            loading.removeFromParent();
        }
    });
}