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

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

Introduction

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

Prototype

public void removeAllRows() 

Source Link

Document

Remove all rows in this table.

Usage

From source file:co.edu.udea.iw.rtf.client.activity.SolicitudesActivity.java

License:Open Source License

/**
 * Metodo para borrar la tabla y cargar solo las solicitudes pendientes
 *//*  ww  w.j a v a2s  .  c  o m*/
public void cleanTable() {

    final SolicitudesView view = clientFactory.getSolicitudesView();
    FlexTable tabla = view.getTable();
    tabla.clear();
    tabla.removeAllRows();
    tabla.setText(0, 0, "Nombre Completo");
    tabla.setText(0, 1, "Correo electronico");
    tabla.setText(0, 2, "Fecha de solicitud");
    tabla.setText(0, 3, "Tipo de solicitud");
    tabla.setText(0, 4, "Texto de la solicitud");
    tabla.getCellFormatter().setWidth(0, 0, "100px");
    tabla.getCellFormatter().setWidth(0, 1, "100px");
    tabla.getCellFormatter().setWidth(0, 2, "100px");
    tabla.getCellFormatter().setWidth(0, 3, "100px");
    tabla.getCellFormatter().setWidth(0, 4, "100px");
    tabla.getRowFormatter().addStyleName(0, "tablaHeader");
}

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

License:Open Source License

/**
 * This is the entry point method.// w w w .  j  av  a  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.ephesoft.dcma.gwt.rv.client.view.TableExtractionView.java

License:Open Source License

/**
 * This method performs insert,delete and delete all operation on table.
 * /*from  w  ww  .  j ava2s . c o  m*/
 * @param action {@link Action} action selected by user
 * @param radioButtonNumber {@link Integer} 0 for insert row before selected row, 1 for insert row after selected row
 * @param button {@link Button} button where focus is set after action is performed
 */
public void insertDeleteRow(final Action action, final int radioButtonNumber, final Button button) {

    List<DataTable> dataTablesList = selectedDocument.getDataTables().getDataTable();
    if (dataTablesList == null || dataTablesList.isEmpty()) {
        TableExtractionView.this.fireEvent(new TableViewDisplayEvent(0));
        return;
    }
    for (final DataTable dataTable : dataTablesList) {
        int focusRow = 0;
        if (dataTable.getName().equals(selectedDataTableName)) {
            HeaderRow headerRow = dataTable.getHeaderRow();
            if (dataTable != null && headerRow != null && headerRow.getColumns() != null
                    && headerRow.getColumns().getColumn() != null
                    && !headerRow.getColumns().getColumn().isEmpty()) {
                FlexTable selectedView = tableNameVsViewMap.get(selectedDataTableName);
                final List<Column> columnList = headerRow.getColumns().getColumn();
                selectedView.clear();
                if (action == Action.DELETE) {
                    dataTable.getRows().getRow().remove(selectedRowNumber - 1);
                    selectedView.removeRow(selectedRowNumber);
                    focusRow = selectedRowNumber;
                } else if (action == Action.INSERT) {
                    Row row = createNewRow(columnList);
                    if (dataTable.getRows().getRow() == null || dataTable.getRows().getRow().isEmpty()) {
                        selectedRowNumber = 1;
                        dataTable.getRows().getRow().add(0, row);
                        focusRow = 1;
                    } else {
                        if (radioButtonNumber == 0) {
                            dataTable.getRows().getRow().add(selectedRowNumber - 1, row);
                            focusRow = selectedRowNumber;
                        } else if (radioButtonNumber == 1) {
                            dataTable.getRows().getRow().add(selectedRowNumber, row);
                            focusRow = selectedRowNumber + 1;
                        }
                    }
                } else if (action == Action.DELETE_ALL) {
                    dataTable.getRows().getRow().clear();
                    selectedView.removeAllRows();
                }
                if (dataTable.getRows().getRow().size() != 0) {
                    addHeaderColumns(headerRow.getColumns().getColumn(), selectedView);
                    createTableList(selectedView, dataTable.getRows().getRow(), columnList, dataTable,
                            selectedDocument);
                } else {
                    selectedRowNumber = 0;
                    setEmptyTableView(selectedView, headerRow);
                    if (button != null) {
                        setFocus(button);
                    }
                }
                if (dataTable.getRows().getRow().size() > selectedRowNumber - 1
                        && !dataTable.getRows().getRow().isEmpty()) {
                    SuggestBox suggestBox = (SuggestBox) selectedView.getWidget(focusRow, 0);
                    suggestBox.getTextBox().setFocus(true);
                } else if (!dataTable.getRows().getRow().isEmpty()) {
                    SuggestBox suggestBox = (SuggestBox) selectedView.getWidget(selectedRowNumber - 1, 0);
                    suggestBox.getTextBox().setFocus(true);
                }
                break;
            }
        }
    }

}

From source file:com.google.api.services.samples.calendar.appengine.client.CalendarGwtSample.java

License:Apache License

void refreshTable() {
    FlexTable calendarsTable = calendarsFrame.calendarsTable;
    calendarsTable.removeAllRows();
    calendarsTable.setText(0, 1, "Calendar Title");
    calendarsTable.getCellFormatter().addStyleName(0, 1, "methodsHeaderRow");
    for (int i = 0; i < calendars.size(); i++) {
        GwtCalendar calendar = calendars.get(i);
        calendarsTable.setWidget(i + 1, 0, new CalendarButtons(this, calendar, i));
        calendarsTable.setText(i + 1, 1, calendar.title);
    }//from ww w  . j a  v  a 2s.  co m
}

From source file:com.google.gwt.sample.healthyeatingapp.client.FoodLog.FoodLog.java

public FlowPanel onModuleLoad() {

    rpcUserNameCall();/*from   w w w  .j  a  v  a 2s.  co m*/
    rpcCall();

    // Create a Flex Table
    final FlexTable flexTable = new FlexTable();
    FlexCellFormatter cellFormatter = flexTable.getFlexCellFormatter();
    flexTable.addStyleName("flexTable");
    flexTable.setCellSpacing(2);
    flexTable.setCellPadding(2);

    lbFG = new ListBox();
    lbFN = new ListBox();
    submit = new Button("Submit");
    cancel = new Button("Pick a New Date");

    fp = new FlowPanel();
    // Add some text
    cellFormatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
    flexTable.setHTML(0, 0, "This table allows you to log your food entries:");
    cellFormatter.setColSpan(0, 0, 2);

    lbFG.setVisibleItemCount(1);

    lbFN.setVisible(false);
    lbFG.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            fp.remove(SuccessLabel);
            int selectedIndex = lbFG.getSelectedIndex();
            int numRows = 0;

            if (selectedIndex > 0) {

                numRows = flexTable.getRowCount();
                flexTable.setWidget(numRows - 1, 0, lbFG);
                lbFN.clear();
                caloriesText.setText("", Direction.DEFAULT);

                String test = lbFG.getValue(lbFG.getSelectedIndex());
                String[] str = getFoodNames(ret, test);
                lbFN.addItem("");
                for (String s : str) {
                    lbFN.addItem(s);
                }
                lbFN.setSelectedIndex(0);
                lbFN.setVisible(true);

                flexTable.setWidget(numRows - 1, 1, lbFN);
            }

        }
    });

    lbFN.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            int selectedIndex = lbFN.getSelectedIndex();
            int numRows = 0;
            if (selectedIndex > 0)

                numRows = flexTable.getRowCount();
            flexTable.setWidget(numRows - 1, 1, lbFN);

            String test = lbFN.getValue(lbFN.getSelectedIndex());
            String str = "" + getCalories(ret, test);
            caloriesText.setText(str, Direction.DEFAULT);
            flexTable.setWidget(numRows - 1, 2, caloriesText);

        }
    });

    // Add a button that will add more rows to the table
    final Button addRowButton = new Button("Add a Row");
    Button btn2 = new Button("Update");
    addRowButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            fp.remove(SuccessLabel);
            addRow(flexTable);
        }
    });

    addRowButton.addStyleName("fixedWidthButton");

    VerticalPanel buttonPanel = new VerticalPanel();
    buttonPanel.setStyleName("flexTable-buttonPanel");
    buttonPanel.add(addRowButton);
    flexTable.setWidget(0, 1, buttonPanel);
    cellFormatter.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);

    // Add two rows to start
    // addRow(flexTable);

    final DatePicker datePicker = new DatePicker();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {

        public void onValueChange(ValueChangeEvent<Date> event) {

            Date date = event.getValue();
            DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd");
            dateString = dfm.format(date);
            dateLabel.setText(dateString, Direction.DEFAULT);
            selectedDate = dateLabel.getText();
            queryRpcCall(userNameTyped, selectedDate);

        }
    });
    final Button Btn2 = new Button();
    ret = new ArrayList<FoodLogItems>();
    Btn2.setSize("100px", "30px");
    Btn2.setText("View/Update");
    Btn2.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            Btn2.setVisible(false);
            datePicker.setVisible(false);

            selectedDate = dateLabel.getText();
            String[] dbRows;
            String[] dbElements;

            // Window.alert(prevFoodData);
            if (!(prevFoodData.equals(""))) {

                dbRows = prevFoodData.split(";");
                for (String s : dbRows)

                {
                    dbElements = s.split(":");
                    FoodLogData e = new FoodLogData(userNameTyped, dbElements[2],
                            Integer.parseInt(dbElements[1]), dbElements[0], selectedDate);
                    foodEntries.add(e);
                }

            }

            String[] temp;
            if (foodLogItems != null) {
                array = foodLogItems.split(";");
                // String s="";
                for (String s : array)

                {
                    temp = s.split(":");
                    FoodLogItems e = new FoodLogItems(temp[0], Integer.parseInt(temp[1]), temp[2]);
                    ret.add(e);
                }
                lbFG.addItem("");

                String[] input = new String[ret.size()];
                int i = 0;
                for (FoodLogItems e : ret) {

                    input[i] = e.FoodGroup();
                    i++;

                }

                Set<String> tmp = new LinkedHashSet<String>();
                for (String each : input) {
                    tmp.add(each);
                }
                String[] output = new String[tmp.size()];
                int j = 0;
                for (String each : tmp) {
                    output[j++] = each;
                }

                for (String s : output) {
                    lbFG.addItem(s);
                }

                lbFG.setSelectedIndex(0);

            }

            int numRows = flexTable.getRowCount();
            // Window.alert(""+numRows);
            flexTable.removeAllRows();
            flexTable.insertRow(0);

            int i = 0;
            for (FoodLogData j : foodEntries) {

                flexTable.insertRow(i + 1);
                numRows = flexTable.getRowCount();

                flexTable.setText(numRows - 1, 0, j.getFoodGroup());
                flexTable.setText(numRows - 1, 1, j.getFoodName());
                flexTable.setText(numRows - 1, 2, j.getCalories() + "");

                flexTable.getFlexCellFormatter().setRowSpan(0, 1, numRows + 1);

                i++;

            }
            numRows = flexTable.getRowCount();
            lbFG.setSelectedIndex(0);
            flexTable.setWidget(numRows, 0, lbFG);
            flexTable.getFlexCellFormatter().setRowSpan(0, 1, numRows + 1);

            fp.add(flexTable);
            fp.add(addRowButton);
            fp.add(submit);
            fp.add(cancel);

        }
    });

    InlineLabel dateMessageLabel = new InlineLabel();
    dateMessageLabel.setText("Pick a date: ");

    submit.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            System.out.println("Submitting these items");
            for (FoodLogData e : foodEntries) {
                System.out.println("Food name is " + e.getFoodName());
                insertRpcCall(e.getUserName(), e.getFoodName(), e.getDate(), e.getCalories());
            }
            fp.add(SuccessLabel);
            foodEntries.clear();
        }

    });
    cancel.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {

            // TODO Auto-generated method stub
            fp.remove(SuccessLabel);
            Window.Location.reload();
        }

    });

    fp.add(dateMessageLabel);
    fp.add(dateLabel);
    fp.add(datePicker);
    fp.add(Btn2);

    return fp;

}

From source file:com.siderakis.demo.client.MultiSelectDemo.java

License:Apache License

private void addMultiUploadInput() {
    final FileInput fileInput = new FileInput();
    fileInput.setAllowMultipleFiles(true);
    panel.add(new Label(fileInput.supportsFileAPI() ? "Select multiple files:"
            : "Your browser doesn't support multiple files!:"));

    fileInput.setName("uploadFormElement");

    panel.add(fileInput);/* w ww .  j a va 2s  .co  m*/

    final FlexTable table = new FlexTable();
    panel.add(table);
    fileInput.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(final ChangeEvent event) {
            table.removeAllRows();
            table.setHTML(0, 0, "<b>File name</b>");
            table.setHTML(0, 1, "<b>File size</b>");
            int row = 1;
            for (final File file : fileInput.getFiles()) {
                table.setText(row, 0, file.getFileName());
                table.setText(row, 1, file.getFileSize() + "");
                ++row;
            }
        }
    });
}

From source file:org.ebayopensource.turmeric.monitoring.client.view.ConsumerView.java

License:Open Source License

/**
 * Sets the tabular data./* w  ww.  j ava  2  s .c  o  m*/
 * 
 * @param table
 *            the table
 * @param cols
 *            the cols
 * @param rows
 *            the rows
 */
protected void setTabularData(FlexTable table, String[] cols, List<Widget[]> rows) {
    table.removeAllRows();
    if (cols != null) {
        for (int i = 0; i < cols.length; i++)
            table.setText(0, i, cols[i]);
    }
    table.getRowFormatter().addStyleName(0, "tbl-header1");

    if (rows != null) {
        int i = 0;
        for (Widget[] row : rows) {
            i++;
            for (int j = 0; j < row.length; j++) {
                table.setWidget(i, j, row[j]);

            }
        }
    }
}

From source file:org.ebayopensource.turmeric.monitoring.client.view.ErrorView.java

License:Open Source License

/**
 * @param errorData/*from   w ww . jav  a 2 s .com*/
 */
private void setErrorTableData(FlexTable table, ErrorMetricData errorData) {
    /*
     * Columns: error Id, error Name, Error Count: date1, date2 Error to Call Ratio: date1, date2
     */
    if (errorData == null)
        return;

    String d1 = formatDateAndDuration(errorData.getMetricCriteria().date1,
            errorData.getMetricCriteria().durationSec);
    String d2 = formatDateAndDuration(errorData.getMetricCriteria().date2,
            errorData.getMetricCriteria().durationSec);

    table.clear();
    table.removeAllRows();
    table.setWidget(0, 2, new Label(ConsoleUtil.constants.count()));
    table.getFlexCellFormatter().setColSpan(0, 2, 2);
    table.getRowFormatter().addStyleName(0, "tbl-header1");
    table.setWidget(0, 3, new Label(ConsoleUtil.constants.errorsToCalls()));
    table.getFlexCellFormatter().setColSpan(0, 3, 2);
    table.setWidget(1, 0, new Label(ConsoleUtil.constants.error()));
    table.setWidget(1, 1, new Label(ConsoleUtil.constants.name()));
    table.setWidget(1, 2, new Label(d1));
    table.setWidget(1, 3, new Label(d2));
    table.setWidget(1, 4, new Label(d1));
    table.setWidget(1, 5, new Label(d2));
    table.getRowFormatter().addStyleName(1, "tbl-header1");

    if (errorData.getReturnData() == null)
        return;
    int i = 2;
    for (ErrorViewData evd : errorData.getReturnData()) {
        Label id = new Label(evd.getErrorId());
        id.addStyleName("clickable");
        table.setWidget(i, 0, id);
        Label name = new Label(evd.getErrorName());
        name.addStyleName("clickable");
        table.setWidget(i, 1, name);
        try {
            table.setWidget(i, 2,
                    new Label(NumberFormat.getDecimalFormat().format(Long.valueOf(evd.getErrorCount1()))));
        } catch (NumberFormatException e) {
            table.setWidget(i, 2, new Label(ConsoleUtil.constants.error()));
        }
        try {
            table.setWidget(i, 3,
                    new Label(NumberFormat.getDecimalFormat().format(Long.valueOf(evd.getErrorCount2()))));
        } catch (NumberFormatException e) {
            table.setWidget(i, 3, new Label(ConsoleUtil.constants.error()));
        }
        try {
            table.setWidget(i, 4, new Label(
                    NumberFormat.getDecimalFormat().format(Double.valueOf(evd.getErrorCallRatio1()))));
        } catch (NumberFormatException e) {
            table.setWidget(i, 4, new Label(ConsoleUtil.constants.error()));
        }
        try {
            table.setWidget(i, 5, new Label(
                    NumberFormat.getDecimalFormat().format(Double.valueOf(evd.getErrorCallRatio2()))));
        } catch (NumberFormatException e) {
            table.setWidget(i, 5, new Label(ConsoleUtil.constants.error()));
        }
        i++;
    }
}

From source file:org.ebayopensource.turmeric.monitoring.client.view.ServiceView.java

License:Open Source License

/**
 * Sets the tabular data.//  w ww.  j a va 2s .  co m
 * 
 * @param table
 *            the table
 * @param cols
 *            the cols
 * @param rows
 *            the rows
 * @param rowStyles
 *            the row styles
 */
protected void setTabularData(FlexTable table, String[] cols, List<String[]> rows, String[] rowStyles) {
    table.removeAllRows();
    table.setText(0, 0, cols[0]);
    table.setText(0, 1, cols[1]);// flip flop dates - this is needed to fix
                                 // the % change sign error!!!
    table.setText(0, 2, cols[2]);// flip flop dates - this is needed to fix
                                 // the % change sign error!!!
    table.setText(0, 3, cols[3]);
    table.getRowFormatter().addStyleName(0, "tbl-header1");

    if (rows != null) {
        int i = 0;
        for (String[] row : rows) {
            i++;
            Label l = new Label(row[0]);
            table.setWidget(i, 0, l);
            // table.getCellFormatter().setWidth(i, 0, "30%");
            if (rowStyles != null && 0 < rowStyles.length && rowStyles[0] != null)
                l.addStyleName(rowStyles[0]);

            l = new Label(NumberFormat.getDecimalFormat().format(new Double(row[1])));
            table.setWidget(i, 1, l);
            table.getCellFormatter().setWidth(i, 1, "25%");
            if (rowStyles != null && 1 < rowStyles.length && rowStyles[1] != null)
                l.addStyleName(rowStyles[1]);

            l = new Label(NumberFormat.getDecimalFormat().format(new Double(row[2])));
            table.setWidget(i, 2, l);
            table.getCellFormatter().setWidth(i, 2, "25%");
            if (rowStyles != null && 2 < rowStyles.length && rowStyles[2] != null)
                l.addStyleName(rowStyles[2]);
            l = new Label(row[3]);
            table.setWidget(i, 3, l);
            table.getCellFormatter().setWidth(i, 3, "15%");
            if (rowStyles != null && 3 < rowStyles.length && rowStyles[3] != null)
                l.addStyleName(rowStyles[3]);
        }

    }
}

From source file:org.kaaproject.avro.ui.gwt.client.widget.AbstractFieldWidget.java

License:Apache License

protected void constructFormData(FlexTable table, FormField field,
        List<HandlerRegistration> handlerRegistrations) {
    table.removeAllRows();
    if (field != null && field.getFieldAccess() != FieldAccess.HIDDEN) {
        int row = 0;
        if (field.getFieldType() == FieldType.RECORD) {
            RecordField recordField = ((RecordField) field);
            for (FormField formField : recordField.getValue()) {
                if (formField.getFieldAccess() != FieldAccess.HIDDEN) {
                    row = constructField(table, row, formField, handlerRegistrations);
                    row++;//  w w  w  .  j a  v a  2 s  .co m
                }
            }
        } else {
            constructField(table, row, field, handlerRegistrations);
        }
    }
}