Changeset 6572 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2013-12-31T01:38:06+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
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.