Changeset 6795 in josm
- Timestamp:
- 2014-01-31T21:42:40+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r6772 r6795 11 11 import java.awt.Insets; 12 12 import java.awt.event.ActionEvent; 13 import java.awt.event.MouseEvent;14 13 import java.util.ArrayList; 15 14 import java.util.Collection; … … 41 40 import org.openstreetmap.josm.gui.ExtendedDialog; 42 41 import org.openstreetmap.josm.gui.MapView; 43 import org.openstreetmap.josm.gui.dialogs.properties.PresetListPanel;44 42 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 45 43 import org.openstreetmap.josm.gui.layer.Layer; … … 220 218 } 221 219 220 boolean presetInitiallyMatches = !selected.isEmpty() && Utils.forAll(selected, this); 222 221 JPanel items = new JPanel(new GridBagLayout()); 223 222 for (TaggingPresetItem i : data){ … … 227 226 presetLink.add(i); 228 227 } else { 229 if(i.addToPanel(items, selected )) {228 if(i.addToPanel(items, selected, presetInitiallyMatches)) { 230 229 p.hasElements = true; 231 230 } … … 240 239 if (!presetLink.isEmpty()) { 241 240 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);241 for(TaggingPresetItem link : presetLink) { 242 link.addToPanel(p, selected, presetInitiallyMatches); 243 } 245 244 } 246 245 247 246 // add Link 248 247 for(TaggingPresetItem link : l) { 249 link.addToPanel(p, selected );248 link.addToPanel(p, selected, presetInitiallyMatches); 250 249 } 251 250 … … 275 274 } 276 275 277 static boolean presetInitiallyMatches = false;278 279 276 @Override 280 277 public void actionPerformed(ActionEvent e) { … … 283 280 284 281 Collection<OsmPrimitive> sel = createSelection(Main.main.getCurrentDataSet().getSelected()); 285 presetInitiallyMatches = !sel.isEmpty() && Utils.forAll(sel, this);286 282 int answer = showDialog(sel, supportsRelation()); 287 283 -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItem.java
r6336 r6795 35 35 * Called by {@link TaggingPreset#createPanel} during tagging preset panel creation. 36 36 * All components defining this tagging preset item must be added to given panel. 37 * 37 38 * @param p The panel where components must be added 38 39 * @param sel The related selected OSM primitives 40 * @param presetInitiallyMatches Whether this {@link TaggingPreset} already matched before applying, 41 * i.e. whether the map feature already existed on the primitive. 39 42 * @return {@code true} if this item adds semantic tagging elements, {@code false} otherwise. 40 43 */ 41 abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel );44 abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches); 42 45 43 46 /** -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
r6792 r6795 352 352 353 353 @Override 354 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {354 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 355 355 initializeLocaleText(null); 356 356 p.add(new JLabel(locale_text), GBC.eol()); … … 372 372 373 373 @Override 374 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {374 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 375 375 initializeLocaleText(tr("More information about this feature")); 376 376 String url = locale_href; … … 397 397 398 398 @Override 399 boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {399 boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 400 400 final String presetName = preset_name; 401 401 final TaggingPreset t = Utils.filter(TaggingPresetPreference.taggingPresets, new Predicate<TaggingPreset>() { … … 427 427 428 428 @Override 429 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {429 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 430 430 p.add(new JLabel(" "), GBC.eol()); // space 431 431 if (!roles.isEmpty()) { … … 452 452 // TODO: Draw a box around optional stuff 453 453 @Override 454 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {454 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 455 455 initializeLocaleText(tr("Optional Attributes:")); 456 456 p.add(new JLabel(" "), GBC.eol()); // space … … 464 464 465 465 @Override 466 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {466 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 467 467 p.add(new JLabel(" "), GBC.eol()); // space 468 468 return false; … … 486 486 487 487 @Override 488 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {488 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 489 489 p.add(new JSeparator(), GBC.eol().fill(GBC.HORIZONTAL).insets(0, 5, 0, 5)); 490 490 return false; … … 540 540 541 541 @Override 542 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {542 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 543 543 return false; 544 544 } … … 578 578 private JComponent value; 579 579 580 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {580 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 581 581 582 582 // find out if our key is already used in the selection. … … 597 597 else if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) { 598 598 // selected osm primitives are untagged or filling default values feature is enabled 599 if (!"false".equals(use_last_as_default) && lastValue.containsKey(key) && ! TaggingPreset.presetInitiallyMatches) {599 if (!"false".equals(use_last_as_default) && lastValue.containsKey(key) && !presetInitiallyMatches) { 600 600 textField.setText(lastValue.get(key)); 601 601 } else { … … 760 760 761 761 @Override 762 boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {762 boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 763 763 Integer cols = Integer.valueOf(columns); 764 764 int rows = (int) Math.ceil(checks.size()/cols.doubleValue()); … … 766 766 767 767 for (Check check : checks) { 768 check.addToPanel(panel, sel );768 check.addToPanel(panel, sel, presetInitiallyMatches); 769 769 } 770 770 … … 797 797 private boolean def; 798 798 799 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {799 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 800 800 801 801 // find out if our key is already used in the selection. … … 912 912 913 913 protected abstract Object getSelectedItem(); 914 protected abstract void addToPanelAnchor(JPanel p, String def );914 protected abstract void addToPanelAnchor(JPanel p, String def, boolean presetInitiallyMatches); 915 915 916 916 protected char getDelChar() { … … 935 935 936 936 @Override 937 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel ) {937 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 938 938 939 939 initListEntries(); … … 946 946 947 947 p.add(new JLabel(tr("{0}:", locale_text)), GBC.std().insets(0, 0, 10, 0)); 948 addToPanelAnchor(p, default_ );948 addToPanelAnchor(p, default_, presetInitiallyMatches); 949 949 950 950 return true; … … 1181 1181 1182 1182 @Override 1183 protected void addToPanelAnchor(JPanel p, String def ) {1183 protected void addToPanelAnchor(JPanel p, String def, boolean presetInitiallyMatches) { 1184 1184 if (!usage.unused()) { 1185 1185 for (String s : usage.values) { … … 1227 1227 // all items were unset (and so is default) 1228 1228 originalValue = lhm.get(""); 1229 if ("force".equals(use_last_as_default) && lastValue.containsKey(key) && ! TaggingPreset.presetInitiallyMatches) {1229 if ("force".equals(use_last_as_default) && lastValue.containsKey(key) && !presetInitiallyMatches) { 1230 1230 combo.setSelectedItem(lhm.get(lastValue.get(key))); 1231 1231 } else { … … 1260 1260 1261 1261 @Override 1262 protected void addToPanelAnchor(JPanel p, String def ) {1262 protected void addToPanelAnchor(JPanel p, String def, boolean presetInitiallyMatches) { 1263 1263 list = new ConcatenatingJList(delimiter, lhm.values().toArray()); 1264 1264 component = list;
Note:
See TracChangeset
for help on using the changeset viewer.