|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Table.java | 0% | 0% | 0% | 0% |
|
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.contrib.table.components; | |
16 | ||
17 | import org.apache.tapestry.BaseComponent; | |
18 | import org.apache.tapestry.IForm; | |
19 | import org.apache.tapestry.TapestryUtils; | |
20 | import org.apache.tapestry.contrib.table.model.ITableColumn; | |
21 | import org.apache.tapestry.contrib.table.model.ITableModel; | |
22 | import org.apache.tapestry.contrib.table.model.ITableModelSource; | |
23 | ||
24 | /** | |
25 | * The facade component in the Table family. Table allows you to present a sortable and pagable | |
26 | * table simply and easily by using only this one component. Please see the Component Reference for | |
27 | * details on how to use this component. [ <a | |
28 | * href="../../../../../../../ComponentReference/contrib.Table.html">Component Reference </a>] | |
29 | * | |
30 | * @author mindbridge | |
31 | */ | |
32 | public abstract class Table extends BaseComponent implements ITableModelSource | |
33 | { | |
34 | public abstract boolean getVolatile(); | |
35 | ||
36 | /** | |
37 | * @see org.apache.tapestry.contrib.table.model.ITableModelSource#getTableModel() | |
38 | */ | |
39 | 0 | public ITableModel getTableModel() |
40 | { | |
41 | 0 | return getTableViewComponent().getTableModel(); |
42 | } | |
43 | ||
44 | /** | |
45 | * Indicates that the table model has changed and it may need to saved. This method has to be | |
46 | * invoked if modifications are made to the model. | |
47 | * | |
48 | * @see org.apache.tapestry.contrib.table.model.ITableModelSource#fireObservedStateChange() | |
49 | */ | |
50 | 0 | public void fireObservedStateChange() |
51 | { | |
52 | 0 | getTableViewComponent().fireObservedStateChange(); |
53 | } | |
54 | ||
55 | /** | |
56 | * Resets the state of the component and forces it to load a new TableModel from the tableModel | |
57 | * binding the next time it renders. | |
58 | */ | |
59 | 0 | public void reset() |
60 | { | |
61 | 0 | getTableViewComponent().reset(); |
62 | } | |
63 | ||
64 | /** | |
65 | * Returns the currently rendered table column. You can call this method to obtain the current | |
66 | * column. | |
67 | * | |
68 | * @return ITableColumn the current table column | |
69 | */ | |
70 | 0 | public ITableColumn getTableColumn() |
71 | { | |
72 | 0 | Object objCurrentRow = getTableRow(); |
73 | ||
74 | // if the current row is null, then we are most likely rendering TableColumns | |
75 | 0 | if (objCurrentRow == null) |
76 | 0 | return getTableColumnsComponent().getTableColumn(); |
77 | ||
78 | 0 | return getTableValuesComponent().getTableColumn(); |
79 | } | |
80 | ||
81 | /** | |
82 | * Returns the currently rendered table row or null if the rows are not rendered at the moment. | |
83 | * You can call this method to obtain the current row. | |
84 | * | |
85 | * @return Object the current table row | |
86 | */ | |
87 | 0 | public Object getTableRow() |
88 | { | |
89 | 0 | return getTableRowsComponent().getTableRow(); |
90 | } | |
91 | ||
92 | 0 | protected TableView getTableViewComponent() |
93 | { | |
94 | 0 | return (TableView) getComponent("tableView"); |
95 | } | |
96 | ||
97 | 0 | protected TableColumns getTableColumnsComponent() |
98 | { | |
99 | 0 | return (TableColumns) getComponent("tableColumns"); |
100 | } | |
101 | ||
102 | 0 | protected TableRows getTableRowsComponent() |
103 | { | |
104 | 0 | return (TableRows) getComponent("tableRows"); |
105 | } | |
106 | ||
107 | 0 | protected TableValues getTableValuesComponent() |
108 | { | |
109 | 0 | return (TableValues) getComponent("tableValues"); |
110 | } | |
111 | ||
112 | 0 | public boolean getShowNormalPages() |
113 | { | |
114 | 0 | if (getVolatile()) |
115 | 0 | return true; |
116 | ||
117 | 0 | IForm form = (IForm) getPage().getRequestCycle().getAttribute(TapestryUtils.FORM_ATTRIBUTE); |
118 | 0 | return (form == null); |
119 | } | |
120 | } |
|