- Timestamp:
- 2013-08-06T23:48:20+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
r6093 r6114 6 6 import java.awt.Font; 7 7 import java.awt.GridBagLayout; 8 import java.awt.GridLayout; 8 9 import java.awt.event.ActionEvent; 9 10 import java.awt.event.ActionListener; … … 24 25 import java.util.Map; 25 26 import java.util.TreeSet; 27 26 28 import javax.swing.ButtonGroup; 27 29 import javax.swing.ImageIcon; … … 35 37 import javax.swing.ListCellRenderer; 36 38 import javax.swing.ListModel; 39 37 40 import org.xml.sax.SAXException; 38 39 41 import org.openstreetmap.josm.Main; 40 42 import org.openstreetmap.josm.actions.search.SearchCompiler; … … 315 317 public void addCommands(List<Tag> changedTags) { 316 318 } 319 320 @Override 321 public String toString() { 322 return "Label [" 323 + (text != null ? "text=" + text + ", " : "") 324 + (text_context != null ? "text_context=" + text_context 325 + ", " : "") 326 + (locale_text != null ? "locale_text=" + locale_text : "") 327 + "]"; 328 } 317 329 } 318 330 … … 391 403 public void addCommands(List<Tag> changedTags) { 392 404 } 405 406 @Override 407 public String toString() { 408 return "Optional"; 409 } 393 410 } 394 411 … … 403 420 @Override 404 421 public void addCommands(List<Tag> changedTags) { 422 } 423 424 @Override 425 public String toString() { 426 return "Space"; 405 427 } 406 428 } … … 643 665 return Collections.emptyList(); 644 666 return Collections.singleton(default_); 667 } 668 } 669 670 /** 671 * A group of {@link Check}s. 672 * @since 6114 673 */ 674 public static class CheckGroup extends TaggingPresetItem { 675 676 /** 677 * Number of columns (positive integer) 678 */ 679 public String columns; 680 681 /** 682 * List of checkboxes 683 */ 684 public final List<Check> checks = new LinkedList<Check>(); 685 686 @Override 687 boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel) { 688 Integer cols = new Integer(columns); 689 int rows = (int) Math.ceil((double)checks.size()/cols.doubleValue()); 690 JPanel panel = new JPanel(new GridLayout(rows, cols)); 691 692 for (Check check : checks) { 693 check.addToPanel(panel, sel); 694 } 695 696 p.add(panel, GBC.eol()); 697 return false; 698 } 699 700 @Override 701 void addCommands(List<Tag> changedTags) { 702 } 703 704 @Override 705 public String toString() { 706 return "CheckGroup [columns=" + columns + "]"; 645 707 } 646 708 } … … 734 796 public Collection<String> getValues() { 735 797 return Arrays.asList(value_on, value_off); 798 } 799 800 @Override 801 public String toString() { 802 return "Check [" 803 + (locale_text != null ? "locale_text=" + locale_text + ", " : "") 804 + (value_on != null ? "value_on=" + value_on + ", " : "") 805 + (value_off != null ? "value_off=" + value_off + ", " : "") 806 + "default_=" + default_ + ", " 807 + (check != null ? "check=" + check + ", " : "") 808 + (initialState != null ? "initialState=" + initialState 809 + ", " : "") + "def=" + def + "]"; 736 810 } 737 811 } -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetReader.java
r6093 r6114 12 12 import java.util.LinkedList; 13 13 import java.util.List; 14 14 15 import javax.swing.JOptionPane; 16 15 17 import org.xml.sax.SAXException; 16 17 18 import org.openstreetmap.josm.Main; 18 19 import org.openstreetmap.josm.gui.preferences.SourceEntry; … … 58 59 parser.mapOnStart("roles", TaggingPresetItems.Roles.class); 59 60 parser.map("role", TaggingPresetItems.Role.class); 61 parser.map("checkgroup", TaggingPresetItems.CheckGroup.class); 60 62 parser.map("check", TaggingPresetItems.Check.class); 61 63 parser.map("combo", TaggingPresetItems.Combo.class); … … 69 71 TaggingPresetMenu lastmenu = null; 70 72 TaggingPresetItems.Roles lastrole = null; 73 final List<TaggingPresetItems.Check> checks = new LinkedList<TaggingPresetItems.Check>(); 71 74 List<TaggingPresetItems.PresetListEntry> listEntries = new LinkedList<TaggingPresetItems.PresetListEntry>(); 72 75 … … 113 116 throw new SAXException(tr("Preset role element without parent")); 114 117 lastrole.roles.add((TaggingPresetItems.Role) o); 118 } else if (o instanceof TaggingPresetItems.Check) { 119 checks.add((TaggingPresetItems.Check) o); 115 120 } else if (o instanceof TaggingPresetItems.PresetListEntry) { 116 121 listEntries.add((TaggingPresetItems.PresetListEntry) o); 122 } else if (o instanceof TaggingPresetItems.CheckGroup) { 123 all.getLast().data.add((TaggingPresetItem) o); 124 ((TaggingPresetItems.CheckGroup) o).checks.addAll(checks); 125 checks.clear(); 117 126 } else { 127 if (!checks.isEmpty()) { 128 all.getLast().data.addAll(checks); 129 checks.clear(); 130 } 118 131 all.getLast().data.add((TaggingPresetItem) o); 119 132 if (o instanceof TaggingPresetItems.ComboMultiSelect) {
Note:
See TracChangeset
for help on using the changeset viewer.