Changeset 3388 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-07-27T20:06:29+02:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r3385 r3388 85 85 import org.openstreetmap.josm.actions.search.SearchAction; 86 86 import org.openstreetmap.josm.gui.layer.Layer; 87 import org.openstreetmap.josm.gui.tagging.TaggingPresetSearchAction; 87 88 import org.openstreetmap.josm.tools.Shortcut; 88 89 /** … … 183 184 public final JumpToAction jumpToAct = new JumpToAction(); 184 185 186 public final TaggingPresetSearchAction presetSearchAction = new TaggingPresetSearchAction(); 187 185 188 186 189 /** … … 289 292 } 290 293 294 add(presetsMenu, presetSearchAction); 295 291 296 add(toolsMenu, splitWay); 292 297 add(toolsMenu, combineWay); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r3327 r3388 2 2 package org.openstreetmap.josm.gui.tagging; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr;5 4 import static org.openstreetmap.josm.tools.I18n.tr; 6 5 import static org.openstreetmap.josm.tools.I18n.trc; … … 21 20 import java.util.Arrays; 22 21 import java.util.Collection; 22 import java.util.EnumSet; 23 23 import java.util.HashMap; 24 24 import java.util.LinkedHashMap; … … 70 70 */ 71 71 public class TaggingPreset extends AbstractAction implements MapView.LayerChangeListener { 72 73 public enum PresetType { 74 NODE("Mf_node"), WAY("Mf_way"), RELATION("Mf_relation"), CLOSEDWAY("Mf_closedway"); 75 76 private final String iconName; 77 78 PresetType(String iconName) { 79 this.iconName = iconName; 80 } 81 82 public String getIconName() { 83 return iconName; 84 } 85 86 public String getName() { 87 return name().toLowerCase(); 88 } 89 90 } 72 91 73 92 public TaggingPresetMenu group = null; … … 487 506 488 507 public static class Role { 489 public List<String> types;508 public EnumSet<PresetType> types; 490 509 public String key; 491 510 public String text; … … 545 564 if(types != null){ 546 565 JPanel pp = new JPanel(); 547 for( Stringt : types) {548 pp.add(new JLabel(ImageProvider.get( "Mf_" + t)));566 for(PresetType t : types) { 567 pp.add(new JLabel(ImageProvider.get(t.getIconName()))); 549 568 } 550 569 p.add(pp, GBC.eol()); … … 607 626 * The types as preparsed collection. 608 627 */ 609 public List<String> types;628 public EnumSet<PresetType> types; 610 629 public List<Item> data = new LinkedList<Item>(); 611 630 private static HashMap<String,String> lastValue = new HashMap<String,String>(); … … 669 688 * Called from the XML parser to set the types this preset affects 670 689 */ 671 private static Collection<String> allowedtypes = Arrays.asList(new String[] 672 {marktr("way"), marktr("node"), marktr("relation"), marktr("closedway")}); 673 674 static public List<String> getType(String types) throws SAXException { 675 List<String> t = Arrays.asList(types.split(",")); 676 for (String type : t) { 677 if(!allowedtypes.contains(type)) 690 691 static public EnumSet<PresetType> getType(String types) throws SAXException { 692 EnumSet<PresetType> result = EnumSet.noneOf(PresetType.class); 693 for (String type : Arrays.asList(types.split(","))) { 694 try { 695 PresetType presetType = PresetType.valueOf(type.toUpperCase()); 696 result.add(presetType); 697 } catch (IllegalArgumentException e) { 678 698 throw new SAXException(tr("Unknown type: {0}", type)); 679 } 680 return t; 699 } 700 } 701 return result; 681 702 } 682 703 … … 833 854 if(types != null){ 834 855 JPanel pp = new JPanel(); 835 for( Stringt : types){836 JLabel la = new JLabel(ImageProvider.get( "Mf_" + t));837 la.setToolTipText(tr("Elements of type {0} are supported.", tr(t )));856 for(PresetType t : types){ 857 JLabel la = new JLabel(ImageProvider.get(t.getIconName())); 858 la.setToolTipText(tr("Elements of type {0} are supported.", tr(t.getName()))); 838 859 pp.add(la); 839 860 } … … 953 974 if(osm instanceof Relation) 954 975 { 955 if(!types.contains( "relation")) {976 if(!types.contains(PresetType.RELATION)) { 956 977 continue; 957 978 } … … 959 980 else if(osm instanceof Node) 960 981 { 961 if(!types.contains( "node")) {982 if(!types.contains(PresetType.NODE)) { 962 983 continue; 963 984 } … … 965 986 else if(osm instanceof Way) 966 987 { 967 if(!types.contains( "way") &&968 !(types.contains( "closedway") && ((Way)osm).isClosed())) {988 if(!types.contains(PresetType.WAY) && 989 !(types.contains(PresetType.CLOSEDWAY) && ((Way)osm).isClosed())) { 969 990 continue; 970 991 }
Note:
See TracChangeset
for help on using the changeset viewer.