Last change
on this file since 15048 was 8308, checked in by Don-vip, 9 years ago |
fix potential NPEs and Sonar issues related to serialization
|
-
Property svn:eol-style
set to
native
|
File size:
1.4 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.dialogs.changeset;
|
---|
3 |
|
---|
4 | import java.util.ArrayList;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import javax.swing.table.AbstractTableModel;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.data.osm.ChangesetDiscussionComment;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Model of changeset discussion table.
|
---|
13 | * @since 7715
|
---|
14 | */
|
---|
15 | public class ChangesetDiscussionTableModel extends AbstractTableModel {
|
---|
16 |
|
---|
17 | private final transient List<ChangesetDiscussionComment> data = new ArrayList<>();
|
---|
18 |
|
---|
19 | @Override
|
---|
20 | public int getRowCount() {
|
---|
21 | return data.size();
|
---|
22 | }
|
---|
23 |
|
---|
24 | @Override
|
---|
25 | public int getColumnCount() {
|
---|
26 | return 3;
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public Object getValueAt(int rowIndex, int columnIndex) {
|
---|
31 | if (rowIndex < 0 || rowIndex >= data.size())
|
---|
32 | return null;
|
---|
33 | switch (columnIndex) {
|
---|
34 | case 0:
|
---|
35 | return data.get(rowIndex).getDate();
|
---|
36 | case 1:
|
---|
37 | return data.get(rowIndex).getUser();
|
---|
38 | default:
|
---|
39 | return data.get(rowIndex).getText();
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Populates the model with the discussion of a changeset. If ds is null, the table is cleared.
|
---|
45 | *
|
---|
46 | * @param list the changeset discussion.
|
---|
47 | */
|
---|
48 | public void populate(List<ChangesetDiscussionComment> list) {
|
---|
49 | data.clear();
|
---|
50 | if (list != null) {
|
---|
51 | data.addAll(list);
|
---|
52 | }
|
---|
53 | fireTableDataChanged();
|
---|
54 | }
|
---|
55 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.