View Javadoc

1   /*
2    *  File: ITableViewState.java 
3    *  Copyright (c) 2004-2007  Peter Kliem (Peter.Kliem@jaret.de)
4    *  A commercial license is available, see http://www.jaret.de.
5    *
6    * All rights reserved. This program and the accompanying materials
7    * are made available under the terms of the Common Public License v1.0
8    * which accompanies this distribution, and is available at
9    * http://www.eclipse.org/legal/cpl-v10.html
10   */
11  package de.jaret.util.ui.table.model;
12  
13  import java.util.List;
14  
15  import de.jaret.util.ui.table.renderer.ICellStyle;
16  import de.jaret.util.ui.table.renderer.ICellStyleProvider;
17  
18  /***
19   * View state of a jaret table. The viewstate controls the rendering of the model (i.e. row heights).
20   * 
21   * @author Peter Kliem
22   * @version $Id: ITableViewState.java 472 2007-05-22 22:30:07Z olk $
23   */
24  public interface ITableViewState {
25      /***
26       * Enumeration for the row height mode of a table row.
27       * <ul>
28       * <li>FIXED: fixed height</li>
29       * <li>OPTIMAL: height will be optimal with information from the renderers. Manual resize of the row will not be
30       * possible.</li>
31       * <li>OPTANDVAR: like OPTIMAL. When the height of the row is changed manually the row height mode is changed to
32       * VARIABLE</li>
33       * <li>VARIABLE: height variable by dragging</li>
34       * </ul>
35       */
36      static enum RowHeightMode {
37          FIXED, OPTIMAL, OPTANDVAR, VARIABLE
38      };
39  
40      /***
41       * Enumeration for the possible resize behaviours:
42       * <ul>
43       * <li>NONE: resize will only have an effect on the resized column</li>
44       * <li>SUBSEQUENT: resize will take/give the space from the next visible column (unless minwidth is reached)</li>
45       * <li>ALLSUBSEQUENT: resize will take/give the space from all following visible columns (unless minwidth of those
46       * is reached)</li>
47       * <li>ALL: width is interpreted as a weight; all columns will be resized</li>
48       * </ul>
49       * Recommended mode is NONE since the other modes result in heavy redraw activity.
50       */
51      static enum ColumnResizeMode {
52          NONE, SUBSEQUENT, ALLSUBSEQUENT, ALL
53      };
54  
55      static enum HAlignment {
56          LEFT, RIGHT, CENTER
57      };
58  
59      static enum VAlignment {
60          TOP, BOTTOM, CENTER
61      };
62  
63      /***
64       * Retrieve the current height of a row.
65       * 
66       * @param row row to query the height for.
67       * @return height in pixel.
68       */
69      int getRowHeight(IRow row);
70  
71      /***
72       * Set the height of a row.
73       * 
74       * @param row row
75       * @param height height
76       */
77      void setRowHeight(IRow row, int height);
78  
79      /***
80       * Set the row height for ALL rows.
81       * 
82       * @param height height
83       */
84      void setRowHeight(int height);
85  
86      /***
87       * Get the configured minimal row heigth.
88       * 
89       * @return minimal row height
90       */
91      int getMinimalRowHeight();
92  
93      /***
94       * Set the minimal row height.
95       * 
96       * @param minimalRowHeight value to set
97       */
98      void setMinimalRowHeight(int minimalRowHeight);
99  
100     /***
101      * Retrieve the row heigth mode for a specific row.
102      * 
103      * @param row row to get the heigth mode for
104      * @return the row height mode
105      */
106     RowHeightMode getRowHeigthMode(IRow row);
107 
108     /***
109      * Set the row height mode for a specific row.
110      * 
111      * @param row row to set the height mode for
112      * @param mode mode to set.
113      */
114     void setRowHeightMode(IRow row, RowHeightMode mode);
115 
116     /***
117      * Set the row heigth mode for all rows and the mode to use as the default for new rows.
118      * 
119      * @param mode mode to be used.
120      */
121     void setRowHeightMode(RowHeightMode mode);
122 
123     /***
124      * Retrieve the default row heigth mode.
125      * 
126      * @return the default row height mode.
127      */
128     RowHeightMode getRowHeightMode();
129 
130     /***
131      * retrive the width of a column.
132      * 
133      * @param column column
134      * @return the width in pixel
135      */
136     int getColumnWidth(IColumn column);
137 
138     /***
139      * Set the width of a column.
140      * 
141      * @param column column
142      * @param width width in pixel
143      */
144     void setColumnWidth(IColumn column, int width);
145 
146     /***
147      * Retrieve the minimum column width.
148      * 
149      * @return the minimum width a col can be shrinked to
150      */
151     int getMinimalColWidth();
152 
153     /***
154      * Set the minimum col width.
155      * 
156      * @param minimalColumnWidth width a column can be minimal sized to
157      */
158     void setMinimalColWidth(int minimalColumnWidth);
159 
160     /***
161      * Check whether a column is visible.
162      * 
163      * @param column column
164      * @return true if the col is visible
165      */
166     boolean getColumnVisible(IColumn column);
167 
168     /***
169      * Set the visibility of a column.
170      * 
171      * @param column column
172      * @param visible true for visible
173      */
174     void setColumnVisible(IColumn column, boolean visible);
175 
176     /***
177      * Set the visibility of a column.
178      * 
179      * @param columnID id of the column
180      * @param visible true for visible
181      */
182     void setColumnVisible(String columnID, boolean visible);
183 
184     /***
185      * Check whether resizing of a column is allowed.
186      * 
187      * @param column column
188      * @return true if resizing is allowed
189      */
190     boolean columnResizingAllowed(IColumn column);
191 
192     /***
193      * Set whether resizing a column is allowed.
194      * 
195      * @param column column
196      * @param resizingAllowed true for allow resizing
197      */
198     void setColumnResizingAllowed(IColumn column, boolean resizingAllowed);
199 
200     /***
201      * Retrieve the mode used when resizing a column.
202      * 
203      * @return the current column resizing mode
204      */
205     ColumnResizeMode getColumnResizeMode();
206 
207     /***
208      * Set the mode to use when the size of a column changes.
209      * 
210      * @param resizeMode the resize mode.
211      */
212     void setColumnResizeMode(ColumnResizeMode resizeMode);
213 
214     /***
215      * Retrieve the list of columns in their display order.
216      * 
217      * @return List of columnsin their display order
218      */
219     List<IColumn> getSortedColumns();
220 
221     /***
222      * Set the order of the columns.
223      * 
224      * @param columns ordered list of columns
225      */
226     void setSortedColumns(List<IColumn> columns);
227 
228     /***
229      * Retrieve the position in the sorting order set.
230      * 
231      * @param column column
232      * @return position
233      */
234     int getColumnSortingPosition(IColumn column);
235 
236     /***
237      * Retrieve the sorting direction for a column.
238      * 
239      * @param column column to check the sorting direction
240      * @return true for ascending, false for descending
241      */
242     boolean getColumnSortingDirection(IColumn column);
243 
244     /***
245      * Handle the slection of a column for sorting (handle a click).
246      * 
247      * @param column column to add to the sorting (or to reverse its sorting direction)
248      */
249     void setSorting(IColumn column);
250 
251     /***
252      * Retrieve the cell style provider of the viewstate.
253      * 
254      * @return the cell style provider
255      */
256     ICellStyleProvider getCellStyleProvider();
257 
258     /***
259      * Retrieve the cell style for a specified cell.
260      * 
261      * @param row row of the cell
262      * @param column column of the cell
263      * @return the cellstyle for the cell
264      */
265     ICellStyle getCellStyle(IRow row, IColumn column);
266 
267     /***
268      * Add a listener to be informed about changes on the viewstate.
269      * 
270      * @param tvsl listener to add
271      */
272     void addTableViewStateListener(ITableViewStateListener tvsl);
273 
274     /***
275      * Remove a listener from the viewstate.
276      * 
277      * @param tvsl listener to be removed
278      */
279     void removeTableViewStateListener(ITableViewStateListener tvsl);
280 }