Modify

Opened 7 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#14923 closed enhancement (fixed)

[patch] JOSM search by preset in the search dialog

Reported by: bafonins Owned by: team
Priority: normal Milestone: 17.07
Component: Core Version:
Keywords: Cc: michael2402

Description (last modified by michael2402)

Currently, there are two menu entries to perform searching - "Search" and "Search for object by preset...". And functionality to search for osm objects is very limiting, namely there is no way to search for two or more presets at the same time, it is not possible to add object that match the preset to the current selection and etc.
I propose to merge these dialogs, actually adding functionality to search for presets to the search dialog. Then queries like
preset:water | preset:waterway or
preset:Village | preset:"Cave Entrance" | highway=motorway
can be performed + the selection settings from the search dialog can be used to control selected objects.

Also, we can embed the "Search for objectsby preset..." dialog intro the "Search" dialog in order to simply select needed presets and append 'preset:...' query to the text field.


Attachments (8)

preset-search..jpg (120.7 KB) - added by bafonins 7 weeks ago.
preset-search.patch (5.2 KB) - added by bafonins 7 weeks ago.
preset-search-v2.patch (5.7 KB) - added by bafonins 7 weeks ago.
Refactored the code a bit
preset-search-v3.patch (10.0 KB) - added by bafonins 6 weeks ago.
Fixed the issue and added tests
en-search-dialog-expert.jpg (181.8 KB) - added by bafonins 3 weeks ago.
The search dialog, expert mode, english
en-search-dialog.jpg (105.3 KB) - added by bafonins 3 weeks ago.
The search dialog, regular mode, english
ger-search-dialog-exp.jpg (205.8 KB) - added by bafonins 3 weeks ago.
The search dialog, expert mode, german
preset-search-v4.patch (29.1 KB) - added by bafonins 3 weeks ago.

Download all attachments as: .zip

Change History (22)

Changed 7 weeks ago by bafonins

Attachment: preset-search..jpg added

Changed 7 weeks ago by bafonins

Attachment: preset-search.patch added

comment:1 Changed 7 weeks ago by bafonins

Summary: JOSM search by preset in the search dialog[patch] JOSM search by preset in the search dialog

comment:2 Changed 7 weeks ago by bafonins

Description: modified (diff)

comment:4 Changed 7 weeks ago by michael2402

Description: modified (diff)

comment:5 Changed 7 weeks ago by stoecker

Milestone: 17.06

Note before applying: Typo in the first line "all object_s_".

comment:6 Changed 7 weeks ago by michael2402

There is a github PR for this patch. Commenting is easier there. I did a review on it - especially to address some coding style issues:

https://github.com/openstreetmap/josm/pull/19

comment:7 in reply to:  6 ; Changed 7 weeks ago by stoecker

Replying to michael2402:

There is a github PR for this patch. Commenting is easier there.

No it is not. It is already enough work to react to one bug-tracker. Starting to react to different places is not a good idea.

Changed 7 weeks ago by bafonins

Attachment: preset-search-v2.patch added

Refactored the code a bit

comment:8 in reply to:  7 Changed 7 weeks ago by michael2402

Replying to stoecker:

Replying to michael2402:

There is a github PR for this patch. Commenting is easier there.

No it is not. It is already enough work to react to one bug-tracker. Starting to react to different places is not a good idea.

For conceptional issues I agree. But my comments were more on stylistic issues (variable names, inverting equals, using blocks in if/else, ...)

@bafonins: You patch looks better that way ;-). Cann you add test cases to it to the SearchCompilerTest? Especially for:

preset:"water"      (Test if it matches correctly)
preset:water        (Test if it matches correctly)
preset: water        (Test if it matches correctly)
preset:             (Should throw a ParseError)
preset:xyz          (Should throw a ParseError)

And fix this exception while typing in a preset search:

Build-Date:2017-06-11 12:26:22
Revision:12354
Is-Local-Build:true

Identification: JOSM/1.5 (12354 SVN en) Linux Ubuntu 14.04.5 LTS
Memory Usage: 615 MB / 3559 MB (423 MB allocated, but free)
Java version: 1.8.0_111-8u111-b14-3~14.04.1-b14, Oracle Corporation, OpenJDK 64-Bit Server VM
Screen: :0.0 1920x1080, :0.1 1920x1080
Maximum Screen Size: 1920x1080
Java package: openjdk-8-jre:amd64-8u111-b14-3~14.04.1
Java ATK Wrapper package: libatk-wrapper-java:all-0.30.4-4
VM arguments: [-Dfile.encoding=UTF-8]
Dataset consistency test: No problems found

Last errors/warnings:
- W: java.util.zip.ZipException: error in opening zip file
- W: PluginException: : org.openstreetmap.josm.plugins.PluginException: Invalid jar file '<josm.pref>/plugins/ebdirigo.jar.new'
- W: Failed to scan file 'ebdirigo.jar.new' for plugin information. Skipping.
- W: Failed to install plugin '<josm.pref>/plugins/ebdirigo.jar' from temporary download file '<josm.pref>/plugins/ebdirigo.jar.new'. error in opening zip file: java.util.zip.ZipException: error in opening zip file
- W: No configuration settings found.  Using hardcoded default values for all pools.
- E: Handled by bug report queue: java.lang.NullPointerException


=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (18) of main
java.lang.NullPointerException
	at java.util.Objects.requireNonNull(Objects.java:203)
	at org.openstreetmap.josm.actions.search.SearchCompiler$Preset.<init>(SearchCompiler.java:1571)
	at org.openstreetmap.josm.actions.search.SearchCompiler$CoreSimpleMatchFactory.get(SearchCompiler.java:159)
	at org.openstreetmap.josm.actions.search.SearchCompiler.parseFactor(SearchCompiler.java:1775)
	at org.openstreetmap.josm.actions.search.SearchCompiler.parseExpressionStep1(SearchCompiler.java:1697)
	at org.openstreetmap.josm.actions.search.SearchCompiler.parseExpression(SearchCompiler.java:1685)
	at org.openstreetmap.josm.actions.search.SearchCompiler.parse(SearchCompiler.java:1670)
	at org.openstreetmap.josm.actions.search.SearchCompiler.compile(SearchCompiler.java:1641)
	at org.openstreetmap.josm.actions.search.SearchAction$1.isValid(SearchAction.java:343)
	at org.openstreetmap.josm.actions.search.SearchAction$1.validate(SearchAction.java:328)
	at org.openstreetmap.josm.gui.widgets.AbstractTextComponentValidator.insertUpdate(AbstractTextComponentValidator.java:166)
	at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:201)
	at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:748)
	at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:707)
	at javax.swing.text.PlainDocument.insertString(PlainDocument.java:130)
	at org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox$AutoCompletingComboBoxDocument.insertString(AutoCompletingComboBox.java:109)
	at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:669)
	at javax.swing.text.JTextComponent.replaceSelection(JTextComponent.java:1328)
	at javax.swing.text.DefaultEditorKit$DefaultKeyTypedAction.actionPerformed(DefaultEditorKit.java:884)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1663)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2882)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2929)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2845)
	at java.awt.Component.processEvent(Component.java:6310)
	at java.awt.Container.processEvent(Container.java:2236)
	at java.awt.Component.dispatchEventImpl(Component.java:4889)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
	at java.awt.Component.dispatchEventImpl(Component.java:4760)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2746)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)
	at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:184)
	at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:229)
	at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:227)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:227)
	at java.awt.Dialog.show(Dialog.java:1084)
	at java.awt.Component.show(Component.java:1671)
	at java.awt.Component.setVisible(Component.java:1623)
	at java.awt.Window.setVisible(Window.java:1014)
	at java.awt.Dialog.setVisible(Dialog.java:1005)
	at org.openstreetmap.josm.gui.ExtendedDialog.setVisible(ExtendedDialog.java:456)
	at org.openstreetmap.josm.gui.ExtendedDialog.showDialog(ExtendedDialog.java:253)
	at org.openstreetmap.josm.actions.search.SearchAction.showSearchDialog(SearchAction.java:390)
	at org.openstreetmap.josm.actions.search.SearchAction.search(SearchAction.java:517)
	at org.openstreetmap.josm.actions.search.SearchAction.actionPerformed(SearchAction.java:191)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1663)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2882)
	at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:307)
	at javax.swing.KeyboardManager.fireKeyboardAction(KeyboardManager.java:263)
	at javax.swing.JComponent.processKeyBindingsForAllComponents(JComponent.java:2974)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2966)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2845)
	at java.awt.Component.processEvent(Component.java:6310)
	at java.awt.Container.processEvent(Container.java:2236)
	at java.awt.Component.dispatchEventImpl(Component.java:4889)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
	at java.awt.Component.dispatchEventImpl(Component.java:4760)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Window.dispatchEventImpl(Window.java:2746)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Last edited 7 weeks ago by michael2402 (previous) (diff)

Changed 6 weeks ago by bafonins

Attachment: preset-search-v3.patch added

Fixed the issue and added tests

comment:9 Changed 6 weeks ago by michael2402

@bafonins: Should I merge this patch now or wait for your work on your future work?

comment:10 Changed 6 weeks ago by bafonins

Do not merge it now, there are still things to be done.

comment:11 Changed 5 weeks ago by michael2402

Milestone: 17.0617.07

Moving this until after the 17.6 release - the patch should be ready before then but we should have time to fix issues.

Changed 3 weeks ago by bafonins

Attachment: en-search-dialog-expert.jpg added

The search dialog, expert mode, english

Changed 3 weeks ago by bafonins

Attachment: en-search-dialog.jpg added

The search dialog, regular mode, english

Changed 3 weeks ago by bafonins

Attachment: ger-search-dialog-exp.jpg added

The search dialog, expert mode, german

comment:12 Changed 3 weeks ago by bafonins

With this update GUI of the search dialog changed a bit. New hints added, as well as a list of possible presets to search for.
The search dialog, regular mode, english
The search dialog, expert mode, english
The search dialog, expert mode, german

After clicking on any preset in the selector, a corresponding string is generated and appended to the text field. Autocomplete is working and in case of selecting some preset that starts already used query, the generated part is selected. And of course, presets can be combined into more sophisticated queries as you usually do with types, names, logical operators, etc.

So, searching works as follows :
Annotation/Address - a regular query that matches all object that have the corresponding preset
Annotation/* - a wildcard query that matches all object that have any preset of the group Annotation

Any suggestions?

Changed 3 weeks ago by bafonins

Attachment: preset-search-v4.patch added

comment:13 Changed 2 weeks ago by michael2402

Resolution: fixed
Status: newclosed

In 12464/josm:

Apply #14923: Adjust the search dialog to allow to search for primitives that use a preset. Patch by bafonins

comment:14 Changed 2 weeks ago by Don-vip

In 12467/josm:

see #14923 - PMD - UseIndexOfChar - String.indexOf(char) is faster than String.indexOf(String)

comment:15 Changed 2 weeks ago by Don-vip

In 12468/josm:

see #14923 - suppress java warnings

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
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.