Changeset 15211 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-07-06T22:15:55+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/preferences/sources/ExtendedSourceEntry.java
r12825 r15211 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import org.openstreetmap.josm.tools.ImageResource; 6 7 import org.openstreetmap.josm.tools.Utils; 7 8 … … 17 18 /** author name used for display */ 18 19 public String author; 20 /** icon used for display */ 21 public ImageResource icon; 19 22 /** webpage link used for display */ 20 23 public String link; -
trunk/src/org/openstreetmap/josm/data/preferences/sources/MapPaintPrefHelper.java
r12846 r15211 7 7 import java.util.Arrays; 8 8 import java.util.Collection; 9 import java.util.HashMap;10 9 import java.util.List; 11 10 import java.util.Map; … … 14 13 15 14 import org.openstreetmap.josm.spi.preferences.Config; 15 import org.openstreetmap.josm.tools.ImageProvider; 16 16 import org.openstreetmap.josm.tools.Utils; 17 17 … … 84 84 defJosmMapcss.active = true; 85 85 defJosmMapcss.name = "standard"; 86 defJosmMapcss.icon = new ImageProvider("logo").getResource(); 86 87 defJosmMapcss.title = tr("JOSM default (MapCSS)"); 87 88 defJosmMapcss.description = tr("Internal style to be used as base for runtime switchable overlay styles"); … … 89 90 defPL2.active = false; 90 91 defPL2.name = "standard"; 92 defPL2.icon = new ImageProvider("dialogs/mappaint", "pl2_small").getResource(); 91 93 defPL2.title = tr("Potlatch 2"); 92 94 defPL2.description = tr("the main Potlatch 2 style"); … … 97 99 @Override 98 100 public Map<String, String> serialize(SourceEntry entry) { 99 Map<String, String> res = new HashMap<>(); 100 res.put("url", entry.url == null ? "" : entry.url); 101 res.put("title", entry.title == null ? "" : entry.title); 101 Map<String, String> res = super.serialize(entry); 102 102 res.put("active", Boolean.toString(entry.active)); 103 103 if (entry.name != null) { -
trunk/src/org/openstreetmap/josm/data/preferences/sources/PresetPrefHelper.java
r12825 r15211 6 6 import java.util.Collection; 7 7 import java.util.Collections; 8 import java.util.HashMap; 9 import java.util.Map;8 9 import org.openstreetmap.josm.tools.ImageProvider; 10 10 11 11 /** … … 31 31 ExtendedSourceEntry i = new ExtendedSourceEntry(type, "defaultpresets.xml", "resource://data/defaultpresets.xml"); 32 32 i.title = tr("Internal Preset"); 33 i.icon = new ImageProvider("logo").getResource(); 33 34 i.description = tr("The default preset for JOSM"); 34 35 return Collections.singletonList(i); 35 36 } 36 37 @Override38 public Map<String, String> serialize(SourceEntry entry) {39 Map<String, String> res = new HashMap<>();40 res.put("url", entry.url);41 res.put("title", entry.title == null ? "" : entry.title);42 return res;43 }44 45 @Override46 public SourceEntry deserialize(Map<String, String> s) {47 return new SourceEntry(type, s.get("url"), null, s.get("title"), true);48 }49 37 } -
trunk/src/org/openstreetmap/josm/data/preferences/sources/SourcePrefHelper.java
r15099 r15211 8 8 import java.util.List; 9 9 import java.util.Map; 10 import java.util.Optional; 10 11 import java.util.Set; 11 12 import java.util.stream.Collectors; … … 44 45 * @return map (key=value) 45 46 */ 46 public abstract Map<String, String> serialize(SourceEntry entry); 47 public Map<String, String> serialize(SourceEntry entry) { 48 Map<String, String> res = new HashMap<>(); 49 res.put("url", entry.url); 50 res.put("title", entry.title == null ? "" : entry.title); 51 return res; 52 } 47 53 48 54 /** … … 51 57 * @return source entry 52 58 */ 53 public abstract SourceEntry deserialize(Map<String, String> entryStr); 59 public SourceEntry deserialize(Map<String, String> entryStr) { 60 return new SourceEntry(type, 61 entryStr.get("url"), 62 entryStr.get("name"), 63 entryStr.get("title"), 64 Optional.ofNullable(entryStr.get("active")).map(Boolean::parseBoolean).orElse(true)); 65 } 54 66 55 67 /** -
trunk/src/org/openstreetmap/josm/data/preferences/sources/ValidatorPrefHelper.java
r14828 r15211 6 6 import java.util.ArrayList; 7 7 import java.util.Collection; 8 import java.util.HashMap;9 8 import java.util.List; 10 9 import java.util.Map; … … 12 11 import org.openstreetmap.josm.data.preferences.BooleanProperty; 13 12 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 13 import org.openstreetmap.josm.tools.ImageProvider; 14 14 15 15 /** … … 86 86 ExtendedSourceEntry i = new ExtendedSourceEntry(type, filename+".mapcss", "resource://data/validator/"+filename+".mapcss"); 87 87 i.title = title; 88 i.icon = new ImageProvider("logo").getResource(); 88 89 i.description = description; 89 90 defaults.add(i); … … 92 93 @Override 93 94 public Map<String, String> serialize(SourceEntry entry) { 94 Map<String, String> res = new HashMap<>(); 95 res.put("url", entry.url); 96 res.put("title", entry.title == null ? "" : entry.title); 95 Map<String, String> res = super.serialize(entry); 97 96 res.put("active", Boolean.toString(entry.active)); 98 97 return res; 99 98 } 100 101 @Override102 public SourceEntry deserialize(Map<String, String> s) {103 return new SourceEntry(type, s.get("url"), null, s.get("title"), Boolean.parseBoolean(s.get("active")));104 }105 99 } -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r14214 r15211 3 3 4 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 import static org.openstreetmap.josm.tools.I18n.marktr; 5 6 import static org.openstreetmap.josm.tools.I18n.tr; 6 7 8 import java.awt.Color; 7 9 import java.awt.Component; 8 10 import java.awt.Dimension; … … 42 44 import javax.swing.DefaultListModel; 43 45 import javax.swing.DefaultListSelectionModel; 44 import javax.swing.ImageIcon;45 46 import javax.swing.JButton; 46 47 import javax.swing.JCheckBox; … … 58 59 import javax.swing.ListCellRenderer; 59 60 import javax.swing.ListSelectionModel; 61 import javax.swing.UIManager; 60 62 import javax.swing.event.CellEditorListener; 61 63 import javax.swing.event.ChangeEvent; … … 74 76 import org.openstreetmap.josm.actions.ExtensionFileFilter; 75 77 import org.openstreetmap.josm.data.Version; 78 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 76 79 import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry; 77 80 import org.openstreetmap.josm.data.preferences.sources.SourceEntry; … … 1353 1356 static class SourceEntryListCellRenderer extends JLabel implements ListCellRenderer<ExtendedSourceEntry> { 1354 1357 1355 private final ImageIcon GREEN_CHECK = ImageProvider.getIfAvailable("misc", "green_check"); 1356 private final ImageIcon GRAY_CHECK = ImageProvider.getIfAvailable("misc", "gray_check"); 1358 private static final NamedColorProperty SOURCE_ENTRY_ACTIVE_BACKGROUND_COLOR = new NamedColorProperty( 1359 marktr("External resource entry: Active"), 1360 new Color(200, 255, 200)); 1361 private static final NamedColorProperty SOURCE_ENTRY_INACTIVE_BACKGROUND_COLOR = new NamedColorProperty( 1362 marktr("External resource entry: Inactive"), 1363 new Color(200, 200, 200)); 1364 1357 1365 private final Map<String, SourceEntry> entryByUrl = new HashMap<>(); 1358 1366 … … 1374 1382 setOpaque(true); 1375 1383 setToolTipText(value.getTooltip()); 1376 final SourceEntry sourceEntry = entryByUrl.get(value.url); 1377 setIcon(sourceEntry == null ? null : sourceEntry.active ? GREEN_CHECK : GRAY_CHECK); 1384 if (!isSelected) { 1385 final SourceEntry sourceEntry = entryByUrl.get(value.url); 1386 GuiHelper.setBackgroundReadable(this, sourceEntry == null ? UIManager.getColor("Table.background") : 1387 sourceEntry.active ? SOURCE_ENTRY_ACTIVE_BACKGROUND_COLOR.get() : SOURCE_ENTRY_INACTIVE_BACKGROUND_COLOR.get()); 1388 } 1389 final ImageSizes size = ImageSizes.TABLE; 1390 setIcon(value.icon == null ? ImageProvider.getEmpty(size) : value.icon.getImageIcon(size.getImageDimension())); 1378 1391 return this; 1379 1392 } … … 1475 1488 } else if ("version".equals(key)) { 1476 1489 last.version = value; 1490 } else if ("icon".equals(key) && last.icon == null) { 1491 last.icon = new ImageProvider(value).setOptional(true).getResource(); 1477 1492 } else if ("link".equals(key) && last.link == null) { 1478 1493 last.link = value;
Note:
See TracChangeset
for help on using the changeset viewer.