use of com.vaadin.ui.Grid.ColumnReorderEvent in project VaadinUtils by rlsutton1.
the class GridHeadingPropertySet method configureSaveColumnOrder.
private void configureSaveColumnOrder(final Grid grid, final String uniqueId) {
final String keyStub = uniqueId + "-order";
final List<Column> availableColumns = grid.getColumns();
final String columns = UserSettingsStorageFactory.getUserSettingsStorage().get(keyStub);
if (availableColumns.size() > 0 && columns != null && !columns.isEmpty()) {
final Object[] parsedColumns = columns.split(", ?");
if (parsedColumns.length > 0) {
grid.setColumns(calculateColumnOrder(availableColumns, parsedColumns));
}
}
grid.addColumnReorderListener(new ColumnReorderListener() {
private static final long serialVersionUID = -2810298692555333890L;
@Override
public void columnReorder(ColumnReorderEvent event) {
final List<Column> columns = ((Grid) event.getSource()).getColumns();
if (columns.size() > 0) {
String parsedColumns = "";
for (Column column : columns) {
parsedColumns += column.getPropertyId() + ", ";
}
parsedColumns = parsedColumns.substring(0, parsedColumns.length() - 2);
UserSettingsStorageFactory.getUserSettingsStorage().store(keyStub, "" + parsedColumns);
}
}
});
}
use of com.vaadin.ui.Grid.ColumnReorderEvent in project VaadinUtils by rlsutton1.
the class GridHeadingV2PropertySet method configureSaveColumnOrder.
private void configureSaveColumnOrder(final Grid grid) {
final String keyStub = uniqueId + "-order";
final List<Column> availableColumns = grid.getColumns();
final String columns = UserSettingsStorageFactory.getUserSettingsStorage().get(keyStub);
if (availableColumns.size() > 0 && columns != null && !columns.isEmpty()) {
final Object[] parsedColumns = columns.split(", ?");
if (parsedColumns.length > 0) {
grid.setColumns(calculateColumnOrder(availableColumns, parsedColumns));
}
}
grid.addColumnReorderListener(new ColumnReorderListener() {
/**
*/
private static final long serialVersionUID = 1L;
@Override
public void columnReorder(ColumnReorderEvent event) {
final List<Column> reorderedColumns = ((Grid) event.getSource()).getColumns();
if (reorderedColumns.size() > 0) {
String parsedColumns = "";
for (Column column : reorderedColumns) {
parsedColumns += column.getPropertyId() + ", ";
}
parsedColumns = parsedColumns.substring(0, parsedColumns.length() - 2);
UserSettingsStorageFactory.getUserSettingsStorage().store(keyStub, "" + parsedColumns);
}
}
});
}
use of com.vaadin.ui.Grid.ColumnReorderEvent in project VaadinUtils by rlsutton1.
the class BasePortal method setupGridColumnReordering.
private void setupGridColumnReordering(final Grid grid, final String keyStub) {
if (columnReorderListeners.get(grid) != null) {
grid.removeColumnReorderListener(columnReorderListeners.get(grid));
} else {
ColumnReorderListener columnReorderListener = new ColumnReorderListener() {
private static final long serialVersionUID = -2810298692555333890L;
@Override
public void columnReorder(ColumnReorderEvent event) {
final List<Column> columns = ((Grid) event.getSource()).getColumns();
if (columns.size() > 0) {
String parsedColumns = "";
for (Column column : columns) {
parsedColumns += column.getPropertyId() + ", ";
}
parsedColumns = parsedColumns.substring(0, parsedColumns.length() - 2);
getConfigDelegate().setValue(getPortal(), keyStub, "" + parsedColumns);
}
}
};
columnReorderListeners.put(grid, columnReorderListener);
}
final List<Column> availableColumns = grid.getColumns();
final String columns = getConfigDelegate().getValueString(getPortal(), keyStub);
if (availableColumns.size() > 0 && columns != null && !columns.isEmpty()) {
final Object[] parsedColumns = columns.split(", ?");
if (parsedColumns.length > 0) {
grid.setColumns(calculateColumnOrder(availableColumns, parsedColumns));
}
}
grid.addColumnReorderListener(columnReorderListeners.get(grid));
}
Aggregations