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
022
023import com.google.gwt.cell.client.Cell.Context;
024import gwt.material.design.client.base.MaterialWidget;
025import gwt.material.design.client.constants.IconSize;
026import gwt.material.design.client.constants.IconType;
027import gwt.material.design.client.data.component.CategoryComponent;
028import gwt.material.design.client.data.component.Component;
029import gwt.material.design.client.data.component.RowComponent;
030import gwt.material.design.client.ui.table.TableData;
031import gwt.material.design.client.ui.table.TableHeader;
032import gwt.material.design.client.ui.table.TableRow;
033import gwt.material.design.client.ui.table.TableSubHeader;
034import gwt.material.design.client.ui.table.cell.Column;
035
036import java.util.List;
037
038/**
039 * Renderer interface for defining data view composition.
040 * @param <T>
041 */
042public interface Renderer<T> {
043    TableRow drawRow(DataView<T> dataView, RowComponent<T> rowComponent, Object valueKey, List<Column<T, ?>> columns, boolean redraw);
044
045    TableSubHeader drawCategory(CategoryComponent category);
046
047    TableRow drawCustom(Component<?> component);
048
049    TableData drawSelectionCell();
050
051    MaterialWidget drawColumn(TableRow row, Context context, T rowValue, Column<T, ?> column, int beforeIndex, boolean visible);
052
053    TableHeader drawColumnHeader(Column<T, ?> column, String header, int index);
054
055    void drawSortIcon(TableHeader th, SortContext<T> sortContext);
056
057    int getExpectedRowHeight();
058
059    void setExpectedRowHeight(int expectedRowHeight);
060
061    void calculateRowHeight(RowComponent<T> row);
062
063    int getCalculatedRowHeight();
064
065    void copy(Renderer<T> renderer);
066
067    IconType getSortAscIcon();
068
069    void setSortAscIcon(IconType sortAscIcon);
070
071    IconType getSortDescIcon();
072
073    void setSortDescIcon(IconType sortDescIcon);
074
075    IconSize getSortIconSize();
076
077    void setSortIconSize(IconSize sortIconSize);
078}