Changeset 35814 in osm for applications/editors


Ignore:
Timestamp:
2021-08-31T23:36:28+02:00 (3 years ago)
Author:
Don-vip
Message:

see #21240 - upgrade HouseNumberTaggingTool plugin to JOSM 18173

Location:
applications/editors/josm/plugins/HouseNumberTaggingTool
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/HouseNumberTaggingTool/.settings/org.eclipse.core.resources.prefs

    r34069 r35814  
    11eclipse.preferences.version=1
     2encoding/<project>=UTF-8
     3encoding/src=UTF-8
    24encoding/test=UTF-8
    3 encoding/src=UTF-8
  • applications/editors/josm/plugins/HouseNumberTaggingTool/build.xml

    r35467 r35814  
    44    <property name="commit.message" value="Initial version."/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="13007"/>
     6    <property name="plugin.main.version" value="18173"/>
    77    <!-- Configure these properties (replace "..." accordingly).
    88         See https://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins
  • applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java

    r35508 r35814  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.housenumbertool;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
     5import static org.openstreetmap.josm.tools.I18n.trn;
     6
     7import java.awt.Dimension;
     8import java.awt.Font;
     9import java.awt.GridBagConstraints;
     10import java.awt.GridBagLayout;
     11import java.awt.Insets;
     12import java.awt.event.ActionEvent;
     13import java.awt.event.ItemEvent;
     14import java.awt.event.ItemListener;
     15import java.io.File;
     16import java.io.FileInputStream;
     17import java.io.FileOutputStream;
     18import java.io.ObjectInputStream;
     19import java.io.ObjectOutputStream;
     20import java.util.ArrayList;
     21import java.util.Arrays;
     22import java.util.Collection;
     23import java.util.List;
     24import java.util.Set;
     25import java.util.TreeSet;
     26import java.util.logging.Level;
     27import java.util.logging.Logger;
     28
     29import javax.swing.ButtonGroup;
     30import javax.swing.JButton;
     31import javax.swing.JCheckBox;
     32import javax.swing.JComboBox;
     33import javax.swing.JLabel;
     34import javax.swing.JPanel;
     35import javax.swing.JRadioButton;
     36import javax.swing.JSlider;
     37import javax.swing.JTextField;
     38import javax.swing.SwingUtilities;
    339
    440import org.openstreetmap.josm.command.ChangePropertyCommand;
     
    1046import org.openstreetmap.josm.gui.ExtendedDialog;
    1147import org.openstreetmap.josm.gui.MainApplication;
    12 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox;
     48import org.openstreetmap.josm.gui.tagging.ac.AutoCompComboBox;
    1349import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
    14 
    15 import javax.swing.*;
    16 import java.awt.*;
    17 import java.awt.event.ActionEvent;
    18 import java.awt.event.ItemEvent;
    19 import java.awt.event.ItemListener;
    20 import java.io.*;
    21 import java.util.List;
    22 import java.util.*;
    23 import java.util.logging.Level;
    24 import java.util.logging.Logger;
    25 
    26 import static org.openstreetmap.josm.tools.I18n.tr;
    27 import static org.openstreetmap.josm.tools.I18n.trn;
    2850
    2951/**
     
    4769
    4870    private static final String[] BUILDING_STRINGS = {
    49         "yes", "apartments", "chapel", "church", "commercial", "dormitory", "hotel", "house", "residential", "terrace", 
    50         "industrial", "retail", "warehouse", "cathedral",  "civic", "hospital", "school", "train_station", "transportation", 
    51         "university", "public", "bridge", "bunker", "cabin", "construction", "farm_auxiliary", "garage", "garages", 
     71        "yes", "apartments", "chapel", "church", "commercial", "dormitory", "hotel", "house", "residential", "terrace",
     72        "industrial", "retail", "warehouse", "cathedral",  "civic", "hospital", "school", "train_station", "transportation",
     73        "university", "public", "bridge", "bunker", "cabin", "construction", "farm_auxiliary", "garage", "garages",
    5274        "greenhouse", "hangar", "hut", "roof", "shed", "stable"};
    5375
     
    6385    private static final String TEMPLATE_DATA = "/template.data";
    6486
    65     private AutoCompletingComboBox source;
    66     private AutoCompletingComboBox country;
    67     private AutoCompletingComboBox state;
    68     private AutoCompletingComboBox suburb;
    69     private AutoCompletingComboBox city;
    70     private AutoCompletingComboBox postcode;
    71     private AutoCompletingComboBox street;
     87    private AutoCompComboBox<AutoCompletionItem> source;
     88    private AutoCompComboBox<AutoCompletionItem> country;
     89    private AutoCompComboBox<AutoCompletionItem> state;
     90    private AutoCompComboBox<AutoCompletionItem> suburb;
     91    private AutoCompComboBox<AutoCompletionItem> city;
     92    private AutoCompComboBox<AutoCompletionItem> postcode;
     93    private AutoCompComboBox<AutoCompletionItem> street;
    7294    private JTextField housnumber;
    7395    private JCheckBox buildingEnabled;
     
    221243        editPanel.add(sourceEnabled, c);
    222244
    223         source = new AutoCompletingComboBox();
    224         source.setPossibleAcItems(acm.getTagValues(TAG_SOURCE));
     245        source = new AutoCompComboBox<>();
     246        source.getModel().addAllElements(acm.getTagValues(TAG_SOURCE));
    225247        source.setPreferredSize(new Dimension(200, 24));
    226248        source.setEditable(true);
     
    271293        editPanel.add(countryEnabled, c);
    272294
    273         country = new AutoCompletingComboBox();
    274         country.setPossibleAcItems(acm.getTagValues(TAG_ADDR_COUNTRY));
     295        country = new AutoCompComboBox<>();
     296        country.getModel().addAllElements(acm.getTagValues(TAG_ADDR_COUNTRY));
    275297        country.setPreferredSize(new Dimension(200, 24));
    276298        country.setEditable(true);
     
    321343        editPanel.add(stateEnabled, c);
    322344
    323         state = new AutoCompletingComboBox();
    324         state.setPossibleAcItems(acm.getTagValues(TAG_ADDR_STATE));
     345        state = new AutoCompComboBox<>();
     346        state.getModel().addAllElements(acm.getTagValues(TAG_ADDR_STATE));
    325347        state.setPreferredSize(new Dimension(200, 24));
    326348        state.setEditable(true);
     
    371393        editPanel.add(suburbEnabled, c);
    372394
    373         suburb = new AutoCompletingComboBox();
    374         suburb.setPossibleAcItems(acm.getTagValues(TAG_ADDR_SUBURB));
     395        suburb = new AutoCompComboBox<>();
     396        suburb.getModel().addAllElements(acm.getTagValues(TAG_ADDR_SUBURB));
    375397        suburb.setPreferredSize(new Dimension(200, 24));
    376398        suburb.setEditable(true);
     
    421443        editPanel.add(cityEnabled, c);
    422444
    423         city = new AutoCompletingComboBox();
    424         city.setPossibleAcItems(acm.getTagValues(TAG_ADDR_CITY));
     445        city = new AutoCompComboBox<>();
     446        city.getModel().addAllElements(acm.getTagValues(TAG_ADDR_CITY));
    425447        city.setPreferredSize(new Dimension(200, 24));
    426448        city.setEditable(true);
     
    471493        editPanel.add(zipEnabled, c);
    472494
    473         postcode = new AutoCompletingComboBox();
    474         postcode.setPossibleAcItems(acm.getTagValues(TAG_ADDR_POSTCODE));
     495        postcode = new AutoCompComboBox<>();
     496        postcode.getModel().addAllElements(acm.getTagValues(TAG_ADDR_POSTCODE));
    475497        postcode.setPreferredSize(new Dimension(200, 24));
    476498        postcode.setEditable(true);
     
    549571        g.add(placeRadio);
    550572
    551         street = new AutoCompletingComboBox();
     573        street = new AutoCompComboBox<>();
    552574        if (dto.isTagStreet()) {
    553             street.setPossibleItems(getPossibleStreets());
     575            street.getModel().addAllElements(getPossibleStreets());
    554576        } else {
    555             street.setPossibleAcItems(acm.getTagValues(TAG_ADDR_PLACE));
     577            street.getModel().addAllElements(acm.getTagValues(TAG_ADDR_PLACE));
    556578        }
    557579        street.setPreferredSize(new Dimension(200, 24));
     
    756778    }
    757779
    758     private String getAutoCompletingComboBoxValue(AutoCompletingComboBox box) {
     780    private String getAutoCompletingComboBoxValue(AutoCompComboBox<AutoCompletionItem> box) {
    759781        Object item = box.getSelectedItem();
    760782        if (item != null) {
     
    886908        if (!commands.isEmpty()) {
    887909            SequenceCommand sequenceCommand = new SequenceCommand(
    888                  trn("Updating properties of up to {0} object", 
     910                 trn("Updating properties of up to {0} object",
    889911                     "Updating properties of up to {0} objects", commands.size(), commands.size()), commands);
    890912
     
    894916    }
    895917
    896     private Collection<String> getPossibleStreets() {
    897         /**
    898          * Generates a list of all visible names of highways in order to do autocompletion on the road name.
    899          */
    900         Set<String> names = new TreeSet<>();
     918    /**
     919     * Generates a list of all visible names of highways in order to do autocompletion on the road name.
     920     */
     921    private Collection<AutoCompletionItem> getPossibleStreets() {
     922        Set<AutoCompletionItem> names = new TreeSet<>();
    901923        for (OsmPrimitive osm : MainApplication.getLayerManager().getEditDataSet().allNonDeletedPrimitives()) {
    902924            if (osm.getKeys() != null && osm.keySet().contains("highway") && osm.keySet().contains("name")) {
    903                 names.add(osm.get("name"));
     925                names.add(new AutoCompletionItem(osm.get("name")));
    904926            }
    905927        }
     
    946968        public void itemStateChanged(ItemEvent e) {
    947969            if (streetRadio.isSelected()) {
    948                 street.setPossibleItems(getPossibleStreets());
     970                street.getModel().addAllElements(getPossibleStreets());
    949971            } else {
    950                 street.setPossibleAcItems(acm.getTagValues(TAG_ADDR_PLACE));
     972                street.getModel().addAllElements(acm.getTagValues(TAG_ADDR_PLACE));
    951973            }
    952974        }
Note: See TracChangeset for help on using the changeset viewer.