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
RevLine 
[2711]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"
[13564]15 * column in which we use a {@link org.openstreetmap.josm.gui.PrimitiveRenderer}.
[2711]16 */
[7715]17public class ChangesetContentTableCellRenderer extends AbstractCellRenderer {
[2711]18
[11878]19 /**
20 * Renders primitive modification type.
21 * @param type modification type
22 */
[2711]23 protected void renderModificationType(ChangesetModificationType type) {
[19050]24 switch (type) {
[2711]25 case CREATED: setText(tr("Created")); break;
26 case UPDATED: setText(tr("Updated")); break;
27 case DELETED: setText(tr("Deleted")); break;
[19307]28 default: throw new IllegalStateException("Unexpected value: " + type);
[2711]29 }
[7712]30 setToolTipText(null);
[2711]31 }
32
[6084]33 @Override
[2711]34 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
35 int row, int column) {
[4072]36 if (value == null)
37 return this;
[2711]38 reset();
39 renderColors(isSelected);
[19050]40 switch (column) {
[2711]41 case 0:
[13344]42 if (value instanceof ChangesetModificationType) {
43 renderModificationType((ChangesetModificationType) value);
44 }
[2711]45 break;
46 case 1:
[13344]47 if (value instanceof HistoryOsmPrimitive) {
48 renderId(((HistoryOsmPrimitive) value).getId());
49 }
[2711]50 break;
51 default:
52 /* do nothing */
53 }
54 return this;
55 }
56}
Note: See TracBrowser for help on using the repository browser.