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 com.google.gwt.user.client.ui.Widget;
023import com.google.gwt.view.client.HasKeyProvider;
024import gwt.material.design.client.data.component.Component;
025import gwt.material.design.client.data.component.Components;
026import gwt.material.design.client.js.JsTableSubHeaders;
027import gwt.material.design.client.ui.MaterialProgress;
028import gwt.material.design.client.ui.table.DataDisplay;
029import gwt.material.design.client.ui.table.TableHeader;
030import gwt.material.design.client.ui.table.TableScaffolding;
031
032import java.util.List;
033
034/**
035 * A data view is in charge of rendering the data within the data table.
036 *
037 * @author Ben Dol
038 */
039public interface DataView<T> extends HasRows<T>, HasColumns<T>, HasDataSource<T>, HasRenderer<T>, HasKeyProvider<T>,
040        HasCategories, ViewSettings {
041
042    /**
043     * Render the data view components to DOM.
044     */
045    void render(Components<Component<?>> components);
046
047    /**
048     * Setup the data view.
049     */
050    void setup(TableScaffolding scaffolding) throws Exception;
051
052    /**
053     * Destroy the data view.
054     */
055    void destroy();
056
057    /**
058     * Invoke a view refresh.
059     */
060    void refresh();
061
062    /**
063     * Get the displays main container.
064     */
065    Widget getContainer();
066
067    /**
068     * Get the data views id.
069     */
070    String getId();
071
072    /**
073     * Set the data views display view.
074     */
075    void setDisplay(DataDisplay<T> display);
076
077    /**
078     * Check if a header with the given index is visible.
079     */
080    boolean isHeaderVisible(int colIndex);
081
082    /**
083     * Get the list of rendered header widgets.
084     */
085    List<TableHeader> getHeaders();
086
087    /**
088     * Get the subheader library API.
089     */
090    JsTableSubHeaders getSubheaderLib();
091
092    /**
093     * Is the data view setup.
094     */
095    boolean isSetup();
096
097    /**
098     * Is the data view rendering.
099     */
100    boolean isRendering();
101
102    /**
103     * Get the visible item count of the data view.
104     */
105    int getVisibleItemCount();
106
107    /**
108     * Get the data views current sort context, or null if no sort context is applied.
109     */
110    SortContext<T> getSortContext();
111
112    /**
113     * Is redrawing the data view.
114     */
115    boolean isRedraw();
116
117    /**
118     * Set redraw data view elements.
119     */
120    void setRedraw(boolean redraw);
121
122    /**
123     * Set the data views loading mask.
124     */
125    void setLoadMask(boolean loadMask);
126
127    /**
128     * Is the data views loading mask applied.
129     */
130    boolean isLoadMask();
131
132    /**
133     * Get the data views progress widget.
134     */
135    MaterialProgress getProgressWidget();
136}