- Timestamp:
- 2021-03-20T23:07:02+01:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging/presets
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r17606 r17609 329 329 330 330 boolean presetInitiallyMatches = !selected.isEmpty() && selected.stream().allMatch(this); 331 final TaggingPresetItemGuiSupport itemGuiSupport = TaggingPresetItemGuiSupport.create(presetInitiallyMatches, selected); 331 332 JPanel items = new JPanel(new GridBagLayout()); 332 333 TaggingPresetItem previous = null; … … 342 343 } 343 344 } 344 if (i.addToPanel(items, selected, presetInitiallyMatches)) {345 if (i.addToPanel(items, itemGuiSupport)) { 345 346 p.hasElements = true; 346 347 } … … 355 356 // add Link 356 357 for (Link link : l) { 357 link.addToPanel(p, selected, presetInitiallyMatches);358 link.addToPanel(p, itemGuiSupport); 358 359 } 359 360 … … 674 675 return iconFuture; 675 676 } 677 676 678 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java
r16690 r17609 57 57 * 58 58 * @param p The panel where components must be added 59 * @param sel The related selected OSM primitives 60 * @param presetInitiallyMatches Whether this {@link TaggingPreset} already matched before applying, 61 * i.e. whether the map feature already existed on the primitive. 59 * @param support supporting class for creating the GUI 62 60 * @return {@code true} if this item adds semantic tagging elements, {@code false} otherwise. 63 61 */ 64 protected abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches);62 protected abstract boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support); 65 63 66 64 /** -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Check.java
r17607 r17609 16 16 import org.openstreetmap.josm.data.osm.OsmUtils; 17 17 import org.openstreetmap.josm.data.osm.Tag; 18 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 18 19 import org.openstreetmap.josm.gui.widgets.QuadStateCheckBox; 19 20 import org.openstreetmap.josm.tools.GBC; … … 38 39 39 40 @Override 40 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {41 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 41 42 42 43 // find out if our key is already used in the selection. 43 final Usage usage = determineBooleanUsage(s el, key);44 final Usage usage = determineBooleanUsage(support.getSelected(), key); 44 45 final String oneValue = usage.values.isEmpty() ? null : usage.values.last(); 45 46 def = "on".equals(default_) ? Boolean.TRUE : "off".equals(default_) ? Boolean.FALSE : null; … … 50 51 if (def != null && !PROP_FILL_DEFAULT.get()) { 51 52 // default is set and filling default values feature is disabled - check if all primitives are untagged 52 for (OsmPrimitive s : s el) {53 for (OsmPrimitive s : support.getSelected()) { 53 54 if (s.hasKeys()) { 54 55 def = null; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/CheckGroup.java
r16042 r17609 3 3 4 4 import java.awt.GridLayout; 5 import java.util.Collection;6 5 import java.util.LinkedList; 7 6 import java.util.List; … … 10 9 import javax.swing.JPanel; 11 10 12 import org.openstreetmap.josm.data.osm.OsmPrimitive;13 11 import org.openstreetmap.josm.data.osm.Tag; 14 12 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 13 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 15 14 import org.openstreetmap.josm.tools.GBC; 16 15 … … 32 31 33 32 @Override 34 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {33 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 35 34 int rows = (int) Math.ceil(checks.size() / ((double) columns)); 36 35 JPanel panel = new JPanel(new GridLayout(rows, columns)); 37 36 38 37 for (Check check : checks) { 39 check.addToPanel(panel, s el, presetInitiallyMatches);38 check.addToPanel(panel, support); 40 39 } 41 40 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
r17605 r17609 28 28 import javax.swing.ListCellRenderer; 29 29 30 import org.openstreetmap.josm.data.osm.OsmPrimitive;31 30 import org.openstreetmap.josm.data.osm.Tag; 31 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 32 32 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector; 33 33 import org.openstreetmap.josm.spi.preferences.Config; … … 206 206 207 207 @Override 208 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {208 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 209 209 initListEntries(true); 210 210 211 211 // find out if our key is already used in the selection. 212 usage = determineTextUsage(s el, key);212 usage = determineTextUsage(support.getSelected(), key); 213 213 if (!usage.hasUniqueValue() && !usage.unused()) { 214 214 presetListEntries.add(new PresetListEntry(DIFFERENT)); … … 220 220 label.setComponentPopupMenu(getPopupMenu()); 221 221 p.add(label, GBC.std().insets(0, 0, 10, 0)); 222 addToPanelAnchor(p, default_, presetInitiallyMatches);222 addToPanelAnchor(p, default_, support.isPresetInitiallyMatches()); 223 223 label.setLabelFor(component); 224 224 component.setToolTipText(getKeyTooltipText()); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ItemSeparator.java
r9665 r17609 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import java.util.Collection;5 4 import java.util.List; 6 5 … … 8 7 import javax.swing.JSeparator; 9 8 10 import org.openstreetmap.josm.data.osm.OsmPrimitive;11 9 import org.openstreetmap.josm.data.osm.Tag; 12 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 13 12 import org.openstreetmap.josm.tools.GBC; 14 13 … … 20 19 21 20 @Override 22 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {21 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 23 22 p.add(new JSeparator(), GBC.eol().fill(GBC.HORIZONTAL).insets(0, 5, 0, 5)); 24 23 return false; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Key.java
r9665 r17609 8 8 import javax.swing.JPanel; 9 9 10 import org.openstreetmap.josm.data.osm.OsmPrimitive;11 10 import org.openstreetmap.josm.data.osm.Tag; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 12 12 13 13 /** … … 20 20 21 21 @Override 22 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {22 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 23 23 return false; 24 24 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Label.java
r17605 r17609 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 4 import java.util.Collection;5 3 6 4 import javax.swing.JLabel; 7 5 import javax.swing.JPanel; 8 6 9 import org.openstreetmap.josm. data.osm.OsmPrimitive;7 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 10 8 import org.openstreetmap.josm.tools.GBC; 11 9 … … 16 14 17 15 @Override 18 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {16 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 19 17 initializeLocaleText(null); 20 18 JLabel label = new JLabel(locale_text); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Link.java
r17605 r17609 6 6 import java.awt.event.MouseEvent; 7 7 import java.util.Arrays; 8 import java.util.Collection;9 8 import java.util.Optional; 10 9 … … 12 11 import javax.swing.SwingUtilities; 13 12 14 import org.openstreetmap.josm.data.osm.OsmPrimitive;15 13 import org.openstreetmap.josm.gui.dialogs.properties.HelpAction; 14 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 16 15 import org.openstreetmap.josm.gui.widgets.UrlLabel; 17 16 import org.openstreetmap.josm.spi.preferences.Config; … … 35 34 36 35 @Override 37 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {36 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 38 37 initializeLocaleText(tr("More information about this feature")); 39 38 Optional.ofNullable(buildUrlLabel()).ifPresent(label -> p.add(label, GBC.eol().insets(0, 10, 0, 0).fill(GBC.HORIZONTAL))); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Optional.java
r9665 r17609 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.util.Collection;7 8 6 import javax.swing.JLabel; 9 7 import javax.swing.JPanel; 10 8 11 import org.openstreetmap.josm. data.osm.OsmPrimitive;9 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 12 10 import org.openstreetmap.josm.tools.GBC; 13 11 … … 20 18 // TODO: Draw a box around optional stuff 21 19 @Override 22 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {20 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 23 21 initializeLocaleText(tr("Optional Attributes:")); 24 22 p.add(new JLabel(" "), GBC.eol()); // space -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/PresetLink.java
r16699 r17609 16 16 import org.openstreetmap.josm.data.osm.Tag; 17 17 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 18 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 18 19 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetLabel; 19 20 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; … … 54 55 55 56 @Override 56 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {57 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 57 58 final String presetName = preset_name; 58 59 Optional<TaggingPreset> found = TaggingPresets.getTaggingPresets().stream().filter(preset -> presetName.equals(preset.name)).findFirst(); … … 60 61 TaggingPreset t = found.get(); 61 62 JLabel lbl = new TaggingPresetLabel(t); 62 lbl.addMouseListener(new TaggingPresetMouseAdapter(t, s el));63 lbl.addMouseListener(new TaggingPresetMouseAdapter(t, support.getSelected())); 63 64 p.add(lbl, GBC.eol().fill(GBC.HORIZONTAL)); 64 65 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Roles.java
r17333 r17609 6 6 import java.awt.GridBagLayout; 7 7 import java.util.ArrayList; 8 import java.util.Collection;9 8 import java.util.List; 10 9 import java.util.Set; … … 13 12 import javax.swing.JPanel; 14 13 15 import org.openstreetmap.josm.data.osm.OsmPrimitive;16 14 import org.openstreetmap.josm.data.osm.Tag; 17 15 import org.openstreetmap.josm.data.osm.search.SearchCompiler; … … 19 17 import org.openstreetmap.josm.data.osm.search.SearchSetting; 20 18 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 19 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 21 20 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 22 21 import org.openstreetmap.josm.tools.GBC; … … 191 190 192 191 @Override 193 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {192 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 194 193 p.add(new JLabel(" "), GBC.eol()); // space 195 194 if (!roles.isEmpty()) { -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Space.java
r9665 r17609 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import java.util.Collection;5 4 import java.util.List; 6 5 … … 8 7 import javax.swing.JPanel; 9 8 10 import org.openstreetmap.josm.data.osm.OsmPrimitive;11 9 import org.openstreetmap.josm.data.osm.Tag; 12 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 13 12 import org.openstreetmap.josm.tools.GBC; 14 13 … … 19 18 20 19 @Override 21 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {20 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 22 21 p.add(new JLabel(" "), GBC.eol()); // space 23 22 return false; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java
r17605 r17609 22 22 import javax.swing.JToggleButton; 23 23 24 import org.openstreetmap.josm.data.osm.OsmPrimitive;25 24 import org.openstreetmap.josm.data.osm.Tag; 26 25 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 27 26 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 27 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 28 28 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 29 29 import org.openstreetmap.josm.gui.widgets.JosmTextField; … … 61 61 62 62 @Override 63 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {63 public boolean addToPanel(JPanel p, TaggingPresetItemGuiSupport support) { 64 64 65 65 // find out if our key is already used in the selection. 66 Usage usage = determineTextUsage(s el, key);66 Usage usage = determineTextUsage(support.getSelected(), key); 67 67 AutoCompletingTextField textField = new AutoCompletingTextField(); 68 68 if (alternative_autocomplete_keys != null) { … … 88 88 } else if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) { 89 89 // selected osm primitives are untagged or filling default values feature is enabled 90 if (! presetInitiallyMatches&& !"false".equals(use_last_as_default) && LAST_VALUES.containsKey(key)) {90 if (!support.isPresetInitiallyMatches() && !"false".equals(use_last_as_default) && LAST_VALUES.containsKey(key)) { 91 91 textField.setText(LAST_VALUES.get(key)); 92 92 } else {
Note:
See TracChangeset
for help on using the changeset viewer.