Example usage for com.google.gwt.user.client.ui Label addClickHandler

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

Introduction

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

Prototype

public HandlerRegistration addClickHandler(ClickHandler handler) 

Source Link

Usage

From source file:org.sonar.plugins.design.ui.page.client.DependencyInfo.java

License:Open Source License

private Label createLink(final long resourceId, final String resourceName) {
    Label link = new Label(resourceName);
    link.setStyleName("link");
    link.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            Links.openResourcePopup(String.valueOf(resourceId));
        }//from  w  ww .j  a va  2s  .c  o  m
    });
    return link;
}

From source file:org.sonar.plugins.design.ui.page.client.DependencyInfo.java

License:Open Source License

private Widget createNewWindowLink() {
    Label popup = new Label(Dictionary.getDictionary("l10n").get("newWindow"));
    popup.setStyleName("newwindow");
    popup.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            popup();/*from  w w w . j  a va2 s .  c om*/
        }
    });
    return popup;
}

From source file:org.sonar.plugins.design.ui.page.client.Dsm.java

License:Open Source License

private Label createDiagonalCell(final int row) {
    Label cell;
    cell = buildLabel("-", GRID_CELL_DIAGONAL);
    cell.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent event) {
            onTitleClicked(row);/*from  ww  w . j a v  a2s. c o m*/
        }
    });
    return cell;
}

From source file:org.ssgwt.client.ui.component.TipBar.java

License:Apache License

/**
 * This function will add a single tip item to the tip bar
 * //ww w  . ja v a 2s.  co  m
 * @author Dmitri De Klerk <dmitri.deklerk@a24group.com>
 * @since  9 June 2014
 * 
 * @param tipBarItem - The tip items that needs to be added to the tip bar
 */
public void addTipBarItem(TipItemInterface tipBarItem) {
    tipBarPanel.setVisible(true);

    Label dashLabel = new Label();
    dashLabel.setText("- ");
    dashLabel.setStyleName(resources.tipBarStyle().dashStyle());

    HorizontalPanel horPanel = new HorizontalPanel();
    horPanel.add(dashLabel);

    FlowPanel flowPanel = new FlowPanel();
    final TipItemInterface currentItem = tipBarItem;

    Label label = new Label();
    label.setText(currentItem.getLabel());
    label.setStyleName(resources.tipBarStyle().fontStyle());

    Label actionLabel = new Label();
    actionLabel.setText(currentItem.getActionLabel());
    actionLabel.setStyleName(resources.tipBarStyle().linkStyle());
    actionLabel.addClickHandler(new ClickHandler() {

        /**
         * Will add the callback function for the action label click
         * 
         * @author Dmitri De Klerk <dmitri.deklerk@a24group.com>
         * @since  9 June 2014
         * 
         * @param event - The click event that fires the callback
         */
        public void onClick(ClickEvent event) {
            currentItem.getCallBack().onClickAction();
        }
    });
    flowPanel.add(label);
    flowPanel.add(actionLabel);

    horPanel.add(flowPanel);

    tipBar.add(horPanel);
}

From source file:org.tagaprice.client.desktopView.UIDesktop.java

License:Creative Commons License

private void init() {
    loginPres = new LoginPresenter(_clientFactory);

    vePa1.setWidth("100%");
    vePa1.add(iVePa);/* w  ww  .  j a  v  a2 s .  c om*/

    iVePa.setStyleName("main");
    vePa1.setCellHorizontalAlignment(iVePa, HorizontalPanel.ALIGN_CENTER);

    //infobox
    _infoBox.setWidth("100%");
    _infoBox.getElement().getStyle().setZIndex(2000);

    //menu
    //menu.setSize("100%", "30px");
    menu.setStyleName("header");
    menu.setWidth("100%");
    iVePa.add(menu);
    //vePa1.setCellHorizontalAlignment(menu, HorizontalPanel.ALIGN_CENTER);

    // Logo
    Image logo = new Image("logo.png");
    logo.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            _clientFactory.getPlaceController().goTo(new StartPlace());
        }
    });

    logo.setStyleName("logo");

    menu.add(logo);
    menu.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
    menu.setCellWidth(logo, "1%");

    //SearchText
    Label searchLink = new Label("Search");
    searchLink.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            _clientFactory.getPlaceController().goTo(new SearchPlace());

        }
    });
    searchLink.setStyleName("login");
    menu.add(searchLink);

    //empty
    SimplePanel empty = new SimplePanel();
    empty.setWidth("100%");
    menu.add(empty);
    menu.setCellWidth(empty, "100%");

    //final Label add Receipt
    final Label addReceipt = new Label("add Receipt");
    addReceipt.setStyleName("login");
    menu.add(addReceipt);
    menu.setCellHorizontalAlignment(addReceipt, HorizontalPanel.ALIGN_RIGHT);
    menu.setCellWidth(addReceipt, "1%");
    addReceipt.setVisible(false);
    addReceipt.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            _clientFactory.getPlaceController().goTo(new CreateReceiptPlace());
        }
    });

    //invite me
    final Label inviteMe = new Label("Request Invitation");
    inviteMe.setStyleName("menuInviteButton");
    menu.add(inviteMe);
    inviteMe.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            _clientFactory.getEventBus().fireEvent(new DisplayLoginEvent(LoginType.invite));
        }
    });

    //login
    final Label login = new Label("Sign in");
    login.setStyleName("login");
    //Button login = new Button("Sign in");
    //$(login).as(gwtquery.plugins.ui.Ui.Ui).button(gwtquery.plugins.ui.widgets.Button.Options.create().icons(gwtquery.plugins.ui.widgets.Button.Icons.create().secondary("ui-icon-triangle-1-s"))); //
    menu.add(login);
    menu.setCellHorizontalAlignment(login, HorizontalPanel.ALIGN_RIGHT);
    menu.setCellWidth(login, "1%");

    //create poptup
    Image close = new Image("desktopView/close_cross.png");
    close.setStyleName("loginPop-close");
    close.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            loginPop.hide();
        }
    });
    AbsolutePanel aPop = new AbsolutePanel();
    loginPres.setLoginView();
    aPop.add(loginPres.getView());
    aPop.add(close);
    aPop.setWidgetPosition(close, 0, 0);
    loginPop.setWidget(aPop);
    loginPop.getElement().getStyle().setZIndex(2000);
    loginPop.setGlassEnabled(true);
    loginPop.setAnimationEnabled(true);
    loginPop.setGlassStyleName("loginPopGlass");

    login.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            if (_clientFactory.getAccountPersistor().isLoggedIn()) {
                _clientFactory.getPlaceController().goTo(new ListReceiptsPlace());
            } else {

                //loginPop.showRelativeTo(login);   
                _clientFactory.getEventBus().fireEvent(new DisplayLoginEvent(LoginType.login));
            }

        }
    });

    _clientFactory.getEventBus().addHandler(LoginChangeEvent.TYPE, new LoginChangeEventHandler() {

        @Override
        public void onLoginChange(LoginChangeEvent event) {
            if (_clientFactory.getAccountPersistor().isLoggedIn()) {
                login.setText("Dashboard");
                addReceipt.setVisible(true);
                inviteMe.setVisible(false);
            } else {
                login.setText("Sign in");
                addReceipt.setVisible(false);
                inviteMe.setVisible(true);
            }

        }
    });

    //center
    center.setStyleName("center");
    center.setWidth("100%");
    iVePa.add(center);
    //vePa1.setCellHorizontalAlignment(center, VerticalPanel.ALIGN_CENTER);

    //center.setHeight((Window.getClientHeight()-240-120)+"px");
    //vePa1.setCellHeight(center, "100%");

    //bottom
    bottom.setStyleName("bottom");
    vePa1.add(bottom);

    //bottom Text
    HorizontalPanel bottomText = new HorizontalPanel();
    bottomText.setStyleName("bottom-text");
    HTML lefthtml = new HTML("" + "<h2>Licence</h2> "
            + "<a href=\"http://creativecommons.org/licenses/by-sa/3.0/\">Creative Commons Attribution-ShareAlike 3.0 Unported License</a> <br /> "
            + "<a href=\"http://www.gnu.org/licenses/agpl.html\">AGPLv3</a> " + "<h2>Blog</h2> "
            + "<a href=\"http://blog.tagaprice.org/\">blog.tagaprice.org</a> " + "<h2>Development</h2> "
            + "<a href=\"http://github.com/tagaprice\">api.tagaprice.org</a> <br /> "
            + "<a href=\"http://github.com/tagaprice\">http://github.com/tagaprice</a>");
    HTML righthtml = new HTML("" + "<h2>Email</h2> " + "team[at]tagaprice[dot]org " + "<h2>Twitter</h2> "
            + "<a href=\"http://twitter.com/tagaprice\">@tagaprice</a>");

    HTML labels = new HTML("" + "<h2>Labels</h2> "
            + "<a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"><img alt=\"Creative Commons License\" style=\"border-width:0\" src=\"desktopView/cc.png\" /></a>"
            + "<br /><br /><a rel=\"license\" href=\"http://www.gnu.org/licenses/agpl.html\"><img alt=\"GNU Affero General Public License\" style=\"border-width:0\" src=\"desktopView/agplv3.png\" /></a>"
            + "<br /><br /><a href=\"http://www.w3.org/html/logo/\"><img src=\"desktopView/html5.png\" alt=\"HTML5 Powered with CSS3 / Styling, Device Access, and Semantics\" title=\"HTML5 Powered with CSS3 / Styling, Device Access, and Semantics\"></a>");

    bottomText.add(lefthtml);
    bottomText.add(righthtml);
    bottomText.add(labels);
    bottom.add(bottomText);
    bottom.setCellHorizontalAlignment(bottomText, HorizontalPanel.ALIGN_CENTER);

    //Set Popvisilb

    _clientFactory.getEventBus().addHandler(LoginChangeEvent.TYPE, new LoginChangeEventHandler() {
        @Override
        public void onLoginChange(LoginChangeEvent event) {
            if (event.isLoggedIn())
                loginPop.hide();
        }
    });

    //ShopLogin
    _clientFactory.getEventBus().addHandler(DisplayLoginEvent.TYPE, new DisplayLoginEventHandler() {

        @Override
        public void onDisplayLogin(DisplayLoginEvent event) {
            if (event.getLoginType().equals(LoginType.login)) {
                Log.debug("Pop Login");
                loginPres.setLoginView();

                loginPop.center();
                loginPop.show();
            } else if (event.getLoginType().equals(LoginType.invite)) {
                loginPres.setInviteMeView();
                Log.debug("open invite");

                loginPop.center();
                loginPop.show();
            } else if (event.getLoginType().equals(LoginType.register)) {
                loginPres.setRegisterView(event.getInviteKey());
                Log.debug("open setRegisterView");

                loginPop.center();
                loginPop.show();
            }
        }
    });

    _activityManager.setDisplay(center);

}

From source file:org.unitime.timetable.gwt.client.curricula.CourseCurriculaTable.java

License:Apache License

protected void populate(TreeSet<CurriculumInterface> curricula) {
    // Create header
    int col = 0;//from   w w  w .j av a  2  s  .  c  o  m
    final Label curriculumLabel = new Label(MESSAGES.colCurriculum(), false);
    curriculumLabel.addClickHandler(iMenu);
    iCurricula.setWidget(0, col, curriculumLabel);
    iCurricula.getFlexCellFormatter().setStyleName(0, col, "unitime-ClickableTableHeader");
    iCurricula.getFlexCellFormatter().setWidth(0, col, "150px");
    col++;

    final Label areaLabel = new Label(MESSAGES.colAcademicArea(), false);
    areaLabel.addClickHandler(iMenu);
    iCurricula.setWidget(0, col, areaLabel);
    iCurricula.getFlexCellFormatter().setStyleName(0, col, "unitime-ClickableTableHeader");
    iCurricula.getFlexCellFormatter().setWidth(0, col, "100px");
    col++;

    final Label majorLabel = new Label(MESSAGES.colMajors(), false);
    majorLabel.addClickHandler(iMenu);
    iCurricula.setWidget(0, col, majorLabel);
    iCurricula.getFlexCellFormatter().setStyleName(0, col, "unitime-ClickableTableHeader");
    iCurricula.getFlexCellFormatter().setWidth(0, col, "100px");
    col++;

    for (AcademicClassificationInterface clasf : iClassifications) {
        final Label clasfLabel = new Label(clasf.getCode());
        clasfLabel.addClickHandler(iMenu);
        iCurricula.setWidget(0, col, clasfLabel);
        iCurricula.getFlexCellFormatter().setStyleName(0, col, "unitime-ClickableTableHeader");
        iCurricula.getFlexCellFormatter().setHorizontalAlignment(0, col, HasHorizontalAlignment.ALIGN_RIGHT);
        iCurricula.getFlexCellFormatter().setWidth(0, col, "75px");
        col++;
    }

    final Label totalLabel = new Label(MESSAGES.colTotal(), false);
    totalLabel.addClickHandler(iMenu);
    iCurricula.setWidget(0, col, totalLabel);
    iCurricula.getFlexCellFormatter().setStyleName(0, col, "unitime-ClickableTableHeader");
    iCurricula.getFlexCellFormatter().setHorizontalAlignment(0, col, HasHorizontalAlignment.ALIGN_RIGHT);
    iCurricula.getFlexCellFormatter().setWidth(0, col, "75px");
    col++;

    // Create body
    iCourses.clear();
    iRowClicks.clear();
    iRowClicks.add(null); // for header row
    iRowTypes.clear();
    iRowTypes.add(sRowTypeHeader);
    iRowAreaId.clear();
    iRowAreaId.add(-2l);

    int row = 0;
    List<CurriculumInterface> otherCurricula = new ArrayList<CurriculumInterface>();
    List<CurriculumInterface> lastArea = new ArrayList<CurriculumInterface>();
    iAllAreas.clear();
    iUsed = new boolean[iClassifications.size()];
    for (int i = 0; i < iUsed.length; i++)
        iUsed[i] = false;
    int[][] total = new int[iClassifications.size()][];
    for (int i = 0; i < total.length; i++)
        total[i] = new int[] { 0, 0, 0, 0, 0 };
    int[][] totalThisArea = new int[iClassifications.size()][];
    for (int i = 0; i < totalThisArea.length; i++)
        totalThisArea[i] = new int[] { 0, 0, 0, 0, 0 };

    for (final CurriculumInterface curriculum : curricula) {
        for (CourseInterface course : curriculum.getCourses()) {
            CourseInterface cx = new CourseInterface();
            cx.setId(course.getId());
            cx.setCourseName(course.getCourseName());
            iCourses.add(cx);
        }
        if (curriculum.getId() == null) {
            otherCurricula.add(curriculum);
            continue;
        }

        iAllAreas.add(curriculum.getAcademicArea().getId());
        if (lastArea.isEmpty() || lastArea.get(0).getAcademicArea().equals(curriculum.getAcademicArea())) {
            lastArea.add(curriculum);
        } else if (!lastArea.equals(curriculum.getAcademicArea())) {
            col = 0;
            row++;
            iCurricula.getFlexCellFormatter().setColSpan(row, col, 3);
            //iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_CENTER);
            iCurricula.setWidget(row, col++,
                    new HTML("<i>" + lastArea.get(0).getAcademicArea().getAbbv() + " - "
                            + lastArea.get(0).getAcademicArea().getName() + " (" + lastArea.size() + ")</i>",
                            false));
            int tExp = 0, tLast = 0, tEnrl = 0, tProj = 0, tReq = 0;
            for (int clasfIdx = 0; clasfIdx < iClassifications.size(); clasfIdx++) {
                int exp = totalThisArea[clasfIdx][0];
                int last = totalThisArea[clasfIdx][1];
                int enrl = totalThisArea[clasfIdx][2];
                int proj = totalThisArea[clasfIdx][3];
                int req = totalThisArea[clasfIdx][4];
                tExp += exp;
                tLast += last;
                tEnrl += enrl;
                tProj += proj;
                tReq += req;
                iCurricula.setWidget(row, col, new MyLabel(exp, enrl, last, proj, req));
                iCurricula.getCellFormatter().setHorizontalAlignment(row, col,
                        HasHorizontalAlignment.ALIGN_RIGHT);
                col++;
            }
            iCurricula.setWidget(row, col, new MyLabel(tExp, tEnrl, tLast, tProj, tReq));
            iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);

            final int finalRow = row;
            final int lastAreas = lastArea.size();
            final Long lastAreaId = lastArea.get(0).getAcademicArea().getId();
            iRowClicks.add(new ChainedCommand() {
                @Override
                public void execute(final ConditionalCommand next) {
                    iExpandedAreas.add(lastAreaId);
                    iCurricula.getRowFormatter().setVisible(finalRow, false);
                    for (int row = 1; row <= lastAreas; row++) {
                        iCurricula.getRowFormatter().setVisible(finalRow - row, true);
                    }
                    if (next != null)
                        next.executeOnSuccess();
                }

                @Override
                public String getLoadingMessage() {
                    return null;
                }
            });
            iRowTypes.add(sRowTypeArea);
            iRowAreaId.add(lastAreaId);
            lastArea.clear();
            for (int i = 0; i < totalThisArea.length; i++)
                totalThisArea[i] = new int[] { 0, 0, 0, 0, 0 };
            lastArea.add(curriculum);
        }
        col = 0;
        row++;
        iCurricula.setText(row, col++, curriculum.getAbbv());
        iCurricula.setText(row, col++, curriculum.getAcademicArea().getAbbv());
        iCurricula.setText(row, col++, curriculum.getMajorCodes(", "));
        int clasfIdx = 0;
        int tExp = 0, tLast = 0, tEnrl = 0, tProj = 0, tReq = 0;
        for (AcademicClassificationInterface clasf : iClassifications) {
            CurriculumClassificationInterface f = null;
            for (CurriculumClassificationInterface x : curriculum.getClassifications()) {
                if (x.getAcademicClassification().getId().equals(clasf.getId())) {
                    f = x;
                    break;
                }
            }
            int exp = 0, last = 0, enrl = 0, proj = 0, req = 0;
            for (CourseInterface course : curriculum.getCourses()) {
                CurriculumCourseInterface cx = course.getCurriculumCourse(clasfIdx);
                if (cx != null) {
                    iUsed[clasfIdx] = true;
                    exp += (f == null || f.getExpected() == null ? 0
                            : Math.round(f.getExpected() * cx.getDisplayedShare()));
                    last += (cx.getLastLike() == null ? 0 : cx.getLastLike());
                    enrl += (cx.getEnrollment() == null ? 0 : cx.getEnrollment());
                    proj += (cx.getProjection() == null ? 0 : cx.getProjection());
                    req += (cx.getRequested() == null ? 0 : cx.getRequested());
                }
            }
            total[clasfIdx][0] += exp;
            total[clasfIdx][1] += last;
            total[clasfIdx][2] += enrl;
            total[clasfIdx][3] += proj;
            total[clasfIdx][4] += req;
            totalThisArea[clasfIdx][0] += exp;
            totalThisArea[clasfIdx][1] += last;
            totalThisArea[clasfIdx][2] += enrl;
            totalThisArea[clasfIdx][3] += proj;
            totalThisArea[clasfIdx][4] += req;
            tExp += exp;
            tLast += last;
            tEnrl += enrl;
            tProj += proj;
            tReq += req;
            iCurricula.setWidget(row, col, new MyLabel(exp, enrl, last, proj, req));
            iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);
            col++;
            clasfIdx++;
        }
        iCurricula.setWidget(row, col, new MyLabel(tExp, tEnrl, tLast, tProj, tReq));
        iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);
        if (iEditable) {
            iRowClicks.add(new ChainedCommand() {
                @Override
                public void execute(final ConditionalCommand next) {
                    iCurriculaService.loadCurriculum(curriculum.getId(),
                            new AsyncCallback<CurriculumInterface>() {
                                @Override
                                public void onFailure(Throwable caught) {
                                    iHeader.setErrorMessage(MESSAGES.failedLoadDetails(curriculum.getAbbv(),
                                            caught.getMessage()));
                                    UniTimeNotifications.error(MESSAGES.failedLoadDetails(curriculum.getAbbv(),
                                            caught.getMessage()), caught);
                                    next.executeOnFailure();
                                }

                                @Override
                                public void onSuccess(CurriculumInterface result) {
                                    openDialog(result, next);
                                }
                            });
                }

                @Override
                public String getLoadingMessage() {
                    return MESSAGES.waitLoadingDetailsOf(curriculum.getName());
                }
            });
        } else {
            final Long lastAreaId = curriculum.getAcademicArea().getId();
            final int finalRow = row;
            iRowClicks.add(new ChainedCommand() {
                @Override
                public void execute(final ConditionalCommand next) {
                    int row = finalRow;
                    while (row > 0 && iRowTypes.get(row) == sRowTypeCurriculum) {
                        iCurricula.getRowFormatter().setVisible(row, false);
                        row--;
                    }
                    row = finalRow + 1;
                    while (iRowTypes.get(row) == sRowTypeCurriculum) {
                        iCurricula.getRowFormatter().setVisible(row, false);
                        row++;
                    }
                    iCurricula.getRowFormatter().setVisible(row, true);
                    iExpandedAreas.remove(lastAreaId);
                    if (next != null)
                        next.executeOnSuccess();
                }

                @Override
                public String getLoadingMessage() {
                    return null;
                }
            });
        }
        iRowTypes.add(sRowTypeCurriculum);
        iRowAreaId.add(curriculum.getAcademicArea().getId());
    }
    if (!lastArea.isEmpty()) {
        col = 0;
        row++;
        iCurricula.getFlexCellFormatter().setColSpan(row, col, 3);
        //iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_CENTER);
        iCurricula.setWidget(row, col++,
                new HTML("<i>" + lastArea.get(0).getAcademicArea().getAbbv() + " - "
                        + lastArea.get(0).getAcademicArea().getName() + " (" + lastArea.size() + ")</i>",
                        false));
        int tExp = 0, tLast = 0, tEnrl = 0, tProj = 0, tReq = 0;
        for (int clasfIdx = 0; clasfIdx < iClassifications.size(); clasfIdx++) {
            int exp = totalThisArea[clasfIdx][0];
            int last = totalThisArea[clasfIdx][1];
            int enrl = totalThisArea[clasfIdx][2];
            int proj = totalThisArea[clasfIdx][3];
            int req = totalThisArea[clasfIdx][4];
            tExp += exp;
            tLast += last;
            tEnrl += enrl;
            tProj += proj;
            tReq += req;
            iCurricula.setWidget(row, col, new MyLabel(exp, enrl, last, proj, req));
            iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);
            col++;
        }
        iCurricula.setWidget(row, col, new MyLabel(tExp, tEnrl, tLast, tProj, tReq));
        iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);
        final int finalRow = row;
        final int lastAreas = lastArea.size();
        final Long lastAreaId = lastArea.get(0).getAcademicArea().getId();
        iRowClicks.add(new ChainedCommand() {
            @Override
            public void execute(final ConditionalCommand next) {
                iExpandedAreas.add(lastAreaId);
                iCurricula.getRowFormatter().setVisible(finalRow, false);
                for (int row = 1; row <= lastAreas; row++) {
                    iCurricula.getRowFormatter().setVisible(finalRow - row, true);
                }
                if (next != null)
                    next.executeOnSuccess();
            }

            @Override
            public String getLoadingMessage() {
                return null;
            }
        });
        iRowTypes.add(sRowTypeArea);
        iRowAreaId.add(lastAreaId);
    }

    // Other line
    if (!otherCurricula.isEmpty()) {
        int[][] totalOther = new int[iClassifications.size()][];
        for (int i = 0; i < totalOther.length; i++)
            totalOther[i] = new int[] { 0, 0, 0, 0, 0 };
        for (CurriculumInterface other : otherCurricula) {
            col = 0;
            row++;
            iCurricula.getFlexCellFormatter().setColSpan(row, col, 3);
            //iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_CENTER);
            iCurricula.setHTML(row, col, "<i>" + other.getAbbv() + " - " + other.getName() + "</i>");
            iCurricula.getCellFormatter().setStyleName(row, col, "unitime-OtherRow");
            col++;
            int tExp = 0, tLast = 0, tEnrl = 0, tProj = 0, tReq = 0;
            for (int clasfIdx = 0; clasfIdx < iClassifications.size(); clasfIdx++) {
                int exp = 0, last = 0, enrl = 0, proj = 0, req = 0;
                for (CourseInterface course : other.getCourses()) {
                    CurriculumCourseInterface cx = course.getCurriculumCourse(clasfIdx);
                    if (cx != null) {
                        iUsed[clasfIdx] = true;
                        exp += 0;
                        last += (cx.getLastLike() == null ? 0 : cx.getLastLike());
                        enrl += (cx.getEnrollment() == null ? 0 : cx.getEnrollment());
                        proj += (cx.getProjection() == null ? 0 : cx.getProjection());
                        req += (cx.getRequested() == null ? 0 : cx.getRequested());
                    }
                }
                total[clasfIdx][0] += exp;
                total[clasfIdx][1] += last;
                total[clasfIdx][2] += enrl;
                total[clasfIdx][3] += proj;
                total[clasfIdx][4] += req;
                totalOther[clasfIdx][0] += exp;
                totalOther[clasfIdx][1] += last;
                totalOther[clasfIdx][2] += enrl;
                totalOther[clasfIdx][3] += proj;
                totalOther[clasfIdx][4] += req;
                tExp += exp;
                tLast += last;
                tEnrl += enrl;
                tProj += proj;
                tReq += req;
                iCurricula.setWidget(row, col, new MyLabel(exp, enrl, last, proj, req));
                iCurricula.getCellFormatter().setHorizontalAlignment(row, col,
                        HasHorizontalAlignment.ALIGN_RIGHT);
                iCurricula.getCellFormatter().setStyleName(row, col, "unitime-OtherRow");
                col++;
            }
            iCurricula.setWidget(row, col, new MyLabel(tExp, tEnrl, tLast, tProj, tReq));
            iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);
            iCurricula.getCellFormatter().setStyleName(row, col, "unitime-OtherRow");
            iRowTypes.add(sRowTypeOtherArea);
            iRowAreaId.add(-1l);
            final int finalRow = row;
            iRowClicks.add(new ChainedCommand() {
                @Override
                public void execute(final ConditionalCommand next) {
                    int row = finalRow;
                    while (row > 0 && iRowTypes.get(row) == sRowTypeOtherArea) {
                        iCurricula.getRowFormatter().setVisible(row, false);
                        row--;
                    }
                    row = finalRow + 1;
                    while (iRowTypes.get(row) == sRowTypeOtherArea) {
                        iCurricula.getRowFormatter().setVisible(row, false);
                        row++;
                    }
                    iCurricula.getRowFormatter().setVisible(row, true);
                    iExpandedAreas.remove(-1l);
                    if (next != null)
                        next.executeOnSuccess();
                }

                @Override
                public String getLoadingMessage() {
                    return null;
                }
            });
        }
        col = 0;
        row++;
        iCurricula.getFlexCellFormatter().setColSpan(row, col, 3);
        //iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_CENTER);
        iCurricula.setWidget(row, col, new HTML("<i>" + MESSAGES.colOtherStudents() + "</i>", false));
        iCurricula.getCellFormatter().setStyleName(row, col, "unitime-OtherRow");
        col++;
        int tExp = 0, tLast = 0, tEnrl = 0, tProj = 0, tReq = 0;
        for (int clasfIdx = 0; clasfIdx < iClassifications.size(); clasfIdx++) {
            int exp = totalOther[clasfIdx][0];
            int last = totalOther[clasfIdx][1];
            int enrl = totalOther[clasfIdx][2];
            int proj = totalOther[clasfIdx][3];
            int req = totalOther[clasfIdx][4];
            tExp += exp;
            tLast += last;
            tEnrl += enrl;
            tProj += proj;
            tReq += req;
            iCurricula.setWidget(row, col, new MyLabel(exp, enrl, last, proj, req));
            iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);
            iCurricula.getCellFormatter().setStyleName(row, col, "unitime-OtherRow");
            col++;
        }
        iCurricula.setWidget(row, col, new MyLabel(tExp, tEnrl, tLast, tProj, tReq));
        iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);
        iCurricula.getCellFormatter().setStyleName(row, col, "unitime-OtherRow");
        final int finalRow = row;
        final int lastAreas = otherCurricula.size();
        iAllAreas.add(-1l);
        iRowClicks.add(new ChainedCommand() {
            @Override
            public void execute(final ConditionalCommand next) {
                iExpandedAreas.add(-1l);
                iCurricula.getRowFormatter().setVisible(finalRow, false);
                for (int row = 1; row <= lastAreas; row++) {
                    iCurricula.getRowFormatter().setVisible(finalRow - row, true);
                }
                if (next != null)
                    next.executeOnSuccess();
            }

            @Override
            public String getLoadingMessage() {
                return null;
            }
        });
        iRowTypes.add(sRowTypeOther);
        iRowAreaId.add(-1l);
    }

    // Total line
    col = 0;
    row++;
    iRowClicks.add(new ChainedCommand() {
        @Override
        public void execute(ConditionalCommand next) {
            CurriculumCookie.getInstance()
                    .setCurriculaCoursesDetails(!CurriculumCookie.getInstance().getCurriculaCoursesDetails());
            if (iHeader.isCollapsible() != null)
                iHeader.setCollapsible(CurriculumCookie.getInstance().getCurriculaCoursesDetails());
            if (iCurricula.getRowCount() > 2) {
                for (int row = 1; row < iCurricula.getRowCount() - 1; row++) {
                    int rowType = iRowTypes.get(row);
                    if (CurriculumCookie.getInstance().getCurriculaCoursesDetails()
                            && (rowType == sRowTypeCurriculum || rowType == sRowTypeOtherArea))
                        continue;
                    iCurricula.getRowFormatter().setVisible(row,
                            CurriculumCookie.getInstance().getCurriculaCoursesDetails());
                }
                for (int col = 0; col < iClassifications.size() + 2; col++) {
                    iCurricula.getCellFormatter().setStyleName(iCurricula.getRowCount() - 1, col,
                            CurriculumCookie.getInstance().getCurriculaCoursesDetails() ? "unitime-TotalRow"
                                    : null);
                }
            }
            if (next != null)
                next.executeOnSuccess();
        }

        @Override
        public String getLoadingMessage() {
            return null;
        }
    });
    iRowTypes.add(sRowTypeTotal);
    iRowAreaId.add(-3l);
    iCurricula.getFlexCellFormatter().setColSpan(row, col, 3);
    iCurricula
            .setWidget(row, col,
                    new Label(
                            MESSAGES.totalEnrollmentOfType(
                                    CurriculumCookie.getInstance().getCourseCurriculaTableType().getName()),
                            false));
    iCurricula.getCellFormatter().setStyleName(row, col, "unitime-TotalRow");
    col++;
    for (int clasfIdx = 0; clasfIdx < iClassifications.size(); clasfIdx++) {
        int exp = total[clasfIdx][0];
        int last = total[clasfIdx][1];
        int enrl = total[clasfIdx][2];
        int proj = total[clasfIdx][3];
        int req = total[clasfIdx][4];
        iCurricula.setWidget(row, col, new MyLabel(exp, enrl, last, proj, req));
        iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);
        iCurricula.getCellFormatter().setStyleName(row, col, "unitime-TotalRow");
        col++;
    }
    int[] tx = new int[] { 0, 0, 0, 0, 0 };
    for (int i = 0; i < total.length; i++)
        for (int j = 0; j < 5; j++)
            tx[j] += total[i][j];
    iCurricula.setWidget(row, col, new MyLabel(tx[0], tx[2], tx[1], tx[3], tx[4]));
    iCurricula.getCellFormatter().setHorizontalAlignment(row, col, HasHorizontalAlignment.ALIGN_RIGHT);
    iCurricula.getCellFormatter().setStyleName(row, col, "unitime-TotalRow");

    // Hide all lines if requested
    if (!CurriculumCookie.getInstance().getCurriculaCoursesDetails()) {
        for (int r = 1; r < iCurricula.getRowCount() - 1; r++) {
            iCurricula.getRowFormatter().setVisible(r, false);
        }
        int r = iCurricula.getRowCount() - 1;
        int hc = getHeaderCols(r);
        for (int c = 0; c < hc + iClassifications.size(); c++) {
            iCurricula.getCellFormatter().setStyleName(r, c, null);
        }
    } else {
        // else collapse all
        for (int r = 1; r < iCurricula.getRowCount() - 1; r++) {
            int rowType = iRowTypes.get(r);
            boolean visible = (rowType != sRowTypeCurriculum && rowType != sRowTypeOtherArea);
            if (iExpandedAreas.contains(iRowAreaId.get(r)))
                visible = !visible;
            iCurricula.getRowFormatter().setVisible(r, visible);
        }
    }

    // Hide not-used classifications
    for (int i = 0; i < iUsed.length; i++) {
        for (int r = 0; r < iCurricula.getRowCount(); r++) {
            if (!iUsed[i]) {
                iCurricula.getCellFormatter().setVisible(r, getHeaderCols(r) + i, false);
            }
        }
    }

    boolean typeChanged = false;
    Type type = CurriculumCookie.getInstance().getCourseCurriculaTableType();
    if (type == Type.EXP && tx[0] == 0) {
        if (tx[2] > 0) {
            type = Type.ENRL;
            typeChanged = true;
        } else if (tx[1] > 0) {
            type = Type.LAST;
            typeChanged = true;
        }
    }
    if (type == Type.ENRL && tx[2] == 0) {
        if (tx[0] > 0) {
            type = Type.EXP;
            typeChanged = true;
        } else if (tx[1] > 0) {
            type = Type.LAST;
            typeChanged = true;
        }
    }
    if (type == Type.LAST && tx[1] == 0) {
        if (tx[0] > 0) {
            type = Type.EXP;
            typeChanged = true;
        } else if (tx[2] > 0) {
            type = Type.ENRL;
            typeChanged = true;
        }
    }
    if (type == Type.PROJ && tx[3] == 0) {
        if (tx[0] > 0) {
            type = Type.EXP;
            typeChanged = true;
        } else if (tx[1] > 0) {
            type = Type.ENRL;
            typeChanged = true;
        } else if (tx[2] > 0) {
            type = Type.LAST;
            typeChanged = true;
        }
    }
    if (type == Type.REQ && tx[4] == 0) {
        if (tx[0] > 0) {
            type = Type.EXP;
            typeChanged = true;
        } else if (tx[1] > 0) {
            type = Type.ENRL;
            typeChanged = true;
        } else if (tx[2] > 0) {
            type = Type.LAST;
            typeChanged = true;
        } else if (tx[3] > 0) {
            type = Type.PROJ;
            typeChanged = true;
        }
    }
    if (typeChanged) {
        CurriculumCookie.getInstance().setCourseCurriculaTableType(type);
        iHint.setText(MESSAGES.hintEnrollmentOfType(type.getName()));
        if (iCurricula.getRowCount() > 1) {
            for (int r = 1; r < iCurricula.getRowCount(); r++) {
                int hc = getHeaderCols(r);
                for (int c = 0; c <= iClassifications.size(); c++) {
                    ((MyLabel) iCurricula.getWidget(r, hc + c)).refresh();
                }
            }
            //((MyLabel)iCurricula.getWidget(iCurricula.getRowCount() - 1, 1)).refresh();
            ((Label) iCurricula.getWidget(iCurricula.getRowCount() - 1, 0))
                    .setText(MESSAGES.totalEnrollmentOfType(type.getName()));
        }
    }

    iHeader.clearMessage();
    iHeader.setEnabled("operations", true);

    iHint.setVisible(true);
}

From source file:org.unitime.timetable.gwt.client.curricula.CurriculumProjectionRulesPage.java

License:Apache License

public void refreshTable() throws CurriculaException {
    for (int row = iTable.getRowCount() - 1; row >= 0; row--)
        iTable.removeRow(row);// www. j a  v  a2  s.co  m

    if (iRules == null || iRules.isEmpty())
        throw new CurriculaException(MESSAGES.errorNoAcademicAreasDefined());

    String areaOrd = (iOrder == null ? null : iOrder.get("CurProjRules.Order"));
    TreeSet<AcademicAreaInterface> areas = null;
    if (areaOrd != null && areaOrd.length() > 0) {
        final String ord = "|" + areaOrd + "|";
        areas = new TreeSet<AcademicAreaInterface>(new Comparator<AcademicAreaInterface>() {
            @Override
            public int compare(AcademicAreaInterface a1, AcademicAreaInterface a2) {
                int i1 = ord.indexOf("|" + a1.getAbbv() + "|");
                if (i1 >= 0) {
                    int i2 = ord.indexOf("|" + a2.getAbbv() + "|");
                    if (i2 >= 0) {
                        return (i1 < i2 ? -1 : i1 > i2 ? 1 : a1.compareTo(a2));
                    }
                }
                return a1.compareTo(a2);
            }
        });
        areas.addAll(iRules.keySet());
    } else {
        areas = new TreeSet<AcademicAreaInterface>(iRules.keySet());
    }
    TreeSet<AcademicClassificationInterface> classifications = null;

    MajorInterface defaultMajor = new MajorInterface();
    defaultMajor.setId(-1l);

    List<Set<AcademicClassificationInterface>> col2clasf = new ArrayList<Set<AcademicClassificationInterface>>();
    HashMap<AcademicClassificationInterface, Integer> clasf2col = new HashMap<AcademicClassificationInterface, Integer>();
    HashMap<Integer, List<MyCell>> col2cells = new HashMap<Integer, List<MyCell>>();

    int row = 1;
    for (AcademicAreaInterface area : areas) {
        HashMap<MajorInterface, HashMap<AcademicClassificationInterface, Number[]>> rules = iRules.get(area);

        MyRow rr = new MyRow(area, null, rules.get(defaultMajor));
        if (classifications == null) {
            classifications = rr.getClassifications();
            for (AcademicClassificationInterface clasf : classifications) {
                if (!isUsed(clasf))
                    continue;
                Integer col = clasf2col.get(clasf);
                if (col == null) {
                    for (int c = 0; c < col2clasf.size(); c++) {
                        if (canCombine(clasf, col2clasf.get(c))) {
                            col2clasf.get(c).add(clasf);
                            clasf2col.put(clasf, c);
                            col = c;
                            break;
                        }
                    }
                }
                if (col == null) {
                    Set<AcademicClassificationInterface> s = new TreeSet<AcademicClassificationInterface>();
                    s.add(clasf);
                    col = col2clasf.size();
                    col2clasf.add(s);
                    clasf2col.put(clasf, col);
                }
            }
        }

        if (!rr.hasLastLike())
            continue;

        iTable.setText(row, 0, area.getAbbv());
        List<MyCell> cells = new ArrayList<MyCell>();
        for (AcademicClassificationInterface clasf : classifications) {
            if (rr.getLastLike(clasf) <= 0)
                continue;
            Integer col = clasf2col.get(clasf);
            MyCell cell = new MyCell(rr, clasf);
            iTable.setWidget(row, 1 + col, cell);
            cells.add(cell);
            List<MyCell> cellsThisCol = col2cells.get(col);
            if (cellsThisCol == null) {
                cellsThisCol = new ArrayList<MyCell>();
                col2cells.put(col, cellsThisCol);
            }
            cellsThisCol.add(cell);
        }
        iTable.setWidget(row, 1 + col2clasf.size(), new MySumCell(cells, false));
        iTable.getCellFormatter().getElement(row, 1 + col2clasf.size()).getStyle()
                .setBackgroundColor("#EEEEEE");
        row++;

        String majorOrd = (iOrder == null ? null : iOrder.get("CurProjRules.Order[" + area.getAbbv() + "]"));
        TreeSet<MajorInterface> majors = null;
        if (majorOrd != null && majorOrd.length() > 0) {
            final String ord = "|" + majorOrd + "|";
            majors = new TreeSet<MajorInterface>(new Comparator<MajorInterface>() {
                @Override
                public int compare(MajorInterface m1, MajorInterface m2) {
                    int i1 = ord.indexOf("|" + m1.getCode() + "|");
                    if (i1 >= 0) {
                        int i2 = ord.indexOf("|" + m2.getCode() + "|");
                        if (i2 >= 0) {
                            return (i1 < i2 ? -1 : i1 > i2 ? 1 : m1.compareTo(m2));
                        }
                    }
                    return m1.compareTo(m2);
                }
            });
            majors.addAll(iRules.get(area).keySet());
        } else {
            majors = new TreeSet<MajorInterface>(iRules.get(area).keySet());
        }

        for (MajorInterface major : majors) {
            if (major.getId() < 0)
                continue;

            MyRow r = new MyRow(area, major, rules.get(major));
            if (!r.hasLastLike())
                continue;
            r.setParent(rr);
            rr.addChild(r);

            Label majorLabel = new Label(major.getCode(), false);
            majorLabel.getElement().getStyle().setMarginLeft(10, Unit.PX);
            iTable.setWidget(row, 0, majorLabel);
            List<MyCell> mcells = new ArrayList<MyCell>();
            for (AcademicClassificationInterface clasf : classifications) {
                if (r.getLastLike(clasf) <= 0)
                    continue;
                Integer col = clasf2col.get(clasf);
                MyCell cell = new MyCell(r, clasf);
                mcells.add(cell);
                iTable.setWidget(row, 1 + col, cell);
                List<MyCell> cellsThisCol = col2cells.get(col);
                if (cellsThisCol == null) {
                    cellsThisCol = new ArrayList<MyCell>();
                    col2cells.put(col, cellsThisCol);
                }
                cellsThisCol.add(cell);
            }
            iTable.setWidget(row, 1 + col2clasf.size(), new MySumCell(mcells, false));
            iTable.getRowFormatter().setVisible(row, r.hasProjection());
            iTable.getCellFormatter().getElement(row, 1 + col2clasf.size()).getStyle()
                    .setBackgroundColor("#EEEEEE");
            row++;
        }
    }
    if (classifications == null || classifications.isEmpty())
        throw new CurriculaException(MESSAGES.errorNoAcademicClassificationsDefined());

    ClickHandler menu = new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            final PopupPanel popup = new PopupPanel(true);
            MenuBar menu = new MenuBar(true);
            if (CurriculumCookie.getInstance().getCurriculumProjectionRulesPercent())
                menu.addItem(new MenuItem(MESSAGES.opShowNumbers(), true, new Command() {
                    @Override
                    public void execute() {
                        popup.hide();
                        CurriculumCookie.getInstance().setCurriculumProjectionRulesPercent(false);
                        updateAll();
                    }
                }));
            else
                menu.addItem(new MenuItem(MESSAGES.opShowPercentages(), true, new Command() {
                    @Override
                    public void execute() {
                        popup.hide();
                        CurriculumCookie.getInstance().setCurriculumProjectionRulesPercent(true);
                        updateAll();
                    }
                }));
            if (CurriculumCookie.getInstance().getCurriculumProjectionRulesShowLastLike())
                menu.addItem(
                        new MenuItem(MESSAGES.opHide(MESSAGES.fieldLastLikeEnrollment()), true, new Command() {
                            @Override
                            public void execute() {
                                popup.hide();
                                CurriculumCookie.getInstance().setCurriculumProjectionRulesShowLastLike(false);
                                updateAll();
                            }
                        }));
            else
                menu.addItem(
                        new MenuItem(MESSAGES.opShow(MESSAGES.fieldLastLikeEnrollment()), true, new Command() {
                            @Override
                            public void execute() {
                                popup.hide();
                                CurriculumCookie.getInstance().setCurriculumProjectionRulesShowLastLike(true);
                                updateAll();
                            }
                        }));
            boolean canCollapse = false, canExpand = false;
            for (int row = 1; row < iTable.getRowCount(); row++) {
                MyRow r = iTable.getMyRow(row);
                if (r != null && r.getMajor() != null && !r.hasProjection()) {
                    if (iTable.getRowFormatter().isVisible(row))
                        canCollapse = true;
                    else
                        canExpand = true;
                }
            }
            if (canCollapse) {
                menu.addItem(new MenuItem(MESSAGES.opCollapseAll(), true, new Command() {
                    @Override
                    public void execute() {
                        popup.hide();
                        for (int row = 1; row < iTable.getRowCount(); row++) {
                            MyRow r = iTable.getMyRow(row);
                            if (r != null && r.getMajor() != null && !r.hasProjection()) {
                                if (iTable.getRowFormatter().isVisible(row))
                                    iTable.getRowFormatter().setVisible(row, false);
                            }
                        }
                    }
                }));
            }
            if (canExpand) {
                menu.addItem(new MenuItem(MESSAGES.opExpandAll(), true, new Command() {
                    @Override
                    public void execute() {
                        popup.hide();
                        for (int row = 1; row < iTable.getRowCount(); row++) {
                            MyRow r = iTable.getMyRow(row);
                            if (r != null && r.getMajor() != null && !r.hasProjection()) {
                                if (!iTable.getRowFormatter().isVisible(row))
                                    iTable.getRowFormatter().setVisible(row, true);
                            }
                        }
                    }
                }));
            }
            menu.setVisible(true);
            popup.add(menu);
            popup.showRelativeTo((Widget) event.getSource());
        }
    };

    for (int c = 0; c < col2clasf.size(); c++) {
        String text = "";
        for (AcademicClassificationInterface clasf : col2clasf.get(c)) {
            if (!text.isEmpty())
                text += " / ";
            text += clasf.getCode();
        }
        Label label = new Label(text, true);
        label.addClickHandler(menu);
        iTable.getFlexCellFormatter().setStyleName(0, c + 1, "unitime-ClickableTableHeader");
        iTable.setWidget(0, c + 1, label);
        iTable.getCellFormatter().setHorizontalAlignment(0, c + 1, HasHorizontalAlignment.ALIGN_CENTER);
    }
    HTML label = new HTML("&nbsp;", false);
    label.addClickHandler(menu);
    iTable.getFlexCellFormatter().setStyleName(0, 0, "unitime-ClickableTableHeader");
    iTable.setWidget(0, 0, label);
    HTML totals = new HTML(MESSAGES.colTotal(), false);
    totals.addClickHandler(menu);
    iTable.getFlexCellFormatter().setStyleName(0, col2clasf.size() + 1, "unitime-ClickableTableHeader");
    iTable.setWidget(0, col2clasf.size() + 1, totals);
    if (row == 1)
        throw new CurriculaException(MESSAGES.errorNoLastLikeEnrollemnts());

    iTable.setText(row, 0, MESSAGES.colTotal());
    iTable.getCellFormatter().getElement(row, 0).getStyle().setBackgroundColor("#EEEEEE");
    List<MyCell> cells = new ArrayList<MyCell>();
    for (int c = 0; c < col2clasf.size(); c++) {
        List<MyCell> cellsThisCol = col2cells.get(c);
        if (cellsThisCol == null || cellsThisCol.isEmpty())
            continue;
        cells.addAll(cellsThisCol);
        iTable.setWidget(row, 1 + c, new MySumCell(cellsThisCol, true));
        iTable.getCellFormatter().getElement(row, 1 + c).getStyle().setBackgroundColor("#EEEEEE");
    }
    iTable.setWidget(row, 1 + col2clasf.size(), new MySumCell(cells, true));
    iTable.getCellFormatter().getElement(row, 1 + col2clasf.size()).getStyle().setBackgroundColor("#EEEEEE");

    for (int r = 1; r < iTable.getRowCount(); r++) {
        for (int c = iTable.getCellCount(r); c < 1 + col2clasf.size(); c++) {
            iTable.setHTML(r, c, "&nbsp;");
        }
    }

    iBottom.setVisible(true);
    iTable.setVisible(true);
    if (!iHeader.isEnabled("close")) {
        iHeader.setEnabled("print", true);
    }
}

From source file:org.unitime.timetable.gwt.client.page.UniTimeMobileMenu.java

License:Apache License

private TreeItem generateItem(final MenuInterface item) {
    final MenuInterface.ValueEncoder encoder = new MenuInterface.ValueEncoder() {
        @Override/*from w w w. j a  va 2  s  .c o m*/
        public String encode(String value) {
            return URL.encodeQueryString(value);
        }
    };
    final Label label = new Label(item.getName(), false);
    final TreeItem treeItem = new TreeItem(label);
    if ("PAGE_HELP".equals(item.getPage())) {
        label.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                PageNameInterface name = UniTimePageLabel.getInstance().getValue();
                if (name.hasHelpUrl())
                    openUrl(MESSAGES.pageHelp(name.getName()), name.getHelpUrl(), item.getTarget());
            }
        });
        treeItem.setVisible(UniTimePageLabel.getInstance().getValue().hasHelpUrl());
        iPageLabelRegistration = UniTimePageLabel.getInstance()
                .addValueChangeHandler(new ValueChangeHandler<MenuInterface.PageNameInterface>() {
                    @Override
                    public void onValueChange(ValueChangeEvent<PageNameInterface> event) {
                        treeItem.setVisible(event.getValue().hasHelpUrl());
                    }
                });
    } else if (item.hasPage()) {
        label.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                openUrl(item.getName(), item.getURL(encoder), item.getTarget());
            }
        });
    }
    if (item.hasSubMenus())
        for (final MenuInterface subItem : item.getSubMenus()) {
            if (subItem.isSeparator())
                continue;
            if (subItem.getName().equals(item.getName()) && !item.hasPage() && subItem.hasPage()
                    && !"PAGE_HELP".equals(subItem.getPage())) {
                label.addClickHandler(new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                        openUrl(subItem.getName(), subItem.getURL(encoder), subItem.getTarget());
                    }
                });
            } else {
                treeItem.addItem(generateItem(subItem));
            }
        }
    return treeItem;
}

From source file:org.utgenome.gwt.utgb.client.track.lib.DBSelectTrack.java

License:Apache License

public void updateFavoriteGroup() {
    favoritePanel.clear();/*from  w  ww  . j a  v  a  2  s .c om*/

    for (String each : favoriteGroup) {
        Label l = new Label(each);
        Style.fontSize(l, 11);
        Style.fontColor(l, "#336699");
        Style.set(l, "textDecoration", "underline");
        Style.cursor(l, Style.CURSOR_POINTER);
        Style.margin(l, Style.LEFT, 5);
        l.addClickHandler(new FavGroupClickHandler(each));
        favoritePanel.add(l);
    }
}

From source file:org.utgenome.gwt.utgb.client.track.lib.KeywordSearchTrack.java

License:Apache License

public KeywordSearchTrack() {
    super("Keyword Search");
    basePanel.setStyleName("form");
    //searchResultPanel.setStyleName("searchresult");

    final KeywordTextBox keywordBox = new KeywordTextBox();

    keywordPanel = new SearchInput("Keyword", keywordBox);
    final HorizontalPanel hp = new HorizontalPanel();
    hp.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    hp.add(keywordPanel);// ww  w. j a v  a  2  s .c om
    Button button = new Button("Search");
    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent e) {
            performSearch(keywordPanel.getInput(), 1, 10);
        }
    });
    hp.add(button);

    // keywordHelp.setStyleName("");
    keywordHelpPopup.add(keywordHelp);
    keywordHelpPopup.setStyleName("helpPopup");
    final Label helpLabel = new Label("keyword help");
    helpLabel.setStyleName("help");
    helpLabel.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent e) {
            keywordHelpPopup.setPopupPosition(helpLabel.getAbsoluteLeft() + 5, helpLabel.getAbsoluteTop() + 10);
            keywordHelpPopup.show();
        }
    });
    hp.add(helpLabel);
    layoutPanel.add(hp);

    basePanel.add(layoutPanel, DockPanel.CENTER);
    basePanel.add(searchResultPanel, DockPanel.SOUTH);
}