Ignore:
Timestamp:
2010-07-05T00:07:32+02:00 (14 years ago)
Author:
pieren
Message:

fix minor issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java

    r22186 r22188  
    9090    private Way selectedWay;
    9191    private Relation selectedRelation;
    92    
    93     MapFrame mapFrame;
    94    
     92    private boolean shift;
     93
    9594    public Address(MapFrame mapFrame) {
    9695        super(tr("Add address"), "buildings",
     
    9897                Shortcut.registerShortcut("mapmode:buildings", tr("Mode: {0}", tr("Buildings")), KeyEvent.VK_E, Shortcut.GROUP_EDIT),
    9998                mapFrame, getCursor());
    100         this.mapFrame = mapFrame;
    10199    }
    102100
     
    111109
    112110    @Override public void exitMode() {
    113         super.exitMode();
    114         Main.map.mapView.removeMouseListener(this);
     111        if (Main.map.mapView != null) {
     112            super.exitMode();
     113            Main.map.mapView.removeMouseListener(this);
     114        }
    115115        dialog.setVisible(false);
    116116    }
     
    120120        if (e.getButton() != MouseEvent.BUTTON1)
    121121            return;
    122 
     122        shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
    123123        MapView mv = Main.map.mapView;
    124124        Point mousePos = e.getPoint();
     
    142142            }
    143143            if (currentMouseNode.get(tagHouseStreet) != null) {
    144                 inputStreet.setText(currentMouseNode.get(tagHouseNumber));
     144                inputStreet.setText(currentMouseNode.get(tagHouseStreet));
    145145                setSelectedWay((Way)null);
    146146            } else {
     
    203203    private void addAddrToPolygon(List<Way> mouseOnExistingBuildingWays, Collection<Command> cmds) {
    204204        for (Way w:mouseOnExistingBuildingWays) {
    205             cmds.add(new ChangePropertyCommand(w, tagHouseNumber, inputNumber.getText()));
    206205            addAddrToPrimitive(w, cmds);
    207206        }
     
    210209    private void addAddrToPrimitive(OsmPrimitive osm, Collection<Command> cmds) {
    211210        // add the current tag addr:housenumber in node and member in relation
     211        if (shift) {
     212            try {
     213                revertInputNumberChange();
     214            } catch (NumberFormatException en) {
     215                System.out.println("Unable to parse house number \"" + inputNumber.getText() + "\"");
     216            }
     217
     218        }
    212219        cmds.add(new ChangePropertyCommand(osm, tagHouseNumber, inputNumber.getText()));           
    213220        if (Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false)) {
     
    373380        if (minus_two.isSelected() && num > 2)
    374381            num = num - 2;
     382        inputNumber.setText(num.toString());
     383    }
     384   
     385    private void revertInputNumberChange() {
     386        Integer num = Integer.parseInt(inputNumber.getText());
     387        if (plus_one.isSelected())
     388            num = num - 1;
     389        if (plus_two.isSelected())
     390            num = num - 2;
     391        if (minus_one.isSelected() && num > 1)
     392            num = num + 1;
     393        if (minus_two.isSelected() && num > 2)
     394            num = num + 2;
    375395        inputNumber.setText(num.toString());
    376396    }
Note: See TracChangeset for help on using the changeset viewer.