List of usage examples for com.google.gwt.user.cellview.client Column getValue
@Override public abstract C getValue(T object);
From source file:com.bearsoft.gwt.ui.widgets.grid.GridSection.java
public <C> void redrawAllRowsInColumn(int aIndex, ListDataProvider<T> aDataProvider) { if (aIndex >= 0 && aIndex < getColumnCount()) { int start = getVisibleRange().getStart(); Column<T, C> column = (Column<T, C>) getColumn(aIndex); Cell<C> cell = column.getCell(); List<T> data = aDataProvider.getList(); ProvidesKey<T> keys = getKeyProvider(); NodeList<TableRowElement> rows = getTableBodyElement().getRows(); for (int i = 0; i < rows.getLength(); i++) { TableRowElement row = rows.getItem(i); NodeList<TableCellElement> cells = row.getCells(); if (aIndex >= 0 && aIndex < cells.getLength()) { TableCellElement toRerender = cells.getItem(aIndex); if (toRerender != null) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); int dataIdx = start + i; if (dataIdx >= 0 && dataIdx < data.size()) { T object = data.get(dataIdx); Cell.Context cx = new Cell.Context(start + i, aIndex, keys.getKey(object)); cell.render(cx, column.getValue(object), sb); // Take into account, that cell builder supports // some // maps // to cells' divs // and generates them. So we have to work with first // <div> // in <td>. toRerender.getFirstChildElement().setInnerSafeHtml(sb.toSafeHtml()); }/* w w w . j a v a 2s.co m*/ } } } } }
From source file:org.rstudio.studio.client.workbench.views.vcs.ChangelistTable.java
License:Open Source License
private void configureTable() { final Column<StatusAndPath, Boolean> stagedColumn = new Column<StatusAndPath, Boolean>( new TriStateCheckboxCell<StatusAndPath>(selectionModel_)) { @Override//from w w w. j a v a 2s .co m public Boolean getValue(StatusAndPath object) { return "??".equals(object.getStatus()) ? Boolean.FALSE : object.getStatus().charAt(1) == ' ' ? Boolean.TRUE : object.getStatus().charAt(0) == ' ' ? Boolean.FALSE : null; } }; stagedColumn.setHorizontalAlignment(Column.ALIGN_CENTER); stagedColumn.setFieldUpdater(new FieldUpdater<StatusAndPath, Boolean>() { @Override public void update(final int index, final StatusAndPath object, Boolean value) { fireEvent(new StageUnstageEvent(!value, getSelectedItems())); } }); stagedColumn.setSortable(true); sortHandler_.setComparator(stagedColumn, new Comparator<StatusAndPath>() { @Override public int compare(StatusAndPath a, StatusAndPath b) { Boolean a1 = stagedColumn.getValue(a); Boolean b1 = stagedColumn.getValue(b); int a2 = a1 == null ? 0 : a1 ? -1 : 1; int b2 = b1 == null ? 0 : b1 ? -1 : 1; return a2 - b2; } }); table_.addColumn(stagedColumn, "Staged"); table_.setColumnWidth(stagedColumn, "46px"); Column<StatusAndPath, String> statusColumn = new Column<StatusAndPath, String>( new TextCell(new StatusRenderer())) { @Override public String getValue(StatusAndPath object) { return object.getStatus(); } }; statusColumn.setSortable(true); statusColumn.setHorizontalAlignment(Column.ALIGN_CENTER); table_.addColumn(statusColumn, "Status"); table_.setColumnWidth(statusColumn, "56px"); sortHandler_.setComparator(statusColumn, new Comparator<StatusAndPath>() { @Override public int compare(StatusAndPath a, StatusAndPath b) { return a.getStatus().compareTo(b.getStatus()); } }); TextColumn<StatusAndPath> pathColumn = new TextColumn<StatusAndPath>() { @Override public String getValue(StatusAndPath object) { return object.getPath(); } }; pathColumn.setSortable(true); sortHandler_.setComparator(pathColumn, new Comparator<StatusAndPath>() { private String[] splitDirAndName(String path) { int index = path.lastIndexOf("/"); if (index < 0) index = path.lastIndexOf("\\"); if (index < 0) return new String[] { "", path }; else return new String[] { path.substring(0, index), path.substring(index + 1) }; } @Override public int compare(StatusAndPath a, StatusAndPath b) { String[] splitA = splitDirAndName(a.getPath()); String[] splitB = splitDirAndName(b.getPath()); int result = splitA[0].compareTo(splitB[0]); if (result == 0) result = splitA[1].compareTo(splitB[1]); return result; } }); table_.addColumn(pathColumn, "Path"); table_.getColumnSortList().push(pathColumn); }
From source file:org.rstudio.studio.client.workbench.views.vcs.git.GitChangelistTable.java
License:Open Source License
@Override protected void configureTable() { final Column<StatusAndPath, Boolean> stagedColumn = new Column<StatusAndPath, Boolean>( new TriStateCheckboxCell<StatusAndPath>(selectionModel_)) { @Override/*from w w w. j a v a2 s. c o m*/ public Boolean getValue(StatusAndPath object) { return "??".equals(object.getStatus()) ? Boolean.FALSE : object.getStatus().charAt(1) == ' ' ? Boolean.TRUE : object.getStatus().charAt(0) == ' ' ? Boolean.FALSE : null; } }; stagedColumn.setHorizontalAlignment(Column.ALIGN_CENTER); stagedColumn.setFieldUpdater(new FieldUpdater<StatusAndPath, Boolean>() { @Override public void update(final int index, final StatusAndPath object, Boolean value) { fireEvent(new StageUnstageEvent(!value, getSelectedItems())); } }); stagedColumn.setSortable(true); sortHandler_.setComparator(stagedColumn, new Comparator<StatusAndPath>() { @Override public int compare(StatusAndPath a, StatusAndPath b) { Boolean a1 = stagedColumn.getValue(a); Boolean b1 = stagedColumn.getValue(b); int a2 = a1 == null ? 0 : a1 ? -1 : 1; int b2 = b1 == null ? 0 : b1 ? -1 : 1; return a2 - b2; } }); table_.addColumn(stagedColumn, "Staged"); table_.setColumnWidth(stagedColumn, "46px"); super.configureTable(); }
From source file:org.switchyard.console.client.ui.common.AbstractDataTable.java
License:Apache License
protected Comparator<T> createColumnCommparator(final Column<T, String> column) { return new Comparator<T>() { @Override//from ww w. j a v a 2 s .com public int compare(T o1, T o2) { return column.getValue(o1).compareToIgnoreCase(column.getValue(o2)); } }; }
From source file:org.switchyard.console.client.ui.common.AbstractDataTable.java
License:Apache License
protected Comparator<T> createNumberColumnCommparator(final Column<T, ? extends Number> column) { return new Comparator<T>() { @SuppressWarnings({ "rawtypes", "unchecked" }) @Override//from ww w . ja va 2 s . co m public int compare(T o1, T o2) { return ((Comparable) column.getValue(o1)).compareTo((Comparable) column.getValue(o2)); } }; }
From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.GridView.java
License:Apache License
@SuppressWarnings("unchecked") public void fillDownKeyboardSelectedColumn() { int colIndex = dataGrid.getKeyboardSelectedColumn(); int rowIndex = dataGrid.getKeyboardSelectedRow() + dataGrid.getPageStart(); if (colIndex >= 1 && colIndex < dataGrid.getColumnCount() && rowIndex >= 0 && rowIndex < dataGrid.getRowCount()) { Column<R, ?> column = dataGrid.getColumn(colIndex); List<R> rows = dataProvider.getList(); if (isColumnEditable(column, rows.get(rowIndex)) && !(column instanceof SamplesViewImpl.SampleNameColumn)) { AbstractEditableCell<R, String> cell = (AbstractEditableCell<R, String>) column.getCell(); String value = (String) column.getValue(rows.get(rowIndex)); FieldUpdater<R, String> updater = (FieldUpdater<R, String>) column.getFieldUpdater(); for (int i = rowIndex + 1; i < rows.size(); i++) { if (isColumnEditable(column, rows.get(i))) { updater.update(i, rows.get(i), value); cell.clearViewData(rows.get(i)); }//w w w . j a va 2s . co m } dataProvider.refresh(); } else { NotificationPopupPanel.warning("Fill-down function is not allowed for this column", true, false); } } }