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:ca.ubc.ece.netsyslab.tagvalue.client.SearchBarWidget.java

License:Open Source License

private void addNewTag() {
    tags.add(newTagBox.getText());//  w  w  w  .j  a  v a2  s.com
    Button newTagButton = new Button(newTagBox.getText());
    newTagButton.addClickHandler(this);
    newTagButton.addKeyUpHandler(this);
    tagButtons.add(newTagButton);
    insertCell(0, cellIdx);
    setWidget(0, cellIdx, newTagButton);
    cellIdx++;
    newTagBox.setText("");
}

From source file:ca.upei.ic.timetable.client.FindCourseView.java

License:Apache License

public FindCourseView(FindCourseViewController controller) {
    controller_ = controller;//from www .jav a 2s .  co  m

    // set up the dialog box
    dialogBox_ = new DialogBox(false, true); // autohide = false, modal = true
    dialogBox_.setAnimationEnabled(true);
    dialogBox_.setText("Find Courses...");

    // i have a horizontal panel
    HorizontalPanel filterPanel = new HorizontalPanel();
    // i have a level flex table
    levelTable_ = controller_.getLevelModel().getWidget();
    departmentTable_ = controller_.getDepartmentModel().getWidget();
    semesterTable_ = controller_.getSemesterModel().getWidget();
    startTimeWidget_ = controller_.getStartTimeModel().getWidget();

    // button panel
    HorizontalPanel buttonPanel = new HorizontalPanel();
    buttonPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);

    // i have an OK button
    final Button okButton = new Button("Search");
    okButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            // search and close the dialog
            controller_.search();
            hide();
        }

    });

    okButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ENTER) {
                okButton.click();
            }
        }

    });

    final Button cancelButton = new Button("Cancel");
    cancelButton.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            hide();
        }
    });

    cancelButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ESCAPE)
                cancelButton.click();
        }

    });

    SimplePanel empty = new SimplePanel();
    empty.setWidth("230px");
    buttonPanel.add(empty);
    buttonPanel.add(cancelButton);
    buttonPanel.add(okButton);
    buttonPanel.setSpacing(5);
    buttonPanel.setWidth("485px");

    // add the panel to the dialog box
    dialogBox_.add(PanelUtils.verticalPanel(PanelUtils.horizontalPanel(
            PanelUtils.verticalPanel(PanelUtils.scrollPanel(levelTable_, 250, 180),
                    PanelUtils.scrollPanel(semesterTable_, 250, 120),
                    PanelUtils.scrollPanel(startTimeWidget_, 250, 30)),
            PanelUtils.scrollPanel(departmentTable_, 250, 320)), buttonPanel));
    dialogBox_.setPopupPosition(240, 0);
}

From source file:ca.upei.ic.timetable.client.MessageView.java

License:Apache License

public MessageView(MessageViewController controller) {
    controller_ = controller;//from   w w w .  j  av  a  2  s  .  c o m
    dialogBox_ = new DialogBox(true, true);
    dialogBox_.setText("Messages");
    dialogBox_.setAnimationEnabled(true);
    dialogBox_.hide();
    // XXX a hack to make sure the dialog display top most
    dialogBox_.getElement().getStyle().setProperty("z-index", "100");

    ScrollPanel scrolled = new ScrollPanel();
    scrolled.setPixelSize(350, 250);

    panel_ = new VerticalPanel();
    panel_.setWidth("232px");

    scrolled.add(panel_);
    Button closeButton = new Button("Close");
    closeButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            dialogBox_.hide();
        }

    });

    closeButton.addKeyboardListener(new KeyboardListener() {

        public void onKeyDown(Widget sender, char keyCode, int modifiers) {
        }

        public void onKeyPress(Widget sender, char keyCode, int modifiers) {
            if (keyCode == KeyboardListener.KEY_ESCAPE)
                dialogBox_.hide();
        }

        public void onKeyUp(Widget sender, char keyCode, int modifiers) {
        }

    });

    Button clearButton = new Button("Clear");
    clearButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            clearMessage();
        }

    });

    dialogBox_.setWidget(
            PanelUtils.verticalPanel(scrolled, PanelUtils.horizontalPanel(closeButton, clearButton)));
}

From source file:cc.alcina.framework.gwt.client.ClientNotificationsImpl.java

License:Apache License

@Override
public void showDialog(String captionHTML, Widget captionWidget, String msg, MessageType messageType,
        List<Button> extraButtons, String containerStyle) {
    ensureImages();/* www.j av a  2  s. co m*/
    HorizontalAlignmentConstant align = messageType == MessageType.ERROR ? HasHorizontalAlignment.ALIGN_LEFT
            : HasHorizontalAlignment.ALIGN_CENTER;
    if (dialogBox != null) {
        dialogBox.hide();
    }
    String title = CommonUtils.friendlyConstant(messageType);
    dialogBox = new GlassDialogBox();
    dialogBox.setAnimationEnabled(dialogAnimationEnabled);
    AbstractImagePrototype aip = null;
    String text = "";
    switch (messageType) {
    case INFO:
        aip = AbstractImagePrototype.create(images.info());
        text = "Information";
        break;
    case WARN:
        aip = AbstractImagePrototype.create(images.warning());
        text = "Warning";
        break;
    case ERROR:
        aip = AbstractImagePrototype.create(images.error());
        text = "Problem notification";
        break;
    }
    dialogBox.setText(text);
    FlexTable ft = new FlexTable();
    containerStyle = containerStyle != null ? containerStyle
            : (messageType == MessageType.ERROR || !CommonUtils.isNullOrEmpty(msg)) ? "medium" : "narrow";
    ft.setCellSpacing(4);
    ft.setStyleName("alcina-Notification");
    ft.addStyleName(containerStyle);
    FlexCellFormatter cf = (FlexCellFormatter) ft.getCellFormatter();
    ft.setWidget(0, 0, aip.createImage());
    cf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
    cf.setWidth(0, 0, "40px");
    FlowPanel fp = new FlowPanel();
    fp.setStyleName("text");
    Widget capWidget = captionHTML != null ? new HTML(captionHTML) : captionWidget;
    if (captionHTML != null) {
        capWidget.setStyleName("caption");
    }
    fp.add(capWidget);
    if (!CommonUtils.isNullOrEmpty(msg)) {
        Link nh = new Link("View detail");
        nh.addStyleName("pad-5");
        dialogHtml = new HTML("<span class='logboxpre'>" + msg.replace("\n", "<br>") + "</span>", true);
        final ScrollPanel sp = new ScrollPanel(dialogHtml);
        sp.setStyleName("logbox");
        sp.setVisible(containerStyle.equals("wide"));
        nh.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                sp.setVisible(!sp.isVisible());
            }
        });
        if (LooseContext.getBoolean(ClientNotifications.CONTEXT_AUTOSHOW_DIALOG_DETAIL)) {
            sp.setVisible(true);
        }
        fp.add(nh);
        fp.add(sp);
    }
    ft.setWidget(0, 1, fp);
    cf.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(8);
    Button closeButton = new Button("Close");
    hp.add(closeButton);
    if (extraButtons != null) {
        for (Button b : extraButtons) {
            hp.add(b);
        }
    }
    ft.setWidget(1, 0, hp);
    cf.setColSpan(1, 0, 2);
    cf.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    closeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
    dialogBox.setWidget(ft);
    dialogBox.center();
    dialogBox.show();
    Scheduler.get().scheduleDeferred(() -> closeButton.setFocus(true));
}

From source file:cc.alcina.framework.gwt.client.widget.dialog.CancellableRemoteDialog.java

License:Apache License

public CancellableRemoteDialog(String msg, PermissibleActionListener l, boolean autoShow) {
    if (l == null) {
        l = new PermissibleActionListener() {
            public void vetoableAction(PermissibleActionEvent evt) {
                CancellableRemoteDialog.this.hide();
            }//from   www. j a  v  a  2s  .  c o  m
        };
    }
    final PermissibleActionListener lCopy = l;
    setText("Please wait...");
    setAnimationEnabled(initialAnimationEnabled());
    Grid grr = new Grid(2, 1);
    status = msg;
    statusLabel = new Label(msg);
    grr.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
    grr.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    grr.setCellPadding(4);
    cancelButton = new Button("Cancel");
    setRetryButton(new Button("Retry"));
    cancelButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            PermissibleAction action = new PermissibleAction();
            action.setActionName(CANCEL_ACTION);
            lCopy.vetoableAction(new PermissibleActionEvent(this, action));
        }
    });
    grr.setWidget(0, 0, statusLabel);
    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(0);
    hp.add(cancelButton);
    hp.add(getRetryButton());
    getRetryButton().setVisible(false);
    grr.setWidget(1, 0, hp);
    setWidget(grr);
    if (autoShow) {
        centerAndShow();
    }
}

From source file:cc.alcina.framework.gwt.client.widget.dialog.LoginDisplayer.java

License:Apache License

public LoginDisplayer() {
    dialogBox = new GlassDialogBox();
    dialogBox.setText("Login");
    dialogBox.setAnimationEnabled(true);
    mainPanel = new FlowPanel();
    mainPanel.setStyleName("alcina-Login");
    mainPanel.ensureDebugId(AlcinaDebugIds.LOGIN_FORM);
    this.introWidget = new FlowPanel();
    introWidget.setVisible(false);/*from   w ww.  j  a v a 2s. c  o m*/
    mainPanel.add(introWidget);
    introWidget.setStyleName("intro");
    cancelButton = new Button("Cancel");
    okButton = new Button("Login");
    okButton.ensureDebugId(AlcinaDebugIds.LOGIN_SUBMIT);
    table = new FlexTable();
    table.setWidth("100%");
    table.setCellSpacing(2);
    this.usernameLabel = new Label("Username: ");
    table.setWidget(0, 0, usernameLabel);
    nameBox = new TextBox();
    WidgetUtils.disableTextBoxHelpers(nameBox);
    nameBox.ensureDebugId(AlcinaDebugIds.LOGIN_USERNAME);
    table.setWidget(0, 1, nameBox);
    table.setWidget(1, 0, new Label("Password: "));
    pwdBox = new PasswordTextBox();
    WidgetUtils.disableTextBoxHelpers(pwdBox);
    pwdBox.ensureDebugId(AlcinaDebugIds.LOGIN_PASSWORD);
    table.setWidget(1, 1, pwdBox);
    pwdBox.addKeyPressHandler(new EnterAsClickKeyboardListener(pwdBox, okButton));
    nameBox.addKeyPressHandler(new EnterAsClickKeyboardListener(nameBox, okButton));
    rememberMeBox = new CheckBox();
    rememberMeBox.setValue(true);
    table.setWidget(2, 0, rememberMeBox);
    table.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    table.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    table.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    table.setWidget(2, 1, new Label("Remember me on this computer"));
    statusLabel = new Label("Logging in");
    statusLabel.setVisible(false);
    table.setWidget(4, 1, statusLabel);
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
    hPanel.setSpacing(5);
    hPanel.add(okButton);
    okButton.addStyleName("marginRight10");
    hPanel.add(cancelButton);
    table.setWidget(3, 1, hPanel);
    mainPanel.add(table);
    dialogBox.setWidget(mainPanel);
}

From source file:cc.alcina.framework.gwt.client.widget.dialog.OkCancelDialogBox.java

License:Apache License

public OkCancelDialogBox(String title, Widget widget, PermissibleActionListener listener,
        HorizontalAlignmentConstant widgetAlign) {
    this.widget = widget;
    this.vetoableActionListener = listener;
    setText(title);//from ww w  .j  a v a 2 s  .co  m
    setAnimationEnabled(showAnimated());
    VerticalPanel vp = new VerticalPanel();
    vp.add(widget);
    vp.setCellHorizontalAlignment(widget, widgetAlign);
    buttonsPanel = new HorizontalPanel();
    cancelButton = new Button("Cancel");
    cancelButton.addClickHandler(e -> cancel());
    okButton = new Button(SafeHtmlUtils.fromString(getOKButtonName()));
    okButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            onOkButtonClicked();
        }
    });
    buttonsPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    buttonsPanel.setSpacing(8);
    buttonsPanel.add(okButton);
    buttonsPanel.add(cancelButton);
    vp.add(buttonsPanel);
    vp.setCellHorizontalAlignment(buttonsPanel, HasHorizontalAlignment.ALIGN_CENTER);
    setWidget(vp);
    adjustDisplay();
    center();
}

From source file:cc.kune.gadgetsample.client.KuneGadgetSampleMainPanel.java

License:GNU Affero Public License

/**
 * Instantiates a new kune gadget sample main panel. We use gin to inject the
 * dependencies.//w w w  . ja  va2s. co m
 *
 * @param eventBus
 *          the event bus
 * @param wave
 *          the wave
 * @param gadgetMessages
 *          the gadget messages
 */
@Inject
public KuneGadgetSampleMainPanel(final EventBus eventBus, final Wave wave,
        final KuneGadgetSampleMessages gadgetMessages) {
    this.messages = gadgetMessages;
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        // We run this deferred, at the end of the gadget load
        @Override
        public void execute() {

            final Image avatar = new Image();
            avatar.setSize(AVATAR_SIZE, AVATAR_SIZE);
            avatar.setTitle(wave.getViewer().getDisplayName());
            avatar.setUrl(wave.getViewer().getThumbnailUrl());

            final boolean lockStatus = getLockStatus(wave);
            final Button btn = new Button(getBtnText(lockStatus));

            btn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(final ClickEvent event) {
                    final Boolean nextStatus = !getLockStatus(wave);
                    // We update the status of key LOCK to the inverse of the current
                    // status
                    wave.getState().submitValue(LOCK, nextStatus.toString());
                }
            });
            final VerticalPanel vp = new VerticalPanel();
            vp.add(avatar);
            vp.add(btn);
            initWidget(vp);
            eventBus.addHandler(StateUpdateEvent.TYPE, new StateUpdateEventHandler() {
                @Override
                public void onUpdate(final StateUpdateEvent event) {
                    // When the status changes we just update the text of the button
                    btn.setText(getBtnText(Boolean.valueOf(event.getState().get(LOCK))));
                }
            });
            eventBus.addHandler(ModeChangeEvent.TYPE, new ModeChangeEventHandler() {
                @Override
                public void onUpdate(final ModeChangeEvent event) {
                    // See the modes in
                    // http://www.waveprotocol.org/wave-apis/google-wave-gadgets-api/reference
                    // EDIT, VIEW, PLAYBACK, etc
                    if (wave.isPlayback()) {
                        // Do something
                    } else {
                        // Do other thing
                    }
                }
            });

        }

        private Boolean getLockStatus(final Wave wave) {
            return Boolean.parseBoolean(wave.getState().get(LOCK));
        }
    });
}

From source file:ccm.CCM1.gwt.client.ui.GwtColorPicker.java

License:Apache License

public GwtColorPicker() {
    // Create a 4x4 grid of buttons with names for 16 colors
    final Grid grid = new Grid(4, 4);
    final String[] colors = new String[] { "aqua", "black", "blue", "fuchsia", "gray", "green", "lime",
            "maroon", "navy", "olive", "purple", "red", "silver", "teal", "white", "yellow" };
    int colornum = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++, colornum++) {
            // Create a button for each color
            final Button button = new Button(colors[colornum]);
            button.addClickListener(this);

            // Put the button in the Grid layout
            grid.setWidget(i, j, button);

            // Set the button background colors.
            DOM.setStyleAttribute(button.getElement(), "background", colors[colornum]);

            // For dark colors, the button label must be in white.
            if ("black navy maroon blue purple".indexOf(colors[colornum]) != -1) {
                DOM.setStyleAttribute(button.getElement(), "color", "white");
            }/*  www.j  a v a2 s  . c  om*/
        }
    }

    // Create a panel with the color grid and currently selected color
    // indicator
    final HorizontalPanel panel = new HorizontalPanel();
    panel.add(grid);
    panel.add(currentcolor);

    // Set the class of the color selection feedback box to allow CSS
    // styling.
    // We need to obtain the DOM element for the current color label.
    // This assumes that the <td> element of the HorizontalPanel is
    // the parent of the label element. Notice that the element has no
    // parent
    // before the widget has been added to the horizontal panel.
    final Element panelcell = DOM.getParent(currentcolor.getElement());
    DOM.setElementProperty(panelcell, "className", "colorpicker-currentcolorbox");

    // Set initial color. This will be overridden with the value read from
    // server.
    setColor("white");

    // Composite GWT widgets must call initWidget().
    initWidget(panel);
}

From source file:ch.amaba.client.ResponseView.java

License:Apache License

@Inject
public ResponseView() {
    closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    textToServerLabel = new Label();
    serverResponseLabel = new HTML();

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    panel.add(closeButton, "closeButton");
    panel.add(textToServerLabel, "textToServerContainer");
    panel.add(serverResponseLabel, "serverResponseContainer");
}