source: josm/trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableCellRenderer.java@ 6084

Last change on this file since 6084 was 6084, checked in by bastiK, 12 years ago

see #8902 - add missing @Override annotations (patch by shinigami)

  • Property svn:eol-style set to native
File size: 2.5 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.tr;
5
6import java.awt.Component;
7
8import javax.swing.JLabel;
9import javax.swing.JTable;
10import javax.swing.UIManager;
11import javax.swing.table.TableCellRenderer;
12
13import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType;
14import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
15
16/**
17 * The table cell renderer used in the changeset content table, except for the "name"
18 * column in which we use a {@link org.openstreetmap.josm.gui.OsmPrimitivRenderer}.
19 *
20 */
21public class ChangesetContentTableCellRenderer extends JLabel implements TableCellRenderer{
22
23 public ChangesetContentTableCellRenderer() {
24 setOpaque(true);
25 }
26
27 protected void reset() {
28 setBackground(UIManager.getColor("Table.background"));
29 setForeground(UIManager.getColor("Table.foreground"));
30 setFont(UIManager.getFont("Table.font"));
31 }
32
33 protected void renderColors(boolean isSelected) {
34 if (isSelected) {
35 setBackground(UIManager.getColor("Table.selectionBackground"));
36 setForeground(UIManager.getColor("Table.selectionForeground"));
37 } else {
38 setBackground(UIManager.getColor("Table.background"));
39 setForeground(UIManager.getColor("Table.foreground"));
40 }
41 }
42
43 protected void renderId(HistoryOsmPrimitive primitive) {
44 setText(Long.toString(primitive.getId()));
45 setToolTipText("");
46 }
47
48 protected void renderModificationType(ChangesetModificationType type) {
49 switch(type) {
50 case CREATED: setText(tr("Created")); break;
51 case UPDATED: setText(tr("Updated")); break;
52 case DELETED: setText(tr("Deleted")); break;
53 }
54 setToolTipText("");
55 }
56
57 @Override
58 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
59 int row, int column) {
60 if (value == null)
61 return this;
62 reset();
63 renderColors(isSelected);
64 switch(column) {
65 case 0:
66 ChangesetModificationType type = (ChangesetModificationType)value;
67 renderModificationType(type);
68 break;
69 case 1:
70 HistoryOsmPrimitive primitive = (HistoryOsmPrimitive)value;
71 renderId(primitive);
72 break;
73 default:
74 /* do nothing */
75 }
76 return this;
77 }
78}
Note: See TracBrowser for help on using the repository browser.