View Javadoc

1   /*
2    *  File: ICellStyleProvider.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.renderer;
12  
13  import org.eclipse.swt.graphics.FontData;
14  import org.eclipse.swt.graphics.RGB;
15  
16  import de.jaret.util.ui.table.model.IColumn;
17  import de.jaret.util.ui.table.model.IRow;
18  import de.jaret.util.ui.table.model.ITableViewState;
19  
20  /***
21   * Interface for a cell style supplier. The cell style provider is responsible for storing the individual cell styles.
22   * It is possible to define a single style for a row, a column or a specific cell. A default cell style is used whenever
23   * no specific cell style has been set.
24   * <p>
25   * The interface operates on cell styles. In some cases this is quite inconvenient so som econvience methods have been
26   * added to support direct setting of the properties.
27   * </p>
28   * 
29   * @author Peter Kliem
30   * @version $Id: ICellStyleProvider.java 347 2007-04-07 15:01:10Z olk $
31   */
32  public interface ICellStyleProvider {
33      /***
34       * Set a style strategy to be involved when delivering styles.
35       * 
36       * @param startegy strategy to use
37       */
38      void setStyleStrategy(IStyleStrategy startegy);
39  
40      /***
41       * Retrieve a style strategy if set.
42       * 
43       * @return the strategy or <code>null</code>
44       */
45      IStyleStrategy getStyleStrategy();
46  
47      /***
48       * Retrieve the cell style for a cell. This method should not create CellStyle objects.
49       * 
50       * @param row row of the cell
51       * @param column col of the cell
52       * @return cell style for the specified cell
53       */
54      ICellStyle getCellStyle(IRow row, IColumn column);
55  
56      /***
57       * Get the cell style defined for a single cell. Should create a new CellStyle object if create is true.
58       * 
59       * @param row row of the cell
60       * @param column column of the cell
61       * @param create true will signal to create a new style object if necessary
62       * @return cell style for the cell
63       */
64      ICellStyle getCellSpecificStyle(IRow row, IColumn column, boolean create);
65  
66      /***
67       * Retrieve the cell style for a column.
68       * 
69       * @param column column
70       * @param create if true and no style has been set for the column, create a copy of the default cell style
71       * @return the cellstyle for the colun which might be the default cell style if create is set to false
72       */
73      ICellStyle getColumnCellStyle(IColumn column, boolean create);
74  
75      /***
76       * Set the cell style for a column.
77       * 
78       * @param column column
79       * @param style style
80       */
81      void setColumnCellStyle(IColumn column, ICellStyle style);
82  
83      /***
84       * Retrieve the cell style for a row.
85       * 
86       * @param row row
87       * @param create if true and no style has been set for the row, create a copy of the default cell style
88       * @return the cellstyle for the row which might be the default cell style if create is set to false
89       */
90      ICellStyle getRowCellStyle(IRow row, boolean create);
91  
92      /***
93       * Set the cell style for a row.
94       * 
95       * @param row row
96       * @param style cell style
97       */
98      void setRowCellStyle(IRow row, ICellStyle style);
99  
100     /***
101      * Set the cell style to use for a specific cell.
102      * 
103      * @param row row of the cell
104      * @param column column of the cell
105      * @param style style to use
106      */
107     void setCellStyle(IRow row, IColumn column, ICellStyle style);
108 
109     /***
110      * Retrieve the default cell style used for cells where no style has been set. If the returned cell style is
111      * modified, this applies for all default styled cells.
112      * 
113      * @return the default cell style.
114      */
115     ICellStyle getDefaultCellStyle();
116 
117     /***
118      * Set the default cell style that is used whenever no specific style has been set for a cell, column or row.
119      * 
120      * @param cellStyle cell style to use as the default cell style
121      */
122     void setDefaultCellStyle(ICellStyle cellStyle);
123 
124     /***
125      * Add a listener to listen on cell style changes.
126      * 
127      * @param csl listener
128      */
129     void addCellStyleListener(ICellStyleListener csl);
130 
131     /***
132      * Remove a cell sytle listener.
133      * 
134      * @param csl listener to remove
135      */
136     void remCellStyleListener(ICellStyleListener csl);
137 
138     /***
139      * Convenience method for setting the background of a row. This method will manipulate or create a style.
140      * 
141      * @param row row
142      * @param background background color
143      */
144     void setBackground(IRow row, RGB background);
145 
146     /***
147      * Convenience method for setting the background of a column. This method will manipulate or create a style.
148      * 
149      * @param column column
150      * @param background background color
151      */
152     void setBackground(IColumn column, RGB background);
153 
154     /***
155      * Convenience method for setting the background of a cell. This method will manipulate or create a style.
156      * 
157      * @param row row of th cell
158      * @param column column of the cell
159      * @param background background color
160      */
161     void setBackground(IRow row, IColumn column, RGB background);
162 
163     /***
164      * Convenience method for setting the foreground of a row. This method will manipulate or create a style.
165      * 
166      * @param row row
167      * @param foreground background color
168      */
169     void setForeground(IRow row, RGB foreground);
170 
171     /***
172      * Convenience method for setting the foreground of a column. This method will manipulate or create a style.
173      * 
174      * @param column column
175      * @param foreground foreground color
176      */
177     void setForeground(IColumn column, RGB foreground);
178 
179     /***
180      * Convenience method for setting the foreground of a cell. This method will manipulate or create a style.
181      * 
182      * @param row row of th cell
183      * @param column column of the cell
184      * @param foreground foreground color
185      */
186     void setForeground(IRow row, IColumn column, RGB foreground);
187 
188     /***
189      * Convenience method for setting the horizontal alignment. The method will create a cell style for the element or
190      * manipulate the already set style.
191      * 
192      * @param row row
193      * @param hAlignment horizontal alignment
194      */
195     void setHorizontalAlignment(IRow row, ITableViewState.HAlignment hAlignment);
196 
197     /***
198      * Convenience method for setting the horizontal alignment. The method will create a cell style for the element or
199      * manipulate the already set style.
200      * 
201      * @param column column
202      * @param hAlignment horizontal alignment
203      */
204     void setHorizontalAlignment(IColumn column, ITableViewState.HAlignment hAlignment);
205 
206     /***
207      * Convenience method for setting the horizontal alignment. The method will create a cell style for the element or
208      * manipulate the already set style.
209      * 
210      * @param row row of th cell
211      * @param column column of the cell
212      * @param hAlignment horizontal alignment
213      */
214     void setHorizontalAlignment(IRow row, IColumn column, ITableViewState.HAlignment hAlignment);
215 
216     /***
217      * Convenience method for setting the vertical alignment. The method will create a cell style for the element or
218      * manipulate the already set style.
219      * 
220      * @param row row
221      * @param vAlignment vertical alignment
222      */
223     void setVerticalAlignment(IRow row, ITableViewState.VAlignment vAlignment);
224 
225     /***
226      * Convenience method for setting the vertical alignment. The method will create a cell style for the element or
227      * manipulate the already set style.
228      * 
229      * @param column column
230      * @param vAlignment vertical alignment
231      */
232     void setVerticalAlignment(IColumn column, ITableViewState.VAlignment vAlignment);
233 
234     /***
235      * Convenience method for setting the vertical alignment. The method will create a cell style for the element or
236      * manipulate the already set style.
237      * 
238      * @param row row of th cell
239      * @param column column of the cell
240      * @param vAlignment vertical alignment
241      */
242     void setVerticalAlignment(IRow row, IColumn column, ITableViewState.VAlignment vAlignment);
243 
244     /***
245      * Convenience method for setting the font. The method will create a cell style for the element or manipulate the
246      * already set style.
247      * 
248      * @param row row
249      * @param fontdata font data for the font to use
250      */
251     void setFont(IRow row, FontData fontdata);
252 
253     /***
254      * Convenience method for setting the font. The method will create a cell style for the element or manipulate the
255      * already set style.
256      * 
257      * @param column column
258      * @param fontdata font data for the font to use
259      */
260     void setFont(IColumn column, FontData fontdata);
261 
262     /***
263      * Convenience method for setting the font. The method will create a cell style for the element or manipulate the
264      * already set style.
265      * 
266      * @param row row of th cell
267      * @param column column of the cell
268      * @param fontdata font data for the font to use
269      */
270     void setFont(IRow row, IColumn column, FontData fontdata);
271 
272 }