- Timestamp:
- 2009-02-15T15:16:23+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/JMultilineLabel.java
r1397 r1407 93 93 float w = insets.left + insets.right; 94 94 float x = insets.left, y=insets.top; 95 96 95 97 96 if (width > 0 && text != null && text.length() > 0) { 98 String[] lines = getText().split("\n"); 97 String[] lines = getText().split("\n"); 99 98 for(String line : lines) { 100 99 // Insert a space so new lines get rendered -
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r1397 r1407 24 24 import java.util.HashMap; 25 25 import java.util.HashSet; 26 import java.util.LinkedList; 26 27 import java.util.Map; 27 28 import java.util.TreeMap; … … 53 54 import org.openstreetmap.josm.data.SelectionChangedListener; 54 55 import org.openstreetmap.josm.data.osm.DataSet; 56 import org.openstreetmap.josm.data.osm.Node; 55 57 import org.openstreetmap.josm.data.osm.OsmPrimitive; 56 58 import org.openstreetmap.josm.data.osm.Relation; 57 59 import org.openstreetmap.josm.data.osm.RelationMember; 60 import org.openstreetmap.josm.data.osm.Way; 58 61 import org.openstreetmap.josm.data.osm.visitor.NameVisitor; 59 62 import org.openstreetmap.josm.gui.ExtendedDialog; 63 import org.openstreetmap.josm.gui.JMultilineLabel; 60 64 import org.openstreetmap.josm.gui.MapFrame; 61 65 import org.openstreetmap.josm.gui.SideButton; 66 import org.openstreetmap.josm.gui.preferences.TaggingPresetPreference; 67 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 62 68 import org.openstreetmap.josm.tools.AutoCompleteComboBox; 63 69 import org.openstreetmap.josm.tools.GBC; … … 438 444 private final SideButton btnEdit; 439 445 private final SideButton btnDel; 446 private final JMultilineLabel presets = new JMultilineLabel(""); 440 447 441 448 private final JLabel selectSth = new JLabel("<html><p>" + tr("Please select the objects you want to change properties for.") + "</p></html>"); … … 525 532 bothTables.add(membershipTable.getTableHeader(), GBC.eol().fill(GBC.HORIZONTAL)); 526 533 bothTables.add(membershipTable, GBC.eol().fill(GBC.BOTH)); 534 bothTables.add(presets, GBC.eol().fill().insets(10, 10, 10, 10)); 527 535 528 536 DblClickWatch dblClickWatch = new DblClickWatch(); … … 532 540 scrollPane.addMouseListener(dblClickWatch); 533 541 add(scrollPane, BorderLayout.CENTER); 534 542 535 543 selectSth.setPreferredSize(scrollPane.getSize()); 544 presets.setPreferredSize(scrollPane.getSize()); 536 545 537 546 JPanel buttonPanel = new JPanel(new GridLayout(1,3)); … … 549 558 NameVisitor n = new NameVisitor(); 550 559 cur.visit(n); 551 552 int result = new ExtendedDialog(Main.parent, 553 tr("Change relation"), 560 561 int result = new ExtendedDialog(Main.parent, 562 tr("Change relation"), 554 563 tr("Really delete selection from relation {0}?", n.name), 555 new String[] {tr("Delete from relation"), tr("Cancel")}, 556 new String[] {"dialogs/delete.png", "cancel.png"}).getValue(); 557 564 new String[] {tr("Delete from relation"), tr("Cancel")}, 565 new String[] {"dialogs/delete.png", "cancel.png"}).getValue(); 566 558 567 if(result == 1) 559 568 { … … 620 629 } 621 630 631 private void checkPresets(int nodes, int ways, int relations, int closedways) 632 { 633 LinkedList<TaggingPreset> p = new LinkedList<TaggingPreset>(); 634 int total = nodes+ways+relations+closedways; 635 if(total != 0) 636 { 637 for(TaggingPreset t : TaggingPresetPreference.taggingPresets) 638 { 639 if(!( (relations > 0 && !t.types.contains("relation")) && 640 (nodes > 0 && !t.types.contains("node")) && 641 (ways+closedways > 0 && !t.types.contains("way")) && 642 (closedways > 0 && !t.types.contains("closedway")))) 643 { 644 int found = 0; 645 for(TaggingPreset.Item i : t.data) 646 { 647 if(i instanceof TaggingPreset.Key) 648 { 649 String val = ((TaggingPreset.Key)i).value; 650 String key = ((TaggingPreset.Key)i).key; 651 // we subtract 100 if not found and add 1 if found 652 found -= 100; 653 if(valueCount.containsKey(key)) 654 { 655 Map<String, Integer> v = valueCount.get(key); 656 if(v.size() == 1 && v.containsKey(val) && v.get(val) == total) 657 { 658 found += 101; 659 } 660 } 661 } 662 } 663 if(found > 0) 664 p.add(t); 665 } 666 } 667 } 668 String t = ""; 669 for(TaggingPreset tp : p) 670 { 671 if(t.length() > 0) 672 t += "\n"; 673 t += tp.getName(); 674 } 675 presets.setText(t); 676 presets.setVisible(t.length() > 0); 677 } 678 622 679 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 623 680 if (!isVisible()) … … 630 687 // re-load property data 631 688 propertyData.setRowCount(0); 689 int nodes = 0; 690 int ways = 0; 691 int relations = 0; 692 int closedways = 0; 632 693 633 694 Map<String, Integer> keyCount = new HashMap<String, Integer>(); 634 695 valueCount.clear(); 635 696 for (OsmPrimitive osm : newSelection) { 697 if(osm instanceof Node) ++nodes; 698 else if(osm instanceof Relation) ++relations; 699 else if(((Way)osm).isClosed()) ++closedways; 700 else ++ways; 636 701 for (Entry<String, String> e : osm.entrySet()) { 637 702 keyCount.put(e.getKey(), keyCount.containsKey(e.getKey()) ? keyCount.get(e.getKey())+1 : 1); … … 666 731 selectSth.setVisible(!hasSelection); 667 732 if(hasTags) propertyTable.changeSelection(0, 0, false, false); 733 734 checkPresets(nodes, ways, relations, closedways); 668 735 669 736 // re-load membership data
Note:
See TracChangeset
for help on using the changeset viewer.