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

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

Introduction

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

Prototype

public FlexTable() 

Source Link

Usage

From source file:client.richedit.RichTextToolbar.java

License:Apache License

protected void showPanelColorsPopup() {
    final BorderedPopup popup = new BorderedPopup();
    FlexTable contents = new FlexTable();
    contents.setCellSpacing(5);/*from   w w  w.  ja va  2 s .  c om*/
    contents.setCellPadding(0);
    contents.setText(0, 0, "Enter panel colors (in hex ASCII format, e.g. #FFCC99):");
    contents.getFlexCellFormatter().setColSpan(0, 0, 2);

    contents.setText(1, 0, "Text color:");
    final TextBox tcolor = MsoyUI.createTextBox(_tcolor, 7, 7);
    contents.setWidget(1, 1, tcolor);

    contents.setText(2, 0, "Background color:");
    final TextBox bgcolor = MsoyUI.createTextBox(_bgcolor, 7, 7);
    contents.setWidget(2, 1, bgcolor);

    HorizontalPanel buttons = new HorizontalPanel();
    buttons.add(new Button(_cmsgs.cancel(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            popup.hide();
        }
    }));
    buttons.add(WidgetUtil.makeShim(5, 5));
    buttons.add(new Button(_cmsgs.update(), new ClickHandler() {
        public void onClick(ClickEvent event) {
            setPanelColors(tcolor.getText().trim().toLowerCase(), bgcolor.getText().trim().toLowerCase());
            popup.hide();
        }
    }));
    contents.setWidget(3, 0, buttons);
    contents.getFlexCellFormatter().setColSpan(3, 0, 2);
    contents.getFlexCellFormatter().setHorizontalAlignment(3, 0, HasAlignment.ALIGN_RIGHT);

    popup.setWidget(contents);
    popup.show();
}

From source file:client.template.dialog.LoginDialog.java

License:Open Source License

public LoginDialog(final String title) {
    this.setText(title);

    final FlexTable panel = new FlexTable();
    panel.setStyleName("gwt-DialogBoxContent");

    this.username = new TextBox();
    this.password = new PasswordTextBox();

    panel.setWidget(0, 0, new Label("Username "));
    panel.setWidget(0, 1, this.username);

    panel.setWidget(1, 0, new Label("Password "));
    panel.setWidget(1, 1, this.password);

    panel.setWidget(2, 0, new Button("Close", new ClickListener() {
        public void onClick(final Widget sender) {
            LoginDialog.this.hide();
        }//w  w  w  .j a  va  2s  .co m
    }));

    panel.setWidget(2, 1, new Button("Sign In", new ClickListener() {
        public void onClick(final Widget sender) {
            LoginDialog.this.logIn();
        }
    }));

    this.setWidget(panel);
}

From source file:client.template.page.DefaultPage.java

License:Open Source License

/**
 * Creates a default page with title + describing text
 *//*ww  w.j  a v a  2 s.c  o  m*/
public DefaultPage(final String title, final String text) {
    final FlexTable table = new FlexTable();

    final HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setStyleName("gui-DefaultPage");

    hPanel.add(new Image("phosphoruslogo.png"));

    final VerticalPanel vPanel = new VerticalPanel();

    final Label titleLabel = new Label(title);
    titleLabel.setStyleName("gui-DefaultPage-Title");
    vPanel.add(titleLabel);

    final HTML ruler = new HTML("<hr />");
    ruler.setStyleName("gui-DefaultPage-Ruler");
    vPanel.add(ruler);

    final Label textLabel = new Label(text);
    textLabel.setStyleName("gui-DefaultPage-Text");
    vPanel.add(textLabel);

    hPanel.add(vPanel);

    table.setWidget(0, 0, hPanel);
    table.setWidth("100%");
    table.setHeight("100%");
    table.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);

    this.initWidget(table);
}

From source file:client.template.panel.ListPanel.java

License:Open Source License

/**
 * Initialize the list./*from ww w.j  a  va  2  s .  c om*/
 */
private void init() {
    this.lastRow = 1;
    this.selectedRow = 1;

    this.table = new FlexTable();

    this.table.setCellSpacing(0);
    this.table.setCellPadding(0);
    this.table.setWidth("100%");

    this.table.addTableListener(this);

    this.initWidget(this.table);
    this.setStyleName("mail-List");
}

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

License:Open Source License

/**
 * Inits the.//from  w w  w . ja  va2 s  .  co  m
 */
@Override
protected void init() {
    if (currentPage == HTMLControl.PAGE_INVITE) {
        InviteUser.exportViewDialogFunction();
        InviteUser.exportViewDialogInvite();
        table_list_3rdParty = new Table();
        tableInterface = new FlexTable();
        tableManagement = new FlexTable();
        filter_box = new ListBox();
        filter_box.setTitle("FILTER");
        filter_box.setStyleName("filter_box");
        filter_box.addItem(defaultFilter);
        filter_box.addItem(filter_Active);
        filter_box.addItem(filter_requesting);
        filter_box.addItem(filter_pending);
        tableManagement.setWidget(0, 0, new HTML(
                "<a class=\"btnInviteUser\" title=\"INVITE USER\" onClick=\"javascript:showDialogInvited()\" />"));
        tableManagement.setWidget(0, 1, filter_box);
        /*tableManagement.setWidget(1, 0, panelLog);*/
        tableManagement.setCellPadding(5);
        tableManagement.getCellFormatter().setHorizontalAlignment(0, 1, VerticalPanel.ALIGN_CENTER);
        /*tableManagement.setCellSpacing(20);*/
        initData(defaultFilter);
    }

}

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

License:Open Source License

/**
 * Show dialog box.//  w  w w.j a  va  2  s.  c  o  m
 *
 * @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:cmg.org.monitor.module.client.InviteUser.java

License:Open Source License

/**
 * Show dialog invited.//  ww  w  . j  a  v a 2 s .c om
 */
static void showDialogInvited() {
    dialogInvite = new DialogBox();
    dialogInvite.setAnimationEnabled(true);
    final Button exitButton = new Button();
    exitButton.setStyleName("");
    exitButton.getElement().setId("closeButton");
    exitButton.addStyleName("align=right");
    exitButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            dialogInvite.hide();
        }
    });
    btt_invite = new Button("Invite");
    btt_invite.setStyleName("margin:6px;");
    btt_invite.addStyleName("form-button");
    btt_invite.addClickHandler(new inviteUserHandler());
    btt_reset = new Button("Reset");
    btt_reset.setStyleName("margin:6px;");
    btt_reset.addStyleName("form-button");
    btt_reset.addClickHandler(new ResetInviteHandler());
    txt_email = new TextArea();
    txt_email.setTitle("Invite user");
    txt_email.setWidth("400px");
    txt_email.setHeight("100px");
    FlexTable panelButton = new FlexTable();
    panelButton.setWidget(0, 0, btt_invite);
    panelButton.setWidget(0, 1, btt_reset);
    panelButton.setCellPadding(5);
    panelButton.setCellSpacing(5);
    panelValidateEmail = new AbsolutePanel();
    panelValidateEmail.setVisible(false);
    listGroupInvi = new ListBox();
    listGroupInvi.setTitle("List Group");
    listGroupInvi.setWidth("200px");
    for (SystemGroup s : listGroup) {
        listGroupInvi.addItem(s.getName());
    }
    Label lblEmail = new Label("Gmail Address");
    FlexTable table = new FlexTable();
    table.setCellPadding(5);
    table.setCellSpacing(5);
    table.setWidget(0, 0, lblEmail);
    table.setWidget(0, 1, txt_email);
    table.setWidget(0, 2, panelValidateEmail);
    table.setWidget(0, 3, listGroupInvi);
    /*table.setWidget(2, 0, panelLog);*/
    table.getCellFormatter().setHorizontalAlignment(0, 0, VerticalPanel.ALIGN_LEFT);
    table.getCellFormatter().setHorizontalAlignment(0, 1, VerticalPanel.ALIGN_RIGHT);
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.add(exitButton);
    dialogVPanel.setCellHorizontalAlignment(exitButton, VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(table);
    dialogVPanel.add(panelButton);
    dialogVPanel.setCellHorizontalAlignment(panelButton, VerticalPanel.ALIGN_RIGHT);
    dialogInvite.setWidget(dialogVPanel);
    dialogInvite.getCaption().asWidget().setStyleName("myCaption");
    dialogInvite.center();
}

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

License:Open Source License

/**
 * This is the entry point method.//from w  w  w. j  a  va 2s .c  om
 */
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.alkacon.opencms.v8.calendar.client.input.CmsSerialDate.java

License:Open Source License

/**
 * Category field widgets for ADE forms.<p>
 * @param labels a JSON of all needed labels
 *//*from   w  ww  .  j  ava 2  s.c om*/
public CmsSerialDate(JSONObject labels) {

    super();

    m_labels = labels;

    m_dailyPattern = new CmsPatternPanelDaily(m_labels);
    m_weeklyPattern = new CmsPatternPanelWeekly(m_labels);
    m_monthlyPattern = new CmsPatternPanelMonthly(m_labels);
    m_yearlyPattern = new CmsPatternPanelYearly(m_labels);
    m_patterPanel = m_dailyPattern;
    try {
        m_timeFormat = DateTimeFormat.getFormat(Messages.get().key(Messages.GUI_DATEBOX_TIME_PATTERN_0));
    } catch (Exception e) {
        // in case the pattern is not available, fall back to standard en pattern
        m_timeFormat = DateTimeFormat.getFormat("hh:mm aa");
    }
    m_endDate.setValue(m_timeFormat.format(new Date()));
    m_startDate.setValue(m_timeFormat.format(new Date()));
    m_dateboxbegin.setValue(new Date());

    setSelectVaues();
    setTopPanel();
    setLowPanel();

    m_dateboxbegin.getTextField().getTextBoxContainer().addStyleName(
            org.opencms.ade.contenteditor.client.css.I_CmsLayoutBundle.INSTANCE.widgetCss().calendarStyle());
    m_dateboxend.getTextField().getTextBoxContainer().addStyleName(
            org.opencms.ade.contenteditor.client.css.I_CmsLayoutBundle.INSTANCE.widgetCss().calendarStyle());

    m_table.addStyleName(I_CmsLayoutBundle.INSTANCE.widgetCss().serialDataTabel());
    m_table.insertRow(0);

    // Table for top panel
    FlexTable topPanel = new FlexTable();
    topPanel.insertRow(0);
    // add the Time view.
    topPanel.setWidget(0, 0, m_topPanel);
    topPanel.getCellFormatter().getElement(0, 0).getStyle().setWidth(200, Unit.PX);
    // add the date view.
    topPanel.setWidget(0, 1, m_lowPanel);
    m_table.setWidget(0, 0, topPanel);
    m_table.getFlexCellFormatter().setColSpan(0, 0, 3);
    m_table.getCellFormatter().addStyleName(0, 0,
            I_CmsLayoutBundle.INSTANCE.widgetCss().serialDataTabelBorderBottom());

    // the selection view
    m_table.insertRow(1);
    m_table.setWidget(1, 0, m_serialPanel);
    m_table.getCellFormatter().getElement(1, 0).getStyle().setWidth(1, Unit.PX);
    m_table.setWidget(1, 1, new SimplePanel());
    m_table.getCellFormatter().addStyleName(1, 1,
            I_CmsLayoutBundle.INSTANCE.widgetCss().serialDataTabelBorderRight());
    m_table.setWidget(1, 2, m_patterPanel);

    for (int i = 0; i < m_arrayRadiobox.length; i++) {
        m_arrayRadiobox[i].addStyleName(org.opencms.ade.contenteditor.client.css.I_CmsLayoutBundle.INSTANCE
                .widgetCss().radioButtonlabel());
        m_arrayRadiobox[i].addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {

                changePattern();
            }
        });

        m_serialPanel.add(m_arrayRadiobox[i]);
    }
    initWidget(m_panel);
    m_panel.add(m_table);
    m_panel.add(m_error);

}

From source file:com.alkacon.opencms.v8.calendar.client.input.CmsSerialDate.java

License:Open Source License

/**
 * Private function to set all the end selections.<p>
 * *///from  ww  w .j  a v a 2s  .  co m
private void setLowPanel() {

    FlexTable table = new FlexTable();
    table.insertRow(0);
    FlowPanel cell1 = new FlowPanel();
    Label startDate = new Label(m_labels.get("GUI_SERIALDATE_TIME_STARTDATE_0").isString().stringValue());
    startDate.addStyleName(I_CmsLayoutBundle.INSTANCE.widgetCss().serialDateLable());
    cell1.add(startDate);
    cell1.getElement().getStyle().setWidth(100, Unit.PCT);
    cell1.add(m_dateboxbegin);
    m_dateboxbegin.setDateOnly(true);
    m_dateboxbegin.getElement().getStyle().setWidth(108, Unit.PX);
    m_dateboxbegin.getElement().getStyle().setFloat(Float.RIGHT);
    m_dateboxbegin.addValueChangeHandler(new ValueChangeHandler<Date>() {

        public void onValueChange(ValueChangeEvent<Date> event) {

            fireValueChange();

        }
    });
    table.setWidget(0, 0, cell1);
    table.getCellFormatter().getElement(0, 0).getStyle().setWidth(185, Unit.PX);
    table.getCellFormatter().getElement(0, 0).getStyle().setVerticalAlign(VerticalAlign.TOP);

    FlowPanel cell2 = new FlowPanel();
    CmsRadioButton sel1 = new CmsRadioButton("1",
            m_labels.get("GUI_SERIALDATE_DURATION_ENDTYPE_NEVER_0").isString().stringValue());
    m_lowRadioButton[0] = sel1;
    sel1.setGroup(m_groupDuration);
    sel1.setChecked(true);
    sel1.addStyleName(I_CmsLayoutBundle.INSTANCE.widgetCss().serialDatelowPanelSelection());
    sel1.addStyleName(
            org.opencms.ade.contenteditor.client.css.I_CmsLayoutBundle.INSTANCE.widgetCss().radioButtonlabel());
    sel1.getElement().getStyle().setMarginLeft(13, Unit.PX);
    sel1.getElement().getStyle().setMarginTop(0, Unit.PX);
    sel1.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {

            fireValueChange();

        }
    });

    CmsRadioButton sel2 = new CmsRadioButton("2",
            m_labels.get("GUI_SERIALDATE_DURATION_ENDTYPE_OCC_0").isString().stringValue());
    m_lowRadioButton[1] = sel2;
    sel2.setGroup(m_groupDuration);
    sel2.addStyleName(I_CmsLayoutBundle.INSTANCE.widgetCss().serialDatelowPanelSelection());
    sel2.addStyleName(
            org.opencms.ade.contenteditor.client.css.I_CmsLayoutBundle.INSTANCE.widgetCss().radioButtonlabel());
    sel2.getElement().setAttribute("style", "clear:left");
    sel2.getElement().getStyle().setMarginLeft(13, Unit.PX);
    sel2.getElement().getStyle().setMarginTop(6, Unit.PX);
    sel2.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {

            if (m_times.getText().isEmpty()) {
                m_times.setValue("1");
            }
            fireValueChange();

        }
    });

    CmsRadioButton sel3 = new CmsRadioButton("3",
            m_labels.get("GUI_SERIALDATE_DURATION_ENDTYPE_DATE_0").isString().stringValue());
    m_lowRadioButton[2] = sel3;
    sel3.setGroup(m_groupDuration);
    sel3.addStyleName(I_CmsLayoutBundle.INSTANCE.widgetCss().serialDatelowPanelSelection());
    sel3.addStyleName(
            org.opencms.ade.contenteditor.client.css.I_CmsLayoutBundle.INSTANCE.widgetCss().radioButtonlabel());
    sel3.getElement().setAttribute("style", "clear:left");
    sel3.getElement().getStyle().setMarginLeft(13, Unit.PX);
    sel3.getElement().getStyle().setMarginTop(6, Unit.PX);
    sel3.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {

            m_dateboxend.setValue(new Date());
            fireValueChange();

        }
    });

    cell2.add(sel1);
    cell2.add(sel2);

    m_times.setStyleName(I_CmsLayoutBundle.INSTANCE.widgetCss().textBoxSerialDate());
    m_times.getElement().getStyle().setMarginTop(5, Unit.PX);
    m_times.getElement().getStyle().setWidth(82, Unit.PX);
    cell2.add(m_times);
    m_times.addKeyPressHandler(new KeyPressHandler() {

        public void onKeyPress(KeyPressEvent event) {

            fireValueChange();

        }
    });
    m_times.addValueChangeHandler(new ValueChangeHandler<String>() {

        public void onValueChange(ValueChangeEvent<String> event) {

            fireValueChange();

        }

    });
    m_times.addFocusHandler(new FocusHandler() {

        public void onFocus(FocusEvent event) {

            selectEnding(1);

        }
    });
    Label times = new Label(
            m_labels.get("GUI_SERIALDATE_DURATION_ENDTYPE_OCC_TIMES_0").isString().stringValue());
    times.addStyleName(I_CmsLayoutBundle.INSTANCE.widgetCss().serialDateLable());
    times.getElement().getStyle().setMarginTop(7, Unit.PX);
    times.getElement().getStyle().setMarginLeft(2, Unit.PX);
    cell2.add(times);
    cell2.add(sel3);

    cell2.add(m_dateboxend);
    m_dateboxend.setDateOnly(true);
    m_dateboxend.getElement().getStyle().setWidth(90, Unit.PX);
    m_dateboxend.getElement().getStyle().setMarginTop(5, Unit.PX);
    m_dateboxend.getElement().getStyle().setMarginLeft(22, Unit.PX);
    m_dateboxend.addValueChangeHandler(new ValueChangeHandler<Date>() {

        public void onValueChange(ValueChangeEvent<Date> event) {

            fireValueChange();

        }
    });
    m_dateboxend.addDomHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {

            selectEnding(2);

        }
    }, ClickEvent.getType());
    table.setWidget(0, 1, cell2);
    m_lowPanel.add(table);
    m_lowPanel.setStyleName(I_CmsLayoutBundle.INSTANCE.widgetCss().serialDatelowPanel());
}