Search in sources :

Example 1 with ColumnReorderEvent

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);
            }
        }
    });
}
Also used : Column(com.vaadin.ui.Grid.Column) ColumnReorderEvent(com.vaadin.ui.Grid.ColumnReorderEvent) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ColumnReorderListener(com.vaadin.ui.Grid.ColumnReorderListener)

Example 2 with ColumnReorderEvent

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);
            }
        }
    });
}
Also used : Column(com.vaadin.ui.Grid.Column) ColumnReorderEvent(com.vaadin.ui.Grid.ColumnReorderEvent) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ColumnReorderListener(com.vaadin.ui.Grid.ColumnReorderListener)

Example 3 with ColumnReorderEvent

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));
}
Also used : Column(com.vaadin.ui.Grid.Column) Grid(com.vaadin.ui.Grid) ColumnReorderEvent(com.vaadin.ui.Grid.ColumnReorderEvent) ColumnReorderListener(com.vaadin.ui.Grid.ColumnReorderListener)

Aggregations

Column (com.vaadin.ui.Grid.Column)3 ColumnReorderEvent (com.vaadin.ui.Grid.ColumnReorderEvent)3 ColumnReorderListener (com.vaadin.ui.Grid.ColumnReorderListener)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Grid (com.vaadin.ui.Grid)1