Modify

Opened 3 years ago

Last modified 3 years ago

#22297 new defect

[Patch] JOSM always sorts value from multiselect when closing preset form

Reported by: sergey.v.liverko@… Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: template_report preset multiselect sort value Cc: marcello@…

Description

What steps will reproduce the problem?

  1. Make simple preset, containing the next element:
<chunk id="voltage">
    <list_entry value="1150000" />
    <list_entry value="750000" />
    <list_entry value="500000" />
    <list_entry value="400000" />
    <list_entry value="330000" />
    <list_entry value="220000" />
    <list_entry value="150000" />
    <list_entry value="110000" />
    <list_entry value="35000" />
    <list_entry value="25000" />
    <list_entry value="20000" />
    <list_entry value="18000" />
    <list_entry value="13800" />
    <list_entry value="10000" />
    <list_entry value="6000" />
    <list_entry value="3000" />
    <list_entry value="1500" />
    <list_entry value="950" />
    <list_entry value="750" />
    <list_entry value="690" />
    <list_entry value="550" />
    <list_entry value="400" />
</chunk>
  1. Create new object, apply newly created preset via "Presets" menu. Select values "6000" and "400" in multiselect.

What is the expected result?

Object have tag "voltage=6000;400"

What happens instead?

Object have tag "voltage=400;6000". Values are sorted lexicographically. Adding attribute values_sort=false doesn't affect, as well as setting taggingpreset.sortvalues=false in advanced preferences.

Please provide any additional information below. Attach a screenshot if possible.

This is very unpretty behaviour, because, according to wiki, voltages of power substation should be listed from highest to lowest. So even in case of using preset I have to check it manually later and edit tag value as text to make it correct.

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2022-08-01 20:38:58 +0200 (Mon, 01 Aug 2022)
Revision:18531
Build-Date:2022-08-02 01:30:56
URL:https://josm.openstreetmap.de/svn/trunk

Identification: JOSM/1.5 (18531 ru) Windows 10 64-Bit
OS Build number: Windows 10 Home 2009 (19044)
Memory Usage: 254 MB / 4042 MB (51 MB allocated, but free)
Java version: 11.0.15+10-LTS, Azul Systems, Inc., OpenJDK 64-Bit Server VM
Look and Feel: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
Screen: \Display0 1920×1080 (scaling 1.00×1.00)
Maximum Screen Size: 1920×1080
Best cursor sizes: 16×16→32×32, 32×32→32×32
System property file.encoding: Cp1251
System property sun.jnu.encoding: Cp1251
Locale info: ru_RU
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [-Dicedtea-web.bin.location=%UserProfile%\AppData\Local\Programs\OpenWebStart\javaws, -Djava.util.Arrays.useLegacyMergeSort=true, --add-exports=jdk.deploy/com.sun.deploy.config=ALL-UNNAMED, --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED, --add-reads=java.naming=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.security.action=ALL-UNNAMED,java.desktop, --add-reads=java.base=ALL-UNNAMED,java.desktop, --add-exports=java.naming/com.sun.jndi.toolkit.url=ALL-UNNAMED,java.desktop, --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED, --add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED, --add-exports=java.desktop/sun.awt=ALL-UNNAMED,java.desktop, --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED, --add-exports=java.base/sun.security.validator=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED, --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED,java.desktop, --add-exports=java.base/jdk.internal.util.jar=ALL-UNNAMED,java.desktop, --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED, --add-exports=java.base/com.sun.net.ssl.internal.ssl=ALL-UNNAMED,java.desktop, --add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED, --add-modules=java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web, --add-exports=java.desktop/sun.awt.X11=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/sun.applet=ALL-UNNAMED,java.desktop,jdk.jsobject, --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED,java.desktop, --add-opens=java.base/java.lang=ALL-UNNAMED, --add-exports=java.base/sun.security.util=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED, --add-reads=java.desktop=ALL-UNNAMED,java.naming, --add-opens=java.base/java.nio=ALL-UNNAMED, --add-exports=java.base/sun.security.x509=ALL-UNNAMED,java.desktop, --add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED, --add-exports=java.desktop/javax.jnlp=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.security.provider=ALL-UNNAMED,java.desktop]

Plugins:
+ FastDraw (35978)
+ PicLayer (1.0.2)
+ alignways (36011)
+ reverter (36011)
+ undelete (36011)
+ utilsplugin2 (36011)

Tagging presets:
+ %UserProfile%\YandexDisk\OpenStreetMap\JOSM\_Release\Power.zip

Map paint styles:
+ %UserProfile%\YandexDisk\OpenStreetMap\JOSM\_Release\Power.zip

Last errors/warnings:
- 00000.406 W: extended font config - overriding 'filename.Myanmar_Text=mmrtext.ttf' with 'MMRTEXT.TTF'
- 00000.409 W: extended font config - overriding 'filename.Mongolian_Baiti=monbaiti.ttf' with 'MONBAITI.TTF'
- 00004.546 W: Unable to request certificate of https://roottest-g3.pkioverheid.nl
- 00004.795 W: Unable to request certificate of https://roottest-g3.pkioverheid.nl

Attachments (0)

Change History (4)

comment:1 by skyper, 3 years ago

Cc: marcello added
Keywords: preset multiselect sort value added

Yes, this is connected to last big changes of muliselect. Sorting values should be disabled with values_sort=false present.

Edit: Maybe it is only needed for values with only numbers.

Last edited 3 years ago by skyper (previous) (diff)

comment:2 by skyper, 3 years ago

Cc: marcello@… added; marcello removed

comment:3 by anonymous, 3 years ago

This patch fixes the problem.

Index: src/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelect.java
===================================================================
--- src/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelect.java	(revision 18618)
+++ src/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelect.java	(working copy)
@@ -103,7 +103,13 @@
 
     @Override
     protected PresetListEntry getSelectedItem() {
-        return new PresetListEntry(list.getSelectedValuesList()
-            .stream().map(e -> e.value).distinct().sorted().collect(Collectors.joining(String.valueOf(delimiter))), this);
+        if(values_sort) {
+            return new PresetListEntry(list.getSelectedValuesList()
+                    .stream().map(e -> e.value).distinct().sorted().collect(Collectors.joining(String.valueOf(delimiter))), this);
+        }
+        else {
+            return new PresetListEntry(list.getSelectedValuesList()
+                    .stream().map(e -> e.value).distinct().collect(Collectors.joining(String.valueOf(delimiter))), this);
+        }
     }
 }

comment:4 by skyper, 3 years ago

Summary: JOSM always sorts value from multiselect when closing preset form[Patch] JOSM always sorts value from multiselect when closing preset form

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to sergey.v.liverko@….
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.