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:client.Tetris.java

License:Apache License

public static void gameOverEx() {
    // Create the dialog box
    final DialogBox dialogBox = new DialogBox();
    final String gameOverText = "You just lost <a href='http://www.google.com/"
            + "search?q=lost+the+game'>The Game</a>";
    dialogBox.setHTML(gameOverText);//from  w ww.  j a v a  2s  .c  o m
    dialogBox.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);
    dialogVPanel.add(button);

    button.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            dialogBox.hide();
            newGame();
        }
    });

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

From source file:client.tools.page.ConsoleSettingsPage.java

License:Open Source License

/**
 * //  w w  w .  j  a v  a  2s . c  o  m
 */
public ConsoleSettingsPage() {
    final VerticalPanel panel = new VerticalPanel();

    final int cookie = this.getValue();

    final Label label = new Label("Console LogLevel");
    panel.add(label);

    // Make some radio buttons, all in one group.
    this.rb0 = new RadioButton("logLevelGrp", "Trace");
    this.rb1 = new RadioButton("logLevelGrp", "Debug");
    this.rb2 = new RadioButton("logLevelGrp", "Warn");
    this.rb4 = new RadioButton("logLevelGrp", "Error");
    this.rb3 = new RadioButton("logLevelGrp", "Fatal");

    this.button = new Button("Save");
    this.button.addClickListener(this);

    if (GuiLogger.DEBUG == cookie) {
        this.rb1.setChecked(true);
    } else if (GuiLogger.WARN == cookie) {
        this.rb2.setChecked(true);
    } else if (GuiLogger.ERROR == cookie) {
        this.rb3.setChecked(true);
    } else if (GuiLogger.FATAL == cookie) {
        this.rb4.setChecked(true);
    } else {
        this.rb0.setChecked(true);
    }

    panel.add(this.rb0);
    panel.add(this.rb1);
    panel.add(this.rb2);
    panel.add(this.rb3);
    panel.add(this.rb4);
    panel.add(this.button);

    this.initWidget(panel);
}

From source file:client.tools.page.NameResolverPage.java

License:Open Source License

/**
 * // www  .  ja v  a  2s.  c  o m
 */
public NameResolverPage() {
    this.query = new TextBox();
    this.button = new Button("Resolve");

    this.button.addClickListener(this);

    final VerticalPanel panel = new VerticalPanel();

    panel.add(new HTML("Please enter hostname"));
    panel.add(this.query);
    panel.add(this.button);

    this.initWidget(panel);
}

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

License:Open Source License

/**
 * Show dialog box.//from  www .  j a  va  2s .com
 *
 * @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:co.edu.udea.iw.rtf.client.activity.SolicitudesActivity.java

License:Open Source License

/**
 * Agrega una nueva solcitud a la tabla de solicitudes.
 * /* w ww. ja v  a  2s  .  c  o m*/
 * @param solicitud
 *            La informacin de la solicitud que se desea listar.
 * */
public void addSolicitud(final SolicitudListado solicitud, Boolean isAdministrador) {

    final SolicitudesView view = clientFactory.getSolicitudesView();
    FlexTable tabla = view.getTable();
    final int indice = tabla.getRowCount();
    tabla.setText(indice, 0, solicitud.getNombreCompletoSolicitante());
    tabla.setText(indice, 1, solicitud.getCorreoElectronico());
    tabla.setText(indice, 2, solicitud.getFechaSolicitud().toString());
    tabla.setText(indice, 3, solicitud.getNombreTipoSolicitud());
    tabla.setText(indice, 4, solicitud.getTextoSolicitud());
    tabla.getCellFormatter().setWidth(indice, 0, "100px");
    tabla.getCellFormatter().setWidth(indice, 1, "100px");
    tabla.getCellFormatter().setWidth(indice, 2, "100px");
    tabla.getCellFormatter().setWidth(indice, 3, "100px");
    tabla.getCellFormatter().setWidth(indice, 4, "100px");

    if (isAdministrador) {
        Button botonEliminar = new Button("Asignar");

        // el boton se agrega para permitir al usuario
        // asignar un
        // responsable a la solicitud.
        botonEliminar.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                cleanTable();
                goTo(new AsignarSolicitudPlace(login, solicitud));
            }
        });

        view.getTable().setWidget(indice, 7, botonEliminar);

    }
}

From source file:co.edu.udea.iw.rtf.client.ui.CrearSolicitudViewImpl.java

License:Open Source License

public CrearSolicitudViewImpl() {
    initWidget(binder.createAndBindUi(this));

    labelNombresSolicitante = new Label("* Nombres: ");
    labelApellidosSolicitante = new Label("* Apellidos: ");
    labelCelular = new Label("Celular: ");
    labelCorreoElectronico = new Label("* Correo electrnico: ");
    labelConfirmacionCorreo = new Label("* Confirmacin del correo: ");
    labelTelefono = new Label("* Telefono: ");
    labelOtroProducto = new Label("Otro producto: ");
    labelProducto = new Label("* Producto: ");
    labelSucursal = new Label("* Sucursal: ");
    labelTextoSolicitud = new Label("* Texto de la solicitud: ");
    labelTipoSolicitud = new Label("* Tipo de solicitud: ");

    labelNombresSolicitanteError = new Label();
    labelApellidosSolicitanteError = new Label();
    labelCelularError = new Label();
    labelCorreoElectronicoError = new Label();
    labelConfirmacionCorreoError = new Label();
    labelTelefonoError = new Label();
    labelOtroProductoError = new Label();
    labelProductoError = new Label();
    labelSucursalError = new Label();
    labelTextoSolicitudError = new Label();
    labelTipoSolicitudError = new Label();
    textBoxApellidosSolicitante = new TextBox();
    textBoxCelular = new TextBox();
    textBoxConfirmacionCorreo = new TextBox();
    textBoxCorreoElectronico = new TextBox();
    textBoxNombresSolicitante = new TextBox();
    textBoxOtroProducto = new TextBox();
    textBoxTelefono = new TextBox();
    textBoxTextoSolicitud = new TextArea();
    listBoxProducto = new ListBox();
    listBoxSuscursal = new ListBox();
    listBoxTipoSolicitud = new ListBox();

    textBoxNombresSolicitante.setMaxLength(45);
    textBoxApellidosSolicitante.setMaxLength(45);
    textBoxTelefono.setMaxLength(15);//w  w w  .  j av a  2  s .c om
    textBoxCelular.setMaxLength(15);
    textBoxCorreoElectronico.setMaxLength(120);
    textBoxConfirmacionCorreo.setMaxLength(120);

    labelNombresSolicitante.addStyleName("label");
    labelApellidosSolicitante.addStyleName("label");
    labelCelular.addStyleName("label");
    labelCorreoElectronico.addStyleName("label");
    labelConfirmacionCorreo.addStyleName("label");
    labelTelefono.addStyleName("label");
    labelOtroProducto.addStyleName("label");
    labelProducto.addStyleName("label");
    labelSucursal.addStyleName("label");
    labelTextoSolicitud.addStyleName("label");
    labelTipoSolicitud.addStyleName("label");
    textBoxNombresSolicitante.addStyleName("textBox");
    textBoxApellidosSolicitante.addStyleName("textBox");
    textBoxCorreoElectronico.addStyleName("textBox");
    textBoxConfirmacionCorreo.addStyleName("textBox");
    textBoxTelefono.addStyleName("textBox");
    textBoxCelular.addStyleName("textBox");
    textBoxOtroProducto.addStyleName("textBox");
    textBoxTextoSolicitud.addStyleName("area");
    listBoxProducto.addStyleName("lista");
    listBoxSuscursal.addStyleName("lista");
    listBoxTipoSolicitud.addStyleName("lista");

    tabla.setWidget(0, 0, labelNombresSolicitante);
    tabla.setWidget(0, 1, textBoxNombresSolicitante);
    tabla.setWidget(0, 2, labelNombresSolicitanteError);
    tabla.setWidget(1, 0, labelApellidosSolicitante);
    tabla.setWidget(1, 1, textBoxApellidosSolicitante);
    tabla.setWidget(1, 2, labelApellidosSolicitanteError);
    tabla.setWidget(2, 0, labelCorreoElectronico);
    tabla.setWidget(2, 1, textBoxCorreoElectronico);
    tabla.setWidget(2, 2, labelCorreoElectronicoError);
    tabla.setWidget(3, 0, labelConfirmacionCorreo);
    tabla.setWidget(3, 1, textBoxConfirmacionCorreo);
    tabla.setWidget(3, 2, labelConfirmacionCorreoError);
    tabla.setWidget(4, 0, labelTelefono);
    tabla.setWidget(4, 1, textBoxTelefono);
    tabla.setWidget(4, 2, labelTelefonoError);
    tabla.setWidget(5, 0, labelCelular);
    tabla.setWidget(5, 1, textBoxCelular);
    tabla.setWidget(5, 2, labelCelularError);
    tabla.setWidget(6, 0, labelProducto);
    tabla.setWidget(6, 1, listBoxProducto);
    tabla.setWidget(6, 2, labelProductoError);
    tabla.setWidget(7, 0, labelOtroProducto);
    tabla.setWidget(7, 1, textBoxOtroProducto);
    tabla.setWidget(7, 2, labelOtroProductoError);
    tabla.setWidget(8, 0, labelSucursal);
    tabla.setWidget(8, 1, listBoxSuscursal);
    tabla.setWidget(8, 2, labelSucursalError);
    tabla.setWidget(9, 0, labelTipoSolicitud);
    tabla.setWidget(9, 1, listBoxTipoSolicitud);
    tabla.setWidget(9, 2, labelTipoSolicitudError);
    tabla.setWidget(10, 0, labelTextoSolicitud);
    tabla.setWidget(10, 1, textBoxTextoSolicitud);
    tabla.setWidget(10, 2, labelTextoSolicitudError);

    dialogBox = new DialogBox();
    dialogBox.setText("Default Dialog Text");
    dialogBox.setAnimationEnabled(true);
    closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);
    dialogBox.hide();
    // Add a handler to close the DialogBox
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();
        }
    });
}

From source file:com.achow101.bctalkaccountpricer.client.Bitcointalk_Account_Pricer.java

License:Open Source License

/**
 * This is the entry point method.//  ww  w.  j  a  v  a 2  s. c  o  m
 */
public void onModuleLoad() {

    // Add Gui stuff      
    final Button sendButton = new Button("Estimate Price");
    final TextBox nameField = new TextBox();
    nameField.setText("User ID/Token");
    final Label errorLabel = new Label();
    final Label uidLabel = new Label();
    final Label usernameLabel = new Label();
    final Label postsLabel = new Label();
    final Label activityLabel = new Label();
    final Label potActivityLabel = new Label();
    final Label postQualityLabel = new Label();
    final Label trustLabel = new Label();
    final Label priceLabel = new Label();
    final Label loadingLabel = new Label();
    final Label tokenLabel = new Label();
    final InlineHTML estimateShareLabel = new InlineHTML();
    final InlineHTML reportTimeStamp = new InlineHTML();
    final RadioButton radioNormal = new RadioButton("merch", "Normal");
    final RadioButton radioMerchant = new RadioButton("merch", "Merchant");

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");
    radioNormal.setValue(true);
    radioMerchant.setValue(false);

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);
    RootPanel.get("uidLabelContainer").add(uidLabel);
    RootPanel.get("usernameLabelContainer").add(usernameLabel);
    RootPanel.get("postsLabelContainer").add(postsLabel);
    RootPanel.get("activityLabelContainer").add(activityLabel);
    RootPanel.get("potActivityLabelContainer").add(potActivityLabel);
    RootPanel.get("postQualityLabelContainer").add(postQualityLabel);
    RootPanel.get("trustLabelContainer").add(trustLabel);
    RootPanel.get("priceLabelContainer").add(priceLabel);
    RootPanel.get("loadingLabelContainer").add(loadingLabel);
    RootPanel.get("tokenLabelContainer").add(tokenLabel);
    RootPanel.get("tokenShareLabelContainer").add(estimateShareLabel);
    RootPanel.get("radioNormalContainer").add(radioNormal);
    RootPanel.get("radioMerchantContainer").add(radioMerchant);
    RootPanel.get("reportTimeStamp").add(reportTimeStamp);

    // Create activity breakdown panel
    final VerticalPanel actPanel = new VerticalPanel();
    final FlexTable actTable = new FlexTable();
    actPanel.add(actTable);
    RootPanel.get("activityBreakdown").add(actPanel);

    // Create posts breakdown panel
    final VerticalPanel postsPanel = new VerticalPanel();
    final FlexTable postsTable = new FlexTable();
    postsPanel.add(postsTable);
    RootPanel.get("postsBreakdown").add(postsPanel);

    // Create addresses breakdown panel
    final VerticalPanel addrPanel = new VerticalPanel();
    final FlexTable addrTable = new FlexTable();
    postsPanel.add(addrTable);
    RootPanel.get("addrBreakdown").add(addrTable);

    // Focus the cursor on the name field when the app loads
    nameField.setFocus(true);
    nameField.selectAll();

    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler, KeyUpHandler {
        /**
         * Fired when the user clicks on the sendButton.
         */
        public void onClick(ClickEvent event) {

            // Add request to queue
            addToQueue();
        }

        /**
         * Fired when the user types in the nameField.
         */
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                addToQueue();
            }
        }

        // Adds the request to server queue
        private void addToQueue() {

            // Clear previous output
            uidLabel.setText("");
            usernameLabel.setText("");
            postsLabel.setText("");
            activityLabel.setText("");
            potActivityLabel.setText("");
            postQualityLabel.setText("");
            trustLabel.setText("");
            priceLabel.setText("");
            sendButton.setEnabled(false);
            errorLabel.setText("");
            loadingLabel.setText("");
            tokenLabel.setText("");
            estimateShareLabel.setText("");
            reportTimeStamp.setText("");
            actTable.removeAllRows();
            postsTable.removeAllRows();
            addrTable.removeAllRows();

            // Create and add request
            request = new QueueRequest();
            request.setMerchant(radioMerchant.getValue());
            if (nameField.getText().matches("^[0-9]+$"))
                request.setUid(Integer.parseInt(escapeHtml(nameField.getText())));
            else {
                request.setToken(escapeHtml(nameField.getText()));
                request.setOldReq();
            }

            final String urlPath = com.google.gwt.user.client.Window.Location.getPath();
            final String host = com.google.gwt.user.client.Window.Location.getHost();
            final String protocol = com.google.gwt.user.client.Window.Location.getProtocol();
            final String url = protocol + "//" + host + urlPath + "?token=";

            // Request check loop
            Timer requestTimer = new Timer() {
                public void run() {
                    // send request to server
                    pricingService.queueServer(request, new AsyncCallback<QueueRequest>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            errorLabel.setText("Request Queuing failed. Please try again.");
                            sendButton.setEnabled(true);
                            pricingService.removeRequest(request, null);
                            cancel();
                        }

                        @Override
                        public void onSuccess(QueueRequest result) {

                            if (result.getQueuePos() == -3) {
                                loadingLabel.setText(
                                        "Please wait for your previous request to finish and try again");
                                sendButton.setEnabled(true);
                                cancel();
                            }

                            else if (result.getQueuePos() == -2) {
                                loadingLabel.setText("Please wait 2 minutes before requesting again.");
                                sendButton.setEnabled(true);
                                cancel();
                            }

                            else if (result.getQueuePos() == -4) {
                                loadingLabel.setText("Invalid token");
                                sendButton.setEnabled(true);
                                cancel();
                            }

                            else {
                                tokenLabel.setText("Your token is " + result.getToken());
                                estimateShareLabel.setHTML("Share this estimate: <a href=\"" + url
                                        + result.getToken() + "\">" + url + result.getToken() + "</a>");
                                if (!result.isProcessing() && !result.isDone()) {
                                    loadingLabel.setText("Please wait. You are number " + result.getQueuePos()
                                            + " in the queue.");
                                }
                                if (result.isProcessing()) {
                                    loadingLabel.setText("Request is processing. Please wait.");
                                }
                                if (result.isDone()) {
                                    // Clear other messages
                                    errorLabel.setText("");
                                    loadingLabel.setText("");

                                    // Output results
                                    uidLabel.setText(result.getResult()[0]);
                                    usernameLabel.setText(result.getResult()[1]);
                                    postsLabel.setText(result.getResult()[2]);
                                    activityLabel.setText(result.getResult()[3]);
                                    potActivityLabel.setText(result.getResult()[4]);
                                    postQualityLabel.setText(result.getResult()[5]);
                                    trustLabel.setText(result.getResult()[6]);
                                    priceLabel.setText(result.getResult()[7]);
                                    int indexOfLastAct = 0;
                                    int startAddrIndex = 0;
                                    for (int i = 8; i < result.getResult().length; i++) {
                                        if (result.getResult()[i].equals("<b>Post Sections Breakdown</b>")) {
                                            indexOfLastAct = i;
                                            break;
                                        }
                                        actTable.setHTML(i - 8, 0, result.getResult()[i]);
                                    }
                                    for (int i = indexOfLastAct; i < result.getResult().length; i++) {
                                        if (result.getResult()[i]
                                                .contains("<b>Addresses posted in non-quoted text</b>")) {
                                            startAddrIndex = i;
                                            break;
                                        }
                                        postsTable.setHTML(i - indexOfLastAct, 0, result.getResult()[i]);
                                    }
                                    if (!result.isMerchant()) {
                                        for (int i = startAddrIndex; i < result.getResult().length; i++) {
                                            addrTable.setHTML(i - startAddrIndex, 0, result.getResult()[i]);
                                        }
                                    }

                                    // Set the right radio
                                    radioMerchant.setValue(result.isMerchant());
                                    radioNormal.setValue(!result.isMerchant());

                                    // Report the time stamp
                                    DateTimeFormat fmt = DateTimeFormat.getFormat("MMMM dd, yyyy, hh:mm:ss a");
                                    Date completedDate = new Date(1000L * result.getCompletedTime());
                                    Date expireDate = new Date(
                                            1000L * (result.getCompletedTime() + result.getExpirationTime()));
                                    reportTimeStamp
                                            .setHTML("<i>Report generated at " + fmt.format(completedDate)
                                                    + " and expires at " + fmt.format(expireDate) + "</i>");

                                    // Kill the timer after everything is done
                                    cancel();
                                }
                                request = result;
                                request.setPoll(true);
                                sendButton.setEnabled(true);
                            }
                        }
                    });
                }
            };
            requestTimer.scheduleRepeating(2000);

        }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);

    // Check the URL for URL parameters
    String urlTokenParam = com.google.gwt.user.client.Window.Location.getParameter("token");
    if (!urlTokenParam.isEmpty()) {
        nameField.setText(urlTokenParam);
        handler.addToQueue();
    }
}

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

License:Open Source License

/**
 * This is the entry point method.//from  ww w  .  j  a  v  a2s. c o  m
 */
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);
}

From source file:com.acme.gwt.client.TvGuide.java

License:Apache License

public void onModuleLoad() {

    //code from jnorthrup's fork, will be moved to a presenter soon enough
    EventBus eventBus = GWT.create(SimpleEventBus.class);
    final MyRequestFactory rf = GWT.create(MyRequestFactory.class);
    rf.initialize(eventBus);/*from   w ww  . j  a  va  2s .  co m*/
    final GateKeeper gateKeeper = new GateKeeper();
    new DialogBox() {
        {
            final TextBox email = new TextBox() {
                {
                    setText("you@example.com");
                }
            };
            final PasswordTextBox passwordTextBox = new PasswordTextBox();
            setText("please log in");
            setWidget(new VerticalPanel() {
                {
                    add(new HorizontalPanel() {
                        {
                            add(new Label("email"));
                            add(email);
                        }
                    });
                    add(new HorizontalPanel() {
                        {
                            add(new Label("Password"));
                            add(passwordTextBox);
                        }
                    });
                    add(new Button("OK!!") {
                        {
                            addClickHandler(new ClickHandler() {
                                @Override
                                public void onClick(ClickEvent event) {
                                    String text = passwordTextBox.getText();
                                    String digest = Md5.md5Hex(text);
                                    Request<TvViewerProxy> authenticate = rf.reqViewer()
                                            .authenticate(email.getText(), digest);
                                    authenticate
                                            .with("geo", "name", "favoriteShows.name",
                                                    "favoriteShows.description")
                                            .to(gateKeeper).fire(new Receiver<Void>() {
                                                @Override
                                                public void onSuccess(Void response) {
                                                    hide(); //todo: review for a purpose
                                                    removeFromParent();
                                                }
                                            });
                                }
                            });
                        }
                    });
                }
            });
            center();
            show();
        }
    };
}

From source file:com.Administration.client.Administration.java

License:Apache License

/**
 * ?   UI//from  w  w  w .  j  a v  a  2 s .c o m
 */
public void onModuleLoad() {

    label = new HTML(); //   ?  ?  
    label.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    loginLabel = new HTML(); //   ?  ?    
    loginLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);

    dialog = new PasswordDialog(); //   
    list = new LinkedList<>(); //  ? ? 

    ProvidesKey<LinkData> KEY_PROVIDER = new ProvidesKey<LinkData>() { //    -   ??   
        @Override
        public Object getKey(LinkData item) {
            return item == null ? null : item.getId();
        }
    };
    cellTable = new CellTable<>(KEY_PROVIDER); //  ? 

    dataProvider = new ListDataProvider<>(); //    
    dataProvider.addDataDisplay(cellTable); // ?,   ????   ? 

    sortHandler = new ListHandler<>(list); //  ?
    cellTable.addColumnSortHandler(sortHandler); //  ?   

    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(SimplePager.TextLocation.CENTER, pagerResources, false, 0, true); //  pager -  ?
    pager.setDisplay(cellTable); // ?,  pager ?  ? 

    initTable(); //   ? 
    cellTable.setWidth("100%");
    cellTable.setHeight("80%");
    cellTable.setAutoHeaderRefreshDisabled(true);
    cellTable.setAutoFooterRefreshDisabled(true);

    //  ?  
    VerticalPanel VP = new VerticalPanel();
    VP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    VP.add(cellTable);
    VP.add(pager);

    logoutButton = new Button("Logout");

    //  ? 
    HorizontalPanel loginHP = new HorizontalPanel();
    loginHP.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    loginHP.setSpacing(5);
    loginHP.add(loginLabel);
    loginHP.add(logoutButton);

    logoutButton.addClickHandler(new ClickHandler() { //  
        @Override
        public void onClick(ClickEvent event) { //  

            Cookies.removeCookie(cookieName); // ?   

            //  ?  ???
            loginLabel.setHTML("");
            loginLabel.setVisible(false);
            label.setHTML("");
            cellTable.setVisible(false);
            pager.setVisible(false);
            logoutButton.setVisible(false);

            dataProvider.getList().clear(); // ? 

            dialog.show(); //   
            dialog.center();

        }
    });
    logoutButton.setVisible(false);

    //  
    RootPanel.get("Login").add(loginHP);
    RootPanel.get("Data").add(VP);
    RootPanel.get("Data").add(label);

    //    ? 
    cellTable.setVisible(false);
    pager.setVisible(false);

    dialog.Login();
}