001/*
002 * #%L
003 * GwtMaterial
004 * %%
005 * Copyright (C) 2015 - 2017 GwtMaterialDesign
006 * %%
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 * You may obtain a copy of the License at
010 * 
011 *      http://www.apache.org/licenses/LICENSE-2.0
012 * 
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 * #L%
019 */
020package gwt.material.design.client.data;
021
022import gwt.material.design.client.ui.table.cell.Column;
023
024import java.util.List;
025
026public interface HasColumns<T> {
027
028    /**
029     * Add a new column to the data view.
030     *
031     * @param column the column object
032     */
033    void addColumn(Column<T, ?> column);
034
035    /**
036     * Add a new column to the data view.
037     *
038     * @param column the column object
039     */
040    void addColumn(Column<T, ?> column, String header);
041
042    /**
043     * Inserts a column into the table at the specified index.
044     *
045     * @param beforeIndex the index to insert the column
046     * @param col the column to be added
047     * @throws IndexOutOfBoundsException if the index is out of range
048     */
049    void insertColumn(int beforeIndex, Column<T, ?> col, String header);
050
051    /**
052     * Remove an existing column by index.
053     * @param colIndex the columns placement index
054     */
055    void removeColumn(int colIndex);
056
057    /**
058     * Remove all columns.
059     */
060    void removeColumns();
061
062    /**
063     * Get the current defined columns.
064     */
065    List<Column<T, ?>> getColumns();
066
067    /**
068     * Get the offset column index (used when selection mode is on).
069     */
070    int getColumnOffset();
071
072    /**
073     * Sort a column matching the given index (the index excludes the selection box row).
074     *
075     * @param columnIndex valid index to the user added {@link Column}s.
076     */
077    void sort(int columnIndex);
078
079    /**
080     * Sort a column matching the given index (the index excludes the selection box row).
081     *
082     * @param columnIndex valid index to the user added {@link Column}s.
083     * @param dir the sort direction or null for auto reversing.
084     */
085    void sort(int columnIndex, SortDir dir);
086
087    /**
088     * Sort a column.
089     *
090     * @param column matching column that was added via {@link ##addColumn(Column)}.
091     */
092    void sort(Column<T, ?> column);
093
094    /**
095     * Sort a column.
096     *
097     * @param column matching column that was added via {@link ##addColumn(Column)}.
098     * @param dir the sort direction or null for auto reversing.
099     */
100    void sort(Column<T, ?> column, SortDir dir);
101}