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.dom.client.Element; 023import com.google.gwt.event.shared.HasHandlers; 024import com.google.gwt.view.client.Range; 025import gwt.material.design.client.data.component.Components; 026import gwt.material.design.client.data.component.RowComponent; 027import gwt.material.design.client.data.factory.RowComponentFactory; 028import gwt.material.design.jquery.client.api.Event; 029 030import java.util.List; 031 032public interface HasRows<T> extends HasHandlers { 033 034 /** 035 * Get the range of visible rows. 036 * 037 * @return the visible range 038 * 039 * @see #setVisibleRange(Range) 040 * @see #setVisibleRange(int, int) 041 */ 042 Range getVisibleRange(); 043 044 /** 045 * Set the visible range or rows. This method defers to 046 * {@link #setVisibleRange(Range)}. 047 * 048 * @param start the start index 049 * @param length the length 050 * 051 * @see #getVisibleRange() 052 */ 053 void setVisibleRange(int start, int length); 054 055 /** 056 * Set the visible range or rows. 057 * 058 * @param range the visible range 059 * 060 * @see #getVisibleRange() 061 */ 062 void setVisibleRange(Range range); 063 064 /** 065 * Get the exact count of all rows. 066 * 067 * @return the exact row count 068 */ 069 int getRowCount(); 070 071 /** 072 * Get the configured total rows count. 073 */ 074 int getTotalRows(); 075 076 /** 077 * Set the total row count. 078 */ 079 void setTotalRows(int totalRows); 080 081 /** 082 * Set values associated with the rows in the visible range. 083 * 084 * @param start the start index of the data 085 * @param values the values within the range 086 */ 087 void setRowData(int start, List<? extends T> values); 088 089 /** 090 * Get the maximum row height. 091 */ 092 int getRowHeight(); 093 094 /** 095 * Set maximum row height. The minimum row height is 096 * 33 pixels as a material design specification. 097 */ 098 void setRowHeight(int rowHeight); 099 100 /** 101 * Update a models row within the table. 102 * @param model a model with a valid <code>equals</code> method. 103 */ 104 void updateRow(T model); 105 106 /** 107 * Get all data views {@link RowComponent}'s. 108 */ 109 List<RowComponent<T>> getRows(); 110 111 /** 112 * Get a row by its representing model. 113 * @param model the model assigned to a row. 114 */ 115 RowComponent<T> getRow(T model); 116 117 /** 118 * Get a row by its rendered index. 119 * @param index the value of the render index. 120 */ 121 RowComponent<T> getRow(int index); 122 123 /** 124 * Get a models {@link RowComponent} or null if not found. 125 * @param model a model with a valid <code>equals</code> method. 126 * @return the models representing {@link RowComponent}. 127 */ 128 RowComponent<T> getRowByModel(T model); 129 130 /** 131 * Clear data rows. 132 * 133 * @param clearData should we also clear the stored data. 134 */ 135 void clearRows(boolean clearData); 136 137 /** 138 * Set your own custom {@link RowComponentFactory} to generate your row components. 139 */ 140 void setRowFactory(RowComponentFactory<T> rowFactory); 141 142 /** 143 * Get the views row factory. 144 */ 145 RowComponentFactory<T> getRowFactory(); 146 147 /** 148 * Set the data views row selection type. 149 */ 150 void setSelectionType(SelectionType selectionType); 151 152 /** 153 * Get the data views row selection type. 154 */ 155 SelectionType getSelectionType(); 156 157 /** 158 * Select or deselect all rows. 159 * @param select true will select, false with deselect 160 */ 161 void selectAllRows(boolean select); 162 163 /** 164 * Select or deselect all rows. 165 * 166 * @param select true will select, false with deselect 167 * @param fireEvent fire the '{@value gwt.material.design.client.ui.table.TableEvents#SELECT_ALL}' event. 168 */ 169 void selectAllRows(boolean select, boolean fireEvent); 170 171 /** 172 * Select a given row. 173 */ 174 void selectRow(Element row, boolean fireEvent); 175 176 /** 177 * Unselect a selected row. 178 */ 179 void deselectRow(Element row, boolean fireEvent); 180 181 /** 182 * Does this view have unselected rows. 183 * 184 * @param visibleOnly should we restrict this check to visible rows only. 185 * @return true if there are unselected rows in this view. 186 */ 187 boolean hasDeselectedRows(boolean visibleOnly); 188 189 /** 190 * Does this view have selected rows. 191 * 192 * @param visibleOnly should we restrict this check to visible rows only. 193 * @return true if there are selected rows in this view. 194 */ 195 boolean hasSelectedRows(boolean visibleOnly); 196 197 /** 198 * Get all the selected row models. 199 * @param visibleOnly should we restrict this check to visible rows only. 200 * @return list of the currently selected row models. 201 */ 202 List<T> getSelectedRowModels(boolean visibleOnly); 203}