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:com.cognitivemedicine.metricsdashboard.client.adminconsole.MetricsTab.java

License:Apache License

public MetricsTab(DashboardController dashController) {
    this.controller = dashController;

    // METRIC GROUPS
    allMetricGroupsListBox = new ListBox();
    allMetricGroupsListBox.setWidth("200px");
    // allMetricGroupsListBox.setWidth("30%");
    allMetricGroupsListBox.setVisibleItemCount(15);
    allMetricGroupsListBox.addChangeHandler(new ChangeHandler() {
        @Override//w  ww.  j  a  va  2 s  .  co m
        public void onChange(ChangeEvent event) {
            String id = allMetricGroupsListBox.getValue(allMetricGroupsListBox.getSelectedIndex());
            // controller.getMetricsGroups().get(id).getMetricList();
            List<Metric> metrics = controller.getMetricsInGroup(id);
            assignedMetricsListBox.clear();
            for (Metric m : metrics) {
                if (m != null) {
                    System.err.println("Name: " + m.getName() + " ID: " + m.getName());
                    assignedMetricsListBox.addItem(m.getName(), m.get_id());
                }
            }
        }
    });
    Collection<MetricGroup> allMetricGroups = controller.getMetricsGroups().values();
    for (MetricGroup g : allMetricGroups) {
        allMetricGroupsListBox.addItem(g.getName(), g.get_id());
    }

    // METRICS
    allMetricsListBox = new ListBox(true);
    allMetricsListBox.setWidth("200px");
    // allMetricsListBox.setWidth("30%");
    allMetricsListBox.setVisibleItemCount(15);
    Collection<Metric> allMetrics = controller.getAvailableMetrics().values();
    for (Metric m : allMetrics) {
        allMetricsListBox.addItem(m.getName(), m.get_id());
    }

    // ASSIGNED
    assignedMetricsListBox = new ListBox(true);
    assignedMetricsListBox.setWidth("200px");
    // assignedMetricsListBox.setWidth("30%");
    assignedMetricsListBox.setVisibleItemCount(15);

    VerticalPanel buttonPanel = new VerticalPanel();
    buttonPanel.setSpacing(2);
    Image image = new Image(MdConstants.IMG_LEFT_ARROW);
    image.setSize("24px", "24px");
    PushButton addButton = new PushButton(image);
    addButton.getElement().setId("addDefinitionButton");
    addButton.setSize("24px", "24px");
    addButton.setTitle("Add");
    // addButton = new Button("<-- Add");
    addButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            addButtonClicked();
        }
    });

    image = new Image(MdConstants.IMG_RIGHT_ARROW);
    image.setSize("24px", "24px");
    PushButton removeButton = new PushButton(image);
    removeButton.getElement().setId("removeDefinitionButton");
    removeButton.setSize("24px", "24px");
    removeButton.setTitle("Add");
    // removeButton = new Button("Remove -->");
    removeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            removeButtonClicked();
        }
    });

    buttonPanel.add(addButton);
    buttonPanel.add(removeButton);
    // buttonPanel.setBorderWidth(2);

    // this.setBorderWidth(3);
    // this.setSpacing(2);
    this.setWidth("100%");

    createGroupTextBox = new TextBox();
    // createGroupTextBox.setWidth("*");

    createGroupButton = new Button("Create Group");
    createGroupButton.getElement().setId("createGroupButton");
    createGroupButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (!(createGroupTextBox.getValue().equals(""))) {
                MetricGroup group = new MetricGroup();
                group.setName(createGroupTextBox.getValue());
                group.setDescription("");
                group.setMetricList(new ArrayList<String>());
                controller.createMetricGroup(group);
            } else {
                Window.alert("You must enter a name to create a group");
            }
        }
    });

    VerticalPanel allMetricsPanel = createLabeledList("Metrics Groups", allMetricGroupsListBox);
    HorizontalPanel createPanel = new HorizontalPanel();
    createPanel.add(createGroupTextBox);
    createPanel.add(createGroupButton);
    allMetricsPanel.add(createPanel);
    this.add(allMetricsPanel);
    // this.add(createLabeledList("Metrics Groups", allMetricGroupsListBox));
    this.add(createLabeledList("Assigned Metrics", assignedMetricsListBox));
    this.add(buttonPanel);
    this.add(createLabeledList("All Metrics", allMetricsListBox));

    setCellHorizontalAlignment(buttonPanel, HasHorizontalAlignment.ALIGN_CENTER);
    setCellVerticalAlignment(buttonPanel, HasVerticalAlignment.ALIGN_MIDDLE);
}

From source file:com.cognitivemedicine.metricsdashboard.client.dialogs.AuthenticationDialog.java

License:Apache License

public AuthenticationDialog(Md_sandbox application, List<Site> siteList) {
    this.application = application;

    mainPanel = new HorizontalPanel();
    mainPanel.getElement().getStyle().setProperty("backgroundColor", "#477E7E");

    warningPanel = new VerticalPanel();
    warningPanel.setWidth("450px");
    // warningPanel.setWidth("100%");
    warningPanel.setHeight("100%");
    warningPanel.setSpacing(20);/* ww w . j  ava2 s.  c om*/
    warningPanel.getElement().getStyle().setProperty("backgroundColor", "#477E7E");

    loginPanel = new VerticalPanel();
    loginPanel.setWidth("450px");
    // loginPanel.setWidth("100%");
    loginPanel.setSpacing(4);
    loginPanel.getElement().getStyle().setProperty("backgroundColor", "#FFFFFF");

    warningMessage = new HTML(warningMessageText);
    warningMessage.getElement().getStyle().setProperty("color", "white");
    warningMessage.getElement().getStyle().setProperty("fontSize", "10px");
    warningMessage.setWordWrap(true);
    warningMessage.setHeight("100%");
    // warningMessage.setWidth("100%");

    titleLabel = new HTML("<h2>CDS METRICS DASHBOARD</h2>");

    vaLogo = new Image(MdConstants.IMG_VA_LOGO);
    vaLogo.setPixelSize(160, 160);
    vaLogo.getElement().getStyle().setProperty("marginTop", "20px");

    facilityListBox = new ListBox();
    facilityListBox.setVisibleItemCount(1);
    facilityListBox.getElement().setId("facilityListBox");
    for (Site s : siteList) {
        facilityListBox.addItem(s.getName(), s.getSiteCode());
    }
    // facilityListBox.setWidth("100%");

    accessCode = new PasswordTextBox();
    accessCode.getElement().setId("accessCode");
    accessCode.setMaxLength(80);
    // accessCode.setWidth("100%");

    verifyCode = new PasswordTextBox();
    verifyCode.getElement().setId("verifyCode");
    verifyCode.setMaxLength(80);
    // verifyCode.setWidth("100%");

    signInButton = new Button("Sign In");
    signInButton.getElement().getStyle().setProperty("background", "#477E7E");
    signInButton.getElement().getStyle().setProperty("color", "white");
    signInButton.getElement().getStyle().setProperty("fontSize", "10px");
    signInButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            signInButtonClicked();
        }
    });

    warningPanel.add(warningMessage);
    warningPanel.setCellVerticalAlignment(warningMessage, HasVerticalAlignment.ALIGN_MIDDLE);

    loginPanel.add(vaLogo);
    loginPanel.add(titleLabel);
    loginPanel.add(createFormPanel("Select a Facility", facilityListBox));
    loginPanel.add(createFormPanel("Access Code", accessCode));
    loginPanel.add(createFormPanel("Vefify Code", verifyCode));
    loginPanel.add(signInButton);

    loginPanel.setCellHorizontalAlignment(vaLogo, HasHorizontalAlignment.ALIGN_CENTER);
    loginPanel.setCellHorizontalAlignment(titleLabel, HasHorizontalAlignment.ALIGN_CENTER);
    loginPanel.setCellHorizontalAlignment(facilityListBox, HasHorizontalAlignment.ALIGN_CENTER);
    loginPanel.setCellHorizontalAlignment(accessCode, HasHorizontalAlignment.ALIGN_CENTER);
    loginPanel.setCellHorizontalAlignment(verifyCode, HasHorizontalAlignment.ALIGN_CENTER);
    loginPanel.setCellHorizontalAlignment(signInButton, HasHorizontalAlignment.ALIGN_RIGHT);

    mainPanel.add(warningPanel);
    mainPanel.add(loginPanel);

    mainPanel.setCellVerticalAlignment(warningPanel, HasVerticalAlignment.ALIGN_MIDDLE);

    this.setTitle("CDS DASHBOARD LOGIN");
    this.setWidget(mainPanel);
    this.setModal(true);
    this.setGlassEnabled(true);
    this.removeStyleName("gwt-DialogBox");
}

From source file:com.connoisseur.menuapp.client.Authenticate.java

/** This is essentially the main method for the menu app. */
public static void go() {
    storage.clear(); // uncomment to completely reset app

    final DialogBox startupBox = new DialogBox(); // movable box that contains widgets
    startupBox.setAnimationEnabled(true);
    final VerticalPanel startupPanel = new VerticalPanel(); // can contain other widgets
    startupPanel.addStyleName("marginPanel"); // interacts with Menuapp.css
    startupPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    // check to see if storage is supported
    if (storage != null) {

        // load viewer if license key and restID have been submitted before
        if (storage.getLength() > 0) {
            Viewer.loadViewer();//from w ww . j a v  a2  s . c o  m
        }

        // otherwise load authentication UI in order to receive input
        else {
            final Button submitButton = new Button("Submit"); // "Submit" appears on button
            submitButton.addStyleName("myButton"); // interacts with Menuapp.css
            final HorizontalPanel buttonPanel = new HorizontalPanel(); // used to center button
            buttonPanel.addStyleName("marginlessPanel");

            // license widgets
            final Label licenseErrorLabel = new Label(); // dynamic text
            licenseErrorLabel.addStyleName("errorLabel"); // interacts with Menuapp.css
            final TextBox submitLicense = new TextBox(); // user can input text using this
            submitLicense.setText("license key..."); // default text to be seen on load

            // restaurant ID widgets
            final Label restErrorLabel = new Label();
            restErrorLabel.addStyleName("errorLabel");
            final TextBox submitRestID = new TextBox();
            submitRestID.setText("restaurant ID...");

            // organize UI
            startupPanel.add(new HTML("Please enter your license key:"));
            startupPanel.add(submitLicense);
            startupPanel.add(licenseErrorLabel);
            startupPanel.add(new HTML("<br>Please enter your restaurant ID:"));
            startupPanel.add(submitRestID);
            startupPanel.add(restErrorLabel);
            startupPanel.add(new HTML("<br>"));
            buttonPanel.add(submitButton);
            startupPanel.add(buttonPanel);

            // setup startupBox, which is what will be seen by the user
            startupBox.setWidget(startupPanel); // connects the two widgets
            startupBox.center(); // also shows the box

            // focus the cursor on submitLicense when startupBox appears
            submitLicense.setFocus(true);
            submitLicense.selectAll();

            // create a handler for submitButton, submitLicense and submitRestID
            class MyHandler implements ClickHandler, KeyUpHandler {
                /** Fired when the user clicks submit. */
                public void onClick(ClickEvent event) {
                    submit();
                }

                /** Fired when the user presses Enter in a submit field. */
                public void onKeyUp(KeyUpEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER)
                        submit();
                }

                /** Checks the submitted license key and restaurant ID for validity. Loads Viewer if valid. */
                private void submit() {
                    String license = submitLicense.getText(); // unused for now
                    String restID = submitRestID.getText(); // not sure how to validate yet
                    int returnFlag = 0; // so that both tests can be done
                    licenseErrorLabel.setText("");
                    restErrorLabel.setText("");

                    // validate license
                    String result = FieldVerifier.isValidLicenseKey(license); // from FieldVerifier.java
                    if (!result.equals("")) { // error
                        licenseErrorLabel.setText("You submitted an invalid license key.");
                        submitLicense.selectAll();
                        returnFlag = 1;
                    }

                    // validate restID
                    result = FieldVerifier.isValidRestaurantID(restID);
                    if (!result.equals("")) { // error
                        restErrorLabel.setText("You submitted an invalid restaurant ID.");
                        submitRestID.selectAll();
                        returnFlag = 1;
                    }

                    // don't do anything until the errors are resolved
                    if (returnFlag == 1)
                        return;

                    // clean up
                    submitButton.setEnabled(false);
                    submitLicense.setEnabled(false);
                    submitRestID.setEnabled(false);
                    startupBox.hide();

                    // set up storage
                    storage.setItem("license", license); // secret key for security
                    storage.setItem("restID", restID); // used for almost every call to the backend

                    // show menu
                    Viewer.loadViewer();
                }
            } // MyHandler

            // attach the handler
            final MyHandler handler = new MyHandler();
            submitButton.addClickHandler(handler);
            submitLicense.addKeyUpHandler(handler);
            submitRestID.addKeyUpHandler(handler);
        } // else load authentication UI

    } // if storage supported

    // storage is not supported, so report error
    else {
        startupPanel.add(new HTML("<font color=red>The app will not function because local<br>"
                + "storage is not supported on this platform.</font>"));
        startupBox.setWidget(startupPanel);
        startupBox.center();
    }
}

From source file:com.controlj.addon.gwttree.client.TreeManager.java

License:Open Source License

/**<!====== createPanel ===================================================>
   Returns a panel that displays the tree.  When the tree options are changed,
   the panel is updated to hold the new tree, so this method does not need to
   be called more than once./*ww w .  j  av  a 2 s. c o m*/
<!=======================================================================>*/
public Widget createPanel() {
    Panel treePanel = new VerticalPanel();
    treePanel.setStylePrimaryName("tree-treePanel");

    // create a panel for the resulting tree(s) now (it's used below)
    // but don't add it to the panel until the end (so it's at the bottom)
    resultPanel = new HorizontalPanel();

    Button optionsButton = new Button("Change Tree Options...");
    optionsButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            options.showDialog();
        }
    });
    treePanel.add(optionsButton);

    resetResultPanel("Getting tree root node...");
    requestTree();

    treePanel.add(resultPanel);
    return treePanel;
}

From source file:com.databasepreservation.visualization.client.common.Dialogs.java

public static void showConfirmDialog(String title, String message, String cancelButtonText,
        String confirmButtonText, final AsyncCallback<Boolean> callback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);/*from www  .jav  a2 s  . c  om*/

    FlowPanel layout = new FlowPanel();
    Label messageLabel = new Label(message);
    Button cancelButton = new Button(cancelButtonText);
    Button confirmButton = new Button(confirmButtonText);
    FlowPanel footer = new FlowPanel();

    layout.add(messageLabel);
    layout.add(footer);
    footer.add(cancelButton);
    footer.add(confirmButton);

    dialogBox.setWidget(layout);

    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(false);

    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(false);
        }
    });

    confirmButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(true);
        }
    });

    dialogBox.addStyleName("wui-dialog-confirm");
    layout.addStyleName("wui-dialog-layout");
    footer.addStyleName("wui-dialog-layout-footer");
    messageLabel.addStyleName("wui-dialog-message");
    cancelButton.addStyleName("btn btn-link");
    confirmButton.addStyleName("btn btn-play");

    dialogBox.center();
    dialogBox.show();
}

From source file:com.databasepreservation.visualization.client.common.Dialogs.java

public static void showInformationDialog(String title, String message, String continueButtonText,
        final AsyncCallback<Void> callback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);//  ww  w . j a  v a  2 s .c  o m

    FlowPanel layout = new FlowPanel();
    Label messageLabel = new Label(message);
    Button continueButton = new Button(continueButtonText);

    layout.add(messageLabel);
    layout.add(continueButton);

    dialogBox.setWidget(layout);

    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(false);

    continueButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(null);
        }
    });

    dialogBox.addStyleName("wui-dialog-information");
    layout.addStyleName("wui-dialog-layout");
    messageLabel.addStyleName("wui-dialog-message");
    continueButton.addStyleName("btn btn-play");

    dialogBox.center();
    dialogBox.show();
}

From source file:com.databasepreservation.visualization.client.common.Dialogs.java

public static void showPromptDialog(String title, String message, String placeHolder, final RegExp validator,
        String cancelButtonText, String confirmButtonText, final AsyncCallback<String> callback) {
    final DialogBox dialogBox = new DialogBox(false, true);
    dialogBox.setText(title);/*ww w. j a va 2  s.  c o m*/

    final FlowPanel layout = new FlowPanel();

    if (message != null) {
        final Label messageLabel = new Label(message);
        layout.add(messageLabel);
        messageLabel.addStyleName("wui-dialog-message");
    }

    final TextBox inputBox = new TextBox();

    if (placeHolder != null) {
        inputBox.getElement().setPropertyString("placeholder", placeHolder);
    }

    final Button cancelButton = new Button(cancelButtonText);
    final Button confirmButton = new Button(confirmButtonText);

    layout.add(inputBox);
    layout.add(cancelButton);
    layout.add(confirmButton);

    dialogBox.setWidget(layout);

    dialogBox.setGlassEnabled(true);
    dialogBox.setAnimationEnabled(false);

    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onFailure(null);
        }
    });

    confirmButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            dialogBox.hide();
            callback.onSuccess(inputBox.getText());
        }
    });

    inputBox.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> event) {
            boolean isValid = validator.test(inputBox.getText());
            if (isValid) {
                inputBox.addStyleName("error");
            } else {
                inputBox.removeStyleName("error");
            }
        }
    });

    inputBox.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            boolean isValid = validator.test(inputBox.getText());
            confirmButton.setEnabled(isValid);
        }
    });

    inputBox.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                boolean isValid = validator.test(inputBox.getText());
                if (isValid) {
                    dialogBox.hide();
                    callback.onSuccess(inputBox.getText());
                }
            }
        }

    });

    confirmButton.setEnabled(validator.test(inputBox.getText()));

    dialogBox.addStyleName("wui-dialog-prompt");
    layout.addStyleName("wui-dialog-layout");
    inputBox.addStyleName("form-textbox wui-dialog-message");
    cancelButton.addStyleName("btn btn-link");
    confirmButton.addStyleName("pull-right btn btn-play");

    dialogBox.center();
    dialogBox.show();
    inputBox.setFocus(true);
}

From source file:com.dawg6.gwt.client.DefaultWidgetFactory.java

License:Open Source License

@Override
public Button createDialogBoxButton(String text) {
    return new Button(text);
}

From source file:com.dawg6.gwt.client.widgets.AbstractSearchable.java

License:Open Source License

protected AbstractSearchable(ValueFactory<T> factory, Comparator<T> sorter) {

    captionPanel = new CaptionPanel("Caption");
    initWidget(captionPanel);/*w w w.  j av a2  s .  c  o  m*/

    VerticalPanel verticalPanel_5 = new VerticalPanel();
    captionPanel.setContentWidget(verticalPanel_5);
    verticalPanel_5.setSize("5cm", "3cm");

    HorizontalPanel row = new HorizontalPanel();
    row.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    row.setSpacing(5);
    verticalPanel_5.add(row);

    Label label = new Label("Filter:");
    row.add(label);

    suggestBox = new TextBox();
    row.add(suggestBox);
    suggestBox.setVisibleLength(20);

    suggestBox.addKeyUpHandler(new KeyUpHandler() {

        @Override
        public void onKeyUp(KeyUpEvent event) {
            setFilter();
        }
    });

    Button button = new Button("Clear");
    row.add(button);
    button.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            suggestBox.setText("");
            setFilter();
        }
    });

    listBox = new CellList<T>(getCell());

    scroll = new ScrollPanel();
    scroll.setWidget(listBox);

    this.list = new Vector<T>();
    this.dataProvider = new ListDataProvider<T>();
    this.dataProvider.addDataDisplay(listBox);
    verticalPanel_5.add(scroll);
    listBox.setPageSize(Integer.MAX_VALUE);

    listBox.setSize("300px", "300px");
    selectionModel = new SingleSelectionModel<T>();
    listBox.setSelectionModel(selectionModel);

    selectionModel.addSelectionChangeHandler(new Handler() {

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            selectionChanged(getSelectedValue());

        }
    });

    this.factory = factory;
    this.sorter = sorter;
}

From source file:com.dawg6.web.dhcalc.client.DamageTypePanel.java

License:Open Source License

public DamageTypePanel() {

    CaptionPanel captionPanel = new CaptionPanel("Elemental Damage Modifiers");
    initWidget(captionPanel);// w w w .j  av a 2s  .  co  m

    flexTable = new FlexTable();
    captionPanel.setContentWidget(flexTable);

    List<DamageType> list = new Vector<DamageType>(DamageType.values().length);
    listBox = new ListBox();

    for (DamageType type : DamageType.values()) {
        list.add(type);
    }

    Collections.sort(list, new Comparator<DamageType>() {

        @Override
        public int compare(DamageType o1, DamageType o2) {
            return o1.getLongName().compareTo(o2.getLongName());
        }
    });

    for (DamageType s : list) {
        listBox.addItem(s.getLongName(), s.name());
    }

    listBox.setSelectedIndex(0);
    addButton = new Button("Add");

    addButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            addType();
        }
    });

    flexTable.setWidget(0, 0, new Label("Type:", false));
    flexTable.setWidget(0, 1, listBox);
    flexTable.getFlexCellFormatter().setColSpan(0, 1, 2);
    flexTable.setWidget(0, 2, addButton);

}