Changeset 17639 in josm for trunk/src/org
- Timestamp:
- 2021-03-22T23:25:18+01:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging/presets/items
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Combo.java
r17077 r17639 19 19 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 20 20 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList; 21 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 21 22 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 22 23 import org.openstreetmap.josm.spi.preferences.Config; … … 47 48 48 49 @Override 49 protected void addToPanelAnchor(JPanel p, String def, boolean presetInitiallyMatches) {50 protected void addToPanelAnchor(JPanel p, String def, TaggingPresetItemGuiSupport support) { 50 51 if (!usage.unused()) { 51 52 for (String s : usage.values) { … … 77 78 } 78 79 combobox.setEditor(tf); 79 combobox.setSelectedItem(getItemToSelect(def, presetInitiallyMatches, false));80 combobox.setSelectedItem(getItemToSelect(def, support, false)); 80 81 81 82 if (key != null && ("colour".equals(key) || key.startsWith("colour:") || key.endsWith(":colour"))) { … … 92 93 p.add(combobox, GBC.eol().fill(GBC.HORIZONTAL)); 93 94 } 95 combobox.addActionListener(l -> support.fireItemValueModified(this, key, getSelectedValue())); 94 96 } 95 97 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
r17609 r17639 188 188 protected abstract Object getSelectedItem(); 189 189 190 protected abstract void addToPanelAnchor(JPanel p, String def, boolean presetInitiallyMatches);190 protected abstract void addToPanelAnchor(JPanel p, String def, TaggingPresetItemGuiSupport support); 191 191 192 192 @Override … … 220 220 label.setComponentPopupMenu(getPopupMenu()); 221 221 p.add(label, GBC.std().insets(0, 0, 10, 0)); 222 addToPanelAnchor(p, default_, support .isPresetInitiallyMatches());222 addToPanelAnchor(p, default_, support); 223 223 label.setLabelFor(component); 224 224 component.setToolTipText(getKeyTooltipText()); … … 343 343 } 344 344 345 protected Object getItemToSelect(String def, boolean presetInitiallyMatches, boolean multi) {345 protected Object getItemToSelect(String def, TaggingPresetItemGuiSupport support, boolean multi) { 346 346 final Object itemToSelect; 347 347 if (usage.hasUniqueValue()) { … … 367 367 // all items were unset (and so is default) 368 368 originalValue = multi ? null : getListEntry(""); 369 if (LAST_VALUES.containsKey(key) && isUseLastAsDefault() && (! presetInitiallyMatches|| isForceUseLastAsDefault())) {369 if (LAST_VALUES.containsKey(key) && isUseLastAsDefault() && (!support.isPresetInitiallyMatches() || isForceUseLastAsDefault())) { 370 370 itemToSelect = getListEntry(LAST_VALUES.get(key)); 371 371 } else { -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelect.java
r17077 r17639 15 15 16 16 import org.openstreetmap.josm.data.osm.Tag; 17 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 17 18 import org.openstreetmap.josm.tools.GBC; 18 19 … … 30 31 31 32 @Override 32 protected void addToPanelAnchor(JPanel p, String def, boolean presetInitiallyMatches) {33 protected void addToPanelAnchor(JPanel p, String def, TaggingPresetItemGuiSupport support) { 33 34 list = new ConcatenatingJList(delimiter, presetListEntries.toArray(new PresetListEntry[0])); 34 35 component = list; 35 36 ListCellRenderer<PresetListEntry> renderer = getListCellRenderer(); 36 37 list.setCellRenderer(renderer); 37 list.setSelectedItem(getItemToSelect(def, presetInitiallyMatches, true));38 list.setSelectedItem(getItemToSelect(def, support, true)); 38 39 JScrollPane sp = new JScrollPane(list); 39 40 // if a number of rows has been specified in the preset, … … 44 45 sp.setPreferredSize(new Dimension((int) sp.getPreferredSize().getWidth(), (int) height)); 45 46 } 47 list.addListSelectionListener(l -> support.fireItemValueModified(this, key, getSelectedValue())); 46 48 p.add(sp, GBC.eol().fill(GBC.HORIZONTAL)); 47 49 }
Note:
See TracChangeset
for help on using the changeset viewer.