source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheTableCellRenderer.java @ 12494

Last change on this file since 12494 was 12494, checked in by Don-vip, 17 months ago

add Changeset.getComment()

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.changeset;
3
4import static org.openstreetmap.josm.tools.I18n.trc;
5
6import java.awt.Component;
7import java.awt.Font;
8
9import javax.swing.JTable;
10import javax.swing.UIManager;
11
12import org.openstreetmap.josm.data.osm.Changeset;
13
14/**
15 * The cell renderer for the changeset table
16 * @since 2689
17 */
18public class ChangesetCacheTableCellRenderer extends AbstractCellRenderer {
19
20    protected void renderUploadComment(Changeset cs) {
21        String comment = cs.getComment();
22        if (comment.trim().isEmpty()) {
23            setText(trc("changeset.upload-comment", "empty"));
24            setFont(UIManager.getFont("Table.font").deriveFont(Font.ITALIC));
25        } else {
26            setText(comment);
27            setToolTipText(comment);
28            setFont(UIManager.getFont("Table.font"));
29        }
30    }
31
32    protected void renderOpen(Changeset cs) {
33        if (cs.isOpen()) {
34            setText(trc("changeset.state", "Open"));
35        } else {
36            setText(trc("changeset.state", "Closed"));
37        }
38        setToolTipText(null);
39    }
40
41    protected void renderDiscussions(Changeset cs) {
42        setText(Integer.toString(cs.getCommentsCount()));
43        setToolTipText(null);
44    }
45
46    @Override
47    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
48            int row, int column) {
49        if (value == null)
50            return this;
51        reset();
52        renderColors(isSelected);
53        Changeset cs = (Changeset) value;
54        switch(column) {
55        case 0: /* id */ renderId(cs.getId()); break;
56        case 1: /* upload comment */ renderUploadComment(cs); break;
57        case 2: /* open/closed */ renderOpen(cs); break;
58        case 3: /* user */ renderUser(cs.getUser()); break;
59        case 4: /* created at */ renderDate(cs.getCreatedAt()); break;
60        case 5: /* closed at */ renderDate(cs.getClosedAt()); break;
61        case 6: /* discussions */ renderDiscussions(cs); break;
62        default: // Do nothing
63        }
64        return this;
65    }
66}
Note: See TracBrowser for help on using the repository browser.