Changeset 1759 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-07-10T20:32:09+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r1743 r1759 67 67 public static abstract class Item { 68 68 public boolean focus = false; 69 abstract voidaddToPanel(JPanel p, Collection<OsmPrimitive> sel);69 abstract boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel); 70 70 abstract void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds); 71 71 boolean requestFocusInWindow() {return false;} … … 133 133 private JComponent value; 134 134 135 @Override public voidaddToPanel(JPanel p, Collection<OsmPrimitive> sel) {135 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 136 136 137 137 // find out if our key is already used in the selection. … … 162 162 p.add(new JLabel(locale_text+":"), GBC.std().insets(0,0,10,0)); 163 163 p.add(value, GBC.eol().fill(GBC.HORIZONTAL)); 164 return true; 164 165 } 165 166 … … 193 194 private boolean def; 194 195 195 @Override public voidaddToPanel(JPanel p, Collection<OsmPrimitive> sel) {196 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 196 197 197 198 // find out if our key is already used in the selection. … … 238 239 } 239 240 p.add(check, GBC.eol().fill(GBC.HORIZONTAL)); 241 return true; 240 242 } 241 243 … … 271 273 private String originalValue; 272 274 273 @Override public voidaddToPanel(JPanel p, Collection<OsmPrimitive> sel) {275 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 274 276 275 277 // find out if our key is already used in the selection. … … 332 334 p.add(new JLabel(locale_text+":"), GBC.std().insets(0,0,10,0)); 333 335 p.add(combo, GBC.eol().fill(GBC.HORIZONTAL)); 336 return true; 334 337 } 335 338 @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) { … … 366 369 public String locale_text; 367 370 368 @Override public voidaddToPanel(JPanel p, Collection<OsmPrimitive> sel) {371 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 369 372 if(locale_text == null) 370 373 locale_text = tr(text); 371 374 p.add(new JLabel(locale_text), GBC.eol()); 375 return false; 372 376 } 373 377 @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {} … … 380 384 public String locale_href; 381 385 382 @Override public voidaddToPanel(JPanel p, Collection<OsmPrimitive> sel) {386 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 383 387 if(locale_text == null) 384 388 locale_text = text == null ? tr("More information about this feature") : tr(text); … … 390 394 p.add(new UrlLabel(url, locale_text), GBC.eol().anchor(GBC.WEST)); 391 395 } 396 return false; 392 397 } 393 398 @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {} … … 396 401 public static class Optional extends Item { 397 402 // TODO: Draw a box around optional stuff 398 @Override public voidaddToPanel(JPanel p, Collection<OsmPrimitive> sel) {403 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 399 404 p.add(new JLabel(" "), GBC.eol()); // space 400 405 p.add(new JLabel(tr("Optional Attributes:")), GBC.eol()); 401 406 p.add(new JLabel(" "), GBC.eol()); // space 407 return false; 402 408 } 403 409 @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {} … … 405 411 406 412 public static class Space extends Item { 407 @Override public voidaddToPanel(JPanel p, Collection<OsmPrimitive> sel) {413 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 408 414 p.add(new JLabel(" "), GBC.eol()); // space 415 return false; 409 416 } 410 417 @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {} … … 415 422 public String value; 416 423 417 @Override public void addToPanel(JPanel p, Collection<OsmPrimitive> sel) {}424 @Override public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { return false; } 418 425 @Override public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) { 419 426 cmds.add(new ChangePropertyCommand(sel, key, value != null && !value.equals("") ? value : null)); … … 570 577 } 571 578 572 public JPanel createPanel(Collection<OsmPrimitive> selected) { 579 private class PresetPanel extends JPanel { 580 boolean hasElements = false; 581 PresetPanel() 582 { 583 super(new GridBagLayout()); 584 } 585 } 586 587 public PresetPanel createPanel(Collection<OsmPrimitive> selected) { 573 588 if (data == null) 574 589 return null; 575 JPanel p = new JPanel(new GridBagLayout());590 PresetPanel p = new PresetPanel(); 576 591 LinkedList<Item> l = new LinkedList<Item>(); 577 592 if(types != null) … … 592 607 l.add(i); 593 608 else 594 i.addToPanel(p, selected); 609 { 610 if(i.addToPanel(p, selected)) 611 p.hasElements = true; 612 } 595 613 } 596 614 for(Item link : l) … … 601 619 public void actionPerformed(ActionEvent e) { 602 620 Collection<OsmPrimitive> sel = createSelection(Main.ds.getSelected()); 603 JPanel p = createPanel(sel);621 PresetPanel p = createPanel(sel); 604 622 if (p == null) 605 623 return; 606 624 607 625 int answer = 1; 608 if (p.getComponentCount() != 0 ) {626 if (p.getComponentCount() != 0 && (sel.size() == 0 || p.hasElements)) { 609 627 String title = trn("Change {0} object", "Change {0} objects", sel.size(), sel.size()); 610 628 if(sel.size() == 0) {
Note:
See TracChangeset
for help on using the changeset viewer.