List of usage examples for com.google.gwt.cell.client FieldUpdater update
void update(int index, T object, C value);
From source file:gwt.material.design.client.ui.table.AbstractDataTable.java
License:Apache License
/** * Fire an event to the Cell within the specified {@link TableCellElement}. *///from w w w .j ava 2s .co m private <C> void fireEventToCell(Event event, String eventType, Element parentElem, final T rowValue, Context context, HasCell<T, C> column) { // Check if the cell consumes the event. Cell<C> cell = column.getCell(); if (!cellConsumesEventType(cell, eventType)) { return; } C cellValue = column.getValue(rowValue); boolean cellWasEditing = cell.isEditing(context, parentElem, cellValue); if (column instanceof Column) { /* * If the HasCell is a Column, let it handle the event itself. This is * here for legacy support. */ Column<T, C> col = (Column<T, C>) column; col.onBrowserEvent(context, parentElem, rowValue, event); } else { // Create a FieldUpdater. final FieldUpdater<T, C> fieldUpdater = column.getFieldUpdater(); final int index = context.getIndex(); ValueUpdater<C> valueUpdater = (fieldUpdater == null) ? null : (value) -> { fieldUpdater.update(index, rowValue, value); }; // Fire the event to the cell. cell.onBrowserEvent(context, parentElem, cellValue, event, valueUpdater); } // Reset focus if needed. cellIsEditing = cell.isEditing(context, parentElem, cellValue); if (cellWasEditing && !cellIsEditing) { CellBasedWidgetImpl.get().resetFocus(() -> { setFocus(true); }); } }
From source file:org.eclipse.che.ide.jseditor.client.preference.editorselection.EditorSelectionColumn.java
License:Open Source License
public EditorSelectionColumn(final List<EditorType> editorTypes, final FileTypeEditorMapping filetypeEditorMapping, final FieldUpdater<FileType, EditorType> fieldUpdater, final EditorTypeRegistry editorTypeRegistry, final EditorType defaultEditor) { super(new EditorSelectionCell(editorTypes, "gwt-ListBox", 12d, Unit.EM, editorTypeRegistry, defaultEditor)); this.valuesHolder = filetypeEditorMapping; setFieldUpdater(new FieldUpdater<FileType, EditorType>() { @Override//from w ww. j a v a 2 s . c om public void update(final int index, final FileType fileType, final EditorType editorType) { Log.debug(EditorSelectionColumn.class, "Value update for filetype " + fileType + " editor=" + editorType); EditorSelectionColumn.this.valuesHolder.setEditor(fileType, editorType); fieldUpdater.update(index, fileType, editorType); } }); }
From source file:org.eclipse.che.ide.jseditor.client.preference.keymaps.KeymapSelectionColumn.java
License:Open Source License
public KeymapSelectionColumn(final KeymapValuesHolder valuesHolder, final FieldUpdater<EditorType, Keymap> fieldUpdater, final String selectWidthStyle) { super(new KeymapSelectionCell("gwt-ListBox", selectWidthStyle)); this.valuesHolder = valuesHolder; setFieldUpdater(new FieldUpdater<EditorType, Keymap>() { @Override// w w w. j av a 2s.c o m public void update(final int index, final EditorType editorType, final Keymap keymap) { Log.debug(KeymapSelectionColumn.class, "Value update for editor " + editorType + " keymap=" + keymap); KeymapSelectionColumn.this.valuesHolder.setKeymap(editorType, keymap); fieldUpdater.update(index, editorType, keymap); } }); }
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)); }/*from w ww. ja v a 2 s .co m*/ } dataProvider.refresh(); } else { NotificationPopupPanel.warning("Fill-down function is not allowed for this column", true, false); } } }
From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.GridView.java
License:Apache License
@SuppressWarnings("unchecked") public boolean importValuesToKeyboardSelectedColumn(List<String> values) { int colIndex = dataGrid.getKeyboardSelectedColumn(); int rowIndex = dataGrid.getKeyboardSelectedRow() + dataGrid.getPageStart(); if (null != values && !values.isEmpty()) { 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))) { if (column instanceof SamplesViewImpl.SampleNameColumn) { for (int i = 0; i < values.size(); i++) { String value = values.get(i); for (int j = i + 1; j < values.size(); j++) { if (value.equalsIgnoreCase(values.get(j))) { NotificationPopupPanel .error("Please ensure all sample names are unique, duplicate name '" + values.get(j) + "'.", true, false); return false; }/*from w w w . j av a 2 s . c o m*/ } } } Cell<String> cell = (Cell<String>) column.getCell(); FieldUpdater<R, String> updater = (FieldUpdater<R, String>) column.getFieldUpdater(); for (int i = 0; i < Math.min(rows.size() - rowIndex, values.size()); i++) { int j = i + rowIndex; if (isColumnEditable(column, rows.get(j))) { updater.update(j, rows.get(j), values.get(i)); ((AbstractEditableCell) cell).clearViewData(rows.get(j)); } } dataProvider.refresh(); } } } return true; }