List of usage examples for com.google.gwt.user.client.ui FlexTable getCellCount
@Override public int getCellCount(int row)
From source file:org.dataconservancy.dcs.access.client.Util.java
License:Apache License
public static void addColumn(FlexTable table, String... values) { int col = table.getCellCount(0); for (int i = 0; i < values.length; i++) { table.setText(i, col, values[i]); }// ww w .j av a 2 s .c om }
From source file:org.dataconservancy.dcs.access.client.Util.java
License:Apache License
public static void addColumn(FlexTable table, Widget... values) { int col = table.getCellCount(0); for (int i = 0; i < values.length; i++) { table.setWidget(i, col, values[i]); }// w ww .j a va2 s. c o m }
From source file:org.drools.workbench.screens.testscenario.client.utils.ScenarioUtils.java
License:Apache License
public static void addBottomAndRightPaddingToTableCells(final FlexTable table) { for (int rowIndex = 0; rowIndex < table.getRowCount(); rowIndex++) { for (int cellIndex = 0; cellIndex < table.getCellCount(rowIndex); cellIndex++) { table.getCellFormatter().getElement(rowIndex, cellIndex).setAttribute("style", BOTTOM_RIGHT_PADDING); }/*from w w w. j a va2s .co m*/ } }
From source file:org.ebayopensource.turmeric.monitoring.client.view.ConsumerView.java
License:Open Source License
/** * Gets the table row.//from w w w . ja va 2 s . c om * * @param metric * the metric * @param row * the row * @param startCol * the start col * @return the table row */ public List<HasClickHandlers> getTableRow(ConsumerMetric metric, int row, int startCol) { FlexTable table = getTable(metric); if (table == null) return null; List<HasClickHandlers> list = new ArrayList<HasClickHandlers>(); for (int i = startCol; i < table.getCellCount(startCol); i++) { Widget w = table.getWidget(row, i); if (w instanceof HasClickHandlers) list.add((HasClickHandlers) w); } return list; }
From source file:org.ebayopensource.turmeric.monitoring.client.view.ServiceView.java
License:Open Source License
/** * Gets the table row./*from w w w . j a v a 2s. co m*/ * * @param metric * the metric * @param row * the row * @param startCol * the start col * @return the table row * @see org.ebayopensource.turmeric.monitoring.client.presenter.ServicePresenter.Display#getTableRow(org.ebayopensource * .turmeric.monitoring.client.model.ServiceMetric, int, int) */ public List<HasClickHandlers> getTableRow(ServiceMetric metric, int row, int startCol) { FlexTable table = getTable(metric); if (table == null) return null; List<HasClickHandlers> list = new ArrayList<HasClickHandlers>(); for (int i = startCol; i < table.getCellCount(startCol); i++) { Widget w = table.getWidget(row, i); if (w instanceof HasClickHandlers) list.add((HasClickHandlers) w); } return list; }
From source file:org.ebayopensource.turmeric.policy.adminui.client.view.policy.FlexTableHelper.java
License:Open Source License
/** * Fixes problem with {@link FlexCellFormatter#setRowSpan(int, int, int)}, * see comment for./*w w w .ja v a2 s. com*/ * * @param flexTable * the flex table {@link #FlexTableHelper}. */ public static void fixRowSpan(final FlexTable flexTable) { Set<Element> tdToRemove = new HashSet<Element>(); { int rowCount = flexTable.getRowCount(); for (int row = 0; row < rowCount; row++) { int cellCount = flexTable.getCellCount(row); for (int cell = 0; cell < cellCount; cell++) { int colSpan = flexTable.getFlexCellFormatter().getColSpan(row, cell); int rowSpan = flexTable.getFlexCellFormatter().getRowSpan(row, cell); if (rowSpan != 1) { int column = getColumnOfCell(flexTable, row, cell); for (int row2 = row + 1; row2 < row + rowSpan; row2++) { int baseCell2 = getCellOfColumn(flexTable, row2, column); for (int cell2 = baseCell2; cell2 < baseCell2 + colSpan; cell2++) { if (cell2 != -1) { Element td = flexTable.getCellFormatter().getElement(row2, cell2); tdToRemove.add(td); } } } } } } } // remove TD elements for (Element td : tdToRemove) { Element tr = DOM.getParent(td); DOM.removeChild(tr, td); } }
From source file:org.ebayopensource.turmeric.policy.adminui.client.view.policy.FlexTableHelper.java
License:Open Source License
private static int getCellOfColumn(final FlexTable flexTable, final int row, final int column) { int cellCount = flexTable.getCellCount(row); int currentColumn = 0; for (int cell = 0; cell < cellCount; cell++) { int colSpan = getColSpan(flexTable, row, cell); if (currentColumn == column) { return cell; }/*from w w w. j av a 2 s. co m*/ currentColumn += colSpan; } return -1; }
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); }/*from w w w . j av a 2 s . co 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.kaaproject.avro.ui.gwt.client.widget.ArrayFieldWidget.java
License:Apache License
private Widget constructTable() { VerticalPanel verticalPanel = new VerticalPanel(); tableScroll = new ScrollPanel(); final FlexTable table = new FlexTable(); table.setWidth("95%"); table.setCellPadding(0);/*from w w w. jav a 2 s . c om*/ table.setCellSpacing(0); table.addStyleName(style.arrayTable()); List<FormField> records = value.getValue(); final FormField elementMetadata = value.getElementMetadata(); final boolean hasHeader; if (elementMetadata.getFieldType() == FieldType.RECORD) { RecordField recordElementData = (RecordField) elementMetadata; float totalWeight = 0f; List<FormField> metaFields = recordElementData.getFieldsWithAccess(FieldAccess.EDITABLE, FieldAccess.READ_ONLY); for (int column = 0; column < metaFields.size(); column++) { FormField metaField = metaFields.get(column); totalWeight += metaField.getWeight(); } for (int column = 0; column < metaFields.size(); column++) { FormField metaField = metaFields.get(column); float weight = metaField.getWeight(); String width = String.valueOf(weight / totalWeight * 100f) + "%"; table.getColumnFormatter().setWidth(column, width); table.setWidget(0, column, new Label(metaField.getDisplayName())); } if (!readOnly) { table.setWidget(0, table.getCellCount(0), new Label(Utils.constants.delete())); } hasHeader = true; } else { hasHeader = false; } final Map<FormField, List<HandlerRegistration>> rowHandlerRegistrationMap = new HashMap<>(); for (int row = 0; row < records.size(); row++) { FormField record = records.get(row); List<HandlerRegistration> rowHandlerRegistrations = new ArrayList<>(); setRow(table, record, row, rowHandlerRegistrations, rowHandlerRegistrationMap, hasHeader); registrations.addAll(rowHandlerRegistrations); rowHandlerRegistrationMap.put(record, rowHandlerRegistrations); } tableScroll.setWidth(getScrollTablePreferredWidth(config.getArrayPanelWidthPx())); tableScroll.getElement().getStyle().setMargin(AbstractGrid.DEFAULT_GRID_MARGIN, Unit.PX); tableScroll.setHeight(config.getTableHeight()); tableScroll.add(table); verticalPanel.setWidth(FULL_WIDTH); verticalPanel.add(tableScroll); if (!readOnly && !value.isReadOnly()) { Button addRow = new Button(Utils.constants.add()); addRow.addStyleName(style.buttonSmall()); addRow.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { FormField newField = value.createRow(); value.addArrayData(newField); List<HandlerRegistration> rowHandlerRegistrations = new ArrayList<>(); setRow(table, newField, value.getValue().size() - 1, rowHandlerRegistrations, rowHandlerRegistrationMap, hasHeader); rowHandlerRegistrationMap.put(newField, rowHandlerRegistrations); fireChanged(); } }); HorizontalPanel buttonsPanel = new HorizontalPanel(); buttonsPanel.addStyleName(style.buttonsPanel()); buttonsPanel.add(addRow); verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); verticalPanel.add(buttonsPanel); } return verticalPanel; }
From source file:org.kaaproject.avro.ui.gwt.client.widget.ArrayFieldWidget.java
License:Apache License
private void setRow(final FlexTable table, FormField field, int row, List<HandlerRegistration> handlerRegistrations, final Map<FormField, List<HandlerRegistration>> rowHandlerRegistrationMap, final boolean hasHeader) { if (hasHeader) { row++;/* w w w .ja va 2 s.c om*/ } if (field.getFieldType() == FieldType.RECORD) { RecordField record = (RecordField) field; List<FormField> recordFields = record.getFieldsWithAccess(FieldAccess.EDITABLE, FieldAccess.READ_ONLY); for (int column = 0; column < recordFields.size(); column++) { FormField cellField = recordFields.get(column); constructAndPlaceWidget(table, cellField, row, column, handlerRegistrations); } } else { constructAndPlaceWidget(table, field, row, 0, handlerRegistrations); } if (!readOnly) { final Button delButton = new Button(""); Image img = new Image(Utils.resources.remove()); img.getElement().getStyle().setVerticalAlign(Style.VerticalAlign.MIDDLE); delButton.getElement().appendChild(img.getElement()); delButton.addStyleName(style.cellButton()); delButton.addStyleName(style.cellButtonSmall()); delButton.getElement().getStyle().setMarginLeft(3, Unit.PX); HandlerRegistration handlerRegistration = delButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { int tableRow = table.getCellForEvent(event).getRowIndex(); int rowIndex = hasHeader ? tableRow - 1 : tableRow; FormField toDelete = value.getValue().get(rowIndex); List<HandlerRegistration> registrations = rowHandlerRegistrationMap.remove(toDelete); if (registrations != null) { for (HandlerRegistration registration : registrations) { registration.removeHandler(); } registrations.clear(); } table.removeRow(tableRow); value.getValue().remove(rowIndex); fireChanged(); } }); handlerRegistrations.add(handlerRegistration); table.setWidget(row, table.getCellCount(row), delButton); } }