Ignore:
Timestamp:
2013-11-13T20:36:34+01:00 (11 years ago)
Author:
raupach
Message:

add support for addr:place

Location:
applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java

    r29475 r30048  
    88public class Dto implements Serializable
    99{
    10    private static final long serialVersionUID = -4035800761473241695L;
     10
     11   private static final long serialVersionUID = 5226513739078369787L;
    1112
    1213   private boolean saveBuilding = true;
     
    1819   private boolean saveHousenumber = true;
    1920
     21   private boolean tagStreet = true; // use tag addr:street or addr:place
     22   
    2023   private String building = "yes";
    2124   private String country;
     
    2427   private String postcode;
    2528   private String street;
     29   private String place;
    2630   private String housenumber;
    2731   private int housenumberChangeValue = 0;
     
    176180      this.building = building;
    177181   }
     182
     183   public boolean isTagStreet()
     184   {
     185       return tagStreet;
     186   }
     187
     188   public void setTagStreet(boolean tagStreet)
     189   {
     190       this.tagStreet = tagStreet;
     191   }
     192
     193   public String getPlace()
     194   {
     195       return place;
     196   }
     197
     198   public void setPlace(String place)
     199   {
     200       this.place = place;
     201   }
    178202}
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java

    r29778 r30048  
    88import java.awt.GridBagLayout;
    99import java.awt.event.ActionEvent;
     10import java.awt.event.ItemEvent;
     11import java.awt.event.ItemListener;
    1012import java.io.File;
    1113import java.io.FileInputStream;
     
    2022import java.util.logging.Logger;
    2123
     24import javax.swing.ButtonGroup;
    2225import javax.swing.JCheckBox;
    2326import javax.swing.JComboBox;
    2427import javax.swing.JLabel;
    2528import javax.swing.JPanel;
     29import javax.swing.JRadioButton;
    2630import javax.swing.JSlider;
    2731import javax.swing.JTextField;
     
    4549{
    4650   private static final String APPLY_CHANGES = tr("Apply Changes");
     51   private static final String TAG_STREET_OR_PLACE = tr("Use tag 'addr:street' or 'addr:place'");
    4752   
    4853   public static final String TAG_BUILDING = "building";
     
    5358   public static final String TAG_ADDR_HOUSENUMBER = "addr:housenumber";
    5459   public static final String TAG_ADDR_STREET = "addr:street";
     60   public static final String TAG_ADDR_PLACE = "addr:place";
    5561
    5662   public static final String[] buildingStrings = {"yes", "apartments", "chapel", "church", "commercial", "dormitory", "hotel", "house", "residential", "terrace",  "industrial", "retail", "warehouse", "cathedral",  "civic", "hospital", "school", "train_station", "transportation", "university", "public", "bridge", "bunker", "cabin", "construction", "farm_auxiliary", "garage", "garages" , "greenhouse", "hangar", "hut", "roof", "shed", "stable" };
    5763   
    5864   private static final int FPS_MIN = -2;
    59    private static final int FPS_MAX = 2;
     65   private static final int FPS_MAX =  2;
    6066   
    6167   private static final long serialVersionUID = 6414385452106276923L;
     
    8389   private JCheckBox housenumberEnabled;
    8490   private JSlider housenumberChangeSequence;
    85    private JComboBox building;
     91   private JComboBox<String[]> building;
     92   private JRadioButton streetRadio;
     93   private JRadioButton placeRadio;
    8694
    8795   public TagDialog(String pluginDir, OsmPrimitive p_selection)
     
    127135      c.gridy = 0;
    128136      c.weightx = 0;
     137      c.gridwidth = 3;
    129138      editPanel.add(buildingEnabled, c);
    130139
     
    133142      building.setSelectedItem(dto.getBuilding());
    134143      building.setMaximumRowCount(50);
    135       c.gridx = 1;
     144      c.gridx = 3;
    136145      c.gridy = 0;
    137146      c.weightx = 1;
     147      c.gridwidth = 1;
    138148      editPanel.add(building, c);
    139149     
     
    148158      c.gridy = 1;
    149159      c.weightx = 0;
     160      c.gridwidth = 3;
    150161      editPanel.add(countryEnabled, c);
    151162
     
    156167      country.setSelectedItem(dto.getCountry());
    157168      c.fill = GridBagConstraints.HORIZONTAL;
    158       c.gridx = 1;
     169      c.gridx = 3;
    159170      c.gridy = 1;
    160171      c.weightx = 1;
     172      c.gridwidth = 1;
    161173      editPanel.add(country, c);
    162174
     
    171183      c.gridy = 2;
    172184      c.weightx = 0;
     185      c.gridwidth = 3;
    173186      editPanel.add(stateEnabled, c);
    174187
     
    179192      state.setSelectedItem(dto.getState());
    180193      c.fill = GridBagConstraints.HORIZONTAL;
    181       c.gridx = 1;
     194      c.gridx = 3;
    182195      c.gridy = 2;
    183196      c.weightx = 1;
     197      c.gridwidth = 1;
    184198      editPanel.add(state, c);
    185199
     
    193207      c.gridy = 3;
    194208      c.weightx = 0;
     209      c.gridwidth = 3;
    195210      editPanel.add(cityEnabled, c);
    196211
     
    201216      city.setSelectedItem(dto.getCity());
    202217      c.fill = GridBagConstraints.HORIZONTAL;
    203       c.gridx = 1;
     218      c.gridx = 3;
    204219      c.gridy = 3;
    205220      c.weightx = 1;
     221      c.gridwidth = 1;
    206222      editPanel.add(city, c);
    207223
     
    215231      c.gridy = 4;
    216232      c.weightx = 0;
     233      c.gridwidth = 3;
    217234      editPanel.add(zipEnabled, c);
    218235
     
    223240      postcode.setSelectedItem(dto.getPostcode());
    224241      c.fill = GridBagConstraints.HORIZONTAL;
    225       c.gridx = 1;
     242      c.gridx = 3;
    226243      c.gridy = 4;
    227244      c.weightx = 1;
     245      c.gridwidth = 1;
    228246      editPanel.add(postcode, c);
    229247
    230248      // street
    231       streetEnabled = new JCheckBox(TAG_ADDR_STREET);
     249      streetEnabled = new JCheckBox();
    232250      streetEnabled.setFocusable(false);
    233251      streetEnabled.setSelected(dto.isSaveStreet());
     
    237255      c.gridy = 5;
    238256      c.weightx = 0;
     257      c.gridwidth = 1;
    239258      editPanel.add(streetEnabled, c);
    240259
     260     
     261      streetRadio = new JRadioButton(TAG_ADDR_STREET);
     262      streetRadio.setToolTipText(TAG_STREET_OR_PLACE);
     263      streetRadio.setSelected(dto.isTagStreet());
     264      streetRadio.addItemListener(new RadioChangeListener());
     265      c.fill = GridBagConstraints.HORIZONTAL;
     266      c.gridx = 1;
     267      c.gridy = 5;
     268      c.weightx = 0;
     269      c.gridwidth = 1;
     270      editPanel.add(streetRadio, c);
     271     
     272      placeRadio = new JRadioButton("addr:place");
     273      placeRadio.setToolTipText(TAG_STREET_OR_PLACE);
     274      placeRadio.setSelected(!dto.isTagStreet());
     275      placeRadio.addItemListener(new RadioChangeListener());
     276      c.fill = GridBagConstraints.HORIZONTAL;
     277      c.gridx = 2;
     278      c.gridy = 5;
     279      c.weightx = 0;
     280      c.gridwidth = 1;
     281      editPanel.add(placeRadio, c);
     282     
     283      ButtonGroup g = new ButtonGroup();
     284      g.add( streetRadio );
     285      g.add( placeRadio );
     286     
    241287      street = new AutoCompletingComboBox();
    242       street.setPossibleItems(getPossibleStreets());
     288      if (dto.isTagStreet())
     289      {
     290          street.setPossibleItems(getPossibleStreets());
     291      }
     292      else
     293      {
     294          street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE));
     295      }
    243296      street.setPreferredSize(new Dimension(200, 24));
    244297      street.setEditable(true);
    245298      street.setSelectedItem(dto.getStreet());
    246299      c.fill = GridBagConstraints.HORIZONTAL;
    247       c.gridx = 1;
     300      c.gridx = 3;
    248301      c.gridy = 5;
    249302      c.weightx = 1;
     303      c.gridwidth = 1;
    250304      editPanel.add(street, c);
    251305
     
    259313      c.gridy = 6;
    260314      c.weightx = 0;
     315      c.gridwidth = 3;
    261316      editPanel.add(housenumberEnabled, c);
    262317
     
    275330     
    276331      c.fill = GridBagConstraints.HORIZONTAL;
    277       c.gridx = 1;
     332      c.gridx = 3;
    278333      c.gridy = 6;
    279334      c.weightx = 1;
     335      c.gridwidth = 1;
    280336      editPanel.add(housnumber, c);
    281337     
     
    285341      c.gridy = 7;
    286342      c.weightx = 0;
     343      c.gridwidth = 3;
    287344      editPanel.add(seqLabel, c);
    288345
     
    293350      housenumberChangeSequence.setPaintLabels(true);
    294351      housenumberChangeSequence.setSnapToTicks(true);
    295       c.gridx = 1;
     352      c.gridx = 3;
    296353      c.gridy = 7;
    297354      c.weightx = 1;
     355      c.gridwidth = 1;
    298356      editPanel.add(housenumberChangeSequence, c);
    299357   
     
    313371         dto.setSavePostcode(zipEnabled.isSelected());
    314372         dto.setSaveStreet(streetEnabled.isSelected());
    315 
     373         dto.setTagStreet(streetRadio.isSelected());
     374         
    316375         dto.setBuilding((String) building.getSelectedItem());
    317376         dto.setCity(getAutoCompletingComboBoxValue(city));
     
    408467      }
    409468
    410       if (dto.isSaveStreet()) {
    411          String value = selection.get(TagDialog.TAG_ADDR_STREET);
    412          if (value == null || (value != null && !value.equals(dto.getStreet())))
    413          {
    414             ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, dto.getStreet());
    415             commands.add(command);
    416          }
    417       }
     469        if (dto.isSaveStreet())
     470        {
     471            if (dto.isTagStreet())
     472            {
     473                String value = selection.get(TagDialog.TAG_ADDR_STREET);
     474                if (value == null || (value != null && !value.equals(dto.getStreet())))
     475                {
     476                    ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, dto.getStreet());
     477                    commands.add(command);
     478                   
     479                    // remove old place-tag
     480                    if (selection.get(TagDialog.TAG_ADDR_PLACE) != null)
     481                    {
     482                        ChangePropertyCommand command2 = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, null);
     483                        commands.add(command2);
     484                    }
     485                }
     486            }
     487            else
     488            {
     489                String value = selection.get(TagDialog.TAG_ADDR_PLACE);
     490                if (value == null || (value != null && !value.equals(dto.getStreet())))
     491                {
     492                    ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, dto.getStreet());
     493                    commands.add(command);
     494                   
     495                    // remove old place-tag
     496                    if (selection.get(TagDialog.TAG_ADDR_STREET) != null)
     497                    {
     498                        ChangePropertyCommand command2 = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, null);
     499                        commands.add(command2);
     500                    }
     501                }
     502            }
     503        }
    418504
    419505      if (dto.isSaveState()) {
     
    475561
    476562   }
     563   
     564    class RadioChangeListener implements ItemListener
     565    {
     566
     567         @Override
     568        public void itemStateChanged(ItemEvent e)
     569        {
     570            if (streetRadio.isSelected())
     571            {
     572                street.setPossibleItems(getPossibleStreets());
     573            }
     574            else
     575            {
     576                street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE));
     577            }
     578        }
     579
     580    }
    477581}
Note: See TracChangeset for help on using the changeset viewer.