1 /***
2 * Copyright (C) 2006 Philipp Mpalampanis
3 *
4 * License: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * Alternatively, the contents of this file may be used under the terms of
17 * either the GNU General Public License Version 2 or later (the "GPL"), or
18 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
19 * in which case the provisions of the GPL or the LGPL are applicable instead
20 * of those above. If you wish to allow use of your version of this file only
21 * under the terms of either the GPL or the LGPL, and not to allow others to
22 * use your version of this file under the terms of the MPL, indicate your
23 * decision by deleting the provisions above and replace them with the notice
24 * and other provisions required by the GPL or the LGPL. If you do not delete
25 * the provisions above, a recipient may use your version of this file under
26 * the terms of any one of the MPL, the GPL or the LGPL.
27 */
28
29 package net.sf.echobinding.table;
30
31 import java.util.*;
32
33 import net.sf.echobinding.binding.BindingContext;
34
35 /***
36 *
37 * A data bound table with selectable rows. On selection, the abstract method
38 * showEditForm() is called, which provides a <code>BindingContext</code> for
39 * the selected row. Use this binding context to arrange your data bound widgets
40 * within a form. Changes made through this form will be reflected by the table.
41 *
42 * @see BoundTable
43 */
44 public abstract class SelectableBoundTable<T> extends SelectableTable<T> {
45
46 public static final String ACTION_SHOW_DETAIL = "showDetail";
47
48 private static final long serialVersionUID = 5397923394009444655L;
49
50
51
52 /***
53 * Creates a new <code>SelectableBoundTable</code> from a list and a binding
54 * context.
55 *
56 * @param list
57 * @param ctx
58 */
59 public SelectableBoundTable(List<T> list, BindingContext ctx) {
60 super(list, ctx);
61 }
62
63 /***
64 * Creates a new <code>SelectableBoundTable</code> using a bounded list and a
65 * binding context.
66 *
67 * @param listBindingId
68 * @param ctx
69 */
70 public SelectableBoundTable(String listBindingId, BindingContext ctx) {
71 super(listBindingId, ctx);
72
73 }
74
75 /***
76 * Defines what will happen on row selection..
77 * @param ctx
78 */
79 public abstract void onSelect(BindingContext ctx);
80
81 @Override
82 public void rowIndexChanged(int rowIndex) {
83 super.rowIndexChanged(rowIndex);
84 onSelect(getBindingContext(rowIndex));
85 }
86
87
88
89
90 @Override
91 protected void initialize() {
92 super.initialize();
93
94 setDefaultRenderer(HashSet.class, new BoundTableCollectionCellRenderer());
95 setDefaultRenderer(Collection.class, new BoundTableCollectionCellRenderer());
96 setDefaultRenderer(List.class, new BoundTableCollectionCellRenderer());
97
98 }
99
100 /***
101 // * @param set
102 // */
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 }