diff --git a/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java b/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java
index 7eb11e4..3965738 100644
|
a
|
b
|
import javax.swing.UIDefaults;
|
| 19 | 19 | import javax.swing.table.DefaultTableCellRenderer; |
| 20 | 20 | import javax.swing.table.TableCellRenderer; |
| 21 | 21 | |
| 22 | | import org.openstreetmap.josm.Main; |
| 23 | 22 | import org.openstreetmap.josm.data.osm.OsmPrimitive; |
| | 23 | import org.openstreetmap.josm.data.preferences.BooleanProperty; |
| | 24 | import org.openstreetmap.josm.data.preferences.CachingProperty; |
| | 25 | import org.openstreetmap.josm.data.preferences.ColorProperty; |
| 24 | 26 | |
| 25 | 27 | /** |
| 26 | 28 | * Cell renderer of tags table. |
| … |
… |
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
| 28 | 30 | */ |
| 29 | 31 | public class PropertiesCellRenderer extends DefaultTableCellRenderer { |
| 30 | 32 | |
| | 33 | private static final CachingProperty<Color> SELECTED_FG |
| | 34 | = new ColorProperty(marktr("Discardable key: selection Foreground"), Color.GRAY).cached(); |
| | 35 | private static final CachingProperty<Color> SELECTED_BG; |
| | 36 | private static final CachingProperty<Color> NORMAL_FG |
| | 37 | = new ColorProperty(marktr("Discardable key: foreground"), Color.GRAY).cached(); |
| | 38 | private static final CachingProperty<Color> NORMAL_BG; |
| | 39 | private static final CachingProperty<Boolean> DISCARDABLE |
| | 40 | = new BooleanProperty("display.discardable-keys", false).cached(); |
| | 41 | |
| | 42 | static { |
| | 43 | UIDefaults defaults = javax.swing.UIManager.getDefaults(); |
| | 44 | SELECTED_BG = new ColorProperty(marktr("Discardable key: selection Background"), |
| | 45 | defaults.getColor("Table.selectionBackground")).cached(); |
| | 46 | NORMAL_BG = new ColorProperty(marktr("Discardable key: background"), |
| | 47 | defaults.getColor("Table.background")).cached(); |
| | 48 | } |
| | 49 | |
| 31 | 50 | private final Collection<TableCellRenderer> customRenderer = new CopyOnWriteArrayList<>(); |
| 32 | 51 | |
| 33 | 52 | private static void setColors(Component c, String key, boolean isSelected) { |
| 34 | | UIDefaults defaults = javax.swing.UIManager.getDefaults(); |
| | 53 | |
| 35 | 54 | if (OsmPrimitive.getDiscardableKeys().contains(key)) { |
| 36 | | if (isSelected) { |
| 37 | | c.setForeground(Main.pref.getColor(marktr("Discardable key: selection Foreground"), Color.GRAY)); |
| 38 | | c.setBackground(Main.pref.getColor(marktr("Discardable key: selection Background"), |
| 39 | | defaults.getColor("Table.selectionBackground"))); |
| 40 | | } else { |
| 41 | | c.setForeground(Main.pref.getColor(marktr("Discardable key: foreground"), Color.GRAY)); |
| 42 | | c.setBackground(Main.pref.getColor(marktr("Discardable key: background"), defaults.getColor("Table.background"))); |
| 43 | | } |
| | 55 | CachingProperty<Color> fg = isSelected ? SELECTED_FG : NORMAL_FG; |
| | 56 | CachingProperty<Color> bg = isSelected ? SELECTED_BG : NORMAL_BG; |
| | 57 | c.setForeground(fg.get()); |
| | 58 | c.setBackground(bg.get()); |
| 44 | 59 | } else { |
| | 60 | UIDefaults defaults = javax.swing.UIManager.getDefaults(); |
| 45 | 61 | c.setForeground(defaults.getColor("Table."+(isSelected ? "selectionF" : "f")+"oreground")); |
| 46 | 62 | c.setBackground(defaults.getColor("Table."+(isSelected ? "selectionB" : "b")+"ackground")); |
| 47 | 63 | } |
| … |
… |
public class PropertiesCellRenderer extends DefaultTableCellRenderer {
|
| 55 | 71 | return component; |
| 56 | 72 | } |
| 57 | 73 | } |
| 58 | | Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column); |
| 59 | 74 | if (value == null) |
| 60 | 75 | return this; |
| | 76 | |
| | 77 | Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column); |
| 61 | 78 | if (c instanceof JLabel) { |
| 62 | 79 | String str = null; |
| 63 | 80 | if (value instanceof String) { |
| … |
… |
public class PropertiesCellRenderer extends DefaultTableCellRenderer {
|
| 76 | 93 | } |
| 77 | 94 | StringBuilder sb = new StringBuilder("<"); |
| 78 | 95 | if (otherCount == 1) { |
| 79 | | for (Map.Entry<?, ?> entry : v.entrySet()) { // Find the non-blank value in the map |
| 80 | | if (!Objects.equals(entry.getKey(), "")) { |
| | 96 | // Find the non-blank value in the map |
| | 97 | v.entrySet().stream().filter(entry -> !Objects.equals(entry.getKey(), "")) |
| 81 | 98 | /* I18n: properties display partial string joined with comma, frst is count, second is value */ |
| 82 | | sb.append(tr("{0} ''{1}''", entry.getValue().toString(), entry.getKey())); |
| 83 | | } |
| 84 | | } |
| | 99 | .findAny().ifPresent(entry -> sb.append(tr("{0} ''{1}''", entry.getValue().toString(), entry.getKey()))); |
| 85 | 100 | } else { |
| 86 | 101 | /* I18n: properties display partial string joined with comma */ |
| 87 | 102 | sb.append(trn("{0} different", "{0} different", otherCount, otherCount)); |
| … |
… |
public class PropertiesCellRenderer extends DefaultTableCellRenderer {
|
| 101 | 116 | } |
| 102 | 117 | ((JLabel) c).putClientProperty("html.disable", Boolean.TRUE); // Fix #8730 |
| 103 | 118 | ((JLabel) c).setText(str); |
| 104 | | if (Main.pref.getBoolean("display.discardable-keys", false)) { |
| | 119 | if (DISCARDABLE.get()) { |
| 105 | 120 | String key = null; |
| 106 | 121 | if (column == 0) { |
| 107 | 122 | key = str; |