Changeset 29230 in osm for applications/editors/josm/plugins/roadsigns/src/org/openstreetmap
- Timestamp:
- 2013-02-06T13:52:07+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignInputDialog.java
r29228 r29230 29 29 import javax.swing.BorderFactory; 30 30 import javax.swing.Box; 31 import javax.swing.ButtonGroup; 31 32 import javax.swing.JButton; 32 33 import javax.swing.JCheckBox; … … 36 37 import javax.swing.JLabel; 37 38 import javax.swing.JPanel; 39 import javax.swing.JRadioButton; 38 40 import javax.swing.JScrollPane; 39 41 import javax.swing.JTabbedPane; … … 694 696 fireTableDataChanged(); 695 697 } 696 697 698 698 } 699 699 … … 814 814 private List<PresetMetaData> presetsData; 815 815 private JComboBox selectionBox; 816 JRadioButton rbAll, rbUseful; 816 817 817 818 public SettingsPanel(boolean standalone, final Action update) { … … 831 832 this.add(selectionBox, GBC.eol().insets(0, 5, 5, 5)); 832 833 if (!standalone) { 834 String snd = "Hide signs that do not have an OSM tag assigned"; 835 836 rbAll = new JRadioButton(tr("Show all signs")); 837 rbUseful = new JRadioButton(tr("Show a selection of the most useful signs")); 838 839 ButtonGroup grp = new ButtonGroup(); 840 grp.add(rbAll); 841 grp.add(rbUseful); 842 843 String filterPref = Main.pref.get("plugin.roadsigns.preset.filter"); 844 if (filterPref.equals("useful")) { 845 rbUseful.setSelected(true); 846 } else { 847 rbAll.setSelected(true); 848 } 849 850 JPanel pnFilter = new JPanel(new GridBagLayout()); 851 pnFilter.setBorder(BorderFactory.createTitledBorder(tr("Filter"))); 852 pnFilter.add(rbAll, GBC.eop()); 853 pnFilter.add(rbUseful, GBC.eop()); 854 855 this.add(pnFilter, GBC.eol().insets(5, 0, 5, 5)); 856 833 857 JButton apply = new JButton(new AbstractAction(tr("Apply")) { 834 858 @Override … … 848 872 849 873 public void apply() throws IOException { 874 String filter = null; 875 if (rbAll != null) { 876 if (rbAll.isSelected()) { 877 filter = "all"; 878 } else if (rbUseful.isSelected()) { 879 filter = "useful"; 880 } 881 } 882 if (filter != null) { 883 Main.pref.put("plugin.roadsigns.preset.filter", filter); 884 } 850 885 RoadSignsPlugin.setSelectedPreset(presetsData.get(selectionBox.getSelectedIndex())); 851 886 } -
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsPlugin.java
r29228 r29230 183 183 List<PresetMetaData> presetsData = getAvailablePresetsMetaData(); 184 184 String code = Main.pref.get("plugin.roadsigns.preset.selection", null); 185 if (selectedPreset != null && selectedPreset.code.equals(code)) return;186 185 187 186 for (PresetMetaData data : presetsData) { -
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/RoadSignsReader.java
r23192 r29230 22 22 import org.xml.sax.helpers.DefaultHandler; 23 23 24 import org.openstreetmap.josm.Main; 24 25 import org.openstreetmap.josm.io.OsmDataParsingException; 25 26 import org.openstreetmap.josm.plugins.roadsigns.Sign.SignParameter; 26 27 import org.openstreetmap.josm.plugins.roadsigns.Sign.Tag; 27 import org.openstreetmap.josm.tools.LanguageInfo;28 29 28 import org.openstreetmap.josm.plugins.roadsigns.javacc.ParseException; 30 29 import org.openstreetmap.josm.plugins.roadsigns.javacc.TokenMgrError; 30 import org.openstreetmap.josm.tools.LanguageInfo; 31 31 32 32 /** … … 113 113 114 114 curSign.help = getLocalized(atts, "help"); 115 116 String useful = atts.getValue("useful"); 117 if (useful != null) { 118 curSign.useful = Boolean.parseBoolean(useful); 119 } 115 120 116 121 } else if (curSign != null && qname.equals("tag")) { … … 312 317 factory.newSAXParser().parse(inputSource, parser); 313 318 parser.wireSupplements(); 314 return parser.allSigns; 319 String filterPref = Main.pref.get("plugin.roadsigns.preset.filter"); 320 if (filterPref.equals("useful")) { 321 List<Sign> filtered = new ArrayList<Sign>(); 322 for (Sign s : parser.allSigns) { 323 if (s.isUseful()) { 324 filtered.add(s); 325 } 326 } 327 return filtered; 328 } else { 329 return parser.allSigns; 330 } 315 331 } catch (ParserConfigurationException e) { 316 332 e.printStackTrace(); // broken SAXException chaining -
applications/editors/josm/plugins/roadsigns/src/org/openstreetmap/josm/plugins/roadsigns/Sign.java
r27675 r29230 34 34 public String wiki; 35 35 public String help; 36 public Boolean useful; 36 37 37 38 public JLabel label; // FIXME: don't put gui stuff here … … 120 121 } 121 122 123 public boolean isUseful() { 124 if (useful != null) return useful; 125 return !tags.isEmpty(); 126 } 127 122 128 @Override 123 129 public String toString() {
Note:
See TracChangeset
for help on using the changeset viewer.