Changeset 30057 in osm for applications/editors


Ignore:
Timestamp:
2013-11-17T20:09:32+01:00 (11 years ago)
Author:
donvip
Message:

[josm_building_tools] arbitrary housenumber increment (patch by kre3d)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/AddressDialog.java

    r30045 r30057  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.Choice;
    76import java.text.NumberFormat;
    87import java.text.ParseException;
    98
     9import javax.swing.JSpinner;
    1010import javax.swing.JTextField;
     11import javax.swing.SpinnerNumberModel;
    1112
    1213@SuppressWarnings("serial")
    1314public class AddressDialog extends MyDialog {
    1415    private static String lhousenum, lstreetname;
    15     private static boolean inc = true;
     16    private static int inc = 0;
    1617    private JTextField housenum = new JTextField();
    1718    private JTextField streetname = new JTextField();
    18     private Choice cincdec = new Choice();
     19    private JSpinner incSpinner;
    1920
    2021    public AddressDialog() {
     
    2627        streetname.setText(lstreetname);
    2728
    28         cincdec.add(tr("Increment"));
    29         cincdec.add(tr("Decrement"));
    30         cincdec.select(inc ? 0 : 1);
    31         addLabelled(tr("Numbers:"), cincdec);
     29        SpinnerNumberModel inc_model = new SpinnerNumberModel(0, Integer.MIN_VALUE, Integer.MAX_VALUE, 1);
     30        incSpinner = new JSpinner(inc_model);
     31        incSpinner.setValue(inc);
     32        addLabelled(tr("Number increment:"), incSpinner);
    3233
    3334        setContent(panel);
     
    3940            return "";
    4041        try {
    41             Integer num = NumberFormat.getInstance().parse(lhousenum).intValue();
    42             if (inc)
    43                 num = num + 2;
    44             else
    45                 num = num - 2;
     42            Integer num = NumberFormat.getInstance().parse(lhousenum).intValue() + inc;
    4643            return num.toString();
    4744        } catch (ParseException e) {
     
    5350        lhousenum = housenum.getText();
    5451        lstreetname = streetname.getText();
    55         inc = cincdec.getSelectedIndex() == 0;
     52        inc = (Integer) incSpinner.getValue();
    5653    }
    5754
Note: See TracChangeset for help on using the changeset viewer.