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.tree.table;
18:
19: import javax.swing.tree.TreeNode;
20:
21: import org.apache.wicket.Component;
22: import org.apache.wicket.MarkupContainer;
23: import org.apache.wicket.markup.html.basic.Label;
24:
25: /**
26: * Convenience class for building tree columns.
27: *
28: * @author Matej Knopp
29: */
30: public abstract class AbstractColumn implements IColumn {
31: private String header;
32:
33: private ColumnLocation location;
34:
35: private TreeTable treeTable = null;
36:
37: /**
38: * Creates the tree column.
39: *
40: * @param location
41: * Specifies how the column should be aligned and what his size
42: * should be
43: *
44: * @param header
45: * Header caption
46: */
47: public AbstractColumn(ColumnLocation location, String header) {
48: this .location = location;
49: this .header = header;
50: }
51:
52: /**
53: * @see IColumn#getLocation()
54: */
55: public ColumnLocation getLocation() {
56: return location;
57: }
58:
59: /**
60: * @see IColumn#getSpan(TreeNode)
61: */
62: public int getSpan(TreeNode node) {
63: return 0;
64: }
65:
66: /**
67: * @see IColumn#isVisible()
68: */
69: public boolean isVisible() {
70: return true;
71: }
72:
73: /**
74: * @see IColumn#newHeader(MarkupContainer, String)
75: */
76: public Component newHeader(MarkupContainer parent, String id) {
77: return new Label(id, header);
78: }
79:
80: /**
81: * @see IColumn#setTreeTable(TreeTable)
82: */
83: public void setTreeTable(TreeTable treeTable) {
84: this .treeTable = treeTable;
85: }
86:
87: /**
88: * Returns the tree table that this columns belongs to. If you call this
89: * method from constructor it will return null, as the column is constructed
90: * before the tree is.
91: *
92: * @return The tree table this column belongs to
93: */
94: protected TreeTable getTreeTable() {
95: return treeTable;
96: }
97: }
|