1 | // Copyright 2004-2007 Jean-Francois Poilpret |
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 net.sourceforge.hivegui.table; |
16 | |
17 | import java.util.ArrayList; |
18 | import java.util.List; |
19 | |
20 | import javax.swing.Action; |
21 | import javax.swing.JPopupMenu; |
22 | |
23 | import org.apache.hivemind.impl.BaseLocatable; |
24 | import org.apache.hivemind.util.ToStringBuilder; |
25 | |
26 | import net.sourceforge.hiveevents.Channel; |
27 | |
28 | /** |
29 | * @author Jean-Francois Poilpret |
30 | */ |
31 | public class TableContribution extends BaseLocatable |
32 | { |
33 | public void setName(String name) |
34 | { |
35 | _name = name; |
36 | } |
37 | public String getName() |
38 | { |
39 | return _name; |
40 | } |
41 | |
42 | public void setPopup(JPopupMenu popup) |
43 | { |
44 | _popup = popup; |
45 | } |
46 | public JPopupMenu getPopup() |
47 | { |
48 | return _popup; |
49 | } |
50 | |
51 | public void setSelectionMode(SelectionMode selectionMode) |
52 | { |
53 | _selectionMode = selectionMode; |
54 | } |
55 | public SelectionMode getSelectionMode() |
56 | { |
57 | return _selectionMode; |
58 | } |
59 | |
60 | public void setSelectionEvent(Channel channel) |
61 | { |
62 | _channel = channel; |
63 | } |
64 | public Channel getSelectionEvent() |
65 | { |
66 | return _channel; |
67 | } |
68 | |
69 | public void setDoubleClickCommand(Action doubleClickCommand) |
70 | { |
71 | _doubleClickCommand = doubleClickCommand; |
72 | } |
73 | public Action getDoubleClickCommand() |
74 | { |
75 | return _doubleClickCommand; |
76 | } |
77 | |
78 | public void setAutoSelectNewRow(boolean autoSelectNewRow) |
79 | { |
80 | _autoSelectNewRow = autoSelectNewRow; |
81 | } |
82 | public boolean isAutoSelectNewRow() |
83 | { |
84 | return _autoSelectNewRow; |
85 | } |
86 | |
87 | public void addColumn(ColumnContribution column) |
88 | { |
89 | _columns.add(column); |
90 | } |
91 | |
92 | public ColumnContribution[] getColumns() |
93 | { |
94 | return _columns.toArray( |
95 | new ColumnContribution[_columns.size()]); |
96 | } |
97 | |
98 | @Override public String toString() |
99 | { |
100 | ToStringBuilder builder = new ToStringBuilder(this); |
101 | builder.append("name", _name); |
102 | builder.append("selectionMode", _selectionMode); |
103 | builder.append("channel", _channel); |
104 | return builder.toString(); |
105 | } |
106 | |
107 | private String _name; |
108 | private JPopupMenu _popup; |
109 | private SelectionMode _selectionMode = SelectionMode.Single; |
110 | private Channel _channel; |
111 | private Action _doubleClickCommand; |
112 | private boolean _autoSelectNewRow; |
113 | private final List<ColumnContribution> _columns = new ArrayList<ColumnContribution>(); |
114 | } |