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

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

Introduction

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

Prototype

public void addCell(int row) 

Source Link

Document

Appends a cell to the specified row.

Usage

From source file:com.google.caliper.cloud.client.BenchmarkDataViewer.java

License:Apache License

public void rebuildResultsTable() {
    if (plainText) {
        Label label = new Label();
        label.setStyleName("plaintext");
        label.setText(gridToString(toGrid()));

        resultsDiv.clear();//from w w  w  .  j a  va2s  . c o m
        resultsDiv.add(label);
        resultsDiv.add(new PlainTextEditor().getWidget());
        HTML dash = new HTML(" - ", false);
        dash.setStyleName("inline");
        resultsDiv.add(dash);
        resultsDiv.add(new SnapshotCreator().getWidget());
        return;
    }

    FlexTable table = new FlexTable();
    table.setStyleName("data");
    int r = 0;
    int c = 0;
    int evenRowMod = 0;

    // results header #1: cValue variables
    if (cVariable != null) {
        evenRowMod = 1;
        table.insertRow(r);
        table.getRowFormatter().setStyleName(r, "valueRow");
        table.getRowFormatter().addStyleName(r, "headerRow");

        table.addCell(r);
        table.getFlexCellFormatter().setColSpan(r, 0, rVariables.size());
        c++;
        for (Value cValue : cValues) {
            table.addCell(r);
            table.getFlexCellFormatter().setColSpan(r, c, 3);
            table.getCellFormatter().setStyleName(r, c, "parameterKey");

            Widget contents = newVariableLabel(cVariable, cValue.getLabel(), rVariables.size());
            contents.setStyleName("valueHeader");

            table.setWidget(r, c++, contents);
        }
        r++;
    }

    // results header 2: rValue variables, followed by "nanos/barchart" column pairs
    c = 0;
    table.insertRow(r);
    table.getRowFormatter().setStyleName(r, "evenRow");
    table.getRowFormatter().addStyleName(r, "headerRow");
    for (Variable variable : rVariables) {
        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c, newVariableLabel(variable, variable.getName(), c));
        c++;
    }
    for (Value unused : cValues) {
        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c++, newUnitLabel(unitMap.get(selectedType).trim()));

        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c++, newRuntimeLabel());

        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c++, new InlineLabel("%"));
    }
    r++;

    Key key = newDefaultKey();
    for (RowsIterator rows = new RowsIterator(rVariables); rows.nextRow();) {
        rows.updateKey(key);

        table.insertRow(r);
        table.getRowFormatter().setStyleName(r, r % 2 == evenRowMod ? "evenRow" : "oddRow");
        c = 0;
        for (int v = 0, size = rVariables.size(); v < size; v++) {
            table.addCell(r);
            table.setWidget(r, c++, new Label(rows.getRValue(v).getLabel()));
        }

        for (Value value : cValues) {
            table.addCell(r);
            table.addCell(r);

            if (cVariable != null) {
                key.set(cVariable, value);
            }

            final Datapoint datapoint = keysToDatapoints.get(key);
            table.getCellFormatter().setStyleName(r, c, "numericCell");
            table.getCellFormatter().setStyleName(r, c + 1, "bar");
            table.getCellFormatter().setStyleName(r, c + 2, "numericCell");
            MeasurementSet measurementSet;
            if (datapoint != null
                    && (measurementSet = datapoint.scenarioResults.getMeasurementSet(selectedType)) != null) {
                double rawMedian = getMedian(selectedType, measurementSet);
                String displayedValue = numberFormatMap.get(selectedType)
                        .format(rawMedian / divideByMap.get(selectedType));
                Anchor valueAnchor = new Anchor(displayedValue, false);
                valueAnchor.setStyleName("subtleLink");
                valueAnchor.setStyleName("nanos", true);

                final DialogBox eventLogPopup = new DialogBox(true);
                eventLogPopup.setText("");

                valueAnchor.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent clickEvent) {
                        // Do this lazily since it takes quite a bit of time to render these popups for all
                        // the scenarios shown, and quite often they won't even be used.
                        if (eventLogPopup.getText().isEmpty()) {
                            eventLogPopup.setText("Event Log");
                            String eventLog = datapoint.scenarioResults.getEventLog(selectedType);
                            if (eventLog == null || eventLog.isEmpty()) {
                                eventLog = "No event log recorded.";
                            }
                            FlowPanel panel = new FlowPanel();
                            for (String line : eventLog.split("\n")) {
                                panel.add(new Label(line));
                            }
                            panel.setStyleName("eventLog");
                            eventLogPopup.add(panel);
                        }
                        eventLogPopup.center();
                        eventLogPopup.show();
                    }
                });

                table.setWidget(r, c, valueAnchor);
                table.setWidget(r, c + 1, newBar(datapoint.style, measurementSet, value));
                table.setWidget(r, c + 2, newPercentOfReferencePointLabel(rawMedian, value));
            } else {
                table.setWidget(r, c, new Label(""));
                table.setWidget(r, c + 1, new Label(""));
                table.setWidget(r, c + 2, new Label(""));
            }
            c += 3;
        }

        r++;
    }
    resultsDiv.clear();
    resultsDiv.add(table);
    resultsDiv.add(new PlainTextEditor().getWidget());
    HTML dash = new HTML(" - ", false);
    dash.setStyleName("inline");
    resultsDiv.add(dash);
    resultsDiv.add(new SnapshotCreator().getWidget());
}

From source file:com.google.caliper.cloud.client.BenchmarkDataViewer.java

License:Apache License

public void rebuildVariablesTable() {
    FlexTable table = new FlexTable();
    table.setStyleName("data");

    int r = 0;/* w  w  w . j ava 2s . c o m*/
    for (Variable variable : variables) {
        table.insertRow(r);

        table.addCell(r);
        table.getRowFormatter().setStyleName(r, r % 2 == 0 ? "evenRow" : "oddrow");
        table.getCellFormatter().setStyleName(r, 0, "fixedParameterKey");
        table.setWidget(r, 0, new Label(variable.getName()));

        table.addCell(r);
        FlowPanel checkBoxes = new FlowPanel();
        if (variable.hasMultipleValues()) {
            for (Value value : variable.getValues()) {
                checkBoxes.add(newShownCheckbox(value));
            }
        } else {
            checkBoxes.add(new Label(variable.getOnlyValue().getName()));
        }
        table.setWidget(r, 1, checkBoxes);

        r++;
    }

    fixedVariablesDiv.clear();
    fixedVariablesDiv.add(table);
}

From source file:org.jbpm.form.builder.ng.model.client.form.items.MIGLayoutFormItem.java

License:Apache License

private void populate(FlexTable grid) {
    if (this.borderWidth != null && this.borderWidth > 0) {
        grid.setBorderWidth(this.borderWidth);
    }//  ww  w .  j a  v  a2 s  . c  o m
    if (this.cellpadding != null && this.cellpadding >= 0) {
        grid.setCellPadding(this.cellpadding);
    }
    if (this.cellspacing != null && this.cellspacing >= 0) {
        grid.setCellSpacing(this.cellspacing);
    }
    if (getHeight() != null) {
        grid.setHeight(getHeight());
    }
    if (getWidth() != null) {
        grid.setWidth(getWidth());
    }
    if (this.title != null) {
        grid.setTitle(this.title);
    }
    if (this.rows != null && this.rows > 0) {
        while (this.rows > grid.getRowCount()) {
            grid.insertRow(grid.getRowCount());
            int columnCount = 0;
            FlexCellFormatter formatter = grid.getFlexCellFormatter();
            for (int cell = 0; cell < grid.getCellCount(grid.getRowCount() - 1); cell++) {
                columnCount += formatter.getColSpan(grid.getRowCount() - 1, cell);
            }
            while (this.columns > columnCount) {
                grid.addCell(grid.getRowCount() - 1); //at least one cell per column. Modified later by colspans
                columnCount++;
            }
        }
        while (this.rows < grid.getRowCount()) {
            grid.removeRow(grid.getRowCount() - 1);
        }
    }
    if (this.columns != null && this.columns > 0) {
        for (int row = 0; row < grid.getRowCount(); row++) {
            int columnCount = 0;
            FlexCellFormatter formatter = grid.getFlexCellFormatter();
            for (int cell = 0; cell < grid.getCellCount(row); cell++) {
                columnCount += formatter.getColSpan(row, cell);
            }
            while (this.columns > columnCount) {
                grid.addCell(row);
                columnCount++;
            }
            while (this.columns < columnCount) {
                int cellCount = grid.getCellCount(row);
                if (cellCount > 0) {
                    int cellColumns = formatter.getColSpan(row, cellCount - 1);
                    if (cellColumns > 1 && columnCount - cellColumns >= this.columns) {
                        grid.removeCell(row, cellCount - 1);
                    } else {
                        grid.removeCell(row, cellCount - 1);
                    }
                }
                columnCount--;
            }
        }
    }
}

From source file:org.jbpm.form.builder.ng.model.client.form.items.MIGLayoutFormItem.java

License:Apache License

@Override
public Widget cloneDisplay(Map<String, Object> data) {
    FlexTable ft = new FlexTable();
    populate(ft);//from   www  . jav a  2  s. co  m
    for (int row = 0; row < table.getRowCount(); row++) {
        for (int column = 0; column < table.getCellCount(row); column++) {
            FBFormItem item = (FBFormItem) this.table.getWidget(row, column);
            if (item != null) {
                ft.addCell(row);
                int colspan = table.getFlexCellFormatter().getColSpan(row, column);
                ft.getFlexCellFormatter().setColSpan(row, column, colspan);
                ft.setWidget(row, column, item.cloneDisplay(data));
            }
        }
    }
    super.populateActions(ft.getElement());
    return ft;
}

From source file:org.onesocialweb.gwt.client.util.FormLayoutHelper.java

License:Apache License

public static void addHTMLLabelRow(FlexTable target, String label, String value) {

    target.insertRow(target.getRowCount());
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.setText(target.getRowCount() - 1, 0, label);
    target.setText(target.getRowCount() - 1, 1, value);

    target.addStyleName("fields");

    // add styling
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 0, "label");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 1, "value");

}

From source file:org.onesocialweb.gwt.client.util.FormLayoutHelper.java

License:Apache License

public static void addWidgetRow(FlexTable target, String label, Widget widget) {

    target.insertRow(target.getRowCount());
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.setText(target.getRowCount() - 1, 0, label);
    target.setWidget(target.getRowCount() - 1, 1, widget);

    target.addStyleName("fields");

    // add styling
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 0, "label");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 1, "value");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 2, "visibility");

}

From source file:org.onesocialweb.gwt.client.util.FormLayoutHelper.java

License:Apache License

public static void addContactRow(FlexTable target, Widget avatar, Widget details) {

    target.insertRow(target.getRowCount());
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.setWidget(target.getRowCount() - 1, 0, avatar);
    target.setWidget(target.getRowCount() - 1, 1, details);

    // add styling
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 0, "avatar");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 1, "details");

}

From source file:org.onesocialweb.gwt.client.util.FormLayoutHelper.java

License:Apache License

public static void addWidgetRowHeader(FlexTable target, String label, Widget widget, String visibility) {

    target.insertRow(target.getRowCount());
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.setText(target.getRowCount() - 1, 0, label);
    target.setWidget(target.getRowCount() - 1, 1, widget);

    // if relevant show the visibility settings for this field
    if (visibility != null && visibility.length() > 0) {
        // TooltipPushButton btnVisibility = new TooltipPushButton(new
        // Image(OswClient.getInstance().getPreference("theme_folder") +
        // "assets/i-visibility.png"), "Visible to: " + visibility);
        // Button btnVisibility = new Button("Friends");
        PrivacySelectorHeader selectorheader = new PrivacySelectorHeader();
        target.setWidget(target.getRowCount() - 1, 2, selectorheader);
    }/*  w  w w.ja  v  a2  s. c  o  m*/

    target.addStyleName("fields");

    // add styling
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 0, "label");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 1, "value");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 2, "visibility");

}

From source file:us.softoption.gwt.proofs.client.Proofs.java

License:Open Source License

FlexTable createTable() {
    FlexTable t = new FlexTable();

    t.insertRow(0);//from   www. j a  va2  s.  c o m
    t.insertRow(0);
    t.insertRow(0);

    for (int i = 0; i < 3; i++) {
        t.addCell(i);
        t.addCell(i);
        t.addCell(i);

    }

    t.setBorderWidth(1);

    return t;
}