Modify

Opened 12 years ago

Closed 12 years ago

#7552 closed enhancement (fixed)

combo item icon in template preset

Reported by: kendzi Owned by: team
Priority: major Milestone:
Component: Core Version:
Keywords: combo Cc:

Description (last modified by skyper)

There is no way to define icon for combo items in template preset.

It should be possible to define icon for combo items. For example:

<combo key="roof:shape" text="Type" values="flat,gabled">
   <comboItem icon="roofs/flat.png" />
   <comboItem icon=”roofs/gabled.png” />
</combo>

Attachments (8)

alpha.png (36.4 KB ) - added by simon04 12 years ago.
7552_alpha.patch (2.9 KB ) - added by simon04 12 years ago.
7552_beta.patch (18.3 KB ) - added by simon04 12 years ago.
7552_gamma.patch (18.8 KB ) - added by simon04 12 years ago.
7552_delta.patch (23.3 KB ) - added by simon04 12 years ago.
new combo.png (113.3 KB ) - added by kendzi 12 years ago.
missing preset name
new combo.2.png (113.3 KB ) - added by kendzi 12 years ago.
missing preset name
old combo.png (79.9 KB ) - added by kendzi 12 years ago.
missing preset name

Download all attachments as: .zip

Change History (37)

comment:1 by kendzi, 12 years ago

Summary: combo item in template presetcombo item icon in template preset

comment:2 by kendzi, 12 years ago

Description: modified (diff)

comment:3 by skyper, 12 years ago

Description: modified (diff)

layout

by simon04, 12 years ago

Attachment: alpha.png added

by simon04, 12 years ago

Attachment: 7552_alpha.patch added

comment:4 by simon04, 12 years ago

Patch attached, not the ideal solution as it abuses <short_description> without using a separate attribute (such as <short_description icon="">). However, the latter requires some adoption in the preset parsing/handling.

<combo key="sac_scale" text="SAC Scale" values="hiking,mountain_hiking,demanding_mountain_hiking,alpine_hiking,demanding_alpine_hiking,difficult_alpine_hiking" default="" delete_if_empty="true" display_values="T1 - hiking trail,T2 - mountain hiking trail,T3 - difficult\, exposed hiking trail,T4 - difficult\, exposed\, steep alpine trail,T5 - difficult alpine trail with climbing,T6 - hazardous alpine trail with climbing">
  <short_description>img:presets/path.png</short_description>
  <short_description>img:http://www.openstreetmap.org/assets/osm_logo-caccd6371f095ca973c373b8e2014896.png</short_description>
  <short_description>exposed sites may be secured with ropes or chains, possible need to use hands for balance. Partly exposed sites with fall hazard, scree, pathless jagged rocks</short_description>
  <short_description>sometimes need for hand use to get ahead. Terrain quite exposed, precarious grassy acclivities, jagged rocks, facile snow-free glaciers.</short_description>
  <short_description>single plainly climbing up to second grade. Exposed, demanding terrain, jagged rocks, few dangerous glacier and snow</short_description>
  <short_description>climbing up to second grade. Often very exposed, precarious jagged rocks, glacier with danger to slip and fall</short_description>
</combo>


comment:5 by kendzi, 12 years ago

I try to test it by applying it to version from svn but variable short_descriptions is never set up.

You commited some change to XmlObjectParser.java but there are missing in this path and svn. More over there are missing in next commit on github.

I think it would be better if combo look more like this:

<combo key="key" text="text”>
	<comboItem value=”...” display_value=”...” icon="...">short description</comboItem>
</combo>
Last edited 12 years ago by kendzi (previous) (diff)

in reply to:  5 ; comment:6 by simon04, 12 years ago

Replying to kendzi:

You commited some change to XmlObjectParser.java but there are missing in this path and svn. More over there are missing in next commit on github.

Handling short_description has been fixed in r5130.

I think it would be better if combo look more like this:

<combo key="key" text="text”>
	<comboItem value=”...” display_value=”...” icon="...">short description</comboItem>
</combo>

To not break backward compatibility, I suggest:

<combo key="sac_scale" text="SAC Scale" values="hiking,mountain_hiking,demanding_mountain_hiking,alpine_hiking,demanding_alpine_hiking,difficult_alpine_hiking" default="" delete_if_empty="true" display_values="T1 - hiking trail,T2 - mountain hiking trail,T3 - difficult\, exposed hiking trail,T4 - difficult\, exposed\, steep alpine trail,T5 - difficult alpine trail with climbing,T6 - hazardous alpine trail with climbing">
  <short_description icon="icon">text</short_description>
  <!-- ... -->
</combo>

in reply to:  6 ; comment:7 by kendzi, 12 years ago

I think this r5135 commit broke short_description again.

Replying to simon04:

Replying to kendzi:

You commited some change to XmlObjectParser.java but there are missing in this path and svn. More over there are missing in next commit on github.

Handling short_description has been fixed in r5130.

I think it would be better if combo look more like this:

<combo key="key" text="text”>
	<comboItem value=”...” display_value=”...” icon="...">short description</comboItem>
</combo>

To not break backward compatibility, I suggest:

<combo key="sac_scale" text="SAC Scale" values="hiking,mountain_hiking,demanding_mountain_hiking,alpine_hiking,demanding_alpine_hiking,difficult_alpine_hiking" default="" delete_if_empty="true" display_values="T1 - hiking trail,T2 - mountain hiking trail,T3 - difficult\, exposed hiking trail,T4 - difficult\, exposed\, steep alpine trail,T5 - difficult alpine trail with climbing,T6 - hazardous alpine trail with climbing">
  <short_description icon="icon">text</short_description>
  <!-- ... -->
</combo>

comment:8 by bastiK, 12 years ago

I would do

<combo key="sac_scale" text="SAC Scale" values="hiking,mountain_hiking,demanding_mountain_hiking,alpine_hiking,demanding_alpine_hiking,difficult_alpine_hiking" default=""
icons="icon1.png,,,icon4.png,,"
delete_if_empty="true" display_values="T1 - hiking trail,T2 - mountain hiking trail,T3 - difficult\, exposed hiking trail,T4 - difficult\, exposed\, steep alpine trail,T5 - difficult alpine trail with climbing,T6 - hazardous alpine trail with climbing">
  <short_description>text</short_description>
  <!-- ... -->
</combo>

or what kendzi suggested.

in reply to:  7 ; comment:9 by simon04, 12 years ago

Replying to kendzi:

I think this r5135 commit broke short_description again.

Oh, no – again … Instead of fixing this, I'd like to push forward this ticket (as then the fix is no longer needed).

Beta patch attached. I guess, we can drop support for <short_description>, can't we?

<combo key="sac_scale" text="SAC Scale">
  <list_entry value="hiking" display_value="T1 - hiking trail" short_description="Trail well cleared. Area flat or slightly sloped, no fall hazard" />
  <list_entry value="mountain_hiking" display_value="T2 - mountain hiking trail" short_description="Trail with continuous line and balanced ascent. Terrain partially steep, fall hazard possible" />
  <list_entry value="demanding_mountain_hiking" display_value="T3 - difficult, exposed hiking trail" short_description="exposed sites may be secured with ropes or chains, possible need to use hands for balance. Partly exposed sites with fall hazard, scree, pathless jagged rocks" />
  <list_entry value="alpine_hiking" display_value="T4 - difficult, exposed, steep alpine trail" short_description="sometimes need for hand use to get ahead. Terrain quite exposed, precarious grassy acclivities, jagged rocks, facile snow-free glaciers" />
  <list_entry value="demanding_alpine_hiking" display_value="T5 - difficult alpine trail with climbing" short_description="single plainly climbing up to second grade. Exposed, demanding terrain, jagged rocks, few dangerous glacier and snow" />
  <list_entry value="difficult_alpine_hiking" display_value="T6 - hazardous alpine trail with climbing" short_description="climbing up to second grade. Often very exposed, precarious jagged rocks, glacier with danger to slip and fall" />
</combo>
Last edited 12 years ago by simon04 (previous) (diff)

by simon04, 12 years ago

Attachment: 7552_beta.patch added

in reply to:  9 comment:10 by kendzi, 12 years ago

It is working great!
Only problem is then there is no attribute “display_value” in preset, it throw exception:

java.lang.NullPointerException
	at org.openstreetmap.josm.gui.tagging.TaggingPreset$PresetListEntry.toString(TaggingPreset.java:245)
	at javax.swing.plaf.basic.BasicComboBoxEditor.setItem(BasicComboBoxEditor.java:60)

Replying to simon04:

Replying to kendzi:

I think this r5135 commit broke short_description again.

Oh, no – again … Instead of fixing this, I'd like to push forward this ticket (as then the fix is no longer needed).

Beta patch attached. I guess, we can drop support for <short_description>, can't we?

<combo key="sac_scale" text="SAC Scale">
  <list_entry value="hiking" display_value="T1 - hiking trail" short_description="Trail well cleared. Area flat or slightly sloped, no fall hazard" />
  <list_entry value="mountain_hiking" display_value="T2 - mountain hiking trail" short_description="Trail with continuous line and balanced ascent. Terrain partially steep, fall hazard possible" />
  <list_entry value="demanding_mountain_hiking" display_value="T3 - difficult, exposed hiking trail" short_description="exposed sites may be secured with ropes or chains, possible need to use hands for balance. Partly exposed sites with fall hazard, scree, pathless jagged rocks" />
  <list_entry value="alpine_hiking" display_value="T4 - difficult, exposed, steep alpine trail" short_description="sometimes need for hand use to get ahead. Terrain quite exposed, precarious grassy acclivities, jagged rocks, facile snow-free glaciers" />
  <list_entry value="demanding_alpine_hiking" display_value="T5 - difficult alpine trail with climbing" short_description="single plainly climbing up to second grade. Exposed, demanding terrain, jagged rocks, few dangerous glacier and snow" />
  <list_entry value="difficult_alpine_hiking" display_value="T6 - hazardous alpine trail with climbing" short_description="climbing up to second grade. Often very exposed, precarious jagged rocks, glacier with danger to slip and fall" />
</combo>

by simon04, 12 years ago

Attachment: 7552_gamma.patch added

comment:11 by simon04, 12 years ago

(Hopefully) fixed in ɣ.

in reply to:  11 comment:12 by kendzi, 12 years ago

Replying to simon04:

(Hopefully) fixed in ɣ.

Now it is working perfect :)

comment:13 by stoecker, 12 years ago

I did not look at the issue itself, but the help text in patch is broken.

in reply to:  13 comment:14 by simon04, 12 years ago

Replying to stoecker:

I did not look at the issue itself, but the help text in patch is broken.

In which sense?

by simon04, 12 years ago

Attachment: 7552_delta.patch added

comment:15 by simon04, 12 years ago

δ: Handle translations correctly.

comment:16 by simon04, 12 years ago

In 5158/josm:

see #7552 - presets: allow icons for individual combo items

in reply to:  15 comment:17 by kendzi, 12 years ago

Replying to simon04:

δ: Handle translations correctly.

It is working quite well. When it well be added to svn? - I didn't saw your answer

To delta patch:

Attributes display_value, short_description are translated correctly, but when it is specified only attribute “value” it is not translated. It is intentionality? (values from old “valuses” attribute in combo are translated)
eg.

<list_entry value="up" />

To version on svn:

Translation for attributes value, display_value, short_description are not working.

To future :)

After choosing value with images, it could be good idea to show this image on template form near chosen text value. But it should support values write to combo text field too. When it is match with list_entry it could be show image.

Last edited 12 years ago by kendzi (previous) (diff)

comment:18 by simon04, 12 years ago

In 5159/josm:

see #7552 - damn confusion with Greek letters: apply delta instead of gamma patch ;-) (translation should work correctly now)

comment:19 by anonymous, 12 years ago

One more problem.
When combo items are specified using list_entry, default value is not working.
This is working:

<combo values="yes,no" text="test1" key="test1"  default="yes" />

This is not working:

<combo text="test2" key="test2" default="yes">
   <list_entry value="yes"  />
   <list_entry value="no"  />
</combo>

in reply to:  19 comment:20 by kendzi, 12 years ago

With new combo preset icon above attributes stop appearing too.

comment:21 by simon04, 12 years ago

Replying to kendzi:

With new combo preset icon above attributes stop appearing too.

I don't really understand – please explain in more detail and/or attach a small example.

comment:22 by simon04, 12 years ago

In 5164/josm:

see #7552 - presets: make default work properly when using <list_entry>s

by kendzi, 12 years ago

Attachment: new combo.png added

missing preset name

by kendzi, 12 years ago

Attachment: new combo.2.png added

missing preset name

by kendzi, 12 years ago

Attachment: old combo.png added

missing preset name

comment:23 by simon04, 12 years ago

I guess the answer is in http://josm.openstreetmap.de/browser/josm/trunk/data/defaultpresets.xml?rev=5164#L103

To be more specific, try to add the attribute match="key to your <combo>.

Last edited 12 years ago by simon04 (previous) (diff)

comment:24 by stoecker, 12 years ago

The list entry is missing a specification for the translation context for the values ("values_context" in <combo>), as well as for short description. Also it seems that normal short-description in the combo is not translated, only in <list_entry>.

comment:25 by simon04, 12 years ago

In 5172/josm:

see #5933 - avoid warnings "Ignoring * attribute as * elements are given"


In fact related to this ticket and not #5933.

comment:26 by simon04, 12 years ago

In 5173/josm:

see #7552 - presets: handle translation correctly for <combo>, propagate values_context to <list_entry> (or set value_context there)

in reply to:  24 comment:27 by simon04, 12 years ago

Replying to stoecker:

The list entry is missing a specification for the translation context for the values ("values_context" in <combo>)

Done.

as well as for short description.

Currently, we don't have a context for short_description in <combo> neither. Shall we add one or reuse values_context?

Also it seems that normal short-description in the combo is not translated, only in <list_entry>.

Fixed.

comment:28 by stoecker, 12 years ago

Currently, we don't have a context for short_description in <combo> neither. Shall we add one or reuse values_context?

I think a "description_context" would be correct here. Meaning of values and descriptions may differ a lot, so contexts should not be same. Thought text conflicts with the short description texts are very unlikely, so a context is not that important.

in reply to:  28 comment:29 by simon04, 12 years ago

Resolution: fixed
Status: newclosed

Replying to stoecker:

Thought text conflicts with the short description texts are very unlikely, so a context is not that important.

Maybe we'll keep this for later when there's need for contexts in short description texts. Currently short descriptions are used very rarely (once in the defaultpresets).

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.