Java Code Examples for com.vaadin.ui.Grid#Column
The following examples show how to use
com.vaadin.ui.Grid#Column .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubaEditorImpl.java From cuba with Apache License 2.0 | 5 votes |
protected Map<String, Object> generatePropertiesMap() { Map<String, Object> properties = new HashMap<>(); for (Map.Entry<Grid.Column<T, ?>, Component> entry : columnFields.entrySet()) { properties.put(entry.getKey().getId(), ((CubaEditorField<?>) entry.getValue()).getValue()); } return properties; }
Example 2
Source File: MGrid.java From viritin with Apache License 2.0 | 5 votes |
public MGrid<T> withColumnHeaders(String... properties) { List<Column<T, ?>> columns = getColumns(); for (int i = 0; i < columns.size(); i++) { Grid.Column<T, ? extends Object> c = columns.get(i); c.setCaption(properties[i]); } return this; }
Example 3
Source File: CubaGridColumn.java From cuba with Apache License 2.0 | 5 votes |
@Override public Grid.Column<T, V> setEditable(boolean editable) { // Removed check that editorBinding is not null, // because we don't use Vaadin binding. getState().editable = editable; return this; }
Example 4
Source File: CubaEditorImpl.java From cuba with Apache License 2.0 | 5 votes |
protected String generateErrorMessage(Map<Component, Grid.Column<T, ?>> fieldToColumn, Map<Component, ValidationResult> errors) { return errors.entrySet().stream() .filter(entry -> !Strings.isNullOrEmpty(entry.getValue().getErrorMessage()) && fieldToColumn.containsKey(entry.getKey())) .map(entry -> fieldToColumn.get(entry.getKey()).getCaption() + ": " + entry.getValue().getErrorMessage()) .collect(Collectors.joining("; ")); }
Example 5
Source File: WebTreeDataGrid.java From cuba with Apache License 2.0 | 5 votes |
@Override protected void onColumnReorder(Grid.ColumnReorderEvent e) { super.onColumnReorder(e); String[] columnOrder = getColumnOrder(); // if the hierarchy column isn't set explicitly, // we set the first column as the hierarchy column if (getHierarchyColumn() == null && columnOrder.length > 0) { String columnId = columnOrder[0]; Grid.Column<E, ?> newHierarchyColumn = component.getColumn(columnId); setHierarchyColumnInternal(newHierarchyColumn); } }
Example 6
Source File: CubaEditorImpl.java From cuba with Apache License 2.0 | 5 votes |
@Override protected void doCancel(boolean afterBeingSaved) { // CAUTION copied from parent with changes T editedBean = edited; // As columnFields is cleared in doClose, we need to make a copy of it Map<Grid.Column<T, ?>, Component> usedColumnFields = ImmutableMap.copyOf(columnFields); doClose(); if (!afterBeingSaved) { eventRouter.fireEvent( new CubaEditorCancelEvent<>(this, editedBean, usedColumnFields)); } }
Example 7
Source File: WebTreeDataGrid.java From cuba with Apache License 2.0 | 5 votes |
protected void setHierarchyColumnInternal(Grid.Column<E, ?> newHierarchyColumn) { Grid.Column<E, ?> prevHierarchyColumn = component.getHierarchyColumn(); component.setHierarchyColumn(newHierarchyColumn); // Due to Vaadin bug, we need to reset column's // collapsible state after changing the hierarchy column if (prevHierarchyColumn != null && !newHierarchyColumn.equals(prevHierarchyColumn)) { updateColumnCollapsible(prevHierarchyColumn); } }
Example 8
Source File: WebTreeDataGrid.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setHierarchyColumn(Column<E> column) { checkNotNullArgument(column); this.hierarchyColumn = column; Grid.Column<E, ?> newHierarchyColumn = ((ColumnImpl<E>) column).getGridColumn(); setHierarchyColumnInternal(newHierarchyColumn); }
Example 9
Source File: CubaEditorCancelEvent.java From cuba with Apache License 2.0 | 4 votes |
/** * @return a mapping of field to columns */ public Map<Grid.Column<T, ?>, Component> getColumnFieldMap() { return columnFieldMap; }
Example 10
Source File: CubaEditorOpenEvent.java From cuba with Apache License 2.0 | 4 votes |
/** * @return a mapping of field to columns */ public Map<Grid.Column<T, ?>, Component> getColumnFieldMap() { return columnFieldMap; }
Example 11
Source File: CubaEditorImpl.java From cuba with Apache License 2.0 | 4 votes |
protected boolean handleValidation(Map<Component, ValidationResult> errors) { if (errors.isEmpty()) { // validate cross fields if there is no errors after validation and // user clicked save or it is not buffered mode if (!isBuffered() || saving) { if (crossFieldValidationHandler != null) { String errorMessage = crossFieldValidationHandler.apply(generatePropertiesMap()); boolean ok = errorMessage == null; confirmSave(ok); rpc.setErrorMessage(errorMessage, Collections.emptyList()); return ok; } else { confirmSave(true); rpc.setErrorMessage(null, Collections.emptyList()); } } } else { confirmSave(false); List<Component> fields = errors.keySet().stream() .filter(columnFields.values()::contains) .collect(Collectors.toList()); Map<Component, Grid.Column<T, ?>> fieldToColumn = new HashMap<>(); columnFields.entrySet().stream() .filter(entry -> fields.contains(entry.getValue())) .forEach(entry -> fieldToColumn.put(entry.getValue(), entry.getKey())); String message = generateErrorMessage(fieldToColumn, errors); List<String> columnIds = fieldToColumn.values().stream() .map(this::getInternalIdForColumn) .collect(Collectors.toList()); rpc.setErrorMessage(message, columnIds); return false; } return true; }
Example 12
Source File: WebTreeDataGrid.java From cuba with Apache License 2.0 | 4 votes |
protected void updateColumnCollapsible(Grid.Column<E, ?> vColumn) { ColumnImpl<E> column = getColumnByGridColumn(vColumn); if (column != null) { column.updateCollapsible(); } }
Example 13
Source File: CubaEditorSaveEvent.java From cuba with Apache License 2.0 | 4 votes |
/** * @return a mapping of field to columns */ public Map<Grid.Column<T, ?>, Component> getColumnFieldMap() { return columnFieldMap; }
Example 14
Source File: CubaEditorBeforeSaveEvent.java From cuba with Apache License 2.0 | 4 votes |
/** * @return a mapping of field to columns */ public Map<Grid.Column<T, ?>, Component> getColumnFieldMap() { return columnFieldMap; }
Example 15
Source File: CubaEditorCancelEvent.java From cuba with Apache License 2.0 | 2 votes |
/** * Constructor for a editor cancel event. * * @param editor the source of the event * @param bean the bean being edited */ public CubaEditorCancelEvent(Editor<T> editor, T bean, Map<Grid.Column<T, ?>, Component> columnFieldMap) { super(editor, bean); this.columnFieldMap = columnFieldMap; }
Example 16
Source File: CubaEditorOpenEvent.java From cuba with Apache License 2.0 | 2 votes |
/** * Constructor for a editor open event. * * @param editor the source of the event * @param bean the bean being edited */ public CubaEditorOpenEvent(Editor<T> editor, T bean, Map<Grid.Column<T, ?>, Component> columnFieldMap) { super(editor, bean); this.columnFieldMap = columnFieldMap; }
Example 17
Source File: CubaEditorSaveEvent.java From cuba with Apache License 2.0 | 2 votes |
/** * Constructor for a editor save event. * * @param editor the source of the event * @param bean the bean being edited */ public CubaEditorSaveEvent(Editor<T> editor, T bean, Map<Grid.Column<T, ?>, Component> columnFieldMap) { super(editor, bean); this.columnFieldMap = columnFieldMap; }
Example 18
Source File: CubaEditorBeforeSaveEvent.java From cuba with Apache License 2.0 | 2 votes |
/** * Constructor for a editor save event. * * @param editor the source of the event * @param bean the bean being edited */ public CubaEditorBeforeSaveEvent(Editor<T> editor, T bean, Map<Grid.Column<T, ?>, Component> columnFieldMap) { super(editor); this.bean = bean; this.columnFieldMap = columnFieldMap; }
Example 19
Source File: CubaGridEditorFieldFactory.java From cuba with Apache License 2.0 | 2 votes |
/** * Generates component for {@link CubaGrid} editor. * * @param bean the editing item * @param column the column for which the field is being created * @return generated component */ CubaEditorField<?> createField(T bean, Grid.Column<T, ?> column);
Example 20
Source File: CubaEnhancedGrid.java From cuba with Apache License 2.0 | votes |
CubaEditorField<?> getColumnEditorField(T bean, Grid.Column<T, ?> column);