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

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

Introduction

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

Prototype

@Override
public void add(Widget widget) 

Source Link

Document

Adds a child widget to the panel.

Usage

From source file:gwt.material.design.client.ui.MaterialInfo.java

License:Apache License

public void showInfo(HTMLPanel panel, ImageResource resource, String message) {
    panel.clear();/*from  www . j av  a  2s .c  o m*/

    HTMLPanel container = new HTMLPanel("");
    container.addStyleName("materialInfo");
    Label label = new Label(message);
    container.add(new Image(resource));
    container.add(label);
    panel.add(container);
}

From source file:it.unibo.cs.v2.client.PrebuiltWizard.java

License:Open Source License

public PrebuiltWizard() {
    super("<h2>Import an existing machine</h2>");
    add(new HTML(
            "<p>Following is a list of machines exported by the other users. The list is ordered by the users' name.</p>"));

    getPrebuiltMachinesProxy.getPrebuiltMachines(new AsyncCallback<HashMap<String, LinkedList<MachineInfo>>>() {

        @Override/*from  www .j  a va 2  s. c o m*/
        public void onSuccess(HashMap<String, LinkedList<MachineInfo>> result) {
            if (result == null) {
                System.err.println("No machines found.");
                return;
            }

            for (String user : result.keySet()) {
                DisclosurePanel userPanel = new DisclosurePanel(
                        user + " exported a total of " + result.get(user).size() + " machines");
                userPanel.setAnimationEnabled(true);
                HTMLPanel userHTMLPanel = new HTMLPanel("");
                userPanel.add(userHTMLPanel);

                for (final MachineInfo m : result.get(user)) {
                    DisclosurePanel machinePanel = new DisclosurePanel(m.getName());
                    Button importButton = new Button("Import this machine");
                    machinePanel.setAnimationEnabled(true);
                    HTMLPanel machineHTMLPanel = new HTMLPanel("");
                    machinePanel.add(machineHTMLPanel);

                    // Fetch the informations about the machine
                    userHTMLPanel.add(machinePanel);
                    machineHTMLPanel.add(new HTML("<b>Short description</b>"));
                    machineHTMLPanel.add(new HTML("&nbsp;" + m.getDescription() + "<br /><br />"));

                    machineHTMLPanel.add(new HTML("<b>Long description</b><br/>"));
                    machineHTMLPanel.add(
                            new HTML("&nbsp;" + m.getLongDescription().replace("<", "&lt;").replace(">", "&gt;")
                                    .replace("\n", "<br />&nbsp;").replace("\\n", "<br />&nbsp;")));

                    machineHTMLPanel.add(new HTML("<b>Storage</b><br />"));
                    machineHTMLPanel.add(new HTML("&nbsp;" + m.getHda() + " (" + m.getHdaSize() + ")<br />"));
                    if (m.isHdbEnabled())
                        machineHTMLPanel
                                .add(new HTML("&nbsp;" + m.getHdb() + " (" + m.getHdbSize() + ")<br />"));
                    machineHTMLPanel.add(new HTML("<br />"));

                    machineHTMLPanel.add(new HTML("<b>Networking</b><br />"));
                    if (m.isVirtuacluster())
                        machineHTMLPanel.add(new HTML("&nbsp;Virtuacluster support is <b>enabled</b>"));
                    else
                        machineHTMLPanel.add(new HTML("&nbsp;Virtuacluster support is <b>disabled</b>"));

                    machineHTMLPanel.add(new HTML("<br />"));
                    machineHTMLPanel.add(importButton);

                    importButton.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            importMachineProxy.importMachine(m, new AsyncCallback<Boolean>() {

                                @Override
                                public void onFailure(Throwable caught) {
                                    clear();
                                    add(new HTML(
                                            "<span style=\"color: red\">" + caught.getMessage() + "</span>"));
                                }

                                @Override
                                public void onSuccess(Boolean result) {
                                    clear();
                                    add(new HTML(
                                            "<span style=\"color: green\">Machine imported successfully. Please note that the process may take a while to complete. "
                                                    + "You'll receive a notification upon completition"));
                                }
                            });
                        }
                    });
                }

                add(userPanel);
                add(new HTML("<br />"));
            }

        }

        @Override
        public void onFailure(Throwable caught) {

        }
    });
}

From source file:net.scran24.user.client.Scran24.java

License:Apache License

public void initPage(final UserInfo userInfo) {
    final RootPanel links = RootPanel.get("navigation-bar");

    Anchor watchTutorial = new Anchor(surveyMessages.navBar_tutorialVideo(), TutorialVideo.url, "_blank");

    Anchor logOut = new Anchor(surveyMessages.navBar_logOut(),
            "../../common/logout" + Location.getQueryString());

    // These divs are no longer used for content, but this code is left here
    // to handle legacy survey files

    Element se = Document.get().getElementById("suspended");
    if (se != null)
        se.removeFromParent();//from ww w . j  a v  a2 s .  c om
    Element ae = Document.get().getElementById("active");
    if (ae != null)
        ae.removeFromParent();
    Element fe = Document.get().getElementById("finished");
    if (fe != null)
        fe.removeFromParent();
    Element ee = Document.get().getElementById("serverError");
    if (ee != null)
        ee.removeFromParent();
    Element fpe = Document.get().getElementById("finalPage");
    if (fpe != null)
        fpe.removeFromParent();

    mainContent = Document.get().getElementById("main-content");
    mainContent.setInnerHTML("");

    HTMLPanel mainContentPanel = HTMLPanel.wrap(mainContent);

    switch (userInfo.surveyParameters.state) {
    case NOT_INITIALISED:
        mainContentPanel
                .add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant(surveyMessages.survey_notInitialised())));
        links.add(new NavigationBar(watchTutorial, logOut));
        break;
    case SUSPENDED:
        mainContentPanel.add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant(surveyMessages
                .survey_suspended(SafeHtmlUtils.htmlEscape(userInfo.surveyParameters.suspensionReason)))));
        links.add(new NavigationBar(watchTutorial, logOut));
        break;
    case ACTIVE:
        Date now = new Date();

        if (now.getTime() > userInfo.surveyParameters.endDate) {
            mainContentPanel
                    .add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant(surveyMessages.survey_finished())));
        } else {
            SurveyInterfaceManager surveyInterfaceManager = new SurveyInterfaceManager(mainContentPanel);

            SurveyScheme scheme = SurveySchemeMap.initScheme(
                    SurveySchemes.schemeForId(userInfo.surveyParameters.schemeName),
                    LocaleInfo.getCurrentLocale().getLocaleName(), surveyInterfaceManager);

            links.add(new NavigationBar(scheme.navBarLinks(), watchTutorial, logOut));

            scheme.showNextPage();
        }
        break;
    }

    RootPanel.get("loading").getElement().removeFromParent();

    initComplete();
}

From source file:net.scran24.user.client.Scran24.java

License:Apache License

public void onModuleLoad() {

    GWT.setUncaughtExceptionHandler(new Intake24UncaughtExceptionHandler());

    // These divs are no longer used for content, but this code is left here
    // to handle legacy survey files

    final Element serverError = Document.get().getElementById("serverError");

    if (serverError != null)
        serverError.removeFromParent();//from   w  w w .j  a  va  2 s .c  o m

    log.info("Fetching user information");

    // This page should not be accessed unless the user is authenticated
    // as a respondent (see net.scran24.common.server.auth.ScranAuthFilter)

    loginService.getUserInfo(new AsyncCallback<Option<UserInfo>>() {
        @Override
        public void onSuccess(Option<UserInfo> result) {
            result.accept(new Option.SideEffectVisitor<UserInfo>() {
                @Override
                public void visitSome(final UserInfo userInfo) {
                    CurrentUser.setUserInfo(userInfo);

                    // Singleton portion size method for weight type-in
                    // Inserted dynamically by client runtime but depends on
                    // server-side configuration parameters (base image url)
                    // so still has to be loaded once

                    FoodLookupPrompt.preloadWeightPortionSizeMethod(new Callback() {
                        @Override
                        public void call() {
                            initPage(userInfo);
                        }
                    }, new Callback() {

                        @Override
                        public void call() {
                            HTMLPanel mainContentPanel = HTMLPanel.wrap(mainContent);
                            mainContentPanel
                                    .add(new HTMLPanel(SafeHtmlUtils.fromString(commonMessages.serverError())));
                        }
                    });

                }

                @Override
                public void visitNone() {
                    // this should never happen as any unauthenticated user
                    // should be
                    // redirected to the log in page, but still may happen
                    // in some weird
                    // case where the authentication token is lost between
                    // the
                    // authentication and opening this page
                    LoginForm.showPopup(new Callback1<UserInfo>() {
                        @Override
                        public void call(final UserInfo userInfo) {
                            initPage(userInfo);
                        }
                    });
                }
            });
        }

        @Override
        public void onFailure(Throwable caught) {
            HTMLPanel mainContentPanel = HTMLPanel.wrap(mainContent);
            mainContentPanel.add(new HTMLPanel(SafeHtmlUtils.fromString(commonMessages.serverError())));

        }
    });
}

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");
    }//w  ww. ja  v  a2s  .  co m
    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:org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.CollectionSummaryTeacherView.java

License:Open Source License

/**
 * This is used to print opened questions data
 * @param result/* w w w .  jav a 2  s .co  m*/
 */
void setOpenendedQuestionsPrintData(ArrayList<UserDataDo> result) {
    try {
        printOpendedData.clear();
        int totalUserCount = collectionMetaData.getUserCount();
        DataTable data = DataTable.create();
        data.addColumn(ColumnType.NUMBER, i18n.GL3259());
        data.addColumn(ColumnType.STRING, i18n.GL0308());
        data.addColumn(ColumnType.STRING, i18n.GL3260());
        data.addColumn(ColumnType.STRING, i18n.GL2084());
        data.addColumn(ColumnType.STRING, i18n.GL3261());
        data.addColumn(ColumnType.STRING, i18n.GL3273());
        data.addRows(result.size());
        if (result.size() != 0) {
            for (int i = 0; i < result.size(); i++) {
                data.setCell(i, 0, result.get(i).getItemSequence(), null, getPropertiesCell());

                //Set Question Title
                Label questionTitle = new Label(AnalyticsUtil
                        .html2text(result.get(i).getTitle() != null ? result.get(i).getTitle() : ""));
                questionTitle.setStyleName(res.css().alignCenterAndBackground());
                questionTitle.addStyleName(res.css().alignLeft());
                data.setValue(i, 1, questionTitle.toString());

                //Set completion
                HTMLPanel completionpnl = new HTMLPanel("");
                Label progressBar = new Label();
                progressBar.setStyleName(res.css().setProgressBar());
                completionpnl.add(progressBar);
                Label incompleteProgressBar = new Label();
                incompleteProgressBar.setStyleName(res.css().setIncorrectProgressBar());
                completionpnl.add(incompleteProgressBar);
                int attemptedCount = result.get(i).getTotalAttemptUserCount();
                float maxAvgVal = ((float) attemptedCount) / ((float) totalUserCount);
                progressBar.getElement().getStyle().setWidth(maxAvgVal * 100, Unit.PX);
                incompleteProgressBar.getElement().getStyle().setWidth((100 - maxAvgVal * 100), Unit.PX);
                Label studentTextlbl = new Label(attemptedCount + "/" + totalUserCount + " Students");
                studentTextlbl.setStyleName(res.css().alignCenterAndBackground());
                studentTextlbl.getElement().getStyle().setWidth(100, Unit.PX);
                completionpnl.add(studentTextlbl);
                data.setValue(i, 2, completionpnl.toString());

                //Set time spent
                data.setValue(i, 3,
                        AnalyticsUtil.getTimeStampLabel(result.get(i).getAvgTimeSpent()).toString());

                //Set reactions
                int reaction = result.get(i).getAvgReaction();
                HTMLPanel reactionpnl = new HTMLPanel("");
                reactionpnl.add(new AnalyticsReactionWidget(reaction));
                Label reactioncount = new Label();
                reactionpnl.add(reactioncount);
                reactioncount.setText(reaction + "/5");
                reactioncount.setStyleName(res.css().alignCenterAndBackground());
                data.setValue(i, 4, reactionpnl.toString());

                //set View response label
                Label viewResponselbl = new Label("");
                viewResponselbl.setStyleName(res.css().viewResponseTextOpended());
                data.setValue(i, 5, viewResponselbl.toString());
            }
        }
        Options options = Options.create();
        options.setAllowHtml(true);
        final Table table = new Table(data, options);
        table.getElement().setId("opendedData");
        printOpendedData.add(table);
        if (result.size() == 0) {
            Label erroeMsg = new Label();
            erroeMsg.setStyleName(res.css().displayMessageTextForOEQuestions());
            erroeMsg.setText(i18n.GL3264());
            printOpendedData.add(erroeMsg);
        }
        //To add OE questions
        opendedQuestionHeading.setText(i18n.GL3266());
        opendedQuestionHeading.getElement().getStyle().setPaddingTop(15, Unit.PX);
        opendedQuestionHeading.getElement().getStyle().setPaddingBottom(20, Unit.PX);
        opendedQuestionHeading.getElement().getStyle().setTextAlign(TextAlign.LEFT);
        printWidget.add(opendedQuestionHeading);
        printWidget.add(printOpendedData);
        printOpendedData.getElement().getStyle().setPaddingBottom(20, Unit.PX);
    } catch (Exception e) {
        AppClientFactory.printSevereLogger(
                "CollectionSummaryTeacherView : setOpenendedQuestionsPrintData : " + e.getMessage());
    }
}

From source file:org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.CollectionSummaryTeacherView.java

License:Open Source License

/**
 * This method is used to set opended question data.
 * @param result/*from  w ww  .  j  a v a  2  s  .  c o  m*/
 */
void setOpenendedQuestionsData(ArrayList<UserDataDo> result) {

    int totalUserCount = collectionMetaData.getUserCount();
    DataTable data = DataTable.create();
    data.addColumn(ColumnType.NUMBER, i18n.GL3259());
    data.addColumn(ColumnType.STRING, i18n.GL0308());
    data.addColumn(ColumnType.STRING, i18n.GL3260());
    data.addColumn(ColumnType.STRING, i18n.GL2084());
    data.addColumn(ColumnType.STRING, i18n.GL3261());
    data.addColumn(ColumnType.STRING, i18n.GL3273());
    data.addRows(result.size());
    if (result.size() != 0) {

        for (int i = 0; i < result.size(); i++) {
            data.setCell(i, 0, result.get(i).getItemSequence(), null, getPropertiesCell());

            //Set Question Title
            Label questionTitle = new Label(AnalyticsUtil.html2text(result.get(i).getTitle()));
            questionTitle.setStyleName(res.css().alignCenterAndBackground());
            questionTitle.addStyleName(res.css().alignLeft());
            data.setValue(i, 1, questionTitle.toString());

            //Set completion
            HTMLPanel completionpnl = new HTMLPanel("");
            Label progressBar = new Label();
            progressBar.setStyleName(res.css().setProgressBar());
            completionpnl.add(progressBar);
            Label incompleteProgressBar = new Label();
            incompleteProgressBar.setStyleName(res.css().setIncorrectProgressBar());
            completionpnl.add(incompleteProgressBar);
            int attemptedCount = result.get(i).getTotalAttemptUserCount();
            float maxAvgVal = ((float) attemptedCount) / ((float) totalUserCount);
            progressBar.getElement().getStyle().setWidth(maxAvgVal * 100, Unit.PX);
            incompleteProgressBar.getElement().getStyle().setWidth((100 - maxAvgVal * 100), Unit.PX);
            Label studentTextlbl = new Label(attemptedCount + "/" + totalUserCount + " Students");
            studentTextlbl.setStyleName(res.css().alignCenterAndBackground());
            studentTextlbl.getElement().getStyle().setWidth(100, Unit.PX);
            completionpnl.add(studentTextlbl);
            data.setValue(i, 2, completionpnl.toString());

            //Set time spent
            data.setValue(i, 3, AnalyticsUtil.getTimeStampLabel(result.get(i).getAvgTimeSpent()).toString());

            //Set reactions
            int reaction = result.get(i).getAvgReaction();
            HTMLPanel reactionpnl = new HTMLPanel("");
            reactionpnl.add(new AnalyticsReactionWidget(reaction));
            Label reactioncount = new Label();
            reactionpnl.add(reactioncount);
            reactioncount.setText(reaction + "/5");
            reactioncount.setStyleName(res.css().alignCenterAndBackground());
            data.setValue(i, 4, reactionpnl.toString());

            //set View response label
            Label viewResponselbl = new Label(i18n.GL2286());
            viewResponselbl.setStyleName(res.css().viewResponseTextOpended());
            viewResponselbl.getElement().setAttribute("resourceGooruId", result.get(i).getResourceGooruOId());
            viewResponselbl.getElement().setAttribute("questionType", result.get(i).getType());
            viewResponselbl.getElement().setAttribute("labelType", "View Response");
            data.setValue(i, 5, viewResponselbl.toString());
        }
    }
    Options options = Options.create();
    options.setAllowHtml(true);
    final Table table = new Table(data, options);
    table.getElement().setId("opendedData");
    teacherOpenendedData.add(table);
    if (result.size() == 0) {
        Label erroeMsg = new Label();
        erroeMsg.setStyleName(res.css().displayMessageTextForOEQuestions());
        erroeMsg.setText(i18n.GL3118());
        teacherOpenendedData.add(erroeMsg);
    }
    table.addDomHandler(new ClickOnTableCell(), ClickEvent.getType());
    table.getElement().getFirstChildElement().getFirstChildElement().getFirstChildElement().getStyle()
            .setProperty("width", "98% !important");
}

From source file:org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.CollectionSummaryTeacherView.java

License:Open Source License

/**
 * This method is used to print collection breakdown data
 * @param result/* w  w  w .  j  a v  a 2  s . c o m*/
 */
void setCollectionBreakDownPrintData(ArrayList<UserDataDo> result) {
    try {
        printResourceData.clear();
        UserDataDo maxAvgValue = Collections.max(result, new Comparator<UserDataDo>() {
            public int compare(UserDataDo o1, UserDataDo o2) {
                Long obj1 = new Long(o1.getTimeSpent());
                Long obj2 = new Long(o2.getTimeSpent());
                return obj1.compareTo(obj2);
            }
        });

        final DataTable data = DataTable.create();
        data.addColumn(ColumnType.NUMBER, i18n.GL3259());
        data.addColumn(ColumnType.STRING, i18n.GL3267());
        data.addColumn(ColumnType.STRING, i18n.GL3182());
        data.addColumn(ColumnType.STRING, i18n.GL3268());
        data.addColumn(ColumnType.STRING, i18n.GL0934());
        data.addColumn(ColumnType.STRING, i18n.GL3261());
        int rowCount = 0, rowVal = 0;
        for (int i = 0; i < result.size(); i++) {
            rowCount = rowCount + 1;
        }
        data.addRows(rowCount);

        for (int i = 0; i < result.size(); i++) {
            data.setCell(rowVal, 0, result.get(i).getItemSequence(), null, getPropertiesCell());
            //set Format
            String resourceCategory = result.get(i).getResourceFormat() != null
                    ? result.get(i).getResourceFormat().trim()
                    : "";
            String categoryStyle = "";
            if (resourceCategory.equalsIgnoreCase("website") || resourceCategory.equalsIgnoreCase("webpage")) {
                resourceCategory = "webpage";
                categoryStyle = res.css().category_new_type_webpage();
            } else if (resourceCategory.equalsIgnoreCase("slide")
                    || resourceCategory.equalsIgnoreCase("image")) {
                resourceCategory = "image";
                categoryStyle = res.css().category_new_type_image();
            } else if (resourceCategory.equalsIgnoreCase("handout")
                    || resourceCategory.equalsIgnoreCase("lesson")
                    || resourceCategory.equalsIgnoreCase("textbook")
                    || resourceCategory.equalsIgnoreCase("text")) {
                resourceCategory = "text";
                categoryStyle = res.css().category_new_type_text();
            } else if (resourceCategory.equalsIgnoreCase("exam")) {
                resourceCategory = "webpage";
                categoryStyle = res.css().category_new_type_webpage();
            } else if (resourceCategory.equalsIgnoreCase("video")) {
                resourceCategory = "video";
                categoryStyle = res.css().category_new_type_video();
            } else if (resourceCategory.equalsIgnoreCase("interactive")) {
                resourceCategory = "webpage";
                categoryStyle = res.css().category_new_type_interactive();
            } else if (resourceCategory.equalsIgnoreCase("audio")) {
                resourceCategory = "audio";
                categoryStyle = res.css().category_new_type_audio();
            } else {
                categoryStyle = res.css().category_new_type_other();
            }
            Label categorylbl = new Label();
            categorylbl.addStyleName(categoryStyle);
            categorylbl.addStyleName(res.css().setMarginAuto());
            data.setValue(rowVal, 1, categorylbl.toString());

            //Set Question Title
            Label questionTitle = new Label(AnalyticsUtil.html2text(result.get(i).getTitle()));
            questionTitle.setStyleName(res.css().alignCenterAndBackground());
            questionTitle.addStyleName(res.css().alignLeft());
            data.setValue(rowVal, 2, questionTitle.toString());

            //Set time spent
            HorizontalPanel timeSpentpnl = new HorizontalPanel();
            timeSpentpnl.add(AnalyticsUtil.getTimeStampLabel(result.get(i).getAvgTimeSpent()));
            Label progressBar = new Label();
            progressBar.setStyleName(res.css().setProgressBar());
            timeSpentpnl.add(progressBar);
            double maxAvgVal = ((double) result.get(i).getAvgTimeSpent())
                    / ((double) maxAvgValue.getTimeSpent());
            progressBar.getElement().getStyle().setWidth(maxAvgVal * 100, Unit.PX);
            data.setValue(rowVal, 3, timeSpentpnl.toString());

            //set Views label
            //HorizontalPanel viewpnl=new HorizontalPanel();
            Label viewlbl = new Label(Integer.toString(result.get(i).getViews()));
            viewlbl.setStyleName(res.css().alignCenterAndBackground());
            /* viewpnl.add(viewlbl);
             Label viewProgressBar=new Label();
             viewProgressBar.setStyleName(res.css().setProgressBar());
             viewpnl.add(viewProgressBar);
             float maxViewVal = ((float) result.get(i).getViews())/((float) maxViews.getViews());
             viewProgressBar.getElement().getStyle().setWidth(maxViewVal*100, Unit.PX);*/
            data.setValue(rowVal, 4, viewlbl.toString());

            //Set reactions
            int reaction = result.get(i).getAvgReaction();
            HTMLPanel reactionpnl = new HTMLPanel("");
            reactionpnl.add(new AnalyticsReactionWidget(reaction));
            Label reactioncount = new Label();
            reactionpnl.add(reactioncount);
            reactioncount.setText(reaction + "/5");
            reactioncount.setStyleName(res.css().alignCenterAndBackground());
            data.setValue(rowVal, 5, reactionpnl.toString());
            rowVal++;
        }
        final Options options = Options.create();
        options.setAllowHtml(true);
        Table table = new Table(data, options);
        printResourceData.add(table);
        printWidget.add(printResourceData);
    } catch (Exception e) {
        AppClientFactory.printSevereLogger(
                "CollectionSummaryTeacherView : setCollectionBreakDownPrintData : " + e.getMessage());
    }
}

From source file:org.ednovo.gooru.client.mvp.analytics.collectionSummaryTeacher.CollectionSummaryTeacherView.java

License:Open Source License

/**
 * This method is used to display collection break down data.
 * @param result//  ww  w  . j  a  va 2s  .  c om
 * @param loadingImage
 */
void setCollectionBreakDown(ArrayList<UserDataDo> result, HTMLPanel loadingImage) {

    final int[] primitivesQuestions = AnalyticsUtil.toIntArray(questionRowIndex);
    final int[] primitivesResources = AnalyticsUtil.toIntArray(resourceRowIndex);

    UserDataDo maxAvgValue = Collections.max(result, new Comparator<UserDataDo>() {
        public int compare(UserDataDo o1, UserDataDo o2) {
            Long obj1 = new Long(o1.getTimeSpent());
            Long obj2 = new Long(o2.getTimeSpent());
            return obj1.compareTo(obj2);
        }
    });

    final DataTable data = DataTable.create();
    data.addColumn(ColumnType.NUMBER, i18n.GL3259());
    data.addColumn(ColumnType.STRING, i18n.GL3267());
    data.addColumn(ColumnType.STRING, i18n.GL3182());
    data.addColumn(ColumnType.STRING, i18n.GL3268());
    data.addColumn(ColumnType.STRING, i18n.GL0934());
    data.addColumn(ColumnType.STRING, i18n.GL3261());
    int rowCount = 0, rowVal = 0;
    for (int i = 0; i < result.size(); i++) {
        rowCount = rowCount + 1;
    }
    data.addRows(rowCount);
    for (int i = 0; i < result.size(); i++) {
        data.setCell(rowVal, 0, result.get(i).getItemSequence(), null, getPropertiesCell());
        //set Format
        String resourceCategory = result.get(i).getResourceFormat() != null
                ? result.get(i).getResourceFormat().trim()
                : "";
        String categoryStyle = "";
        if (resourceCategory.equalsIgnoreCase("website") || resourceCategory.equalsIgnoreCase("webpage")) {
            resourceCategory = "webpage";
            categoryStyle = res.css().category_new_type_webpage();
        } else if (resourceCategory.equalsIgnoreCase("slide") || resourceCategory.equalsIgnoreCase("image")) {
            resourceCategory = "image";
            categoryStyle = res.css().category_new_type_image();
        } else if (resourceCategory.equalsIgnoreCase("handout") || resourceCategory.equalsIgnoreCase("lesson")
                || resourceCategory.equalsIgnoreCase("textbook") || resourceCategory.equalsIgnoreCase("text")) {
            resourceCategory = "text";
            categoryStyle = res.css().category_new_type_text();
        } else if (resourceCategory.equalsIgnoreCase("exam")) {
            resourceCategory = "webpage";
            categoryStyle = res.css().category_new_type_webpage();
        } else if (resourceCategory.equalsIgnoreCase("video")) {
            resourceCategory = "video";
            categoryStyle = res.css().category_new_type_video();
        } else if (resourceCategory.equalsIgnoreCase("interactive")) {
            resourceCategory = "webpage";
            categoryStyle = res.css().category_new_type_interactive();
        } else if (resourceCategory.equalsIgnoreCase("audio")) {
            resourceCategory = "audio";
            categoryStyle = res.css().category_new_type_audio();
        } else {
            categoryStyle = res.css().category_new_type_other();
        }
        Label categorylbl = new Label();
        categorylbl.addStyleName(categoryStyle);
        categorylbl.addStyleName(res.css().setMarginAuto());
        data.setValue(rowVal, 1, categorylbl.toString());

        //Set Question Title
        Label questionTitle = new Label(
                AnalyticsUtil.html2text(result.get(i).getTitle() != null ? result.get(i).getTitle() : ""));
        questionTitle.setStyleName(res.css().alignCenterAndBackground());
        questionTitle.addStyleName(res.css().alignLeft());
        data.setValue(rowVal, 2, questionTitle.toString());

        //Set time spent
        HorizontalPanel timeSpentpnl = new HorizontalPanel();
        timeSpentpnl.add(AnalyticsUtil.getTimeStampLabel(result.get(i).getAvgTimeSpent()));
        Label progressBar = new Label();
        progressBar.setStyleName(res.css().setProgressBar());
        timeSpentpnl.add(progressBar);
        double maxAvgVal = ((double) result.get(i).getAvgTimeSpent()) / ((double) maxAvgValue.getTimeSpent());
        progressBar.getElement().getStyle().setWidth(maxAvgVal * 100, Unit.PX);
        data.setValue(rowVal, 3, timeSpentpnl.toString());

        //set Views label
        Label viewlbl = new Label(Integer.toString(result.get(i).getViews()));
        viewlbl.setStyleName(res.css().alignCenterAndBackground());

        data.setValue(rowVal, 4, viewlbl.toString());

        //Set reactions
        int reaction = result.get(i).getAvgReaction();
        HTMLPanel reactionpnl = new HTMLPanel("");
        reactionpnl.add(new AnalyticsReactionWidget(reaction));
        Label reactioncount = new Label();
        reactionpnl.add(reactioncount);
        reactioncount.setText(reaction + "/5");
        reactioncount.setStyleName(res.css().alignCenterAndBackground());
        data.setValue(rowVal, 5, reactionpnl.toString());
        rowVal++;
    }
    final Options options = Options.create();
    options.setAllowHtml(true);
    Table table = new Table(data, options);
    table.getElement().setId("collectionBreakDown");
    teacherResourceBreakdownData.add(table);
    table.getElement().getFirstChildElement().getFirstChildElement().getFirstChildElement().getStyle()
            .setProperty("width", "98% !important");
    filterDropDown.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            teacherResourceBreakdownData.clear();
            int selectedIndex = filterDropDown.getSelectedIndex();
            operationsView = DataView.create(data);
            Table table = new Table(operationsView, options);
            table.setStyleName("collectionProgressTable");
            table.getElement().setId("collectionBreakDown");
            if (selectedIndex == 1) {
                operationsView.hideRows(primitivesResources);
                teacherResourceBreakdownData.add(table);
                if (primitivesQuestions.length == 0) {
                    Label erroeMsg = new Label();
                    erroeMsg.setStyleName(res.css().displayMessageTextForOEQuestions());
                    erroeMsg.setText(i18n.GL3274());
                    teacherResourceBreakdownData.add(erroeMsg);
                }
            } else if (selectedIndex == 2) {
                operationsView.hideRows(primitivesQuestions);
                teacherResourceBreakdownData.add(table);
                if (primitivesResources.length == 0) {
                    Label erroeMsg = new Label();
                    erroeMsg.setStyleName(res.css().displayMessageTextForOEQuestions());
                    erroeMsg.setText(i18n.GL3275());
                    teacherResourceBreakdownData.add(erroeMsg);
                }
            } else {
                teacherResourceBreakdownData.add(table);
            }
            table.addDomHandler(new ClickOnTableCell(), ClickEvent.getType());
        }
    });
    loadingImage.setVisible(false);

}

From source file:org.ednovo.gooru.client.mvp.assessments.play.collection.end.study.AssessmentsHomeMetadataView.java

License:Open Source License

public void setReplyLink() {
    Anchor resourceAnchor = new Anchor();
    resourceAnchor.setHref(getReplayLink());
    resourceAnchor.setStyleName("");
    HTMLPanel collectionHTMLPanel = new HTMLPanel("");
    resourceAnchor.addClickHandler(new ReplayCollectionEvent());
    collectionHTMLPanel.setStyleName(PlayerBundle.INSTANCE.getPlayerStyle().collectionreplay());
    Label collectionReplayButton = new Label(i18n.GL0632());
    collectionReplayButton.setStyleName(PlayerBundle.INSTANCE.getPlayerStyle().collectionreplayText());
    collectionHTMLPanel.add(collectionReplayButton);
    resourceAnchor.getElement().appendChild(collectionHTMLPanel.getElement());
}