Changeset 10878 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-08-23T20:31:46+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRenderer.java
r10043 r10878 17 17 import javax.swing.JTable; 18 18 import javax.swing.UIDefaults; 19 import javax.swing.UIManager; 19 20 import javax.swing.table.DefaultTableCellRenderer; 20 21 import javax.swing.table.TableCellRenderer; 21 22 22 import org.openstreetmap.josm.Main;23 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 24 import org.openstreetmap.josm.data.preferences.BooleanProperty; 25 import org.openstreetmap.josm.data.preferences.CachingProperty; 26 import org.openstreetmap.josm.data.preferences.ColorProperty; 24 27 25 28 /** … … 29 32 public class PropertiesCellRenderer extends DefaultTableCellRenderer { 30 33 34 private static final CachingProperty<Color> SELECTED_FG 35 = new ColorProperty(marktr("Discardable key: selection Foreground"), Color.GRAY).cached(); 36 private static final CachingProperty<Color> SELECTED_BG; 37 private static final CachingProperty<Color> NORMAL_FG 38 = new ColorProperty(marktr("Discardable key: foreground"), Color.GRAY).cached(); 39 private static final CachingProperty<Color> NORMAL_BG; 40 private static final CachingProperty<Boolean> DISCARDABLE 41 = new BooleanProperty("display.discardable-keys", false).cached(); 42 43 static { 44 UIDefaults defaults = UIManager.getDefaults(); 45 SELECTED_BG = new ColorProperty(marktr("Discardable key: selection Background"), 46 defaults.getColor("Table.selectionBackground")).cached(); 47 NORMAL_BG = new ColorProperty(marktr("Discardable key: background"), 48 defaults.getColor("Table.background")).cached(); 49 } 50 31 51 private final Collection<TableCellRenderer> customRenderer = new CopyOnWriteArrayList<>(); 32 52 33 53 private static void setColors(Component c, String key, boolean isSelected) { 34 UIDefaults defaults = javax.swing.UIManager.getDefaults(); 54 35 55 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 } 56 c.setForeground((isSelected ? SELECTED_FG : NORMAL_FG).get()); 57 c.setBackground((isSelected ? SELECTED_BG : NORMAL_BG).get()); 44 58 } else { 59 UIDefaults defaults = UIManager.getDefaults(); 45 60 c.setForeground(defaults.getColor("Table."+(isSelected ? "selectionF" : "f")+"oreground")); 46 61 c.setBackground(defaults.getColor("Table."+(isSelected ? "selectionB" : "b")+"ackground")); … … 56 71 } 57 72 } 58 Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);59 73 if (value == null) 60 74 return this; 75 Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column); 61 76 if (c instanceof JLabel) { 62 77 String str = null; … … 77 92 StringBuilder sb = new StringBuilder("<"); 78 93 if (otherCount == 1) { 79 for (Map.Entry<?, ?> entry : v.entrySet()) { // Find the non-blank value in the map 80 if (!Objects.equals(entry.getKey(), "")) { 81 /* 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 } 94 // Find the non-blank value in the map 95 v.entrySet().stream().filter(entry -> !Objects.equals(entry.getKey(), "")) 96 /* I18n: properties display partial string joined with comma, first is count, second is value */ 97 .findAny().ifPresent(entry -> sb.append(tr("{0} ''{1}''", entry.getValue().toString(), entry.getKey()))); 85 98 } else { 86 99 /* I18n: properties display partial string joined with comma */ … … 102 115 ((JLabel) c).putClientProperty("html.disable", Boolean.TRUE); // Fix #8730 103 116 ((JLabel) c).setText(str); 104 if ( Main.pref.getBoolean("display.discardable-keys", false)) {117 if (DISCARDABLE.get()) { 105 118 String key = null; 106 119 if (column == 0) {
Note:
See TracChangeset
for help on using the changeset viewer.