Example usage for com.google.gwt.user.client.ui HTML setHTML

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

Introduction

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

Prototype

public void setHTML(SafeHtml html) 

Source Link

Document

Sets this object's contents via known-safe HTML.

Usage

From source file:bingo.client.Bingo.java

License:Open Source License

private void initAdminGrid(final String userId, final BingoGrid bingoGrid, final boolean hasFinished) {
    final Timer timer = new Timer() {
        int totalParticipants = 0;

        @Override//from w  ww .  j ava 2  s  .c o  m
        public void run() {
            bingoService.getTotalParticipants(userId, new AsyncCallback<Integer>() {
                @Override
                public void onFailure(Throwable caught) {
                }

                @Override
                public void onSuccess(Integer result) {
                    totalParticipants = result.intValue();
                }
            });

            bingoService.getVotes(userId, new AsyncCallback<int[][]>() {
                @Override
                public void onFailure(Throwable caught) {
                    message.setText(caught.getMessage());
                }

                @Override
                public void onSuccess(int[][] result) {
                    if (result == null) {
                        result = new int[BingoGrid.ROW][BingoGrid.COL];
                        for (int i = 0; i < BingoGrid.ROW; i++)
                            for (int j = 0; j < BingoGrid.COL; j++)
                                result[i][j] = 0;
                    }

                    for (int row = 0; row < BingoGrid.ROW; ++row)
                        for (int col = 0; col < BingoGrid.COL; ++col) {
                            bingoGrid.setVoteString(row, col, String.valueOf(result[row][col]),
                                    String.valueOf(totalParticipants));
                        }
                }
            });
        }
    };

    // If the game is not finished, repeat; if so, run once
    if (!hasFinished)
        timer.scheduleRepeating(ADMIN_TIMER);
    else
        timer.run();

    HorizontalPanel panel = new HorizontalPanel();
    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    final Button finishButton = new Button();

    // If the game is not finished, allow finishing it; if so, allow download data
    if (!hasFinished)
        finishButton.setText(strings.finishBingo());
    else
        finishButton.setText(strings.download());

    finishButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (!hasFinished)
                bingoService.finishBingo(userId, new AsyncCallback<Void>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        message.setText(caught.getMessage());
                    }

                    @Override
                    public void onSuccess(Void result) {
                        message.setText(strings.finishedBingo());
                        finishButton.setText(strings.download());
                        timer.cancel();
                    }
                });

            bingoService.getVotes(userId, new AsyncCallback<int[][]>() {
                @Override
                public void onFailure(Throwable caught) {
                    message.setText(caught.getMessage());
                }

                @Override
                public void onSuccess(int[][] result) {
                    // Create a popup dialog box
                    final DialogBox box = new DialogBox();
                    box.setText(strings.info());
                    box.setAnimationEnabled(true);

                    final Button boxAcceptButton = new Button(strings.accept());
                    boxAcceptButton.addClickHandler(new ClickHandler() {
                        @Override
                        public void onClick(ClickEvent event) {
                            box.hide();
                        }
                    });

                    Label boxLabel = new Label();
                    boxLabel.setText(strings.finishMessage());
                    HTML voteData = new HTML();
                    if (result == null) {
                        result = new int[BingoGrid.ROW][BingoGrid.COL];
                        for (int i = 0; i < BingoGrid.ROW; i++)
                            for (int j = 0; j < BingoGrid.COL; j++)
                                result[i][j] = 0;
                    }

                    String cellKey = "";
                    String cellString = "";
                    String voteDataString = "";
                    for (int row = 0; row < BingoGrid.ROW; ++row)
                        for (int col = 0; col < BingoGrid.COL; ++col) {
                            cellKey = "cell" + row + col;
                            cellString = strings.map().get(cellKey);
                            voteDataString += "&nbsp;&nbsp;&nbsp;" + cellString + " = " + result[row][col]
                                    + "<br>";
                        }
                    voteData.setHTML(voteDataString);
                    voteData.addStyleName("boxData");

                    VerticalPanel boxPanel = new VerticalPanel();
                    boxPanel.addStyleName("boxPanel");
                    boxPanel.add(boxLabel);
                    boxPanel.add(voteData);

                    HorizontalPanel buttonsPanel = new HorizontalPanel();
                    buttonsPanel.add(boxAcceptButton);
                    boxPanel.add(buttonsPanel);
                    boxPanel.setCellHorizontalAlignment(buttonsPanel, HasHorizontalAlignment.ALIGN_CENTER);

                    box.setWidget(boxPanel);
                    box.center();
                }
            });
        }
    });
    panel.add(finishButton);

    final Button terminateButton = new Button(strings.terminateButton());
    terminateButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // Create a popup dialog box
            final DialogBox box = new DialogBox();
            box.setText(strings.warning());
            box.setAnimationEnabled(true);

            final Button boxCancelButton = new Button(strings.cancel());
            boxCancelButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    box.hide();
                }
            });
            final Button boxAcceptButton = new Button(strings.accept());
            boxAcceptButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    bingoService.terminateBingo(userId, new AsyncCallback<Void>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            message.setText(caught.getMessage());
                        }

                        @Override
                        public void onSuccess(Void result) {
                            message.setText(strings.terminatedBingo());
                            timer.cancel();
                        }

                    });
                    box.hide();
                }
            });

            final Label boxLabel = new Label();
            boxLabel.setText(strings.terminateMessage());

            VerticalPanel boxPanel = new VerticalPanel();

            boxPanel.addStyleName("boxPanel");
            boxPanel.add(boxLabel);

            HorizontalPanel buttonsPanel = new HorizontalPanel();
            buttonsPanel.add(boxCancelButton);
            buttonsPanel.add(boxAcceptButton);
            boxPanel.add(buttonsPanel);

            box.setWidget(boxPanel);
            box.center();
        }
    });
    panel.add(terminateButton);

    RootPanel.get("buttons").clear();
    RootPanel.get("buttons").add(panel);
}

From source file:cc.kune.gspace.client.licensewizard.pages.LicenseWizardFirstForm.java

License:GNU Affero Public License

/**
 * Instantiates a new license wizard first form.
 * //from  www.ja  va2  s  .co  m
 * @param i18n
 *          the i18n
 */
@Inject
public LicenseWizardFirstForm(final I18nTranslationService i18n) {
    super.setFrame(true);
    super.setPadding(10);
    super.setAutoHeight(true);
    // super.setHeight(LicenseWizardView.HEIGHT);

    final Label intro = new Label();
    intro.setText(
            i18n.t("Select the license you prefer using for sharing your group contents with other people:"));
    intro.addStyleName("kune-Margin-10-b");
    final FieldSet fieldSet = new FieldSet();
    // fieldSet.setTitle(i18n.t("license recommended"));
    fieldSet.addStyleName("margin-left: 105px");
    fieldSet.setWidth(250);
    copyleftRadio = DefaultFormUtils.createRadio(fieldSet, i18n.t("Use a copyleft license (recommended)"),
            RADIO_FIELD_NAME, null, RADIO_COPYLEFT_ID);
    anotherLicenseRadio = DefaultFormUtils.createRadio(fieldSet,
            i18n.t("Use another kind of license (advanced)"), RADIO_FIELD_NAME, null, RADIO_ANOTHER_ID);

    final RadioGroup radioGroup = new RadioGroup();
    radioGroup.add(copyleftRadio);
    radioGroup.add(anotherLicenseRadio);
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setHideLabel(true);
    radioGroup.addListener(Events.Change, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(final BaseEvent be) {
            onChange.onCallback();
        }
    });

    final FieldSet infoFS = new FieldSet();
    infoFS.setHeadingHtml("Info");
    // infoFS.setFrame(false);
    // infoFS.setIcon("k-info-icon");
    infoFS.setCollapsible(false);
    infoFS.setAutoHeight(true);

    final HTML recommendCopyleft = new HTML();
    final HTML whyALicense = new HTML();
    final HTML youCanChangeTheLicenseLater = new HTML();
    recommendCopyleft.setHTML(POINT + i18n.t("We recommend [%s] licenses, specially for practical works",
            TextUtils.generateHtmlLink("http://en.wikipedia.org/wiki/Copyleft", i18n.t("copyleft"))));
    whyALicense.setHTML(POINT + TextUtils.generateHtmlLink("http://mirrors.creativecommons.org/getcreative/",
            i18n.t("Why do we need a license?")));
    youCanChangeTheLicenseLater.setHTML(POINT + i18n.t("You can change this license later"));

    infoFS.addStyleName("kune-Margin-20-t");
    add(intro);
    add(radioGroup);
    infoFS.add(recommendCopyleft);
    infoFS.add(whyALicense);
    infoFS.add(youCanChangeTheLicenseLater);
    add(infoFS);
}

From source file:ch.eaternity.client.Search.java

License:Apache License

/**
 * the displaying functions for recipes//  w  w w. j  a  va 2 s.  c  om
 */

public void displayRecipeItem(final Recipe recipe, boolean yours) {
    if (yours) {
        final int row = tableMealsYours.getRowCount();

        Button removeRezeptButton = new Button(" x ");
        removeRezeptButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                final ConfirmDialog dlg = new ConfirmDialog("Hiermit werden Sie das...");
                dlg.statusLabel.setText("Rezept lschen.");

                //  recheck user if he really want to do this...
                dlg.yesButton.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        presenter.removeRecipe(recipe);
                        tableMealsYours.removeCells(row, 0, tableMealsYours.getCellCount(row));
                        dlg.hide();
                        dlg.clear();
                    }
                });
                dlg.show();
                dlg.center();

            }
        });
        // remove button is 1
        tableMealsYours.setWidget(row, 1, removeRezeptButton);

        HTML item = new HTML();

        if (recipe.eaternitySelected != null && recipe.eaternitySelected) {
            item.setHTML(item.getHTML() + "<img src='pixel.png' height=1 width=20 />");
            item.setStyleName("base-icons carrot");
        }
        if (recipe.regsas != null && recipe.regsas) {
            item.setHTML(item.getHTML()
                    + "<div class='extra-icon regloc'><img src='pixel.png' height=1 width=20 /></div>");
        }
        if (recipe.bio != null && recipe.bio) {
            item.setHTML(item.getHTML()
                    + "<div class='extra-icon bio'><img src='pixel.png' height=1 width=20 /></div>");
        }

        item.setHTML(item.getHTML() + "<div class='ingText'>" + recipe.getSymbol() + "</div>");
        // Text and CO2 is 0
        tableMealsYours.setWidget(row, 0, item);

        recipe.setCO2Value();
        String formatted = NumberFormat.getFormat("##").format(recipe.getCO2Value());
        item.setHTML(item.getHTML() + "<div class='putRight2'>ca " + formatted + " g*</div>");

        if (presenter.getLoginInfo().isAdmin()) {
            // This is ugly, but that's the way it is...
            if (!recipe.isOpen()) {
                //               if(recipe.openRequested){
                // this should be a link to make it open
                Anchor openThis = new Anchor("o");
                openThis.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        presenter.recipeApproval(recipe, true);
                    }
                });
                tableMealsYours.setWidget(row, 2, openThis);
                //               item.setHTML(openThis+" "+item.getHTML());
                //               }
            } else {
                // this should be a link to make it close
                Anchor closeThis = new Anchor("c");
                closeThis.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        presenter.recipeApproval(recipe, false);
                    }
                });
                tableMealsYours.setWidget(row, 2, closeThis);
                //               item.setHTML(closeThis+" "+item.getHTML());
            }
        } else {

            //             how to show, that this recipe is public??

            //            if(recipe.isOpen()){
            //               tableMealsYours.setText(row, 2,"o");
            //            } else if(recipe.openRequested){
            //               tableMealsYours.setText(row, 2,"c");
            //            }

            //TODO better show in the menu itself

        }

        //TODO should this not be called after the sort?
        if ((row % 2) == 1) {
            String style = evenStyleRow.evenRow();
            tableMealsYours.getRowFormatter().addStyleName(row, style);
        }

    } else {
        final int row = tableMeals.getRowCount();
        HTML item = new HTML();

        if (recipe.eaternitySelected != null && recipe.eaternitySelected) {
            item.setHTML(item.getHTML() + "<img src='pixel.png' height=1 width=20 />");
            item.setStyleName("base-icons carrot");
        }
        if (recipe.regsas != null && recipe.regsas) {
            item.setHTML(item.getHTML()
                    + "<div class='extra-icon regloc'><img src='pixel.png' height=1 width=20 /></div>");
        }
        if (recipe.bio != null && recipe.bio) {
            item.setHTML(item.getHTML()
                    + "<div class='extra-icon bio'><img src='pixel.png' height=1 width=20 /></div>");
        }

        item.setHTML(item.getHTML() + "<div class='ingText'>" + recipe.getSymbol() + "</div>");

        // Text and CO2 is 0
        tableMeals.setWidget(row, 0, item);

        recipe.setCO2Value();
        String formatted = NumberFormat.getFormat("##").format(recipe.getCO2Value());
        item.setHTML(item.getHTML() + "<div class='putRight'>ca " + formatted + " g*</div>");

        if (presenter.getLoginInfo() != null && presenter.getLoginInfo().isAdmin()) {

            Anchor removeRezeptButton = new Anchor(" x ");
            removeRezeptButton.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    final ConfirmDialog dlg = new ConfirmDialog("Sie wollen dieses...");
                    dlg.statusLabel.setText("Rezept lschen?");
                    // TODO recheck user if he really want to do this...
                    dlg.yesButton.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent event) {
                            presenter.removeRecipe(recipe);
                            tableMeals.removeCells(row, 0, tableMealsYours.getCellCount(row));
                            dlg.hide();
                            dlg.clear();
                        }
                    });
                    dlg.show();
                    dlg.center();
                }
            });

            // remove button is 1
            tableMeals.setWidget(row, 1, removeRezeptButton);
            //            item.setHTML(item.getHTML()+"<div class='putRight2'>ca "+formatted+ " g* ("+removeRezeptButton+")</div>");

            if (!recipe.isOpen()) {
                if (recipe.openRequested) {
                    // TODO this should be a link to make it open
                    Anchor openThis = new Anchor("o");
                    openThis.addClickHandler(new ClickHandler() {
                        public void onClick(ClickEvent event) {
                            presenter.recipeApproval(recipe, true);
                            //                         initTable();
                            // why does the layout suck after this button press?????
                        }
                    });
                    tableMeals.setWidget(row, 2, openThis);
                    //                  item.setHTML(openThis+" "+item.getHTML());
                }
            } else {
                // TODO this should be a link to make it close
                Anchor closeThis = new Anchor("c");
                closeThis.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent event) {
                        presenter.recipeApproval(recipe, false);
                        //                      initTable();
                    }
                });
                tableMeals.setWidget(row, 2, closeThis);
                //               item.setHTML(closeThis+" "+item.getHTML());
            }
        }

        //TODO should this not be called after the sort?
        if ((row % 2) == 1) {
            String style = evenStyleRow.evenRow();
            tableMeals.getRowFormatter().addStyleName(row, style);
        }
    }

}

From source file:ch.eaternity.client.Search.java

License:Apache License

/**
 * the displaying functions for ingredients
 *//*w  ww .j  ava2s  . c  o  m*/
public void displayIngredient(final Ingredient ingredient) {
    int row = table.getRowCount();

    /*if ((row % 2) == 1) {
       String style = evenStyleRow.evenRow();
       table.getRowFormatter().addStyleName(row, style);
    }*/

    HTML icon = new HTML();

    //      icon.addMouseListener(
    //             new TooltipListener(
    //               "add", 15000 /* timeout in milliseconds*/,"bla",400,10));

    // these value (400,1200) are based on the 0.2 and 0.5 quantile of all ingredients
    if (ingredient.getCo2eValue() < 400) {
        //         icon.setHTML(icon.getHTML()+"<img src='pixel.png' height=1 width=20 />");
        icon.setStyleName("base-icons");
        icon.setHTML(icon.getHTML()
                + "<div class='extra-icon smiley2'><img src='pixel.png' height=1 width=20 /></div>");
        icon.setHTML(icon.getHTML()
                + "<div class='extra-icon smiley1'><img src='pixel.png' height=1 width=20 /></div>");
    } else if (ingredient.getCo2eValue() < 1200) {
        //         icon.setHTML(icon.getHTML()+"<img src='pixel.png' height=1 width=20 />");
        icon.setStyleName("base-icons");
        icon.setHTML(icon.getHTML()
                + "<div class='extra-icon smiley2'><img src='pixel.png' height=1 width=20 /></div>");

    }

    if (ingredient.hasSeason != null && ingredient.hasSeason) {
        //         Date date = DateTimeFormat.getFormat("MM").parse(Integer.toString(TopPanel.Monate.getSelectedIndex()+1));
        //         presenter
        Date date = null;
        if (presenter != null) {
            date = DateTimeFormat.getFormat("MM").parse(Integer.toString(presenter.getSelectedMonth()));
        }

        // In Tagen
        //      String test = InfoZutat.zutat.getStartSeason();
        Date dateStart = DateTimeFormat.getFormat("dd.MM").parse(ingredient.stdExtraction.startSeason);
        Date dateStop = DateTimeFormat.getFormat("dd.MM").parse(ingredient.stdExtraction.stopSeason);

        if (dateStart.before(dateStop) && date.after(dateStart) && date.before(dateStop)
                || dateStart.after(dateStop) && !(date.before(dateStart) && date.after(dateStop))) {
            icon.setHTML(icon.getHTML()
                    + "<div class='extra-icon regloc'><img src='pixel.png' height=1 width=20 /></div>");
        }
    }

    if (ingredient.noAlternative) {
        icon.setHTML(icon.getHTML() + "<div class='ingText'>" + ingredient.getSymbol() + "</div>");

    } else {
        icon.setHTML(icon.getHTML() + "(alt): " + ingredient.getSymbol());
    }

    icon.setHTML(icon.getHTML() + "<div class='putRight'>ca "
            + Integer.toString((int) ingredient.getCo2eValue() / 10).concat(" g*") + "</div>");

    table.setWidget(row, 0, icon);

}

From source file:ch.heftix.mailxel.client.AttachmentPanel.java

License:Open Source License

public AttachmentPanel(final AttachmentTO attachmentTO, final MailServiceAsync mailxelService,
        final MailxelPanel mailxelPanel, final boolean directDownload) {

    String url = GWT.getModuleBaseURL() + "mailxel?id=" + Integer.toString(attachmentTO.id);
    int type = MimeTypeDescriptor.TYPE_ANY;

    final MimeTypeDescriptor mtd = MimeTypeUtil.mimeTypeByName(attachmentTO.name);
    type = mtd.fileType;// ww w . j a va  2s.  c o  m

    Frame frame = null;

    if (directDownload) {
        frame = new Frame(url);
        add(frame);
        return;
    }

    ServiceCall sc = new ServiceCall() {

        public String getMessage() {
            return "get attachment data";
        };

        public boolean runSynchronized() {
            return true;
        };

        public void run(final StatusItem si) {
            mailxelService.getAttachmentData(attachmentTO.id, new AsyncCallback<String>() {

                public void onSuccess(String result) {
                    si.done();
                    switch (mtd.fileType) {
                    case MimeTypeDescriptor.TYPE_HTM:
                        HTML html = new HTML();
                        html.setHTML(result);
                        add(html);
                        break;

                    default:
                        TextArea ta = new TextArea();
                        ta.setCharacterWidth(80);
                        ta.setVisibleLines(25);
                        ta.setReadOnly(true);
                        ta.setText(result);
                        add(ta);
                        break;
                    }
                }

                public void onFailure(Throwable caught) {
                    si.error(caught);
                }
            });
        }
    };

    switch (type) {
    case MimeTypeDescriptor.TYPE_IMG:
        Image img = new Image(url);
        add(img);
        break;

    case MimeTypeDescriptor.TYPE_HTM:
    case MimeTypeDescriptor.TYPE_TXT:

        mailxelPanel.statusStart(sc);
        break;

    default:
        frame = new Frame(url);
        add(frame);
        break;
    }
}

From source file:ch.heftix.mailxel.client.MailxelMainToolBar.java

License:Open Source License

public MailxelMainToolBar(final MailServiceAsync mailxelService, final MailxelPanel mailxelPanel) {

    this.mailxelService = mailxelService;
    this.mailxelPanel = mailxelPanel;

    logo = new Image("img/mailxel.png");
    logo.setTitle("MailXel " + Version.getVersion());
    logo.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            PopupPanel pp = new PopupPanel(true);
            DisclosurePanel dp = new DisclosurePanel("MailXel " + Version.getVersion());
            dp.setWidth("400px");
            dp.setOpen(true);/*from   ww  w  .  j  a  v  a 2 s  . c o m*/

            HTML html = new HTML();
            StringBuffer sb = new StringBuffer();
            sb.append("(c) 2008-2010 by Simon Hefti. All rights reserved.<br/>");
            sb.append(
                    "<p>mailxel is licensed under the <a href=\"http://www.eclipse.org/legal/epl-v10.html\">EPL 1.0</a>. mailxel is distributed on an \"AS IS\" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.");
            sb.append("<p>mailxel relies on the following components:");
            sb.append("<ul>");
            sb.append(
                    "<li>GWT, <a href=\"http://code.google.com/webtoolkit\">http://code.google.com/webtoolkit</a></li>");
            sb.append(
                    "<li>sqlite-jdbc, <a href=\"http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC\">http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC</a></li>");
            sb.append(
                    "<li>(and thus on sqlite itself, <a href=\"http://www.sqlite.org\">http://www.sqlite.org</a>)</li>");
            sb.append(
                    "<li>Java Mail API, <a href=\"http://java.sun.com/products/javamail\">http://java.sun.com/products/javamail</a></li>");
            sb.append(
                    "<li>jetty servlet container, <a href=\"http://www.eclipse.org/jetty/\">http://www.eclipse.org/jetty/</a></li>");
            sb.append(
                    "<li>fugue-icons, <a href=\"http://code.google.com/p/fugue-icons-src/\">http://code.google.com/p/fugue-icons-src/</a></li>");
            sb.append("<li>jsoup, <a href=\"http://jsoup.org\">http://jsoup.org</a></li>");
            sb.append("</ul>");
            html.setHTML(sb.toString());
            dp.add(html);
            dp.setOpen(true);

            pp.add(dp);
            pp.show();
        }
    });

    Image home = new Image("img/find.png");
    home.setTitle("Search");
    home.setStylePrimaryName("mailxel-toolbar-item");
    home.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            Panel panel = new MailOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(panel, "Search");
        }
    });

    final Image query = new Image("img/document-task.png");
    query.setTitle("Search (predefined query)");
    query.setStylePrimaryName("mailxel-toolbar-item");
    query.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            final StatusItem si = mailxelPanel.statusStart("retrieve stored message queries");

            mailxelService.searchQueries(MessageQueryTO.T_MESSAGE_QUERY, null,
                    new AsyncCallback<List<MessageQueryTO>>() {

                        public void onFailure(Throwable caught) {
                            si.error(caught);
                        }

                        public void onSuccess(List<MessageQueryTO> result) {
                            si.done();
                            if (null != result && result.size() > 0) {
                                PopupMenu popupMenu = new PopupMenu(query);
                                for (MessageQueryTO mqTO : result) {
                                    String name = mqTO.shortname + " (" + UIUtil.shorten(mqTO.name) + ")";
                                    MenuItem menuItem = new MenuItem(name, new MessageQueryCommand(
                                            mailxelService, mailxelPanel, popupMenu, mqTO));
                                    String url = DirectMailServiceUtil.getIconURL(mqTO.iconId);
                                    if (null != url) {
                                        String html = "<img src=\"" + url + "\"/>&nbsp;" + name;
                                        menuItem.setHTML(html);
                                    }
                                    popupMenu.addItem(menuItem);
                                }
                                popupMenu.show();
                            }
                        }
                    });
        }
    });

    Image mailnew = new Image("img/mail-new.png");
    mailnew.setTitle("New Mail");
    mailnew.setStylePrimaryName("mailxel-toolbar-item");
    mailnew.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            final MailSendGrid mailSendGrid = new MailSendGrid(mailxelService, mailxelPanel, null,
                    MailSendGrid.TYPE_NEW);
            mailxelPanel.addTab(mailSendGrid, "New Mail");
        }
    });

    Image noteToSelf = new Image("img/note.png");
    noteToSelf.setTitle("Note to myself");
    noteToSelf.setStylePrimaryName("mailxel-toolbar-item");
    noteToSelf.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            final MailSendGrid mailSendGrid = new MailSendGrid(mailxelService, mailxelPanel, null,
                    MailSendGrid.TYPE_SELF);
            mailxelPanel.addTab(mailSendGrid, "New Note");
        }
    });

    Image contacts = new Image("img/address-book.png");
    contacts.setTitle("Address Book");
    contacts.setStylePrimaryName("mailxel-toolbar-item");
    contacts.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            AddressOverviewGrid ag = new AddressOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(ag, "Contacts");
        }
    });

    /**
     * mail download menu on click, a menu with the available accounts is
     * displayed, allowing the user is asked to choose the data source.
     */
    final Image download = new Image("img/download-mail.png");
    download.setTitle("Mail download");
    download.setStylePrimaryName("mailxel-toolbar-item");
    download.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            ConfigTO configTO = mailxelPanel.getConfig();
            String[] accounts = configTO.accountNames;

            if (null != accounts && accounts.length > 0) {

                PopupMenu popupMenu = new PopupMenu(download);
                // first item: allow download from all known accounts
                MenuItem menuItem = new MenuItem("Scan all accounts",
                        new ScanMailFolderCommand(mailxelService, mailxelPanel, popupMenu, accounts));
                popupMenu.addItem(menuItem);

                // add one menu item per account
                for (int i = 0; i < accounts.length; i++) {
                    String[] selectedAccount = new String[1];
                    selectedAccount[0] = accounts[i];
                    menuItem = new MenuItem(accounts[i], new ScanMailFolderCommand(mailxelService, mailxelPanel,
                            popupMenu, selectedAccount));
                    popupMenu.addItem(menuItem);
                }
                popupMenu.show();
            }
        }
    });

    final Image reorgMailFolder = new Image("img/wand.png");
    reorgMailFolder.setTitle("reorganize mail folder");
    reorgMailFolder.setStylePrimaryName("mailxel-toolbar-item");
    reorgMailFolder.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            ConfigTO configTO = mailxelPanel.getConfig();
            String[] accounts = configTO.accountNames;

            if (null != accounts && accounts.length > 0) {

                PopupMenu popupMenu = new PopupMenu(reorgMailFolder);
                // first item: allow reorg from all known accounts
                MenuItem menuItem = new MenuItem("All accounts", new ReorgMailFolderCommand(mailxelService,
                        mailxelPanel, popupMenu, reorgMailFolder, accounts));
                popupMenu.addItem(menuItem);

                // add one menu item per account
                for (int i = 0; i < accounts.length; i++) {
                    String[] selectedAccount = new String[1];
                    selectedAccount[0] = accounts[i];
                    menuItem = new MenuItem(accounts[i], new ReorgMailFolderCommand(mailxelService,
                            mailxelPanel, popupMenu, reorgMailFolder, selectedAccount));
                    popupMenu.addItem(menuItem);
                }
                popupMenu.show();
            }
        }
    });

    final Image categories = new Image("img/tags.png");
    categories.setTitle("Manage Categories");
    categories.setStylePrimaryName("mailxel-toolbar-item");
    categories.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {
            CategoryOverviewGrid cog = new CategoryOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(cog, "Categories");
        }
    });

    final Image setup = new Image("img/preferences-system.png");
    setup.setTitle("System Setup");
    setup.setStylePrimaryName("mailxel-toolbar-item");
    setup.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // ConfigTabPanel cg = new ConfigTabPanel();
            ConfigGrid cg = new ConfigGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(cg, "Setup");
        }
    });

    final Image login = new Image("img/lock.png");
    login.setTitle("Login");
    login.setStylePrimaryName("mailxel-toolbar-item");
    login.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {

            // create login box
            LoginPanel loginPanel = new LoginPanel(mailxelService, mailxelPanel);
            int x = login.getAbsoluteLeft();
            int y = login.getAbsoluteTop();
            loginPanel.setPopupPosition(x, y);
            loginPanel.show();
        }
    });

    final Image additional = new Image("img/context-menu.png");
    additional.setTitle("Additional functions");
    additional.setStylePrimaryName("mailxel-toolbar-item");

    final PopupCommand importMboxCommand = new PopupCommand() {

        public void execute() {

            final PopupPanel pup = new PopupPanel(true);
            HorizontalPanel hp = new HorizontalPanel();
            final TextBox tb = new TextBox();
            tb.setWidth("300px");
            hp.add(tb);

            Button b = new Button();
            b.setText("import");
            b.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent sender) {
                    String name = tb.getText();
                    if (null != name) {
                        name = name.trim();
                        if (name.length() > 0) {
                            final StatusItem si = mailxelPanel.statusStart("Import from mbox: " + name);
                            mailxelService.importMboxFile(name, new AsyncCallback<Void>() {

                                public void onFailure(Throwable caught) {
                                    si.error(caught);
                                }

                                public void onSuccess(Void result) {
                                    si.done();
                                }
                            });
                            pup.hide();
                        }
                    }
                }
            });

            hp.add(b);
            pup.add(hp);

            int x = additional.getAbsoluteLeft();
            int y = additional.getAbsoluteTop();
            pup.setPopupPosition(x, y);
            /** show input box for path to mbox file */
            pup.show();
            /** hide the list of available additional commands */
            hide();
        }
    };

    final PopupCommand addressUploadCommand = new PopupCommand() {

        public void execute() {
            AddressUploadGrid ug = new AddressUploadGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(ug, "Address Upload");
            /** hide the list of available additional commands */
            hide();
        }
    };

    final Command showWelcomePanelCommand = new Command() {

        public void execute() {
            WelcomeToMailxelPanel wp = new WelcomeToMailxelPanel(mailxelService, mailxelPanel);
            mailxelPanel.addTab(wp, "Welcome");
        }
    };

    final PopupCommand deleteConfigCommand = new PopupCommand() {

        public void execute() {

            PopupPanel pop = new PopupPanel(true, true);
            HorizontalPanel hp = new HorizontalPanel();
            Label label = new Label("Really delete all configuration?");
            hp.add(label);
            Button b = new Button();
            b.setText("Ok");
            b.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    final StatusItem si = mailxelPanel.statusStart("deleting configuration");
                    mailxelService.deleteConfig(new AsyncCallback<Void>() {

                        public void onFailure(Throwable caught) {
                            si.error(caught);
                        }

                        public void onSuccess(Void result) {
                            si.done();
                        }
                    });
                }
            });
            hp.add(b);
            pop.add(hp);

            int x = additional.getAbsoluteLeft();
            int y = additional.getAbsoluteTop();
            pop.setPopupPosition(x, y);
            pop.show();
            /** hide the list of available additional commands */
            hide();
        }
    };

    final Command updateToMeFlagCommand = new Command() {

        public void execute() {
            final StatusItem si = mailxelPanel.statusStart("Update 'to me' flag");
            mailxelService.updateToMeFlag(new AsyncCallback<Void>() {

                public void onFailure(Throwable caught) {
                    si.error(caught);
                }

                public void onSuccess(Void result) {
                    si.done();
                }
            });
        }
    };

    final Command updateFromMeFlagCommand = new Command() {

        public void execute() {
            final StatusItem si = mailxelPanel.statusStart("Update 'from me' flag");
            mailxelService.updateFromMeFlag(new AsyncCallback<Void>() {

                public void onFailure(Throwable caught) {
                    si.error(caught);
                }

                public void onSuccess(Void result) {
                    si.done();
                }
            });
        }
    };

    final Command showStatisticsCommand = new Command() {

        public void execute() {
            StatisticsGrid sg = new StatisticsGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(sg, "Statistics");
        }
    };

    final Command showIconsCommand = new Command() {

        public void execute() {
            IconOverviewGrid og = new IconOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(og, "Icons");
        }
    };

    final Command showMessageQueriesCommand = new Command() {

        public void execute() {
            MessageQueryOverviewGrid mqog = new MessageQueryOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(mqog, "Message Queries");
        }
    };

    final Command showAttachmentGridCommand = new Command() {

        public void execute() {
            AttachmentOverviewGrid aog = new AttachmentOverviewGrid(mailxelService, mailxelPanel);
            mailxelPanel.addTab(aog, "Attachment Overview");
        }
    };

    final Command closeAllTabsCommand = new Command() {

        public void execute() {
            mailxelPanel.closeAllNonEditTabs();
        }
    };

    final Command dbHousekeeping = new Command() {

        public void execute() {
            final StatusItem si = mailxelPanel.statusStart("DB housekeeping");
            mailxelService.housekeeping(new AsyncCallback<String>() {

                public void onFailure(Throwable caught) {
                    si.error(caught);
                }

                public void onSuccess(String result) {
                    if (result.startsWith("200 OK")) {
                        si.done();
                    } else {
                        si.error(result);
                    }
                }
            });
        }
    };

    final Command messageCount = new Command() {

        public void execute() {
            updateCounts();
        }
    };

    additional.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent sender) {

            MenuBar popupMenuBar = new MenuBar(true);
            PopupPanel popupPanel = new PopupPanel(true);

            MenuItem menuItem = new MenuItem("Attachment Overview", showAttachmentGridCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Close all Tabs", closeAllTabsCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Message Queries", showMessageQueriesCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("DB Housekeeping", dbHousekeeping);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("update pending messages count", messageCount);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Statistics", showStatisticsCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Icons", showIconsCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Import mbox file", importMboxCommand);
            importMboxCommand.setPopupPanel(popupPanel);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Address upload", addressUploadCommand);
            addressUploadCommand.setPopupPanel(popupPanel);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Welcome", showWelcomePanelCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Delete existing configuration", deleteConfigCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Update 'from me' flag", updateFromMeFlagCommand);
            popupMenuBar.addItem(menuItem);

            menuItem = new MenuItem("Update 'to me' flag", updateToMeFlagCommand);
            popupMenuBar.addItem(menuItem);

            popupMenuBar.setVisible(true);
            popupPanel.add(popupMenuBar);

            int x = additional.getAbsoluteLeft();
            int y = additional.getAbsoluteTop();

            popupPanel.setPopupPosition(x, y);
            popupPanel.show();
        }
    });

    updateCounts();

    add(home);
    add(query);
    add(mailnew);
    add(noteToSelf);
    add(contacts);
    add(categories);
    add(download);
    add(reorgMailFolder);
    add(setup);
    add(login);
    add(additional);
    add(logo);
    add(msgCountAct);
}

From source file:ch.unifr.pai.twice.comm.serverPush.standalone.client.ServerPushStandalone.java

License:Apache License

/**
 * This is the entry point method./*from  w ww .j a  v a 2 s .c om*/
 */
/*
 * (non-Javadoc)
 * @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
 */
@Override
public void onModuleLoad() {

    //
    //
    //
    //
    FlexTable table = new FlexTable();
    final TextBox message = new TextBox();
    table.setWidget(0, 0, new Label("Message"));
    table.setWidget(0, 1, message);
    table.setWidget(1, 0, new Label("Event date"));
    final DatePicker datePicker = new DatePicker();
    table.setWidget(1, 1, datePicker);

    Button undoable = new Button("Send as undoable event", new ClickHandler() {

        /**
         * Creates an {@link UndoableTestEvent} and fires it on the event bus.
         * 
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
         */
        @Override
        public void onClick(ClickEvent event) {
            UndoableTestEvent e = GWT.create(UndoableTestEvent.class);
            e.setFoo(message.getText());
            if (datePicker.getValue() != null)
                e.setTimestamp(datePicker.getValue().getTime());
            eventBus.fireEvent(e);
        }
    });

    Button blocking = new Button("Send as blocking event", new ClickHandler() {

        /**
         * Creates an {@link BlockingTestEvent} and fires it on the event bus.
         * 
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
         */
        @Override
        public void onClick(ClickEvent event) {
            BlockingTestEvent e = GWT.create(BlockingTestEvent.class);
            e.foo = message.getText();
            if (datePicker.getValue() != null)
                e.setTimestamp(datePicker.getValue().getTime());
            eventBus.fireEvent(e);
        }
    });

    Button discarding = new Button("Send as discarding event", new ClickHandler() {

        /**
         * Creates an {@link DiscardingTestEvent} and fires it on the event bus.
         * 
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
         */
        @Override
        public void onClick(ClickEvent event) {
            DiscardingTestEvent e = GWT.create(DiscardingTestEvent.class);
            e.setInstanceId("eventTests");
            e.setFoo(message.getText());
            if (datePicker.getValue() != null)
                e.setTimestamp(datePicker.getValue().getTime());
            eventBus.fireEvent(e);
        }
    });

    final HTML html = new HTML("");
    final HTML value = new HTML("");
    eventBus.addHandler(BlockingTestEvent.TYPE, new BlockingTestHandler() {

        /**
         * listens for blocking test events and adds their message to the display
         * 
         * @param event
         */
        @Override
        public void onEvent(BlockingTestEvent event) {
            html.setHTML(html.getHTML() + " [BLOCKING " + event.getTimestamp() + "] " + event.foo);
            value.setHTML(event.foo);
        }
    });
    eventBus.addHandler(UndoableTestEvent.TYPE, new UndoableTestHandler() {

        /**
         * undo the event in case of a conflict by resetting the display to the values valid before the event has been applied
         * 
         * @param event
         */
        @Override
        public void undo(UndoableTestEvent event) {
            html.setHTML(event.getOldHistory());
            value.setHTML(event.getOldValue());
        }

        /**
         * listens for undoable events and adds their message to the display
         * 
         * @param event
         */
        @Override
        public void onEvent(UndoableTestEvent event) {
            html.setHTML(html.getHTML() + " [UNDOABLE " + event.getTimestamp() + "] " + event.getFoo());
            value.setHTML(event.getFoo());
        }

        /**
         * stores the state of the display before the newly arrived event has arrived
         * 
         * @param event
         */
        @Override
        public void saveState(UndoableTestEvent event) {
            event.setOldHistory(html.getHTML());
            event.setOldValue(value.getHTML());
        }
    });

    eventBus.addHandler(DiscardingTestEvent.TYPE, new DiscardingTestHandler() {

        /**
         * listens for discarding test events and adds their message to the display
         * 
         * @param event
         */
        @Override
        public void onEvent(DiscardingTestEvent event) {
            html.setHTML(html.getHTML() + " [DISCARDING " + event.getTimestamp() + "] " + event.getFoo());
            value.setHTML(event.getFoo());
        }
    });

    table.setWidget(2, 0, undoable);
    table.setWidget(2, 1, blocking);
    table.setWidget(2, 2, discarding);
    table.setWidget(3, 0, new Label("Current value: "));
    table.setWidget(3, 1, value);
    table.setWidget(4, 0, new Label("Event history: "));
    table.setWidget(4, 1, html);

    Button ping = new Button("Send ping", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            PingEvent e = GWT.create(PingEvent.class);
            e.setInstanceId("eventTests");
            if (datePicker.getValue() != null)
                e.setTimestamp(datePicker.getValue().getTime());
            eventBus.fireEvent(e);
        }
    });

    RootPanel.get().add(table);
    RootPanel.get().add(ping);

    RootPanel.get().add(new Label("GWTEvent wrapper"));
    FlexTable table2 = new FlexTable();

    final TextBox box = new TextBox();
    table2.setWidget(0, 0, new Label("Textbox"));
    table2.setWidget(0, 1, box);

    eventBus.addHandlerToSource(RemoteKeyPressEvent.TYPE, "test",
            new RemoteKeyPressEvent.RemoteKeyPressHandler() {

                @Override
                public void onEvent(RemoteKeyPressEvent event) {
                    box.setValue(box.getValue() + event.getCharCode());
                }
            });
    box.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            RemoteKeyPressEvent e = GWT.create(RemoteKeyPressEvent.class);
            e.wrap(event);
            eventBus.fireEventFromSource(e, "test");
            event.preventDefault();
        }
    });

    final MyNewTextBox box4 = new MyNewTextBox(eventBus, "myNewTextBox");
    table2.setWidget(1, 0, new Label("My new textbox"));
    table2.setWidget(1, 1, box4);

    final RemoteKeyRecorder recorder = new RemoteKeyRecorder("multiFocus", eventBus);
    RootPanel.get().add(recorder);

    // final RemoteTextBox box3 = new RemoteTextBox("multiFocus", eventBus);
    // box3.setValue("");
    // RootPanel.get().add(box3);
    // table2.setWidget(2, 0, new Label("Textbox (undoable - other resource)"));
    // table2.setWidget(2,1,box3);
    // RootPanel.get().add(table2);
    //
    MultiFocusTextBox multiFocus = new RemoteMultiFocusTextBox("multiFocus", eventBus);
    RootPanel.get().add(multiFocus);

}

From source file:cl.uai.client.page.EditMarkDialog.java

License:Open Source License

public void addFeedback(final String name, String auxLink, String source, String rawLink, int id) {

    HorizontalPanel rowFeedback = new HorizontalPanel();
    HTML feedback = new HTML();
    Icon iconRemove = new Icon(IconType.TRASH);
    String sourceName = "";

    HTML lessIcon = new HTML(iconRemove.toString());
    lessIcon.addStyleName(Resources.INSTANCE.css().plusicon());

    switch (source) {
    case "ocwmit":
        sourceName = "OCW MIT";
        break;/*from w  ww . j a  v a2 s.  c  om*/
    case "merlot":
        sourceName = "Merlot";
        break;
    case "CS50":
        sourceName = "CS50 Harvard";
        break;
    default:
        sourceName = "Webcursos";
    }

    String html = "<p>" + count + ". " + sourceName + " - " + name + "</p><p>Link " + auxLink + "</p><hr>";
    count += 1;
    feedback.setHTML(html);
    rowFeedback.add(lessIcon);
    rowFeedback.add(feedback);
    feedbackForStudent.add(rowFeedback);

    if (id > 0) {
        feedbackArray.add(new FeedbackObject(id, name, rawLink, source));
    } else if (id == 0) {
        feedbackArray.add(new FeedbackObject(name, rawLink, source));
    }
    lessIcon.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            removeFeedback(name);
            loadFeedback();
        }
    });

}

From source file:cmg.org.monitor.module.client.InviteUser.java

License:Open Source License

/**
 * Show dialog box.//from   w w w  .j  av  a 2 s  . c om
 *
 * @param idUser the id user
 * @param actionType the action type
 * @param filter the filter
 */
static void showDialogBox(final String idUser, String actionType, String filter) {
    filterStatic = filter;
    ActionStatic = actionType;
    if (filter.equalsIgnoreCase(filter_Active)) {
        dialogFunction = new DialogBox();
        dialogFunction.setAnimationEnabled(true);
        VerticalPanel dialogVPanel = new VerticalPanel();
        //if filter is active so the idUser will be inactive or delete.we will do this in this
        String tempName = null;
        for (InvitedUser u : listUser3rds) {
            if (u.getEmail().toString().equals(idUser)) {
                tempName = u.getEmail();
            }
        }

        final Button closeButton = new Button("Cancel");
        closeButton.setStyleName("margin:6px;");
        closeButton.addStyleName("form-button");
        final Button okButton = new Button("OK");
        okButton.setStyleName("margin:6px;");
        okButton.addStyleName("form-button");
        final Button exitButton = new Button();
        exitButton.setStyleName("");
        exitButton.getElement().setId("closeButton");
        exitButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                dialogFunction.hide();
            }
        });
        HTML popupContent = new HTML();
        popupContent.setHTML("<h4>Do you want to " + actionType + " user : " + tempName + "?</h4>");
        popupContent.setWidth("400px");
        FlexTable flexHTML = new FlexTable();
        flexHTML.setWidget(0, 0, popupContent);
        flexHTML.getCellFormatter().setWidth(0, 0, "400px");
        flexHTML.setStyleName("table-popup");
        FlexTable table = new FlexTable();
        table.setCellPadding(5);
        table.setCellSpacing(5);
        table.setWidget(0, 0, okButton);
        table.setWidget(0, 1, closeButton);
        table.getCellFormatter().setHorizontalAlignment(0, 0, VerticalPanel.ALIGN_RIGHT);
        table.getCellFormatter().setHorizontalAlignment(0, 1, VerticalPanel.ALIGN_RIGHT);
        dialogVPanel.add(exitButton);
        dialogVPanel.add(flexHTML);
        dialogVPanel.add(table);
        dialogVPanel.setCellHorizontalAlignment(exitButton, VerticalPanel.ALIGN_RIGHT);
        dialogVPanel.setCellHorizontalAlignment(flexHTML, VerticalPanel.ALIGN_LEFT);
        dialogVPanel.setCellHorizontalAlignment(table, VerticalPanel.ALIGN_RIGHT);
        okButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                setVisibleWidget(HTMLControl.ID_BODY_CONTENT, false);
                setVisibleLoadingImage(true);
                popupAction(filterStatic, ActionStatic, idUser);
            }
        });
        closeButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                dialogFunction.hide();
            }
        });
        dialogFunction.setWidget(dialogVPanel);
        dialogFunction.getCaption().asWidget().setStyleName("myCaption");
        dialogFunction.center();

    }
    if (filter.equalsIgnoreCase(filter_requesting)) {
        //if filter requesting,so they will action to active this user
        dialogFunction = new DialogBox();
        dialogFunction.setAnimationEnabled(true);
        VerticalPanel dialogVPanel = new VerticalPanel();
        //if filter is active so the idUser will be inactive.we will do this in this
        String tempName = null;
        for (InvitedUser u : listUser3rds) {
            if (u.getEmail().toString().equals(idUser)) {
                tempName = u.getEmail();
            }
        }
        final Button closeButton = new Button("Cancel");
        closeButton.setStyleName("margin:6px;");
        closeButton.addStyleName("form-button");
        final Button okButton = new Button("OK");
        okButton.setStyleName("margin:6px;");
        okButton.addStyleName("form-button");
        final Button exitButton = new Button();
        exitButton.setStyleName("");
        exitButton.getElement().setId("closeButton");
        exitButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                dialogFunction.hide();
            }
        });
        HTML popupContent = new HTML();
        popupContent.setHTML("<h4>Assgin this" + " user : " + tempName + " to group</h4>");
        popupContent.setWidth("400px");
        listTemp = new ListBox();
        listTemp.setMultipleSelect(true);
        listTemp.setWidth("300px");
        listTemp.setHeight("80px");
        listTemp.addItem(DefaulValueOfListTemp);
        listAll = new ListBox();
        listAll.setWidth("150px");
        for (SystemGroup s : listGroup) {
            listAll.addItem(s.getName());
        }
        btt_MappingGroup = new Button("Mapping");
        btt_MappingGroup.addClickHandler(new MappingGroup());
        btt_UnMappingGroup = new Button("UnMapping");
        btt_UnMappingGroup.addClickHandler(new UnMappingGroup());
        panelValidateGroups = new AbsolutePanel();
        FlexTable flexHTML = new FlexTable();
        flexHTML.getCellFormatter().setWidth(1, 0, "100px");
        flexHTML.getCellFormatter().setWidth(1, 1, "100px");
        flexHTML.getCellFormatter().setWidth(1, 2, "100px");
        flexHTML.getCellFormatter().setWidth(1, 3, "200px");
        flexHTML.getCellFormatter().setWidth(1, 4, "400px");
        flexHTML.getFlexCellFormatter().setColSpan(0, 0, 5);
        flexHTML.setWidget(0, 0, popupContent);
        flexHTML.setWidget(1, 0, listAll);
        flexHTML.setWidget(1, 1, btt_MappingGroup);
        flexHTML.setWidget(1, 2, btt_UnMappingGroup);
        flexHTML.setWidget(1, 3, listTemp);
        flexHTML.setStyleName("table-popup");
        FlexTable table = new FlexTable();
        table.setCellPadding(5);
        table.setCellSpacing(5);
        table.setWidget(0, 0, okButton);
        table.setWidget(0, 1, closeButton);
        table.getCellFormatter().setHorizontalAlignment(0, 0, VerticalPanel.ALIGN_RIGHT);
        table.getCellFormatter().setHorizontalAlignment(0, 1, VerticalPanel.ALIGN_RIGHT);
        dialogVPanel.add(exitButton);
        dialogVPanel.add(flexHTML);
        dialogVPanel.add(table);
        dialogVPanel.setCellHorizontalAlignment(exitButton, VerticalPanel.ALIGN_RIGHT);
        dialogVPanel.setCellHorizontalAlignment(flexHTML, VerticalPanel.ALIGN_LEFT);
        dialogVPanel.setCellHorizontalAlignment(table, VerticalPanel.ALIGN_RIGHT);
        okButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                //send to server
                if (listTemp.getValue(0).equalsIgnoreCase(DefaulValueOfListTemp)) {
                    listTemp.setFocus(true);
                    return;
                } else {
                    setVisibleWidget(HTMLControl.ID_BODY_CONTENT, false);
                    setVisibleLoadingImage(true);
                    popupAction(filterStatic, ActionStatic, idUser);
                }

            }
        });
        closeButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                dialogFunction.hide();
            }
        });
        dialogFunction.setWidget(dialogVPanel);
        dialogFunction.getCaption().asWidget().setStyleName("myCaption");
        dialogFunction.center();
    }
    if (filter.equalsIgnoreCase(filter_pending)) {
        dialogFunction = new DialogBox();
        dialogFunction.setAnimationEnabled(true);
        VerticalPanel dialogVPanel = new VerticalPanel();
        //if filter is pending so the idUser will be delete.we will do this in this
        String tempName = null;
        for (InvitedUser u : listUser3rds) {
            if (u.getEmail().toString().equals(idUser)) {
                tempName = u.getEmail();
            }
        }

        final Button closeButton = new Button("Cancel");
        closeButton.setStyleName("margin:6px;");
        closeButton.addStyleName("form-button");
        final Button okButton = new Button("OK");
        okButton.setStyleName("margin:6px;");
        okButton.addStyleName("form-button");
        final Button exitButton = new Button();
        exitButton.setStyleName("");
        exitButton.getElement().setId("closeButton");
        exitButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                dialogFunction.hide();
            }
        });
        HTML popupContent = new HTML();
        popupContent.setHTML("<h4>Do you want to " + actionType + " user : " + tempName + "?</h4>");
        popupContent.setWidth("400px");
        FlexTable flexHTML = new FlexTable();
        flexHTML.setWidget(0, 0, popupContent);
        flexHTML.getCellFormatter().setWidth(0, 0, "400px");
        flexHTML.setStyleName("table-popup");
        FlexTable table = new FlexTable();
        table.setCellPadding(5);
        table.setCellSpacing(5);
        table.setWidget(0, 0, okButton);
        table.setWidget(0, 1, closeButton);
        table.getCellFormatter().setHorizontalAlignment(0, 0, VerticalPanel.ALIGN_RIGHT);
        table.getCellFormatter().setHorizontalAlignment(0, 1, VerticalPanel.ALIGN_RIGHT);
        dialogVPanel.add(exitButton);
        dialogVPanel.add(flexHTML);
        dialogVPanel.add(table);
        dialogVPanel.setCellHorizontalAlignment(exitButton, VerticalPanel.ALIGN_RIGHT);
        dialogVPanel.setCellHorizontalAlignment(flexHTML, VerticalPanel.ALIGN_LEFT);
        dialogVPanel.setCellHorizontalAlignment(table, VerticalPanel.ALIGN_RIGHT);
        okButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                setVisibleWidget(HTMLControl.ID_BODY_CONTENT, false);
                setVisibleLoadingImage(true);
                popupAction(filterStatic, ActionStatic, idUser);
            }
        });
        closeButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                dialogFunction.hide();
            }
        });
        dialogFunction.setWidget(dialogVPanel);
        dialogFunction.getCaption().asWidget().setStyleName("myCaption");
        dialogFunction.center();
    }
}

From source file:com.achow101.bittipaddr.client.bittipaddr.java

License:Open Source License

/**
 * This is the entry point method.// w w  w .  j a va 2s .c om
 */
public void onModuleLoad() {

    // Add textboxes
    TextBox unitLookupBox = new TextBox();
    TextBox unitPassBox = new TextBox();
    TextBox xpubBox = new TextBox();
    xpubBox.setWidth("600");
    TextArea addrsArea = new TextArea();
    addrsArea.setWidth("300");
    addrsArea.setHeight("300");

    // Checkbox to enable editing with lookup
    CheckBox submitEdit = new CheckBox("Submit changes after clicking button");
    CheckBox allowEdit = new CheckBox("Allow editing the unit");

    // Add text elements
    HTML output = new HTML();

    // Create Button
    Button submitBtn = new Button("Submit");

    submitBtn.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {

            // Clear previous output
            output.setHTML("");

            // Get entered data and some prelim checking
            String xpub = xpubBox.getText();
            String pass = unitPassBox.getText();
            String unit = unitLookupBox.getText();
            String[] addrs = addrsArea.getText().split("\n");
            if (!xpub.isEmpty() && !addrs[0].isEmpty() && unit.isEmpty() && pass.isEmpty()) {
                output.setHTML("<p style=\"color:red;\">Cannot set both xpub and a list of addresses</p>");
                return;
            }

            // Send to server
            AddrReq req = new AddrReq();
            if (!unit.isEmpty()) {
                req.setId(unit);
                req.setPassword(pass);
                req.setEditable(allowEdit.getValue());
                if (edited) {
                    if (xpub.isEmpty()) {
                        output.setHTML(
                                "<p style=\"color:red;\">Must have an xpub. Set as \"NONE\" (without quotes) if no xpub</p>");
                        return;
                    }

                    req.setEdited();
                    req.setAddresses(addrs);
                    req.setXpub(xpub.isEmpty() ? "NONE" : xpub);
                }
            } else if (!xpub.isEmpty()) {
                req = new AddrReq(xpub);
            } else if (addrs.length != 0) {
                req = new AddrReq(addrs);
            }
            bittipaddrService.App.getInstance().addAddresses(req,
                    new AddAddrAsyncCallback(output, xpubBox, addrsArea));
        }
    });

    // Add to html
    RootPanel.get("submitBtn").add(submitBtn);
    RootPanel.get("unitLookup").add(unitLookupBox);
    RootPanel.get("unitPass").add(unitPassBox);
    RootPanel.get("enterxpub").add(xpubBox);
    RootPanel.get("enterAddrList").add(addrsArea);
    RootPanel.get("completedReqOutput").add(output);
    RootPanel.get("edit").add(submitEdit);
    RootPanel.get("allowEdit").add(allowEdit);
}