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

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

Introduction

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

Prototype

protected Button(com.google.gwt.dom.client.Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

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

License:Apache License

/**
 * the displaying functions for recipes/*  w ww .j av a2  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:cl.uai.client.chat.ChatInterface.java

License:Open Source License

/**
 * Creates a new chat interface/*w w w .j  a va2 s .c o m*/
 */
public ChatInterface() {

    this.source = NodeChat.SOURCE_CHAT;

    this.addStyleName(Resources.INSTANCE.css().chatdialog());

    // Dialog parameters
    this.setAutoHideEnabled(false);
    this.setAnimationEnabled(true);
    this.setModal(false);
    this.setHTML(MarkingInterface.messages.Chat());

    // Initialize interfaces and assign css
    messagesPanel = new VerticalPanel();
    messagesPanel.addStyleName(Resources.INSTANCE.css().chatmessages());

    scrollMessagesPanel = new ScrollPanel(messagesPanel);
    scrollMessagesPanel.addStyleName(Resources.INSTANCE.css().chatscrollmessages());
    scrollMessagesPanel.scrollToBottom();

    usersConnectedPanel = new ConnectedUsersPanel();

    sendMessageTextArea = new TextArea();
    sendMessageTextArea.setVisibleLines(2);
    sendMessageTextArea.addStyleName(Resources.INSTANCE.css().chatTextarea());

    // KeyDown for text area for sending message
    sendMessageTextArea.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                event.stopPropagation();
                String msg = sendMessageTextArea.getValue();
                msg = msg.replace("\n", "");
                sendMessage(msg);
                sendMessageTextArea.setValue(null);
            }
        }
    });

    // Vertical panel that contains everything
    mainPanel = new VerticalPanel();
    mainPanel.addStyleName(Resources.INSTANCE.css().chatmainpanel());

    mainPanel.add(usersConnectedPanel);
    mainPanel.setCellHorizontalAlignment(usersConnectedPanel, HasAlignment.ALIGN_CENTER);
    mainPanel.add(scrollMessagesPanel);
    mainPanel.add(sendMessageTextArea);

    closeButton = new Button(MarkingInterface.messages.Close());
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            hide();
        }
    });

    mainPanel.add(closeButton);
    mainPanel.setCellHorizontalAlignment(closeButton, HasAlignment.ALIGN_RIGHT);

    timer = new Timer() {
        @Override
        public void run() {
            for (int i = 0; i < messagesPanel.getWidgetCount(); i++) {
                if (messagesPanel.getWidget(i) instanceof ChatMessage) {
                    ChatMessage chatMessage = (ChatMessage) messagesPanel.getWidget(i);
                    chatMessage.updateElapsedTime();
                }
            }
        }
    };

    timer.scheduleRepeating(1000 * 60); // Every minute

    this.setWidget(mainPanel);
}

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

License:Open Source License

/**
 * Creates a comment dialog at a specific position
 *///from  w w w . jav  a  2s. c  o m
public AddMarkDialog(MarkingPage _parent) {
    super(true, false);

    this.page = _parent;

    this.mainPanel = new VerticalPanel();
    this.mainPanel.addStyleName(Resources.INSTANCE.css().addmarkdialog());

    this.rubricPanel = new RubricPanel(true);

    this.mainPanel.add(rubricPanel);

    // Adds the CSS style and other settings
    this.addStyleName(Resources.INSTANCE.css().commentdialog());

    this.setAnimationEnabled(true);
    this.setGlassEnabled(true);

    this.setHTML(MarkingInterface.messages.AddEditMark());

    // Cancel button
    Button btnCancel = new Button(MarkingInterface.messages.Cancel());
    btnCancel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = true;
            hide();
        }
    });

    // Add buttons
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.add(btnCancel);
    mainPanel.add(hpanel);
    mainPanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT);

    this.addCloseHandler(new CloseHandler<PopupPanel>() {
        @Override
        public void onClose(CloseEvent<PopupPanel> event) {
            if (!cancelled && levelId > 0) {
                EMarkingWeb.markingInterface.addRubricMark(levelId, rubricLeft, rubricTop, page);
            } else if (!cancelled) {
                logger.severe("Error adding mark! Level id " + levelId);
            }
        }
    });

    this.getElement().getStyle().setProperty("MaxWidth", (Window.getClientWidth() - 100) + "px");

    this.setWidget(mainPanel);
}

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

License:Open Source License

/**
 * Creates a comment dialog at a specific position
 * /*from w ww . j  av a  2s . c  o  m*/
 * @param posx Top position for the dialog
 * @param posy Left position for the dialog
 * @param level An optional rubric level in case we are editing one
 */
public EditMarkDialog(int posx, int posy, int level, int regradeid) {
    super(true, false);

    this.regradeId = regradeid;

    this.levelId = level;
    Level lvl = MarkingInterface.submissionData.getLevelById(levelId);

    if (EMarkingConfiguration.getKeywords() != null && EMarkingConfiguration.getKeywords().length() > 0) {
        logger.fine("Keywords: " + EMarkingConfiguration.getKeywords());
    }
    if (!EMarkingConfiguration.getKeywords().equals("") && (level > 0 || regradeid > 0)) {
        feedbackArray = new ArrayList<FeedbackObject>();
        feedbackPanel = new FeedbackInterface();
        feedbackPanel.setParent(this);
    } else {
        simplePanel = true;
    }

    superPanel = new HorizontalPanel();
    superPanel.addStyleName(Resources.INSTANCE.css().feedbackdialog());

    feedbackForStudent = new VerticalPanel();
    feedbackForStudent.addStyleName(Resources.INSTANCE.css().feedbackforstudent());

    feedbackSummary = new ScrollPanel(feedbackForStudent);
    feedbackSummary.addStyleName(Resources.INSTANCE.css().feedbacksummary());

    mainPanel = new VerticalPanel();
    mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialog());

    // Adds the CSS style and other settings
    this.addStyleName(Resources.INSTANCE.css().commentdialog());
    this.setAnimationEnabled(true);
    this.setGlassEnabled(true);

    bonusTxt = new TextBox();
    bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslist());

    this.levelsList = new ListBox();
    this.levelsList.addStyleName(Resources.INSTANCE.css().levelslist());
    this.levelsList.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            int levelid = Integer.parseInt(levelsList.getValue(levelsList.getSelectedIndex()));
            levelId = levelid;
            Level lvl = MarkingInterface.submissionData.getLevelById(levelId);
            setBonus(lvl.getBonus());
        }
    });

    // If there's a rubric level we should edit a Mark
    // otherwise we are just editing its comment
    if (this.levelId == 0) {
        this.setHTML(MarkingInterface.messages.AddEditComment());
    } else {
        this.setHTML(MarkingInterface.messages.AddEditMark() + "<br/>" + lvl.getCriterion().getDescription());
    }

    // Position the dialog
    if (simplePanel) {
        this.setPopupPosition(posx, posy);
    } else {
        // The Dialog is more big, so we need to fix the position
        this.setPopupPosition((int) (Window.getClientWidth() * 0.08), (int) (Window.getClientHeight() * 0.15));
    }

    if (this.levelId > 0) {

        loadLevelsList();

        HorizontalPanel hpanelLevels = new HorizontalPanel();
        hpanelLevels.setWidth("100%");
        Label messages = new Label(MarkingInterface.messages.Level());
        hpanelLevels.add(messages);
        hpanelLevels.add(levelsList);
        hpanelLevels.setCellHorizontalAlignment(levelsList, HasHorizontalAlignment.ALIGN_RIGHT);
        mainPanel.add(hpanelLevels);
        mainPanel.setCellHorizontalAlignment(hpanelLevels, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Save button
    Button btnSave = new Button(MarkingInterface.messages.Save());
    btnSave.addStyleName(Resources.INSTANCE.css().btnsave());
    btnSave.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (levelId > 0 && !bonusIsValid()) {
                Window.alert(MarkingInterface.messages.InvalidBonusValue());
                return;
            }
            cancelled = false;
            hide();
        }
    });

    // Cancel button
    Button btnCancel = new Button(MarkingInterface.messages.Cancel());
    btnSave.addStyleName(Resources.INSTANCE.css().btncancel());
    btnCancel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = true;
            hide();
        }
    });

    // The comment text box
    TextArea txt = new TextArea();
    txt.setVisibleLines(5);
    txt.getElement().getStyle().setMarginBottom(5, Unit.PT);
    txtComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt);
    txtComment.setAutoSelectEnabled(false);
    txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestbox());

    HorizontalPanel hpanelComment = new HorizontalPanel();
    hpanelComment.setWidth("100%");
    hpanelComment.add(new Label(MarkingInterface.messages.Comment()));
    hpanelComment.add(txtComment);
    hpanelComment.setCellHorizontalAlignment(txtComment, HasHorizontalAlignment.ALIGN_RIGHT);
    mainPanel.add(hpanelComment);
    mainPanel.setCellHorizontalAlignment(hpanelComment, HasHorizontalAlignment.ALIGN_RIGHT);

    // If the rubric level is not null then create the bonus list and add it to the dialog 
    if (this.levelId > 0) {
        setBonus(lvl.getBonus());

        HorizontalPanel hpanelBonus = new HorizontalPanel();
        hpanelBonus.setWidth("100%");
        hpanelBonus.add(new Label(MarkingInterface.messages.SetBonus()));
        hpanelBonus.add(bonusTxt);
        hpanelBonus.setCellHorizontalAlignment(bonusTxt, HasHorizontalAlignment.ALIGN_RIGHT);
        if (EMarkingConfiguration.isFormativeFeedbackOnly()) {
            hpanelBonus.setVisible(false);
        }
        mainPanel.add(hpanelBonus);
        mainPanel.setCellHorizontalAlignment(hpanelBonus, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // The regrade comment text box
    txt = new TextArea();
    txt.setVisibleLines(5);
    txt.getElement().getStyle().setMarginBottom(5, Unit.PT);
    txtRegradeComment = new SuggestBox(EMarkingWeb.markingInterface.previousCommentsOracle, txt);

    if (this.regradeId > 0) {

        mainPanel.add(new HTML("<hr>"));
        mainPanel.add(new Label(MarkingInterface.messages.Regrade()));

        // Add the textbox
        HorizontalPanel hpanelRegradeComment = new HorizontalPanel();
        hpanelRegradeComment.setWidth("100%");
        hpanelRegradeComment.add(new Label(MarkingInterface.messages.RegradeComment()));
        hpanelRegradeComment.add(txtRegradeComment);
        hpanelRegradeComment.setCellHorizontalAlignment(txtRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT);
        mainPanel.add(hpanelRegradeComment);
        mainPanel.setCellHorizontalAlignment(hpanelRegradeComment, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Add buttons
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setSpacing(2);
    hpanel.setWidth("100%");
    hpanel.add(btnSave);
    hpanel.add(btnCancel);
    hpanel.setCellWidth(btnSave, "100%");
    hpanel.setCellWidth(btnCancel, "0px");
    hpanel.setCellHorizontalAlignment(btnCancel, HasHorizontalAlignment.ALIGN_RIGHT);
    hpanel.setCellHorizontalAlignment(btnSave, HasHorizontalAlignment.ALIGN_RIGHT);
    mainPanel.add(hpanel);
    mainPanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT);

    if (simplePanel) {
        // No feedback
        this.setWidget(mainPanel);
    } else {
        // Remove CSS Style
        mainPanel.removeStyleName(Resources.INSTANCE.css().editmarkdialog());
        mainPanel.addStyleName(Resources.INSTANCE.css().editmarkdialogWithFeedback());

        bonusTxt.removeStyleName(Resources.INSTANCE.css().bonuslist());
        bonusTxt.addStyleName(Resources.INSTANCE.css().bonuslistWithFeedback());

        this.levelsList.removeStyleName(Resources.INSTANCE.css().levelslist());
        this.levelsList.addStyleName(Resources.INSTANCE.css().levelslistWithFeedback());

        txtComment.removeStyleName(Resources.INSTANCE.css().editmarksuggestbox());
        txtComment.addStyleName(Resources.INSTANCE.css().editmarksuggestboxWithFeedback());

        // Add feedback panel
        mainPanel.add(new HTML("<h4>Feedback</h4>"));
        mainPanel.add(feedbackSummary);

        superPanel.add(mainPanel);
        superPanel.add(feedbackPanel);
        this.setWidget(superPanel);
    }
}

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

License:Open Source License

/**
 * Creates a comment dialog at a specific position
 *//*from  w ww  .j  av a2 s  .co  m*/
public RequestRegradeDialog() {
    super(true, false);

    this.addStyleName(Resources.INSTANCE.css().requestregradedialog());

    this.mainPanel = new VerticalPanel();
    this.mainPanel.setWidth("100%");

    motive = new ListBox();
    motive.setWidth("390px");

    motive.addItem(MarkingInterface.messages.Select(), "0");
    for (int motiveId : EMarkingConfiguration.getRegradeMotives().keySet()) {
        String motiveName = EMarkingConfiguration.getRegradeMotives().get(motiveId);
        motive.addItem(motiveName, Integer.toString(motiveId));
    }

    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setWidth("100%");
    hpanel.add(new Label(MarkingInterface.messages.Motive()));
    hpanel.add(motive);
    hpanel.setCellHorizontalAlignment(motive, HasAlignment.ALIGN_RIGHT);
    this.mainPanel.add(hpanel);

    comment = new TextArea();
    comment.setVisibleLines(10);
    comment.setWidth("380px");
    comment.setHeight("150px");

    hpanel = new HorizontalPanel();
    hpanel.setWidth("100%");
    hpanel.add(new Label(MarkingInterface.messages.CommentForMarker()));
    hpanel.add(comment);
    hpanel.setCellHorizontalAlignment(comment, HasAlignment.ALIGN_RIGHT);
    this.mainPanel.add(hpanel);

    // Adds the CSS style and other settings
    this.addStyleName(Resources.INSTANCE.css().commentdialog());

    this.setAnimationEnabled(true);
    this.setGlassEnabled(true);

    this.setHTML(MarkingInterface.messages.RequestRegrade());

    // Save button
    Button btnSave = new Button(MarkingInterface.messages.Save());
    btnSave.addStyleName(Resources.INSTANCE.css().btnsave());
    btnSave.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (comment.getText().length() > 500) {
                Window.alert(MarkingInterface.messages.RequestMaximumLength(comment.getText().length()));
                return;
            } else if (motive.isItemSelected(0)) {
                Window.alert(MarkingInterface.messages.MotiveIsMandatory());
                return;
            } else {
                cancelled = false;
                hide();
            }
        }
    });

    // Cancel button
    Button btnCancel = new Button(MarkingInterface.messages.Cancel());
    btnSave.addStyleName(Resources.INSTANCE.css().btncancel());
    btnCancel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = true;
            hide();
        }
    });

    // Add buttons
    hpanel = new HorizontalPanel();
    hpanel.add(btnSave);
    hpanel.add(btnCancel);
    mainPanel.add(hpanel);
    mainPanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT);

    this.setWidget(mainPanel);
}

From source file:cl.uai.client.rubric.ChangeLogInterface.java

License:Open Source License

public ChangeLogInterface() {
    this.mainPanel = new VerticalPanel();
    this.mainPanel.addStyleName(Resources.INSTANCE.css().previouscomments());

    this.title = new Label(MarkingInterface.messages.ChangeLogInstructions());

    this.changeLogText = new TextArea();
    this.changeLogText.addStyleName(Resources.INSTANCE.css().generalfeedbacktxt());
    this.changeLogText.addValueChangeHandler(new ValueChangeHandler<String>() {
        @Override//from w w  w .j  a  va  2s. c  o  m
        public void onValueChange(ValueChangeEvent<String> event) {
            logger.fine("Changed!");
        }
    });

    this.saveLog = new Button(MarkingInterface.messages.SaveChanges());
    this.saveLog.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            AjaxRequest.ajaxRequest("action=addchangelog&txt=" + URL.encode(getChangeLogText()),
                    new AsyncCallback<AjaxData>() {
                        @Override
                        public void onSuccess(AjaxData result) {
                            Window.alert("Success!");
                        }

                        @Override
                        public void onFailure(Throwable caught) {
                            Window.alert("Falied! :-( Please try again later");
                        }
                    });
        }
    });

    mainPanel.add(title);
    mainPanel.add(changeLogText);
    mainPanel.add(saveLog);
    mainPanel.setCellHorizontalAlignment(saveLog, HasHorizontalAlignment.ALIGN_RIGHT);

    this.initWidget(mainPanel);
}

From source file:cl.uai.client.toolbar.FinishMarkingDialog.java

License:Open Source License

public FinishMarkingDialog() {
    this.setHTML(MarkingInterface.messages.GeneralFeedback());
    this.addStyleName(Resources.INSTANCE.css().commentdialog());

    generalFeedback = new TextArea();
    generalFeedback.addStyleName(Resources.INSTANCE.css().generalfeedbacktxt());

    this.setModal(true);
    this.setAutoHideEnabled(false);
    this.setGlassEnabled(true);

    vpanel = new VerticalPanel();
    vpanel.add(new Label(MarkingInterface.messages.GeneralFeedbackInstructions()));
    vpanel.add(generalFeedback);//  w  w  w .j a  v a 2  s.co m

    HorizontalPanel hpanel = new HorizontalPanel();

    Button saveButton = new Button(MarkingInterface.messages.Save());
    saveButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = false;
            hide();
        }
    });

    Button cancelButton = new Button(MarkingInterface.messages.Cancel());
    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = true;
            hide();
        }
    });

    hpanel.add(saveButton);
    hpanel.add(cancelButton);

    vpanel.add(hpanel);
    vpanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT);

    this.setWidget(vpanel);
}

From source file:cl.uai.client.toolbar.RotatePagesDialog.java

License:Open Source License

public RotatePagesDialog() {
    this.setHTML(MarkingInterface.messages.SortPages());
    this.addStyleName(Resources.INSTANCE.css().commentdialog());

    int pages = EMarkingWeb.markingInterface.getMarkingPagesInterface().getNumPages();

    this.setPixelSize(300, 300);

    scrollpanel = new ScrollPanel();
    scrollpanel.setPixelSize(300, 300);// ww w  .j a  v a  2  s . c o m

    apanel = new VerticalPanel();
    for (int i = 0; i < pages; i++) {
        PushButton btnPage = new PushButton(MarkingInterface.messages.RotatePage(i + 1));
        btnPage.setTabIndex(i + 1);
        btnPage.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                PushButton btn = (PushButton) event.getSource();
                selectedPage = btn.getTabIndex();
                cancelled = false;
                hide();
            }
        });
        apanel.add(btnPage);
    }
    scrollpanel.add(apanel);

    this.setModal(true);
    this.setAutoHideEnabled(false);
    this.setGlassEnabled(true);

    vpanel = new VerticalPanel();
    vpanel.add(new Label(MarkingInterface.messages.RotatePagesInstructions()));
    vpanel.add(scrollpanel);

    // Basic save/cancel buttons
    HorizontalPanel hpanel = new HorizontalPanel();

    Button cancelButton = new Button(MarkingInterface.messages.Cancel());
    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = true;
            hide();
        }
    });

    hpanel.add(cancelButton);

    vpanel.add(hpanel);
    vpanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT);

    this.setWidget(vpanel);
}

From source file:cl.uai.client.toolbar.SortPagesDialog.java

License:Open Source License

public SortPagesDialog() {
    this.setHTML(MarkingInterface.messages.SortPages());
    this.addStyleName(Resources.INSTANCE.css().commentdialog());

    int pages = EMarkingWeb.markingInterface.getMarkingPagesInterface().getNumPages();

    this.setPixelSize(300, 300);

    scrollpanel = new ScrollPanel();
    scrollpanel.setPixelSize(300, 300);//from  w w  w  .j  a  va 2s  .c om

    apanel = new AbsolutePanel();
    scrollpanel.add(apanel);

    FlexTableRowDragController drag = new FlexTableRowDragController(apanel);
    pagesTable = new SortPagesFlexTable(pages, 1, drag);
    pagesTable.addStyleName(Resources.INSTANCE.css().generalfeedbacktxt());
    apanel.add(pagesTable);

    FlexTableRowDropController drop = new FlexTableRowDropController(pagesTable);
    drag.registerDropController(drop);

    this.setModal(true);
    this.setAutoHideEnabled(false);
    this.setGlassEnabled(true);

    vpanel = new VerticalPanel();
    vpanel.add(new Label(MarkingInterface.messages.SortPagesInstructions()));
    vpanel.add(scrollpanel);

    HorizontalPanel hpanel = new HorizontalPanel();

    Button saveButton = new Button(MarkingInterface.messages.SaveChanges());
    saveButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = false;
            hide();
        }
    });

    Button cancelButton = new Button(MarkingInterface.messages.Cancel());
    cancelButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cancelled = true;
            hide();
        }
    });

    hpanel.add(saveButton);
    hpanel.add(cancelButton);

    vpanel.add(hpanel);
    vpanel.setCellHorizontalAlignment(hpanel, HasHorizontalAlignment.ALIGN_RIGHT);

    this.setWidget(vpanel);
}

From source file:client.NewGameDialog.java

License:Apache License

public NewGameDialog() {
    String gameOverText = "You just lost <a href='http://www.google.com/"
            + "search?q=lost+the+game'>The Game</a>";
    this.setHTML("Tetris");
    this.setAnimationEnabled(true);
    HTML html = new HTML("<u>Controls</u><br/>" + "<b>Right Left Down</b>: move around<br/>"
            + "<b>Up</b>: rotate clockwise<br/>" + "<b>Space</b>: drop");
    Button button = new Button("New Game");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.setWidth("100%");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    dialogVPanel.add(html);/*from   ww  w.j a  v  a 2s.co m*/
    dialogVPanel.add(button);

    button.addClickListener(this);

    // Set the contents of the Widget
    this.setWidget(dialogVPanel);
    this.center();
}