Changeset 8863 in josm
- Timestamp:
- 2015-10-12T22:58:25+02:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 21 added
- 1 deleted
- 21 edited
- 17 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/taginfoextract.groovy
r8717 r8863 37 37 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser 38 38 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference 39 import org.openstreetmap.josm.gui.tagging.TaggingPreset 40 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems 41 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader 42 import org.openstreetmap.josm.gui.tagging.TaggingPresetType 39 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset 40 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader 41 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType 42 import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem 43 import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem.MatchType 43 44 import org.openstreetmap.josm.io.CachedFile 44 45 import org.openstreetmap.josm.tools.Utils … … 252 253 def tags = [] 253 254 for (TaggingPreset preset : presets) { 254 for ( TaggingPresetItems.KeyedItem item : Utils.filteredCollection(preset.data, TaggingPresetItems.KeyedItem.class)) {255 for (KeyedItem item : Utils.filteredCollection(preset.data, KeyedItem.class)) { 255 256 def values 256 switch ( TaggingPresetItems.MatchType.ofString(item.match)) {257 case TaggingPresetItems.MatchType.KEY_REQUIRED: values = item.getValues(); break;258 case TaggingPresetItems.MatchType.KEY_VALUE_REQUIRED: values = item.getValues(); break;257 switch (MatchType.ofString(item.match)) { 258 case MatchType.KEY_REQUIRED: values = item.getValues(); break; 259 case MatchType.KEY_VALUE_REQUIRED: values = item.getValues(); break; 259 260 default: values = []; 260 261 } … … 463 464 } 464 465 } 465 466 466 } 467 -
trunk/src/org/openstreetmap/josm/Main.java
r8857 r8863 99 99 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor; 100 100 import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor; 101 import org.openstreetmap.josm.gui.tagging. TaggingPresets;101 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 102 102 import org.openstreetmap.josm.gui.util.RedirectInputMap; 103 103 import org.openstreetmap.josm.gui.widgets.JMultilineLabel; -
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r8840 r8863 21 21 import org.openstreetmap.josm.data.validation.Test; 22 22 import org.openstreetmap.josm.data.validation.TestError; 23 import org.openstreetmap.josm.gui.tagging. TaggingPreset;24 import org.openstreetmap.josm.gui.tagging. TaggingPresetItem;25 import org.openstreetmap.josm.gui.tagging. TaggingPresetItems.Key;26 import org.openstreetmap.josm.gui.tagging. TaggingPresetItems.Role;27 import org.openstreetmap.josm.gui.tagging. TaggingPresetItems.Roles;28 import org.openstreetmap.josm.gui.tagging. TaggingPresetType;29 import org.openstreetmap.josm.gui.tagging. TaggingPresets;23 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 24 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 25 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 26 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 27 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 28 import org.openstreetmap.josm.gui.tagging.presets.items.Roles; 29 import org.openstreetmap.josm.gui.tagging.presets.items.Roles.Role; 30 30 import org.openstreetmap.josm.tools.Utils; 31 31 -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r8855 r8863 45 45 import org.openstreetmap.josm.gui.preferences.validator.ValidatorPreference; 46 46 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 47 import org.openstreetmap.josm.gui.tagging. TaggingPreset;48 import org.openstreetmap.josm.gui.tagging. TaggingPresetItem;49 import org.openstreetmap.josm.gui.tagging. TaggingPresetItems.Check;50 import org.openstreetmap.josm.gui.tagging. TaggingPresetItems.CheckGroup;51 import org.openstreetmap.josm.gui.tagging. TaggingPresetItems.KeyedItem;52 import org.openstreetmap.josm.gui.tagging. TaggingPresets;47 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 48 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 49 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 50 import org.openstreetmap.josm.gui.tagging.presets.items.Check; 51 import org.openstreetmap.josm.gui.tagging.presets.items.CheckGroup; 52 import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem; 53 53 import org.openstreetmap.josm.gui.widgets.EditableList; 54 54 import org.openstreetmap.josm.io.CachedFile; -
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r8846 r8863 37 37 import org.openstreetmap.josm.data.osm.history.HistoryRelation; 38 38 import org.openstreetmap.josm.data.osm.history.HistoryWay; 39 import org.openstreetmap.josm.gui.tagging. TaggingPreset;40 import org.openstreetmap.josm.gui.tagging. TaggingPresetNameTemplateList;39 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 40 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetNameTemplateList; 41 41 import org.openstreetmap.josm.tools.AlphanumComparator; 42 42 import org.openstreetmap.josm.tools.I18n; -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r8840 r8863 130 130 import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; 131 131 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 132 import org.openstreetmap.josm.gui.tagging. TaggingPresetSearchAction;133 import org.openstreetmap.josm.gui.tagging. TaggingPresetSearchPrimitiveDialog;132 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSearchAction; 133 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSearchPrimitiveDialog; 134 134 import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField; 135 135 import org.openstreetmap.josm.tools.Shortcut; -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java
r7128 r8863 3 3 4 4 import org.openstreetmap.josm.data.osm.OsmPrimitive; 5 import org.openstreetmap.josm.gui.tagging. PresetHandler;6 import org.openstreetmap.josm.gui.tagging. TaggingPreset;7 import org.openstreetmap.josm.gui.tagging. TaggingPresetType;8 import org.openstreetmap.josm.gui.tagging. PresetLabel;5 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 6 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetLabel; 7 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 8 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 9 9 import org.openstreetmap.josm.tools.GBC; 10 10 … … 34 34 * and associates an interaction with (matching) presets via {@code presetHandler}. 35 35 */ 36 public void updatePresets(final Collection<TaggingPresetType> types, final Map<String, String> tags, final PresetHandler presetHandler) {36 public void updatePresets(final Collection<TaggingPresetType> types, final Map<String, String> tags, final TaggingPresetHandler presetHandler) { 37 37 38 38 removeAll(); … … 43 43 44 44 for (final TaggingPreset t : TaggingPreset.getMatchingPresets(types, tags, true)) { 45 final JLabel lbl = new PresetLabel(t);45 final JLabel lbl = new TaggingPresetLabel(t); 46 46 lbl.addMouseListener(new MouseAdapter() { 47 47 @Override -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r8846 r8863 85 85 import org.openstreetmap.josm.gui.help.HelpUtil; 86 86 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 87 import org.openstreetmap.josm.gui.tagging. PresetHandler;88 import org.openstreetmap.josm.gui.tagging. TaggingPreset;89 import org.openstreetmap.josm.gui.tagging. TaggingPresetType;87 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 88 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 89 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 90 90 import org.openstreetmap.josm.gui.util.GuiHelper; 91 91 import org.openstreetmap.josm.gui.util.HighlightHelper; … … 215 215 + tr("Select objects for which to change tags.") + "</p></html>"); 216 216 217 private final transient PresetHandler presetHandler = newPresetHandler() {217 private final transient TaggingPresetHandler presetHandler = new TaggingPresetHandler() { 218 218 @Override public void updateTags(List<Tag> tags) { 219 219 Command command = TaggingPreset.createCommand(getSelection(), tags); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r8846 r8863 69 69 import org.openstreetmap.josm.gui.ExtendedDialog; 70 70 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 71 import org.openstreetmap.josm.gui.tagging.TaggingPreset;72 71 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 73 72 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 74 73 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 74 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 75 75 import org.openstreetmap.josm.gui.util.GuiHelper; 76 76 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r8855 r8863 79 79 import org.openstreetmap.josm.gui.help.HelpUtil; 80 80 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 81 import org.openstreetmap.josm.gui.tagging.PresetHandler;82 81 import org.openstreetmap.josm.gui.tagging.TagEditorModel; 83 82 import org.openstreetmap.josm.gui.tagging.TagEditorPanel; 84 import org.openstreetmap.josm.gui.tagging.TaggingPreset;85 import org.openstreetmap.josm.gui.tagging.TaggingPresetType;86 83 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 87 84 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 85 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 86 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 87 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 88 88 import org.openstreetmap.josm.io.OnlineResource; 89 89 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 137 137 WindowGeometry.centerInWindow(Main.parent, new Dimension(700, 650))); 138 138 139 final PresetHandler presetHandler = newPresetHandler() {139 final TaggingPresetHandler presetHandler = new TaggingPresetHandler() { 140 140 141 141 @Override -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r8855 r8863 39 39 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionTypeCalculator; 40 40 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 41 import org.openstreetmap.josm.gui.tagging. PresetHandler;42 import org.openstreetmap.josm.gui.tagging. TaggingPreset;43 import org.openstreetmap.josm.gui.tagging. TaggingPresetType;41 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 42 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 43 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 44 44 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel; 45 45 … … 56 56 private final CopyOnWriteArrayList<IMemberModelListener> listeners; 57 57 private final transient OsmDataLayer layer; 58 private final transient PresetHandler presetHandler;58 private final transient TaggingPresetHandler presetHandler; 59 59 60 60 private final transient WayConnectionTypeCalculator wayConnectionTypeCalculator = new WayConnectionTypeCalculator(); … … 64 64 * constructor 65 65 */ 66 public MemberTableModel(OsmDataLayer layer, PresetHandler presetHandler) {66 public MemberTableModel(OsmDataLayer layer, TaggingPresetHandler presetHandler) { 67 67 members = new ArrayList<>(); 68 68 listeners = new CopyOnWriteArrayList<>(); -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r8840 r8863 69 69 import org.openstreetmap.josm.actions.ParameterizedAction; 70 70 import org.openstreetmap.josm.actions.ParameterizedActionDecorator; 71 import org.openstreetmap.josm.gui.tagging. TaggingPreset;71 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 72 72 import org.openstreetmap.josm.tools.GBC; 73 73 import org.openstreetmap.josm.tools.ImageProvider; -
trunk/src/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreference.java
r8836 r8863 28 28 import org.openstreetmap.josm.gui.preferences.SourceEditor; 29 29 import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry; 30 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; 30 31 import org.openstreetmap.josm.gui.preferences.SourceEntry; 31 32 import org.openstreetmap.josm.gui.preferences.SourceProvider; … … 33 34 import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting; 34 35 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 35 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader;36 36 import org.openstreetmap.josm.tools.GBC; 37 37 import org.xml.sax.SAXException; -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorPanel.java
r8760 r8863 23 23 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 24 24 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 25 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 26 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 25 27 import org.openstreetmap.josm.tools.CheckParameterUtil; 26 28 … … 39 41 40 42 private PresetListPanel presetListPanel; 41 private final transient PresetHandler presetHandler;43 private final transient TaggingPresetHandler presetHandler; 42 44 43 45 /** … … 140 142 * internally and can be retrieved with {@link #getModel()}. 141 143 */ 142 public TagEditorPanel( PresetHandler presetHandler) {144 public TagEditorPanel(TaggingPresetHandler presetHandler) { 143 145 this(null, presetHandler, 0); 144 146 } … … 151 153 * @param maxCharacters maximum number of characters allowed, 0 for unlimited 152 154 */ 153 public TagEditorPanel(TagEditorModel model, PresetHandler presetHandler, final int maxCharacters) {155 public TagEditorPanel(TagEditorModel model, TaggingPresetHandler presetHandler, final int maxCharacters) { 154 156 this.model = model; 155 157 this.presetHandler = presetHandler; -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java
r8786 r8863 28 28 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 29 29 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 30 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 31 import org.openstreetmap.josm.gui.tagging.TaggingPresetItem; 32 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems; 33 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Role; 30 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 31 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 32 import org.openstreetmap.josm.gui.tagging.presets.items.CheckGroup; 33 import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem; 34 import org.openstreetmap.josm.gui.tagging.presets.items.Roles; 35 import org.openstreetmap.josm.gui.tagging.presets.items.Roles.Role; 34 36 import org.openstreetmap.josm.tools.CheckParameterUtil; 35 37 import org.openstreetmap.josm.tools.MultiMap; … … 216 218 217 219 protected static void cachePresetItem(TaggingPreset p, TaggingPresetItem item) { 218 if (item instanceof TaggingPresetItems.KeyedItem) {219 TaggingPresetItems.KeyedItem ki = (TaggingPresetItems.KeyedItem) item;220 if (item instanceof KeyedItem) { 221 KeyedItem ki = (KeyedItem) item; 220 222 if (ki.key != null && ki.getValues() != null) { 221 223 try { … … 225 227 } 226 228 } 227 } else if (item instanceof TaggingPresetItems.Roles) {228 TaggingPresetItems.Roles r = (TaggingPresetItems.Roles) item;229 for ( TaggingPresetItems.Role i : r.roles) {229 } else if (item instanceof Roles) { 230 Roles r = (Roles) item; 231 for (Role i : r.roles) { 230 232 if (i.key != null) { 231 233 PRESET_ROLE_CACHE.add(i.key); 232 234 } 233 235 } 234 } else if (item instanceof TaggingPresetItems.CheckGroup) {235 for ( TaggingPresetItems.KeyedItem check : ((TaggingPresetItems.CheckGroup) item).checks) {236 } else if (item instanceof CheckGroup) { 237 for (KeyedItem check : ((CheckGroup) item).checks) { 236 238 cachePresetItem(p, check); 237 239 } -
trunk/src/org/openstreetmap/josm/gui/tagging/package-info.java
r8624 r8863 2 2 3 3 /** 4 * Provides classes for handling edition of OSM tags: tag ging presets, tagtables, tag editors.5 * Autocompletion of tags isdealt with a subpackage.4 * Provides classes for handling edition of OSM tags: tag tables, tag editors. 5 * Autocompletion of tags and tagging presets are dealt with a subpackage. 6 6 */ 7 7 package org.openstreetmap.josm.gui.tagging; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 48 48 import org.openstreetmap.josm.gui.layer.Layer; 49 49 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 50 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Link; 51 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.PresetLink; 52 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Role; 53 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Roles; 50 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 51 import org.openstreetmap.josm.gui.tagging.presets.items.Label; 52 import org.openstreetmap.josm.gui.tagging.presets.items.Link; 53 import org.openstreetmap.josm.gui.tagging.presets.items.Optional; 54 import org.openstreetmap.josm.gui.tagging.presets.items.PresetLink; 55 import org.openstreetmap.josm.gui.tagging.presets.items.Roles; 56 import org.openstreetmap.josm.gui.tagging.presets.items.Roles.Role; 57 import org.openstreetmap.josm.gui.tagging.presets.items.Space; 54 58 import org.openstreetmap.josm.gui.util.GuiHelper; 55 59 import org.openstreetmap.josm.tools.GBC; … … 77 81 public static final int DIALOG_ANSWER_CANCEL = 3; 78 82 83 public static final String OPTIONAL_TOOLTIP_TEXT = "Optional tooltip text"; 84 79 85 public TaggingPresetMenu group; 80 86 public String name; … … 83 89 public String locale_name; 84 90 public boolean preset_name_label; 85 public static final String OPTIONAL_TOOLTIP_TEXT = "Optional tooltip text";86 91 87 92 /** … … 93 98 public transient TemplateEntry nameTemplate; 94 99 public transient Match nameTemplateFilter; 100 101 /** 102 * True whenever the original selection given into createSelection was empty 103 */ 104 private boolean originalSelectionEmpty; 95 105 96 106 /** … … 118 128 if (locale_name == null) { 119 129 if (name_context != null) { 120 locale_name = trc(name_context, TaggingPresetItem s.fixPresetString(name));130 locale_name = trc(name_context, TaggingPresetItem.fixPresetString(name)); 121 131 } else { 122 locale_name = tr(TaggingPresetItem s.fixPresetString(name));132 locale_name = tr(TaggingPresetItem.fixPresetString(name)); 123 133 } 124 134 } … … 190 200 */ 191 201 public void setType(String types) throws SAXException { 192 this.types = TaggingPresetItem s.getType(types);202 this.types = TaggingPresetItem.getType(types); 193 203 } 194 204 … … 235 245 } 236 246 if (preset_name_label) { 237 TaggingPresetItems.Label.addLabel(p, getIcon(), getName());247 Label.addLabel(p, getIcon(), getName()); 238 248 } 239 249 … … 279 289 public boolean isShowable() { 280 290 for (TaggingPresetItem i : data) { 281 if (!(i instanceof TaggingPresetItems.Optional || i instanceof TaggingPresetItems.Space || i instanceof TaggingPresetItems.Key))291 if (!(i instanceof Optional || i instanceof Space || i instanceof Key)) 282 292 return true; 283 293 } … … 412 422 413 423 /** 414 * True whenever the original selection given into createSelection was empty415 */416 private boolean originalSelectionEmpty;417 418 /**419 424 * Removes all unsuitable OsmPrimitives from the given list 420 425 * @param participants List of possible OsmPrimitives to tag -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetHandler.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import java.util.Collection; … … 8 8 import org.openstreetmap.josm.data.osm.Tag; 9 9 10 public interface PresetHandler {10 public interface TaggingPresetHandler { 11 11 Collection<OsmPrimitive> getSelection(); 12 12 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.tools.I18n.trc; 6 7 import java.io.File; 4 8 import java.util.Arrays; 5 9 import java.util.Collection; 10 import java.util.EnumSet; 11 import java.util.LinkedHashMap; 6 12 import java.util.List; 7 13 import java.util.Map; 14 import java.util.Set; 8 15 16 import javax.swing.ImageIcon; 9 17 import javax.swing.JPanel; 10 18 … … 15 23 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 16 24 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 25 import org.openstreetmap.josm.tools.ImageProvider; 26 import org.xml.sax.SAXException; 17 27 18 28 /** … … 21 31 */ 22 32 public abstract class TaggingPresetItem { 33 34 // cache the parsing of types using a LRU cache (http://java-planet.blogspot.com/2005/08/how-to-set-up-simple-lru-cache-using.html) 35 private static final Map<String, Set<TaggingPresetType>> TYPE_CACHE = new LinkedHashMap<>(16, 1.1f, true); 23 36 24 37 protected void initAutoCompletionField(AutoCompletingTextField field, String... key) { … … 47 60 * @return {@code true} if this item adds semantic tagging elements, {@code false} otherwise. 48 61 */ 49 abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches);62 protected abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches); 50 63 51 64 /** … … 53 66 * @param changedTags The list of changed tags to modify if needed 54 67 */ 55 abstract void addCommands(List<Tag> changedTags); 56 57 boolean requestFocusInWindow() { 58 return false; 59 } 68 protected abstract void addCommands(List<Tag> changedTags); 60 69 61 70 /** … … 65 74 * @return {@code true} if matches (positive), {@code null} if neutral, {@code false} if mismatches (negative). 66 75 */ 67 Boolean matches(Map<String, String> tags) {76 protected Boolean matches(Map<String, String> tags) { 68 77 return null; 69 78 } 79 80 protected static Set<TaggingPresetType> getType(String types) throws SAXException { 81 if (types == null || types.isEmpty()) { 82 throw new SAXException(tr("Unknown type: {0}", types)); 83 } 84 if (TYPE_CACHE.containsKey(types)) 85 return TYPE_CACHE.get(types); 86 Set<TaggingPresetType> result = EnumSet.noneOf(TaggingPresetType.class); 87 for (String type : Arrays.asList(types.split(","))) { 88 try { 89 TaggingPresetType presetType = TaggingPresetType.fromString(type); 90 result.add(presetType); 91 } catch (IllegalArgumentException e) { 92 throw new SAXException(tr("Unknown type: {0}", type), e); 93 } 94 } 95 TYPE_CACHE.put(types, result); 96 return result; 97 } 98 99 protected static String fixPresetString(String s) { 100 return s == null ? s : s.replaceAll("'", "''"); 101 } 102 103 protected static String getLocaleText(String text, String text_context, String defaultText) { 104 if (text == null) { 105 return defaultText; 106 } else if (text_context != null) { 107 return trc(text_context, fixPresetString(text)); 108 } else { 109 return tr(fixPresetString(text)); 110 } 111 } 112 113 protected static Integer parseInteger(String str) { 114 if (str == null || str.isEmpty()) 115 return null; 116 try { 117 return Integer.valueOf(str); 118 } catch (Exception e) { 119 if (Main.isTraceEnabled()) { 120 Main.trace(e.getMessage()); 121 } 122 } 123 return null; 124 } 125 126 protected static ImageIcon loadImageIcon(String iconName, File zipIcons, Integer maxSize) { 127 final Collection<String> s = Main.pref.getCollection("taggingpreset.icon.sources", null); 128 ImageProvider imgProv = new ImageProvider(iconName).setDirs(s).setId("presets").setArchive(zipIcons).setOptional(true); 129 if (maxSize != null) { 130 imgProv.setMaxSize(maxSize); 131 } 132 return imgProv.get(); 133 } 70 134 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetLabel.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import java.awt.Cursor; … … 11 11 import javax.swing.JLabel; 12 12 13 public class PresetLabel extends JLabel {13 public class TaggingPresetLabel extends JLabel { 14 14 15 15 protected final TaggingPreset t; … … 19 19 * @param t the tagging preset 20 20 */ 21 public PresetLabel(TaggingPreset t) {21 public TaggingPresetLabel(TaggingPreset t) { 22 22 super(t.getName() + " …"); 23 23 setIcon(t.getIcon()); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetListener.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 /** -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetMenu.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetNameTemplateList.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import java.util.Collection; … … 17 17 private static TaggingPresetNameTemplateList instance; 18 18 19 private final List<TaggingPreset> presetsWithPattern = new LinkedList<>(); 20 19 21 /** 20 22 * Replies the unique instance. … … 28 30 return instance; 29 31 } 30 31 private final List<TaggingPreset> presetsWithPattern = new LinkedList<>();32 32 33 33 private TaggingPresetNameTemplateList() { -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReader.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 26 26 import org.openstreetmap.josm.Main; 27 27 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 28 import org.openstreetmap.josm.gui.tagging.presets.items.Check; 29 import org.openstreetmap.josm.gui.tagging.presets.items.CheckGroup; 30 import org.openstreetmap.josm.gui.tagging.presets.items.Combo; 31 import org.openstreetmap.josm.gui.tagging.presets.items.ComboMultiSelect; 32 import org.openstreetmap.josm.gui.tagging.presets.items.ItemSeparator; 33 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 34 import org.openstreetmap.josm.gui.tagging.presets.items.Label; 35 import org.openstreetmap.josm.gui.tagging.presets.items.Link; 36 import org.openstreetmap.josm.gui.tagging.presets.items.MultiSelect; 37 import org.openstreetmap.josm.gui.tagging.presets.items.Optional; 38 import org.openstreetmap.josm.gui.tagging.presets.items.PresetLink; 39 import org.openstreetmap.josm.gui.tagging.presets.items.Roles; 40 import org.openstreetmap.josm.gui.tagging.presets.items.Roles.Role; 41 import org.openstreetmap.josm.gui.tagging.presets.items.Space; 42 import org.openstreetmap.josm.gui.tagging.presets.items.Text; 28 43 import org.openstreetmap.josm.io.CachedFile; 29 44 import org.openstreetmap.josm.io.UTFInputStreamReader; … … 46 61 "application/xml, text/xml, text/plain; q=0.8, application/zip, application/octet-stream; q=0.5"; 47 62 48 private TaggingPresetReader() {49 // Hide default constructor for utils classes50 }51 52 63 private static volatile File zipIcons; 53 64 private static volatile boolean loadIcons = true; 54 55 /**56 * Returns the set of preset source URLs.57 * @return The set of preset source URLs.58 */59 public static Set<String> getPresetSources() {60 return new TaggingPresetPreference.PresetPrefHelper().getActiveUrls();61 }62 65 63 66 /** … … 75 78 /** Reference matching a chunk id defined earlier **/ 76 79 public String ref; 80 } 81 82 static class HashSetWithLast<E> extends LinkedHashSet<E> { 83 protected E last; 84 85 @Override 86 public boolean add(E e) { 87 last = e; 88 return super.add(e); 89 } 90 91 /** 92 * Returns the last inserted element. 93 */ 94 public E getLast() { 95 return last; 96 } 97 } 98 99 /** 100 * Returns the set of preset source URLs. 101 * @return The set of preset source URLs. 102 */ 103 public static Set<String> getPresetSources() { 104 return new TaggingPresetPreference.PresetPrefHelper().getActiveUrls(); 77 105 } 78 106 … … 82 110 parser.mapOnStart("separator", TaggingPresetSeparator.class); 83 111 parser.mapBoth("group", TaggingPresetMenu.class); 84 parser.map("text", T aggingPresetItems.Text.class);85 parser.map("link", TaggingPresetItems.Link.class);86 parser.map("preset_link", TaggingPresetItems.PresetLink.class);87 parser.mapOnStart("optional", TaggingPresetItems.Optional.class);88 parser.mapOnStart("roles", TaggingPresetItems.Roles.class);89 parser.map("role", TaggingPresetItems.Role.class);90 parser.map("checkgroup", TaggingPresetItems.CheckGroup.class);91 parser.map("check", TaggingPresetItems.Check.class);92 parser.map("combo", TaggingPresetItems.Combo.class);93 parser.map("multiselect", TaggingPresetItems.MultiSelect.class);94 parser.map("label", TaggingPresetItems.Label.class);95 parser.map("space", TaggingPresetItems.Space.class);96 parser.map("key", TaggingPresetItems.Key.class);97 parser.map("list_entry", TaggingPresetItems.PresetListEntry.class);98 parser.map("item_separator", TaggingPresetItems.ItemSeparator.class);112 parser.map("text", Text.class); 113 parser.map("link", Link.class); 114 parser.map("preset_link", PresetLink.class); 115 parser.mapOnStart("optional", Optional.class); 116 parser.mapOnStart("roles", Roles.class); 117 parser.map("role", Role.class); 118 parser.map("checkgroup", CheckGroup.class); 119 parser.map("check", Check.class); 120 parser.map("combo", Combo.class); 121 parser.map("multiselect", MultiSelect.class); 122 parser.map("label", Label.class); 123 parser.map("space", Space.class); 124 parser.map("key", Key.class); 125 parser.map("list_entry", ComboMultiSelect.PresetListEntry.class); 126 parser.map("item_separator", ItemSeparator.class); 99 127 parser.mapBoth("chunk", Chunk.class); 100 128 parser.map("reference", Reference.class); 101 129 return parser; 102 }103 104 static class HashSetWithLast<E> extends LinkedHashSet<E> {105 protected E last;106 107 @Override108 public boolean add(E e) {109 last = e;110 return super.add(e);111 }112 113 /**114 * Returns the last inserted element.115 */116 public E getLast() {117 return last;118 }119 130 } 120 131 … … 145 156 /** to detect end of reused {@code <group>} */ 146 157 TaggingPresetMenu lastmenuOriginal = null; 147 TaggingPresetItems.Roles lastrole = null;148 final List< TaggingPresetItems.Check> checks = new LinkedList<>();149 List< TaggingPresetItems.PresetListEntry> listEntries = new LinkedList<>();158 Roles lastrole = null; 159 final List<Check> checks = new LinkedList<>(); 160 List<ComboMultiSelect.PresetListEntry> listEntries = new LinkedList<>(); 150 161 final Map<String, List<Object>> byId = new HashMap<>(); 151 162 final Deque<String> lastIds = new ArrayDeque<>(); … … 238 249 } else { 239 250 if (!all.isEmpty()) { 240 if (o instanceof TaggingPresetItems.Roles) {251 if (o instanceof Roles) { 241 252 all.getLast().data.add((TaggingPresetItem) o); 242 253 if (all.getLast().roles != null) { 243 254 throw new SAXException(tr("Roles cannot appear more than once")); 244 255 } 245 all.getLast().roles = ( TaggingPresetItems.Roles) o;246 lastrole = ( TaggingPresetItems.Roles) o;247 } else if (o instanceof TaggingPresetItems.Role) {256 all.getLast().roles = (Roles) o; 257 lastrole = (Roles) o; 258 } else if (o instanceof Role) { 248 259 if (lastrole == null) 249 260 throw new SAXException(tr("Preset role element without parent")); 250 lastrole.roles.add(( TaggingPresetItems.Role) o);251 } else if (o instanceof TaggingPresetItems.Check) {252 checks.add(( TaggingPresetItems.Check) o);253 } else if (o instanceof TaggingPresetItems.PresetListEntry) {254 listEntries.add(( TaggingPresetItems.PresetListEntry) o);255 } else if (o instanceof TaggingPresetItems.CheckGroup) {261 lastrole.roles.add((Role) o); 262 } else if (o instanceof Check) { 263 checks.add((Check) o); 264 } else if (o instanceof ComboMultiSelect.PresetListEntry) { 265 listEntries.add((ComboMultiSelect.PresetListEntry) o); 266 } else if (o instanceof CheckGroup) { 256 267 all.getLast().data.add((TaggingPresetItem) o); 257 268 // Make sure list of checks is empty to avoid adding checks several times 258 269 // when used in chunks (fix #10801) 259 (( TaggingPresetItems.CheckGroup) o).checks.clear();260 (( TaggingPresetItems.CheckGroup) o).checks.addAll(checks);270 ((CheckGroup) o).checks.clear(); 271 ((CheckGroup) o).checks.addAll(checks); 261 272 checks.clear(); 262 273 } else { … … 266 277 } 267 278 all.getLast().data.add((TaggingPresetItem) o); 268 if (o instanceof TaggingPresetItems.ComboMultiSelect) {269 (( TaggingPresetItems.ComboMultiSelect) o).addListEntries(listEntries);270 } else if (o instanceof TaggingPresetItems.Key) {271 if ((( TaggingPresetItems.Key) o).value == null) {272 (( TaggingPresetItems.Key) o).value = ""; // Fix #8530279 if (o instanceof ComboMultiSelect) { 280 ((ComboMultiSelect) o).addListEntries(listEntries); 281 } else if (o instanceof Key) { 282 if (((Key) o).value == null) { 283 ((Key) o).value = ""; // Fix #8530 273 284 } 274 285 } … … 403 414 TaggingPresetReader.loadIcons = loadIcons; 404 415 } 416 417 private TaggingPresetReader() { 418 // Hide default constructor for utils classes 419 } 405 420 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchAction.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchDialog.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 17 17 public final class TaggingPresetSearchDialog extends ExtendedDialog { 18 18 19 private static TaggingPresetSearchDialog instance; 20 19 21 private TaggingPresetSelector selector; 20 21 private static TaggingPresetSearchDialog instance;22 22 23 23 /** -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSearchPrimitiveDialog.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 19 19 /** 20 20 * A dialog that allows to select a preset and then selects all matching OSM objects. 21 * @see org.openstreetmap.josm.gui.tagging. TaggingPresetSearchDialog21 * @see org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSearchDialog 22 22 */ 23 23 public final class TaggingPresetSearchPrimitiveDialog extends ExtendedDialog { 24 24 25 private static TaggingPresetSearchPrimitiveDialog instance; 26 25 27 private TaggingPresetSelector selector; 26 28 27 private static TaggingPresetSearchPrimitiveDialog instance; 29 /** 30 * An action executing {@link TaggingPresetSearchPrimitiveDialog}. 31 */ 32 public static class Action extends JosmAction { 33 34 /** 35 * Constructs a new {@link TaggingPresetSearchPrimitiveDialog.Action}. 36 */ 37 public Action() { 38 super(tr("Search for objects by preset"), "dialogs/search", tr("Show preset search dialog"), 39 Shortcut.registerShortcut("preset:search-objects", tr("Search for objects by preset"), KeyEvent.VK_F3, Shortcut.SHIFT), 40 false); 41 putValue("toolbar", "presets/search-objects"); 42 Main.toolbar.register(this); 43 } 44 45 @Override 46 public void actionPerformed(ActionEvent e) { 47 if (Main.main.hasEditLayer()) { 48 TaggingPresetSearchPrimitiveDialog.getInstance().showDialog(); 49 } 50 } 51 } 28 52 29 53 /** … … 69 93 } 70 94 } 71 72 /**73 * An action executing {@link TaggingPresetSearchPrimitiveDialog}.74 */75 public static class Action extends JosmAction {76 77 /**78 * Constructs a new {@link TaggingPresetSearchPrimitiveDialog.Action}.79 */80 public Action() {81 super(tr("Search for objects by preset"), "dialogs/search", tr("Show preset search dialog"),82 Shortcut.registerShortcut("preset:search-objects", tr("Search for objects by preset"), KeyEvent.VK_F3, Shortcut.SHIFT),83 false);84 putValue("toolbar", "presets/search-objects");85 Main.toolbar.register(this);86 }87 88 @Override89 public void actionPerformed(ActionEvent e) {90 if (Main.main.hasEditLayer()) {91 TaggingPresetSearchPrimitiveDialog.getInstance().showDialog();92 }93 }94 }95 96 95 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 49 49 import org.openstreetmap.josm.data.osm.OsmPrimitive; 50 50 import org.openstreetmap.josm.data.preferences.BooleanProperty; 51 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Key; 52 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.KeyedItem; 53 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Role; 54 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems.Roles; 51 import org.openstreetmap.josm.gui.tagging.presets.items.ComboMultiSelect; 52 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 53 import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem; 54 import org.openstreetmap.josm.gui.tagging.presets.items.Roles; 55 import org.openstreetmap.josm.gui.tagging.presets.items.Roles.Role; 55 56 import org.openstreetmap.josm.gui.widgets.JosmTextField; 56 57 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; … … 125 126 * Computes the match ration of a {@link TaggingPreset} wrt. a searchString. 126 127 */ 127 static class PresetClassification implements Comparable<PresetClassification> {128 public static class PresetClassification implements Comparable<PresetClassification> { 128 129 public final TaggingPreset preset; 129 130 public int classification; … … 144 145 if (item instanceof KeyedItem) { 145 146 tags.add(((KeyedItem) item).key); 146 if (item instanceof TaggingPresetItems.ComboMultiSelect) {147 final TaggingPresetItems.ComboMultiSelect cms = (TaggingPresetItems.ComboMultiSelect) item;147 if (item instanceof ComboMultiSelect) { 148 final ComboMultiSelect cms = (ComboMultiSelect) item; 148 149 if (Boolean.parseBoolean(cms.values_searchable)) { 149 150 tags.addAll(cms.getDisplayValues()); … … 366 367 * A collection of {@link PresetClassification}s with the functionality of filtering wrt. searchString. 367 368 */ 368 static class PresetClassifications implements Iterable<PresetClassification> {369 public static class PresetClassifications implements Iterable<PresetClassification> { 369 370 370 371 private final List<PresetClassification> classifications = new ArrayList<>(); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSeparator.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 /** -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetType.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import org.openstreetmap.josm.data.osm.OsmPrimitive; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import java.util.ArrayList; -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/ConditionalKeysTest.groovy
r7938 r8863 3 3 4 4 import org.openstreetmap.josm.JOSMFixture 5 import org.openstreetmap.josm.gui.tagging. TaggingPresets5 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 6 6 7 7 class ConditionalKeysTest extends GroovyTestCase { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java
r8857 r8863 21 21 import org.openstreetmap.josm.data.osm.Tag; 22 22 import org.openstreetmap.josm.data.validation.Severity; 23 import org.openstreetmap.josm.gui.tagging. TaggingPreset;24 import org.openstreetmap.josm.gui.tagging. TaggingPresetItem;25 import org.openstreetmap.josm.gui.tagging. TaggingPresetItems;26 import org.openstreetmap.josm.gui.tagging. TaggingPresetReader;23 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 24 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 25 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; 26 import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem; 27 27 28 28 /** … … 213 213 for (final TaggingPreset p : presets) { 214 214 for (final TaggingPresetItem i : p.data) { 215 if (i instanceof TaggingPresetItems.KeyedItem &&216 Arrays.asList("opening_hours", "service_times", "collection_times").contains((( TaggingPresetItems.KeyedItem) i).key)) {217 for (final String v : (( TaggingPresetItems.KeyedItem) i).getValues()) {218 values.add(new Tag((( TaggingPresetItems.KeyedItem) i).key, v));215 if (i instanceof KeyedItem && 216 Arrays.asList("opening_hours", "service_times", "collection_times").contains(((KeyedItem) i).key)) { 217 for (final String v : ((KeyedItem) i).getValues()) { 218 values.add(new Tag(((KeyedItem) i).key, v)); 219 219 } 220 220 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/RelationCheckerTest.groovy
r7938 r8863 9 9 import org.openstreetmap.josm.data.osm.Way 10 10 import org.openstreetmap.josm.data.validation.TestError 11 import org.openstreetmap.josm.gui.tagging. TaggingPresets11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 12 12 13 13 class RelationCheckerTest extends GroovyTestCase { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r8857 r8863 13 13 import org.openstreetmap.josm.data.osm.OsmUtils; 14 14 import org.openstreetmap.josm.data.validation.TestError; 15 import org.openstreetmap.josm.gui.tagging. TaggingPresets;15 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 16 16 17 17 /** -
trunk/test/unit/org/openstreetmap/josm/gui/DefaultNameFormatterTest.java
r8857 r8863 20 20 import org.openstreetmap.josm.data.osm.Relation; 21 21 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.gui.tagging. TaggingPresetReader;23 import org.openstreetmap.josm.gui.tagging. TaggingPresets;22 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; 23 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 24 24 import org.openstreetmap.josm.io.Compression; 25 25 import org.openstreetmap.josm.io.IllegalDataException; -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/PresetClassificationsTest.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import static org.junit.Assert.assertFalse; … … 18 18 import org.openstreetmap.josm.data.osm.OsmUtils; 19 19 import org.openstreetmap.josm.data.osm.Way; 20 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassification; 21 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassifications; 20 22 import org.openstreetmap.josm.tools.Utils; 21 23 import org.xml.sax.SAXException; 22 24 25 /** 26 * Unit tests of {@link PresetClassifications} class. 27 */ 23 28 public class PresetClassificationsTest { 24 29 25 static final TaggingPresetSelector.PresetClassifications classifications = new TaggingPresetSelector.PresetClassifications();30 static final PresetClassifications classifications = new PresetClassifications(); 26 31 27 32 /** 28 33 * Setup test. 34 * @throws SAXException if any XML error occurs 35 * @throws IOException if any I/O error occurs 29 36 */ 30 37 @BeforeClass … … 35 42 } 36 43 37 private List< TaggingPresetSelector.PresetClassification> getMatchingPresets(String searchText, OsmPrimitive w) {44 private List<PresetClassification> getMatchingPresets(String searchText, OsmPrimitive w) { 38 45 return classifications.getMatchingPresets(searchText, true, true, EnumSet.of(TaggingPresetType.forPrimitive(w)), 39 46 Collections.singleton(w)); … … 41 48 42 49 private List<String> getMatchingPresetNames(String searchText, OsmPrimitive w) { 43 return Utils.transform(getMatchingPresets(searchText, w), new Utils.Function< TaggingPresetSelector.PresetClassification, String>() {50 return Utils.transform(getMatchingPresets(searchText, w), new Utils.Function<PresetClassification, String>() { 44 51 @Override 45 public String apply( TaggingPresetSelector.PresetClassification x) {52 public String apply(PresetClassification x) { 46 53 return x.preset.name; 47 54 } … … 49 56 } 50 57 58 /** 59 * Test building preset. 60 */ 51 61 @Test 52 public void testBuilding() throws Exception{62 public void testBuilding() { 53 63 final Way w = new Way(); 54 64 final Node n1 = new Node(); … … 61 71 } 62 72 73 /** 74 * Test public transport tram relations presets. 75 */ 63 76 @Test 64 77 public void testRelationsForTram() { -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java
r8862 r8863 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.tagging ;2 package org.openstreetmap.josm.gui.tagging.presets; 3 3 4 4 import static org.CustomMatchers.hasSize; … … 15 15 import org.openstreetmap.josm.JOSMFixture; 16 16 import org.openstreetmap.josm.TestUtils; 17 import org.openstreetmap.josm.gui.tagging.presets.items.Check; 18 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 17 19 import org.openstreetmap.josm.tools.Utils; 18 20 import org.xml.sax.SAXException; … … 33 35 /** 34 36 * #8954 - last checkbox in the preset is not added 37 * @throws SAXException if any XML error occurs 38 * @throws IOException if any I/O error occurs 35 39 */ 36 40 @Test … … 42 46 Assert.assertEquals("Number of entries", 1, preset.data.size()); 43 47 final TaggingPresetItem item = preset.data.get(0); 44 Assert.assertTrue("Entry is not checkbox", item instanceof TaggingPresetItems.Check);48 Assert.assertTrue("Entry is not checkbox", item instanceof Check); 45 49 } 46 50 51 /** 52 * Test nested chunks 53 * @throws SAXException if any XML error occurs 54 * @throws IOException if any I/O error occurs 55 */ 47 56 @Test 48 public void testNestedChunks() throws Exception {57 public void testNestedChunks() throws SAXException, IOException { 49 58 final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(TestUtils.getTestDataRoot() + "preset_chunk.xml", true); 50 59 assertThat(presets, hasSize(1)); … … 53 62 @Override 54 63 public String apply(TaggingPresetItem x) { 55 return (( TaggingPresetItems.Key) x).key;64 return ((Key) x).key; 56 65 } 57 66 }); … … 62 71 * Validate internal presets 63 72 * See #9027 73 * @throws SAXException if any XML error occurs 74 * @throws IOException if any I/O error occurs 64 75 */ 65 76 @Test
Note:
See TracChangeset
for help on using the changeset viewer.