Modify

#22908 closed enhancement (fixed)

[patch] Search button's dropdown list not initialized on JOSM lunch

Reported by: gaben Owned by: team
Priority: minor Milestone: 23.05
Component: Core Version:
Keywords: template_report search dropdown arrow Cc:

Description (last modified by gaben)

What steps will reproduce the problem?

  1. Lunch JOSM
  2. Have some search history in the preferences by making some search, content doesn't matter
  3. Relaunch JOSM
  4. Add a new empty layer
  5. Click on the arrow button


What is the expected result?

The dropdown list is available from lunch, without clicking on the Search button.

What happens instead?

One need to click Search button first to initialise the search history, then the dropdown list will be available.

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

It makes some of the manual dev testing hard, because of the extra clicks.

URL:https://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2023-04-27 16:45:28 +0200 (Thu, 27 Apr 2023)
Build-Date:2023-04-28 01:30:56
Revision:18719
Relative:URL: ^/trunk

Identification: JOSM/1.5 (18719 hu) Windows 10 64-Bit
OS Build number: Windows 10 Pro for Workstations 2009 (19045)
Memory Usage: 975 MB / 7266 MB (611 MB allocated, but free)
Java version: 1.8.0_371-b11, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Look and Feel: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
Screen: \Display0 1920×1200 (scaling 1.00×1.00)
Maximum Screen Size: 1920×1200
Best cursor sizes: 16×16→32×32, 32×32→32×32
System property file.encoding: Cp1250
System property sun.jnu.encoding: Cp1250
Locale info: hu_HU
Numbers with default locale: 1234567890 -> 1234567890
VM arguments: [-Djava.security.manager, -Djnlp.application.href=https://josm.openstreetmap.de/download/josm-latest.jnlp, -Djava.util.Arrays.useLegacyMergeSort=true, -Djnlp.tk=awt, -Djnlpx.jvm=<java.home>\bin\javaw.exe, -Djnlpx.splashport=58330, -Djnlpx.home=<java.home>\bin, -Djnlpx.remove=false, -Djnlpx.offline=false, -Djnlpx.relaunch=true, -Djnlpx.session.data=%UserProfile%\AppData\Local\Temp\session6912936828087324594, -Djnlpx.heapsize=NULL,NULL, -Djava.security.policy=file:<java.home>\lib\security\javaws.policy, -DtrustProxy=true, -Djnlpx.origFilenameArg=%UserProfile%\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\31\583aa85f-32780bce]

Attachments (3)

arrow.png (10.8 KB ) - added by gaben 17 months ago.
josm_22908_search_button_arrow.patch (1.6 KB ) - added by gaben 17 months ago.
josm_22908_search_button_arrow_v2.patch (1.6 KB ) - added by gaben 17 months ago.
in javadoc use @link instead of @code

Download all attachments as: .zip

Change History (10)

by gaben, 17 months ago

Attachment: arrow.png added

comment:1 by gaben, 17 months ago

Description: modified (diff)
Milestone: 23.0523.04

Maybe it fits in April's release as it's a minor change :)

comment:2 by taylor.smock, 17 months ago

Milestone: 23.0423.05

Ticket retargeted after milestone closed

by gaben, 17 months ago

in javadoc use @link instead of @code

comment:3 by taylor.smock, 17 months ago

As a stupid question, why not in the static initializer? Like so:

  • src/org/openstreetmap/josm/actions/search/SearchAction.java

    diff --git a/src/org/openstreetmap/josm/actions/search/SearchAction.java b/src/org/openstreetmap/josm/actions/search/SearchAction.java
    a b  
    7272            SearchSetting::readFromString, SearchSetting::writeToString);
    7373
    7474    static {
     75        // Load the history on initial load (for the drop-down dialog)
     76        prefs.load("search.history");
    7577        SearchCompiler.addMatchFactory(new SimpleMatchFactory() {
    7678            @Override
    7779            public Collection<String> getKeywords() {

comment:4 by gaben, 17 months ago

It's a good one, I completely missed the static initializer.

In that case the preference load call can be moved from the search() method to the initializer, although I'm not sure why. I suspect the AutoCompComboBoxModel.Preferences gets associated with the given preference key, which is needed only once.

  • src/org/openstreetmap/josm/actions/search/SearchAction.java

    diff --git a/src/org/openstreetmap/josm/actions/search/SearchAction.java b/src/org/openstreetmap/josm/actions/search/SearchAction.java
    a b  
    7272            SearchSetting::readFromString, SearchSetting::writeToString);
    7373
    7474    static {
     75        // Load the history on initial load (for the drop-down dialog)
     76        prefs.load("search.history");
    7577        SearchCompiler.addMatchFactory(new SimpleMatchFactory() {
    7678            @Override
    7779            public Collection<String> getKeywords() {
     
    185186     * Launches the dialog for specifying search criteria and runs a search
    186187     */
    187188    public static void search() {
    188         prefs.load("search.history");
    189189        SearchSetting se = showSearchDialog(lastSearch);
    190190        if (se != null) {
    191191            searchWithHistory(se);

comment:5 by taylor.smock, 17 months ago

I didn't move it out of the search function just in case someone, somewhere, is fiddling with the search.history config variable. The combobox doesn't actually add a listener on the config key, so changes won't propagate to the search dialog.

It probably worked for you in testing since prefs will add the search term to the model and then save the preferences value. Funky things would start happening if a plugin decides to allow users to use the search terms from the search dialog and then said plugin saves new search terms to the same preference key.

I think it would be better to just leave the prefs.load("search.history") in the search function.

comment:6 by gaben, 17 months ago

Ah yes, we need to think about plugins as well. Then it's clear.

comment:7 by taylor.smock, 17 months ago

Resolution: fixed
Status: newclosed

In 18732/josm:

Fix #22908: Search button's dropdown list not initialized on JOSM launch (patch by gaben, modified)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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