Changeset 6572 in josm
- Timestamp:
- 2013-12-31T01:38:06+01:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/defaultpresets.xml
r6570 r6572 23 23 link: link to the relating map features website 24 24 href: the URL 25 26 preset_link: a link to an other preset 27 preset_name: the exact name of the preset to link to 25 28 26 29 label: simple static text label … … 3873 3876 <key key="amenity" value="kindergarten" /> 3874 3877 <text key="name" text="Name" /> 3878 <preset_link preset_name="Contact (common schema)" /> 3875 3879 </item> 3876 3880 <item name="School" icon="presets/school.png" type="node,closedway,relation"> … … 3889 3893 <key key="amenity" value="school" /> 3890 3894 <text key="name" text="Name" /> 3895 <preset_link preset_name="Contact (common schema)" /> 3891 3896 </item> 3892 3897 <item name="University" icon="styles/standard/education/university.png" type="node,closedway,relation"> … … 3904 3909 <key key="amenity" value="university" /> 3905 3910 <text key="name" text="Name" /> 3911 <preset_link preset_name="Contact (common schema)" /> 3906 3912 </item> 3907 3913 <item name="College" icon="styles/standard/education/college.png" type="node,closedway,relation"> … … 3916 3922 <key key="amenity" value="college" /> 3917 3923 <text key="name" text="Name" /> 3924 <preset_link preset_name="Contact (common schema)" /> 3918 3925 </item> 3919 3926 <item name="Driving School" icon="styles/standard/education/driving_school.png" type="node,closedway"> … … 3924 3931 <reference ref="name_operator" /> 3925 3932 <combo key="license_classes" text="License Classes" values="A;A1;B;BE;C,A;A1;B;B1;C;C1;D;D1;BE;CE;C1E;DE;D1E" /> 3933 <preset_link preset_name="Contact (common schema)" /> 3926 3934 </item> 3927 3935 </group> <!-- Education --> -
trunk/data/tagging-preset.xsd
r6558 r6572 105 105 <element name="space" type="tns:space" /> 106 106 <element name="link" type="tns:link" /> 107 <element name="preset_link" type="tns:preset_link" /> 107 108 <element name="text" type="tns:text" /> 108 109 <element name="combo" type="tns:combo" /> … … 129 130 <attribute name="name" use="prohibited" /> 130 131 <anyAttribute processContents="skip" /> 132 </complexType> 133 134 <complexType name="preset_link"> 135 <attribute name="preset_name" type="string" use="required" /> 136 <attribute name="name" use="prohibited" /> 131 137 </complexType> 132 138 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java
r6403 r6572 40 40 * the corresponding preset when clicked 41 41 */ 42 p rivatestatic class PresetLabelML implements MouseListener {42 public static class PresetLabelML implements MouseListener { 43 43 final JLabel label; 44 44 final Font hover; … … 47 47 final PresetHandler presetHandler; 48 48 49 PresetLabelML(JLabel lbl, TaggingPreset t, PresetHandler presetHandler) {49 public PresetLabelML(JLabel lbl, TaggingPreset t, PresetHandler presetHandler) { 50 50 super(); 51 51 label = lbl; … … 82 82 } 83 83 84 public static JLabel createLabelForPreset(TaggingPreset t) { 85 JLabel lbl = new JLabel(t.getName() + " …"); 86 lbl.setIcon(t.getIcon()); 87 return lbl; 88 } 89 84 90 public void updatePresets(final Collection<TaggingPresetType> types, final Map<String, String> tags, PresetHandler presetHandler) { 85 91 … … 91 97 92 98 for (TaggingPreset t : TaggingPreset.getMatchingPresets(types, tags, true)) { 93 JLabel lbl = new JLabel(t.getName() + " …"); 94 lbl.setIcon(t.getIcon()); 99 final JLabel lbl = createLabelForPreset(t); 95 100 lbl.addMouseListener(new PresetLabelML(lbl, t, presetHandler)); 96 101 add(lbl, GBC.eol().fill(GBC.HORIZONTAL)); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r6403 r6572 11 11 import java.awt.Insets; 12 12 import java.awt.event.ActionEvent; 13 import java.awt.event.MouseEvent; 13 14 import java.util.ArrayList; 14 15 import java.util.Collection; … … 40 41 import org.openstreetmap.josm.gui.ExtendedDialog; 41 42 import org.openstreetmap.josm.gui.MapView; 43 import org.openstreetmap.josm.gui.dialogs.properties.PresetListPanel; 42 44 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 43 45 import org.openstreetmap.josm.gui.layer.Layer; … … 207 209 PresetPanel p = new PresetPanel(); 208 210 LinkedList<TaggingPresetItem> l = new LinkedList<TaggingPresetItem>(); 211 LinkedList<TaggingPresetItem> presetLink = new LinkedList<TaggingPresetItem>(); 209 212 if(types != null){ 210 213 JPanel pp = new JPanel(); … … 221 224 if(i instanceof Link) { 222 225 l.add(i); 226 } else if (i instanceof TaggingPresetItems.PresetLink) { 227 presetLink.add(i); 223 228 } else { 224 229 if(i.addToPanel(items, selected)) { … … 232 237 } 233 238 239 // add PresetLink 240 if (!presetLink.isEmpty()) { 241 p.add(new JLabel(tr("Edit also …")), GBC.eol().insets(0, 8, 0, 0)); 242 } 243 for(TaggingPresetItem link : presetLink) { 244 link.addToPanel(p, selected); 245 } 246 247 // add Link 234 248 for(TaggingPresetItem link : l) { 235 249 link.addToPanel(p, selected); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
r6442 r6572 12 12 import java.awt.event.ActionEvent; 13 13 import java.awt.event.ActionListener; 14 import java.awt.event.MouseEvent; 14 15 import java.io.File; 15 16 import java.lang.reflect.Method; … … 48 49 import org.openstreetmap.josm.data.osm.Tag; 49 50 import org.openstreetmap.josm.data.preferences.BooleanProperty; 51 import org.openstreetmap.josm.gui.dialogs.properties.PresetListPanel; 52 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 50 53 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 51 54 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPriority; … … 57 60 import org.openstreetmap.josm.tools.GBC; 58 61 import org.openstreetmap.josm.tools.ImageProvider; 62 import org.openstreetmap.josm.tools.Predicate; 59 63 import org.openstreetmap.josm.tools.Utils; 60 64 import org.xml.sax.SAXException; … … 375 379 } 376 380 if (url != null) { 377 p.add(new UrlLabel(url, locale_text, 2), GBC.eol(). anchor(GBC.WEST));381 p.add(new UrlLabel(url, locale_text, 2), GBC.eol().insets(0, 10, 0, 0)); 378 382 } 379 383 return false; … … 385 389 + (href != null ? "href=" + href + ", " : "") 386 390 + (locale_href != null ? "locale_href=" + locale_href + ", " : ""); 391 } 392 } 393 394 public static class PresetLink extends TaggingPresetItem { 395 396 public String preset_name = ""; 397 398 @Override 399 boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 400 final String presetName = preset_name; 401 final TaggingPreset t = Utils.filter(TaggingPresetPreference.taggingPresets, new Predicate<TaggingPreset>() { 402 @Override 403 public boolean evaluate(TaggingPreset object) { 404 return presetName.equals(object.name); 405 } 406 }).iterator().next(); 407 if (t == null) return false; 408 JLabel lbl = PresetListPanel.createLabelForPreset(t); 409 lbl.addMouseListener(new PresetListPanel.PresetLabelML(lbl, t, null) { 410 @Override 411 public void mouseClicked(MouseEvent arg0) { 412 t.actionPerformed(null); 413 } 414 }); 415 p.add(lbl, GBC.eol().fill(GBC.HORIZONTAL)); 416 return false; 417 } 418 419 @Override 420 void addCommands(List<Tag> changedTags) { 387 421 } 388 422 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetReader.java
r6562 r6572 72 72 parser.map("text", TaggingPresetItems.Text.class); 73 73 parser.map("link", TaggingPresetItems.Link.class); 74 parser.map("preset_link", TaggingPresetItems.PresetLink.class); 74 75 parser.mapOnStart("optional", TaggingPresetItems.Optional.class); 75 76 parser.mapOnStart("roles", TaggingPresetItems.Roles.class);
Note:
See TracChangeset
for help on using the changeset viewer.