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

Last change on this file was 19307, checked in by taylor.smock, 7 weeks ago

Fix most new PMD issues

It would be better to use the newer switch syntax introduced in Java 14 (JEP 361),
but we currently target Java 11+. When we move to Java 17, this should be
reverted and the newer switch syntax should be used.

  • Property svn:eol-style set to native
File size: 1.8 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.JTable;
9
10import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType;
11import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
12
13/**
14 * The table cell renderer used in the changeset content table, except for the "name"
15 * column in which we use a {@link org.openstreetmap.josm.gui.PrimitiveRenderer}.
16 */
17public class ChangesetContentTableCellRenderer extends AbstractCellRenderer {
18
19 /**
20 * Renders primitive modification type.
21 * @param type modification type
22 */
23 protected void renderModificationType(ChangesetModificationType type) {
24 switch (type) {
25 case CREATED: setText(tr("Created")); break;
26 case UPDATED: setText(tr("Updated")); break;
27 case DELETED: setText(tr("Deleted")); break;
28 default: throw new IllegalStateException("Unexpected value: " + type);
29 }
30 setToolTipText(null);
31 }
32
33 @Override
34 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
35 int row, int column) {
36 if (value == null)
37 return this;
38 reset();
39 renderColors(isSelected);
40 switch (column) {
41 case 0:
42 if (value instanceof ChangesetModificationType) {
43 renderModificationType((ChangesetModificationType) value);
44 }
45 break;
46 case 1:
47 if (value instanceof HistoryOsmPrimitive) {
48 renderId(((HistoryOsmPrimitive) value).getId());
49 }
50 break;
51 default:
52 /* do nothing */
53 }
54 return this;
55 }
56}
Note: See TracBrowser for help on using the repository browser.