Ignore:
Timestamp:
2006-07-20T01:29:55+02:00 (19 years ago)
Author:
imi
Message:
  • added <combo> as annotation item
  • added CONTRIBUTION and java version to About dialog
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/gui/dialogs/AnnotationPreset.java

    r116 r117  
    1414
    1515import javax.swing.JCheckBox;
     16import javax.swing.JComboBox;
    1617import javax.swing.JLabel;
    1718import javax.swing.JPanel;
     
    7677                public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
    7778                        cmds.add(new ChangePropertyCommand(sel, key, check.isSelected() ? "true" : null));
     79                }
     80        }
     81
     82        public static class Combo implements Item {
     83                String key;
     84                String label;
     85                JComboBox combo;
     86
     87                public void addToPanel(JPanel p) {
     88                        p.add(new JLabel(label), GBC.std().insets(0,0,10,0));
     89                        p.add(combo, GBC.eol().fill(GBC.HORIZONTAL));
     90                }
     91                public Combo(String key, String label, String def, String[] values, boolean editable) {
     92                        this.key = key;
     93                        this.label = label;
     94                        combo = new JComboBox(values);
     95                        combo.setEditable(editable);
     96                        combo.setSelectedItem(def);
     97                }
     98                public void addCommands(Collection<OsmPrimitive> sel, List<Command> cmds) {
     99                        String str = combo.isEditable()?combo.getEditor().getItem().toString() : combo.getSelectedItem().toString();
     100                        cmds.add(new ChangePropertyCommand(sel, key, str));
    78101                }
    79102        }
     
    120143                                        currentName = "Unnamed Preset #"+(unknownCounter++);
    121144                        } else if (qname.equals("text"))
    122                                 current.add(new Text(a.getValue("key"), a.getValue("label"), a.getValue("default")));
     145                                current.add(new Text(a.getValue("key"), a.getValue("text"), a.getValue("default")));
    123146                        else if (qname.equals("check")) {
    124147                                String s = a.getValue("default");
    125                                 boolean check = s == null || s.equals("0") || s.startsWith("off") || s.startsWith("false") || s.startsWith("no");
    126                                 current.add(new Check(a.getValue("key"), a.getValue("label"), check));
     148                                boolean clear = s == null || s.equals("0") || s.startsWith("off") || s.startsWith("false") || s.startsWith("no");
     149                                current.add(new Check(a.getValue("key"), a.getValue("text"), !clear));
    127150                        } else if (qname.equals("label"))
    128                                 current.add(new Label(a.getValue("label")));
    129                         else if (qname.equals("key"))
     151                                current.add(new Label(a.getValue("text")));
     152                        else if (qname.equals("combo")) {
     153                                String[] values = a.getValue("values").split(",");
     154                                String s = a.getValue("readonly");
     155                                boolean editable = s == null || s.equals("0") || s.startsWith("off") || s.startsWith("false") || s.startsWith("no");
     156                                current.add(new Combo(a.getValue("key"), a.getValue("text"), a.getValue("default"), values, editable));
     157                        } else if (qname.equals("key"))
    130158                                current.add(new Key(a.getValue("key"), a.getValue("value")));
    131159                        else
     
    176204                return p;
    177205        }
    178        
     206
    179207        @Override public String toString() {
    180208                return name;
     
    191219                else
    192220                        return new SequenceCommand(tr("Change Properties"), cmds);
    193     }
     221        }
    194222}
Note: See TracChangeset for help on using the changeset viewer.