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