|
@@ -0,0 +1,92 @@
|
|
1
|
+/*
|
|
2
|
+ * Copyright (c) 2006-2011 DMDirc Developers
|
|
3
|
+ *
|
|
4
|
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+ * of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+ * in the Software without restriction, including without limitation the rights
|
|
7
|
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+ * copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+ * furnished to do so, subject to the following conditions:
|
|
10
|
+ *
|
|
11
|
+ * The above copyright notice and this permission notice shall be included in
|
|
12
|
+ * all copies or substantial portions of the Software.
|
|
13
|
+ *
|
|
14
|
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+ * SOFTWARE.
|
|
21
|
+ */
|
|
22
|
+
|
|
23
|
+package com.dmdirc.addons.ui_swing.dialogs.channellist;
|
|
24
|
+
|
|
25
|
+import com.dmdirc.addons.ui_swing.adapters.ObservableListTableModelAdapter;
|
|
26
|
+import com.dmdirc.lists.GroupListEntry;
|
|
27
|
+import com.dmdirc.lists.GroupListManager;
|
|
28
|
+
|
|
29
|
+/**
|
|
30
|
+ * Table model for channel list results.
|
|
31
|
+ */
|
|
32
|
+public class ChannelListTableModel extends ObservableListTableModelAdapter<GroupListEntry> {
|
|
33
|
+
|
|
34
|
+ /** Serial version UID. */
|
|
35
|
+ private static final long serialVersionUID = 1L;
|
|
36
|
+
|
|
37
|
+ /** The names to use for the model's columns. */
|
|
38
|
+ private static final String[] COLUMN_NAMES = new String[] {
|
|
39
|
+ "Name", "Users", "Topic"
|
|
40
|
+ };
|
|
41
|
+
|
|
42
|
+ /** The types to use for the model's columns. */
|
|
43
|
+ @SuppressWarnings("rawtypes")
|
|
44
|
+ private static final Class[] COLUMN_TYPES = new Class[] {
|
|
45
|
+ String.class, Integer.class, String.class
|
|
46
|
+ };
|
|
47
|
+
|
|
48
|
+ /**
|
|
49
|
+ * Creates a new table model backed by the given manager.
|
|
50
|
+ *
|
|
51
|
+ * @param manager The manager to use to retrieve group list entries.
|
|
52
|
+ */
|
|
53
|
+ public ChannelListTableModel(final GroupListManager manager) {
|
|
54
|
+ super(manager.getGroups());
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ /** {@inheritDoc} */
|
|
58
|
+ @Override
|
|
59
|
+ public int getColumnCount() {
|
|
60
|
+ return 3;
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ /** {@inheritDoc} */
|
|
64
|
+ @Override
|
|
65
|
+ public Object getValueAt(final int rowIndex, final int columnIndex) {
|
|
66
|
+ final GroupListEntry entry = list.get(rowIndex);
|
|
67
|
+
|
|
68
|
+ switch (columnIndex) {
|
|
69
|
+ case 0:
|
|
70
|
+ return entry.getName();
|
|
71
|
+ case 1:
|
|
72
|
+ return entry.getUsers();
|
|
73
|
+ case 2:
|
|
74
|
+ return entry.getTopic();
|
|
75
|
+ }
|
|
76
|
+
|
|
77
|
+ return null;
|
|
78
|
+ }
|
|
79
|
+
|
|
80
|
+ /** {@inheritDoc} */
|
|
81
|
+ @Override
|
|
82
|
+ public Class<?> getColumnClass(final int columnIndex) {
|
|
83
|
+ return COLUMN_TYPES[columnIndex];
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ /** {@inheritDoc} */
|
|
87
|
+ @Override
|
|
88
|
+ public String getColumnName(final int column) {
|
|
89
|
+ return COLUMN_NAMES[column];
|
|
90
|
+ }
|
|
91
|
+
|
|
92
|
+}
|