01: /*
02: * $Id: AbstractColumn.java 460368 2006-04-24 01:43:59Z ivaynberg $
03: * $Revision: 460368 $
04: * $Date: 2006-04-24 03:43:59 +0200 (Mon, 24 Apr 2006) $
05: *
06: * ====================================================================
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: */
19: package wicket.extensions.markup.html.repeater.data.table;
20:
21: import wicket.Component;
22: import wicket.markup.html.basic.Label;
23: import wicket.model.IModel;
24:
25: /**
26: * A helper implementation for the IColumn interface
27: *
28: * @author Igor Vaynberg ( ivaynberg )
29: */
30: public abstract class AbstractColumn implements IColumn {
31: private IModel displayModel;
32: private String sortProperty;
33:
34: /**
35: * @param displayModel
36: * model used to generate header text
37: * @param sortProperty
38: * sort property this column represents
39: */
40: public AbstractColumn(IModel displayModel, String sortProperty) {
41: this .displayModel = displayModel;
42: this .sortProperty = sortProperty;
43: }
44:
45: /**
46: * @param displayModel
47: * model used to generate header text
48: */
49: public AbstractColumn(IModel displayModel) {
50: this (displayModel, null);
51: }
52:
53: /**
54: * @return returns display model to be used for the header component
55: */
56: public IModel getDisplayModel() {
57: return displayModel;
58: }
59:
60: /**
61: * @see wicket.extensions.markup.html.repeater.data.table.IColumn#getSortProperty()
62: */
63: public String getSortProperty() {
64: return sortProperty;
65: }
66:
67: /**
68: * @see wicket.extensions.markup.html.repeater.data.table.IColumn#isSortable()
69: */
70: public boolean isSortable() {
71: return sortProperty != null;
72: }
73:
74: /**
75: * @see wicket.extensions.markup.html.repeater.data.table.IColumn#getHeader(java.lang.String)
76: */
77: public Component getHeader(String componentId) {
78: return new Label(componentId, getDisplayModel());
79: }
80:
81: }
|