Index: applications/editors/josm/plugins/HouseNumberTaggingTool/.project
===================================================================
--- applications/editors/josm/plugins/HouseNumberTaggingTool/.project	(revision 30774)
+++ applications/editors/josm/plugins/HouseNumberTaggingTool/.project	(revision 30775)
@@ -13,4 +13,5 @@
 	</buildSpec>
 	<natures>
+		<nature>org.sonar.ide.eclipse.core.sonarNature</nature>
 		<nature>org.eclipse.jdt.core.javanature</nature>
 	</natures>
Index: applications/editors/josm/plugins/HouseNumberTaggingTool/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- applications/editors/josm/plugins/HouseNumberTaggingTool/.settings/org.eclipse.jdt.core.prefs	(revision 30774)
+++ applications/editors/josm/plugins/HouseNumberTaggingTool/.settings/org.eclipse.jdt.core.prefs	(revision 30775)
@@ -7,6 +7,12 @@
 org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
 org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
@@ -32,4 +38,9 @@
 org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
 org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
 org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
 org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
@@ -38,7 +49,15 @@
 org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
 org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore
 org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
 org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
Index: applications/editors/josm/plugins/HouseNumberTaggingTool/.settings/org.sonar.ide.eclipse.core.prefs
===================================================================
--- applications/editors/josm/plugins/HouseNumberTaggingTool/.settings/org.sonar.ide.eclipse.core.prefs	(revision 30775)
+++ applications/editors/josm/plugins/HouseNumberTaggingTool/.settings/org.sonar.ide.eclipse.core.prefs	(revision 30775)
@@ -0,0 +1,6 @@
+eclipse.preferences.version=1
+extraProperties=
+lastAnalysisDate=1414543226641
+projectKey=josm-plugins
+serverUrl=http\://donvip.fr/sonar
+version=2
Index: applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java
===================================================================
--- applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java	(revision 30774)
+++ applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/Dto.java	(revision 30775)
@@ -6,197 +6,162 @@
  * @author Oliver Raupach 18.01.2012 <http://www.oliver-raupach.de>
  */
-public class Dto implements Serializable
-{
+public class Dto implements Serializable {
 
-   private static final long serialVersionUID = 5226513739078369787L;
+    private static final long serialVersionUID = 5226513739078369787L;
 
-   private boolean saveBuilding = true;
-   private boolean saveCountry = true;
-   private boolean saveState = true;
-   private boolean saveCity = true;
-   private boolean savePostcode = true;
-   private boolean saveStreet = true;
-   private boolean saveHousenumber = true;
+    private boolean saveBuilding = true;
+    private boolean saveCountry = true;
+    private boolean saveState = true;
+    private boolean saveCity = true;
+    private boolean savePostcode = true;
+    private boolean saveStreet = true;
+    private boolean saveHousenumber = true;
 
-   private boolean tagStreet = true; // use tag addr:street or addr:place
+    private boolean tagStreet = true; // use tag addr:street or addr:place
    
-   private String building = "yes";
-   private String country;
-   private String state;
-   private String city;
-   private String postcode;
-   private String street;
-   private String place;
-   private String housenumber;
-   private int housenumberChangeValue = 0;
+    private String building = "yes";
+    private String country;
+    private String state;
+    private String city;
+    private String postcode;
+    private String street;
+    private String place;
+    private String housenumber;
+    private int housenumberChangeValue = 0;
 
-   public boolean isSaveBuilding()
-   {
-      return saveBuilding;
-   }
+    public boolean isSaveBuilding() {
+        return saveBuilding;
+    }
 
-   public void setSaveBuilding(boolean saveBuilding)
-   {
-      this.saveBuilding = saveBuilding;
-   }
+    public void setSaveBuilding(boolean saveBuilding) {
+        this.saveBuilding = saveBuilding;
+    }
 
-   public boolean isSaveCountry()
-   {
-      return saveCountry;
-   }
+    public boolean isSaveCountry() {
+        return saveCountry;
+    }
 
-   public void setSaveCountry(boolean saveCountry)
-   {
-      this.saveCountry = saveCountry;
-   }
+    public void setSaveCountry(boolean saveCountry) {
+        this.saveCountry = saveCountry;
+    }
 
-   public boolean isSaveCity()
-   {
-      return saveCity;
-   }
+    public boolean isSaveCity() {
+        return saveCity;
+    }
 
-   public void setSaveCity(boolean saveCity)
-   {
-      this.saveCity = saveCity;
-   }
+    public void setSaveCity(boolean saveCity) {
+        this.saveCity = saveCity;
+    }
 
-   public boolean isSavePostcode()
-   {
-      return savePostcode;
-   }
+    public boolean isSavePostcode() {
+        return savePostcode;
+    }
 
-   public void setSavePostcode(boolean savePostcode)
-   {
-      this.savePostcode = savePostcode;
-   }
+    public void setSavePostcode(boolean savePostcode) {
+        this.savePostcode = savePostcode;
+    }
 
-   public boolean isSaveStreet()
-   {
-      return saveStreet;
-   }
+    public boolean isSaveStreet() {
+        return saveStreet;
+    }
 
-   public void setSaveStreet(boolean saveStreet)
-   {
-      this.saveStreet = saveStreet;
-   }
+    public void setSaveStreet(boolean saveStreet) {
+        this.saveStreet = saveStreet;
+    }
 
-   public boolean isSaveHousenumber()
-   {
-      return saveHousenumber;
-   }
+    public boolean isSaveHousenumber() {
+        return saveHousenumber;
+    }
 
-   public void setSaveHousenumber(boolean saveHousenumber)
-   {
-      this.saveHousenumber = saveHousenumber;
-   }
+    public void setSaveHousenumber(boolean saveHousenumber) {
+        this.saveHousenumber = saveHousenumber;
+    }
 
-   public String getCountry()
-   {
-      return country;
-   }
+    public String getCountry() {
+        return country;
+    }
 
-   public void setCountry(String country)
-   {
-      this.country = country;
-   }
+    public void setCountry(String country) {
+        this.country = country;
+    }
 
-   public String getCity()
-   {
-      return city;
-   }
+    public String getCity() {
+        return city;
+    }
 
-   public void setCity(String city)
-   {
-      this.city = city;
-   }
+    public void setCity(String city) {
+        this.city = city;
+    }
 
-   public String getPostcode()
-   {
-      return postcode;
-   }
+    public String getPostcode() {
+        return postcode;
+    }
 
-   public void setPostcode(String postcode)
-   {
-      this.postcode = postcode;
-   }
+    public void setPostcode(String postcode) {
+        this.postcode = postcode;
+    }
 
-   public String getStreet()
-   {
-      return street;
-   }
+    public String getStreet() {
+        return street;
+    }
 
-   public void setStreet(String street)
-   {
-      this.street = street;
-   }
+    public void setStreet(String street) {
+        this.street = street;
+    }
 
-   public String getHousenumber()
-   {
-      return housenumber;
-   }
+    public String getHousenumber() {
+        return housenumber;
+    }
 
-   public void setHousenumber(String housenumber)
-   {
-      this.housenumber = housenumber;
-   }
+    public void setHousenumber(String housenumber) {
+        this.housenumber = housenumber;
+    }
 
-   public String getState()
-   {
-      return state;
-   }
+    public String getState() {
+        return state;
+    }
 
-   public void setState(String state)
-   {
-      this.state = state;
-   }
+    public void setState(String state) {
+        this.state = state;
+    }
 
-   public boolean isSaveState()
-   {
-      return saveState;
-   }
+    public boolean isSaveState() {
+        return saveState;
+    }
 
-   public void setSaveState(boolean saveState)
-   {
-      this.saveState = saveState;
-   }
+    public void setSaveState(boolean saveState) {
+        this.saveState = saveState;
+    }
 
-   public int getHousenumberChangeValue()
-   {
-      return housenumberChangeValue;
-   }
+    public int getHousenumberChangeValue() {
+        return housenumberChangeValue;
+    }
 
-   public void setHousenumberChangeValue(int housenumberChangeValue)
-   {
-      this.housenumberChangeValue = housenumberChangeValue;
-   }
+    public void setHousenumberChangeValue(int housenumberChangeValue) {
+        this.housenumberChangeValue = housenumberChangeValue;
+    }
 
-   public String getBuilding()
-   {
-      return building;
-   }
+    public String getBuilding() {
+        return building;
+    }
 
-   public void setBuilding(String building)
-   {
-      this.building = building;
-   }
+    public void setBuilding(String building) {
+        this.building = building;
+    }
 
-   public boolean isTagStreet()
-   {
-       return tagStreet;
-   }
+    public boolean isTagStreet() {
+        return tagStreet;
+    }
 
-   public void setTagStreet(boolean tagStreet)
-   {
-       this.tagStreet = tagStreet;
-   }
+    public void setTagStreet(boolean tagStreet) {
+        this.tagStreet = tagStreet;
+    }
 
-   public String getPlace()
-   {
-       return place;
-   }
+    public String getPlace() {
+        return place;
+    }
 
-   public void setPlace(String place)
-   {
-       this.place = place;
-   }
+    public void setPlace(String place) {
+        this.place = place;
+    }
 }
Index: applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberTaggingToolPlugin.java
===================================================================
--- applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberTaggingToolPlugin.java	(revision 30774)
+++ applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/HouseNumberTaggingToolPlugin.java	(revision 30775)
@@ -6,14 +6,18 @@
 import org.openstreetmap.josm.plugins.PluginInformation;
 
+/**
+ * Simple tool to tag house numbers. Select house and press 'k'. Select your addr-tags and press OK.
+ */
 public class HouseNumberTaggingToolPlugin extends Plugin {
-   LaunchAction action;
+    private final LaunchAction action;
 
-   /**
-    * constructor
-    */
-   public HouseNumberTaggingToolPlugin(PluginInformation info) {
-      super(info);
-      action = new LaunchAction(getPluginDir());
-      MainMenu.add(Main.main.menu.dataMenu, action, false,0);
-   }
+    /**
+     * constructor
+     * @param info plugin info
+     */
+    public HouseNumberTaggingToolPlugin(PluginInformation info) {
+        super(info);
+        action = new LaunchAction(getPluginDir());
+        MainMenu.add(Main.main.menu.dataMenu, action, false,0);
+    }
 }
Index: applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java
===================================================================
--- applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java	(revision 30774)
+++ applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/LaunchAction.java	(revision 30775)
@@ -11,61 +11,48 @@
 import org.openstreetmap.josm.tools.Shortcut;
 
-public class LaunchAction extends JosmAction implements SelectionChangedListener
-{
+public class LaunchAction extends JosmAction implements SelectionChangedListener {
 
-   private static final long serialVersionUID = -3508864293222033185L;
-   private OsmPrimitive selection = null;
+    private OsmPrimitive selection = null;
 
-   private String pluginDir;
+    private String pluginDir;
    
-   public LaunchAction(String pluginDir)
-   {
-      super("HouseNumberTaggingTool", 
-            "home-icon32", 
-            "Launches the HouseNumberTaggingTool dialog", 
-            Shortcut.registerShortcut("edit:housenumbertaggingtool", "HouseNumberTaggingTool", KeyEvent.VK_K, Shortcut.DIRECT),
-            true);
+    public LaunchAction(String pluginDir) {
+        super("HouseNumberTaggingTool", 
+              "home-icon32", 
+              "Launches the HouseNumberTaggingTool dialog", 
+              Shortcut.registerShortcut("edit:housenumbertaggingtool", "HouseNumberTaggingTool", KeyEvent.VK_K, Shortcut.DIRECT),
+              true);
 
-      this.pluginDir = pluginDir;
-      DataSet.addSelectionListener(this);
-      setEnabled(false);
+        this.pluginDir = pluginDir;
+        DataSet.addSelectionListener(this);
+        setEnabled(false);
+    }
+
+    /**
+     * launch the editor
+     */
+    protected void launchEditor() {
+        if (!isEnabled()) {
+            return;
+        }
       
-   }
+        TagDialog dialog = new TagDialog(pluginDir, selection);
+        dialog.showDialog();
+    }
 
-   /**
-    * launch the editor
-    */
-   protected void launchEditor()
-   {
-      if (!isEnabled())
-      {
-         return;
-      }
-      
-      TagDialog dialog = new TagDialog(pluginDir, selection);
-      dialog.showDialog();
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        launchEditor();
+    }
 
-   }
-
-   @Override
-   public void actionPerformed(ActionEvent e)
-   {
-      launchEditor();
-   }
-
-   @Override
-   public void selectionChanged(Collection<? extends OsmPrimitive> newSelection)
-   {
-      if ((newSelection != null && newSelection.size() == 1))
-      {
-         setEnabled(true);
-         selection  =  newSelection.iterator().next();
-      }
-      else
-      {
-         setEnabled(false);
-         selection = null;
-      }
-
-   }
+    @Override
+    public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
+        if (newSelection != null && newSelection.size() == 1) {
+            setEnabled(true);
+            selection  =  newSelection.iterator().next();
+        } else {
+            setEnabled(false);
+            selection = null;
+        }
+    }
 }
Index: applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java
===================================================================
--- applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java	(revision 30774)
+++ applications/editors/josm/plugins/HouseNumberTaggingTool/src/org/openstreetmap/josm/plugins/housenumbertool/TagDialog.java	(revision 30775)
@@ -18,4 +18,6 @@
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.List;
+import java.util.Set;
 import java.util.TreeSet;
 import java.util.logging.Level;
@@ -46,455 +48,438 @@
  * @author Victor Kropp 10.03.2012 <http://victor.kropp.name>
  */
-public class TagDialog extends ExtendedDialog
-{
-   private static final String APPLY_CHANGES = tr("Apply Changes");
-   private static final String TAG_STREET_OR_PLACE = tr("Use tag ''addr:street'' or ''addr:place''");
-
-   public static final String TAG_BUILDING = "building";
-   public static final String TAG_ADDR_COUNTRY = "addr:country";
-   public static final String TAG_ADDR_STATE = "addr:state";
-   public static final String TAG_ADDR_CITY = "addr:city";
-   public static final String TAG_ADDR_POSTCODE = "addr:postcode";
-   public static final String TAG_ADDR_HOUSENUMBER = "addr:housenumber";
-   public static final String TAG_ADDR_STREET = "addr:street";
-   public static final String TAG_ADDR_PLACE = "addr:place";
-
-   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" };
-
-   private static final int FPS_MIN = -2;
-   private static final int FPS_MAX =  2;
-
-   private static final long serialVersionUID = 6414385452106276923L;
-
-   static private final Logger logger = Logger.getLogger(TagDialog.class.getName());
-
-   private String pluginDir;
-   private AutoCompletionManager acm;
-   private OsmPrimitive selection;
-
-   public static final String TEMPLATE_DATA = "/template.data";
-
-   private AutoCompletingComboBox country;
-   private AutoCompletingComboBox state;
-   private AutoCompletingComboBox city;
-   private AutoCompletingComboBox postcode;
-   private AutoCompletingComboBox street;
-   private JTextField housnumber;
-   private JCheckBox buildingEnabled;
-   private JCheckBox countryEnabled;
-   private JCheckBox stateEnabled;
-   private JCheckBox cityEnabled;
-   private JCheckBox zipEnabled;
-   private JCheckBox streetEnabled;
-   private JCheckBox housenumberEnabled;
-   private JSlider housenumberChangeSequence;
-   private JComboBox<String> building;
-   private JRadioButton streetRadio;
-   private JRadioButton placeRadio;
-
-   public TagDialog(String pluginDir, OsmPrimitive p_selection)
-   {
-      super(Main.parent, tr("House Number Editor"), new String[] { tr("OK"), tr("Cancel") }, true);
-      this.pluginDir = pluginDir;
-      this.selection = p_selection;
-
-      JPanel editPanel = createContentPane();
-
-      setContent(editPanel);
-      setButtonIcons(new String[] { "ok.png", "cancel.png" });
-      setDefaultButton(1);
-      setupDialog();
-      getRootPane().setDefaultButton(defaultButton);
-
-      // middle of the screen
-      setLocationRelativeTo(null);
-
-      SwingUtilities.invokeLater(new Runnable()  {
-         @Override
-         public void run() {
-            housnumber.requestFocus();
-            housnumber.selectAll();
-         }
-      });
-   }
-
-   private JPanel createContentPane() {
-      acm = selection.getDataSet().getAutoCompletionManager();
-
-      Dto dto = loadDto();
-
-      JPanel editPanel = new JPanel(new GridBagLayout());
-      GridBagConstraints c = new GridBagConstraints();
-
-      buildingEnabled = new JCheckBox(TAG_BUILDING);
-      buildingEnabled.setFocusable(false);
-      buildingEnabled.setSelected(dto.isSaveBuilding());
-      buildingEnabled.setToolTipText(APPLY_CHANGES);
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 0;
-      c.gridy = 0;
-      c.weightx = 0;
-      c.gridwidth = 3;
-      editPanel.add(buildingEnabled, c);
-
-      Arrays.sort(buildingStrings);
-      building = new JComboBox<>(buildingStrings);
-      building.setSelectedItem(dto.getBuilding());
-      building.setMaximumRowCount(50);
-      c.gridx = 3;
-      c.gridy = 0;
-      c.weightx = 1;
-      c.gridwidth = 1;
-      editPanel.add(building, c);
-
-      // country
-      countryEnabled = new JCheckBox(TAG_ADDR_COUNTRY);
-      countryEnabled.setFocusable(false);
-      countryEnabled.setSelected(dto.isSaveCountry());
-      countryEnabled.setToolTipText(APPLY_CHANGES);
-      c = new GridBagConstraints();
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 0;
-      c.gridy = 1;
-      c.weightx = 0;
-      c.gridwidth = 3;
-      editPanel.add(countryEnabled, c);
-
-      country = new AutoCompletingComboBox();
-      country.setPossibleACItems(acm.getValues(TAG_ADDR_COUNTRY));
-      country.setPreferredSize(new Dimension(200, 24));
-      country.setEditable(true);
-      country.setSelectedItem(dto.getCountry());
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 3;
-      c.gridy = 1;
-      c.weightx = 1;
-      c.gridwidth = 1;
-      editPanel.add(country, c);
-
-      // state
-      stateEnabled = new JCheckBox(TAG_ADDR_STATE);
-      stateEnabled.setFocusable(false);
-      stateEnabled.setSelected(dto.isSaveState());
-      stateEnabled.setToolTipText(APPLY_CHANGES);
-      c = new GridBagConstraints();
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 0;
-      c.gridy = 2;
-      c.weightx = 0;
-      c.gridwidth = 3;
-      editPanel.add(stateEnabled, c);
-
-      state = new AutoCompletingComboBox();
-      state.setPossibleACItems(acm.getValues(TAG_ADDR_STATE));
-      state.setPreferredSize(new Dimension(200, 24));
-      state.setEditable(true);
-      state.setSelectedItem(dto.getState());
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 3;
-      c.gridy = 2;
-      c.weightx = 1;
-      c.gridwidth = 1;
-      editPanel.add(state, c);
-
-      // city
-      cityEnabled = new JCheckBox(TAG_ADDR_CITY);
-      cityEnabled.setFocusable(false);
-      cityEnabled.setSelected(dto.isSaveCity());
-      cityEnabled.setToolTipText(APPLY_CHANGES);
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 0;
-      c.gridy = 3;
-      c.weightx = 0;
-      c.gridwidth = 3;
-      editPanel.add(cityEnabled, c);
-
-      city = new AutoCompletingComboBox();
-      city.setPossibleACItems(acm.getValues(TAG_ADDR_CITY));
-      city.setPreferredSize(new Dimension(200, 24));
-      city.setEditable(true);
-      city.setSelectedItem(dto.getCity());
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 3;
-      c.gridy = 3;
-      c.weightx = 1;
-      c.gridwidth = 1;
-      editPanel.add(city, c);
-
-      // postcode
-      zipEnabled = new JCheckBox(TAG_ADDR_POSTCODE);
-      zipEnabled.setFocusable(false);
-      zipEnabled.setSelected(dto.isSavePostcode());
-      zipEnabled.setToolTipText(APPLY_CHANGES);
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 0;
-      c.gridy = 4;
-      c.weightx = 0;
-      c.gridwidth = 3;
-      editPanel.add(zipEnabled, c);
-
-      postcode = new AutoCompletingComboBox();
-      postcode.setPossibleACItems(acm.getValues(TAG_ADDR_POSTCODE));
-      postcode.setPreferredSize(new Dimension(200, 24));
-      postcode.setEditable(true);
-      postcode.setSelectedItem(dto.getPostcode());
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 3;
-      c.gridy = 4;
-      c.weightx = 1;
-      c.gridwidth = 1;
-      editPanel.add(postcode, c);
-
-      // street
-      streetEnabled = new JCheckBox();
-      streetEnabled.setFocusable(false);
-      streetEnabled.setSelected(dto.isSaveStreet());
-      streetEnabled.setToolTipText(APPLY_CHANGES);
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 0;
-      c.gridy = 5;
-      c.weightx = 0;
-      c.gridwidth = 1;
-      editPanel.add(streetEnabled, c);
-
-
-      streetRadio = new JRadioButton(TAG_ADDR_STREET);
-      streetRadio.setToolTipText(TAG_STREET_OR_PLACE);
-      streetRadio.setSelected(dto.isTagStreet());
-      streetRadio.addItemListener(new RadioChangeListener());
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 1;
-      c.gridy = 5;
-      c.weightx = 0;
-      c.gridwidth = 1;
-      editPanel.add(streetRadio, c);
-
-      placeRadio = new JRadioButton("addr:place");
-      placeRadio.setToolTipText(TAG_STREET_OR_PLACE);
-      placeRadio.setSelected(!dto.isTagStreet());
-      placeRadio.addItemListener(new RadioChangeListener());
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 2;
-      c.gridy = 5;
-      c.weightx = 0;
-      c.gridwidth = 1;
-      editPanel.add(placeRadio, c);
-
-      ButtonGroup g = new ButtonGroup();
-      g.add( streetRadio );
-      g.add( placeRadio );
-
-      street = new AutoCompletingComboBox();
-      if (dto.isTagStreet())
-      {
-          street.setPossibleItems(getPossibleStreets());
-      }
-      else
-      {
-          street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE));
-      }
-      street.setPreferredSize(new Dimension(200, 24));
-      street.setEditable(true);
-      street.setSelectedItem(dto.getStreet());
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 3;
-      c.gridy = 5;
-      c.weightx = 1;
-      c.gridwidth = 1;
-      editPanel.add(street, c);
-
-      // housenumber
-      housenumberEnabled = new JCheckBox(TAG_ADDR_HOUSENUMBER);
-      housenumberEnabled.setFocusable(false);
-      housenumberEnabled.setSelected(dto.isSaveHousenumber());
-      housenumberEnabled.setToolTipText(APPLY_CHANGES);
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 0;
-      c.gridy = 6;
-      c.weightx = 0;
-      c.gridwidth = 3;
-      editPanel.add(housenumberEnabled, c);
-
-      housnumber = new JTextField();
-      housnumber.setPreferredSize(new Dimension(200, 24));
-
-      int number = 0;
-      try {
-         number = Integer.valueOf(dto.getHousenumber()) + dto.getHousenumberChangeValue();
-      }
-      catch (NumberFormatException e)  { }
-      if (number > 0) {
-         housnumber.setText(String.valueOf(number));
-      }
-
-
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 3;
-      c.gridy = 6;
-      c.weightx = 1;
-      c.gridwidth = 1;
-      editPanel.add(housnumber, c);
-
-      JLabel seqLabel = new JLabel(tr("House number increment:"));
-      c.fill = GridBagConstraints.HORIZONTAL;
-      c.gridx = 0;
-      c.gridy = 7;
-      c.weightx = 0;
-      c.gridwidth = 3;
-      editPanel.add(seqLabel, c);
-
-      housenumberChangeSequence = new JSlider(JSlider.HORIZONTAL,  FPS_MIN, FPS_MAX, dto.getHousenumberChangeValue());
-      housenumberChangeSequence.setPaintTicks(true);
-      housenumberChangeSequence.setMajorTickSpacing(1);
-      housenumberChangeSequence.setMinorTickSpacing(1);
-      housenumberChangeSequence.setPaintLabels(true);
-      housenumberChangeSequence.setSnapToTicks(true);
-      c.gridx = 3;
-      c.gridy = 7;
-      c.weightx = 1;
-      c.gridwidth = 1;
-      editPanel.add(housenumberChangeSequence, c);
-
-      return editPanel;
-   }
-
-   @Override
-   protected void buttonAction(int buttonIndex, ActionEvent evt)
-   {
-      if (buttonIndex == 0)  {
-         Dto dto = new Dto();
-         dto.setSaveBuilding(buildingEnabled.isSelected());
-         dto.setSaveCity(cityEnabled.isSelected());
-         dto.setSaveCountry(countryEnabled.isSelected());
-         dto.setSaveState(stateEnabled.isSelected());
-         dto.setSaveHousenumber(housenumberEnabled.isSelected());
-         dto.setSavePostcode(zipEnabled.isSelected());
-         dto.setSaveStreet(streetEnabled.isSelected());
-         dto.setTagStreet(streetRadio.isSelected());
-
-         dto.setBuilding((String) building.getSelectedItem());
-         dto.setCity(getAutoCompletingComboBoxValue(city));
-         dto.setCountry(getAutoCompletingComboBoxValue(country));
-         dto.setHousenumber(housnumber.getText());
-         dto.setPostcode(getAutoCompletingComboBoxValue(postcode));
-         dto.setStreet(getAutoCompletingComboBoxValue(street));
-         dto.setState(getAutoCompletingComboBoxValue(state));
-         dto.setHousenumberChangeValue(housenumberChangeSequence.getValue());
-
-         updateJOSMSelection(selection, dto);
-         saveDto(dto);
-      }
-      setVisible(false);
-   }
-
-   private String getAutoCompletingComboBoxValue(AutoCompletingComboBox box)
-   {
-      Object item = box.getSelectedItem();
-      if (item != null) {
-         if (item instanceof String) {
-            return (String) item;
-         }
-         if (item instanceof AutoCompletionListItem) {
-            return ((AutoCompletionListItem) item).getValue();
-         }
-         return item.toString();
-      } else {
-         return "";
-      }
-   }
-
-   protected void saveDto(Dto dto)
-   {
-      File path = new File(pluginDir);
-      File fileName = new File(pluginDir + TagDialog.TEMPLATE_DATA);
-
-      try {
-         path.mkdirs();
-         try (
-	         FileOutputStream file = new FileOutputStream(fileName);
-	         ObjectOutputStream o = new ObjectOutputStream(file)
-         ) {
-             o.writeObject(dto);
-         }
-      } catch (Exception ex) {
-         logger.log(Level.SEVERE, ex.getMessage());
-         fileName.delete();
-      }
-   }
-
-   protected void updateJOSMSelection(OsmPrimitive selection, Dto dto)
-   {
-      ArrayList<Command> commands = new ArrayList<>();
-
-      if (dto.isSaveBuilding()) {
-         String value = selection.get(TagDialog.TAG_BUILDING);
-         if (value == null || (value != null && !value.equals(dto.getBuilding()))) {
-            ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_BUILDING, dto.getBuilding());
-            commands.add(command);
-         }
-      }
-
-      if (dto.isSaveCity()) {
-         String value = selection.get(TagDialog.TAG_ADDR_CITY);
-         if (value == null || (value != null && !value.equals(dto.getCity()))) {
-            ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_CITY, dto.getCity());
-            commands.add(command);
-         }
-      }
-
-      if (dto.isSaveCountry())  {
-         String value = selection.get(TagDialog.TAG_ADDR_COUNTRY);
-         if (value == null || (value != null && !value.equals(dto.getCountry())))
-         {
-            ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_COUNTRY, dto.getCountry());
-            commands.add(command);
-         }
-      }
-
-      if (dto.isSaveHousenumber())  {
-         String value = selection.get(TagDialog.TAG_ADDR_HOUSENUMBER);
-         if (value == null || (value != null && !value.equals(dto.getHousenumber())))  {
-            ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_HOUSENUMBER, dto.getHousenumber());
-            commands.add(command);
-         }
-      }
-
-      if (dto.isSavePostcode()) {
-         String value = selection.get(TagDialog.TAG_ADDR_POSTCODE);
-         if (value == null || (value != null && !value.equals(dto.getPostcode()))) {
-            ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_POSTCODE, dto.getPostcode());
-            commands.add(command);
-         }
-      }
-
-        if (dto.isSaveStreet())
-        {
-            if (dto.isTagStreet())
-            {
+public class TagDialog extends ExtendedDialog {
+    private static final String APPLY_CHANGES = tr("Apply Changes");
+    private static final String TAG_STREET_OR_PLACE = tr("Use tag ''addr:street'' or ''addr:place''");
+
+    private static final String TAG_BUILDING = "building";
+    private static final String TAG_ADDR_COUNTRY = "addr:country";
+    private static final String TAG_ADDR_STATE = "addr:state";
+    private static final String TAG_ADDR_CITY = "addr:city";
+    private static final String TAG_ADDR_POSTCODE = "addr:postcode";
+    private static final String TAG_ADDR_HOUSENUMBER = "addr:housenumber";
+    private static final String TAG_ADDR_STREET = "addr:street";
+    private static final String TAG_ADDR_PLACE = "addr:place";
+
+    private static final String[] BUILDING_STRINGS = {
+        "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"};
+
+    private static final int FPS_MIN = -2;
+    private static final int FPS_MAX =  2;
+
+    private static final Logger LOGGER = Logger.getLogger(TagDialog.class.getName());
+
+    private String pluginDir;
+    private AutoCompletionManager acm;
+    private OsmPrimitive selection;
+
+    private static final String TEMPLATE_DATA = "/template.data";
+
+    private AutoCompletingComboBox country;
+    private AutoCompletingComboBox state;
+    private AutoCompletingComboBox city;
+    private AutoCompletingComboBox postcode;
+    private AutoCompletingComboBox street;
+    private JTextField housnumber;
+    private JCheckBox buildingEnabled;
+    private JCheckBox countryEnabled;
+    private JCheckBox stateEnabled;
+    private JCheckBox cityEnabled;
+    private JCheckBox zipEnabled;
+    private JCheckBox streetEnabled;
+    private JCheckBox housenumberEnabled;
+    private JSlider housenumberChangeSequence;
+    private JComboBox<String> building;
+    private JRadioButton streetRadio;
+    private JRadioButton placeRadio;
+
+    public TagDialog(String pluginDir, OsmPrimitive selection) {
+        super(Main.parent, tr("House Number Editor"), new String[] { tr("OK"), tr("Cancel") }, true);
+        this.pluginDir = pluginDir;
+        this.selection = selection;
+
+        JPanel editPanel = createContentPane();
+
+        setContent(editPanel);
+        setButtonIcons(new String[] { "ok.png", "cancel.png" });
+        setDefaultButton(1);
+        setupDialog();
+        getRootPane().setDefaultButton(defaultButton);
+
+        // middle of the screen
+        setLocationRelativeTo(null);
+
+        SwingUtilities.invokeLater(new Runnable()  {
+            @Override
+            public void run() {
+                housnumber.requestFocus();
+                housnumber.selectAll();
+            }
+        });
+    }
+
+    private JPanel createContentPane() {
+        acm = selection.getDataSet().getAutoCompletionManager();
+
+        Dto dto = loadDto();
+
+        JPanel editPanel = new JPanel(new GridBagLayout());
+        GridBagConstraints c = new GridBagConstraints();
+
+        buildingEnabled = new JCheckBox(TAG_BUILDING);
+        buildingEnabled.setFocusable(false);
+        buildingEnabled.setSelected(dto.isSaveBuilding());
+        buildingEnabled.setToolTipText(APPLY_CHANGES);
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 0;
+        c.gridy = 0;
+        c.weightx = 0;
+        c.gridwidth = 3;
+        editPanel.add(buildingEnabled, c);
+
+        Arrays.sort(BUILDING_STRINGS);
+        building = new JComboBox<>(BUILDING_STRINGS);
+        building.setSelectedItem(dto.getBuilding());
+        building.setMaximumRowCount(50);
+        c.gridx = 3;
+        c.gridy = 0;
+        c.weightx = 1;
+        c.gridwidth = 1;
+        editPanel.add(building, c);
+
+        // country
+        countryEnabled = new JCheckBox(TAG_ADDR_COUNTRY);
+        countryEnabled.setFocusable(false);
+        countryEnabled.setSelected(dto.isSaveCountry());
+        countryEnabled.setToolTipText(APPLY_CHANGES);
+        c = new GridBagConstraints();
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 0;
+        c.gridy = 1;
+        c.weightx = 0;
+        c.gridwidth = 3;
+        editPanel.add(countryEnabled, c);
+
+        country = new AutoCompletingComboBox();
+        country.setPossibleACItems(acm.getValues(TAG_ADDR_COUNTRY));
+        country.setPreferredSize(new Dimension(200, 24));
+        country.setEditable(true);
+        country.setSelectedItem(dto.getCountry());
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 3;
+        c.gridy = 1;
+        c.weightx = 1;
+        c.gridwidth = 1;
+        editPanel.add(country, c);
+
+        // state
+        stateEnabled = new JCheckBox(TAG_ADDR_STATE);
+        stateEnabled.setFocusable(false);
+        stateEnabled.setSelected(dto.isSaveState());
+        stateEnabled.setToolTipText(APPLY_CHANGES);
+        c = new GridBagConstraints();
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 0;
+        c.gridy = 2;
+        c.weightx = 0;
+        c.gridwidth = 3;
+        editPanel.add(stateEnabled, c);
+
+        state = new AutoCompletingComboBox();
+        state.setPossibleACItems(acm.getValues(TAG_ADDR_STATE));
+        state.setPreferredSize(new Dimension(200, 24));
+        state.setEditable(true);
+        state.setSelectedItem(dto.getState());
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 3;
+        c.gridy = 2;
+        c.weightx = 1;
+        c.gridwidth = 1;
+        editPanel.add(state, c);
+
+        // city
+        cityEnabled = new JCheckBox(TAG_ADDR_CITY);
+        cityEnabled.setFocusable(false);
+        cityEnabled.setSelected(dto.isSaveCity());
+        cityEnabled.setToolTipText(APPLY_CHANGES);
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 0;
+        c.gridy = 3;
+        c.weightx = 0;
+        c.gridwidth = 3;
+        editPanel.add(cityEnabled, c);
+
+        city = new AutoCompletingComboBox();
+        city.setPossibleACItems(acm.getValues(TAG_ADDR_CITY));
+        city.setPreferredSize(new Dimension(200, 24));
+        city.setEditable(true);
+        city.setSelectedItem(dto.getCity());
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 3;
+        c.gridy = 3;
+        c.weightx = 1;
+        c.gridwidth = 1;
+        editPanel.add(city, c);
+
+        // postcode
+        zipEnabled = new JCheckBox(TAG_ADDR_POSTCODE);
+        zipEnabled.setFocusable(false);
+        zipEnabled.setSelected(dto.isSavePostcode());
+        zipEnabled.setToolTipText(APPLY_CHANGES);
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 0;
+        c.gridy = 4;
+        c.weightx = 0;
+        c.gridwidth = 3;
+        editPanel.add(zipEnabled, c);
+
+        postcode = new AutoCompletingComboBox();
+        postcode.setPossibleACItems(acm.getValues(TAG_ADDR_POSTCODE));
+        postcode.setPreferredSize(new Dimension(200, 24));
+        postcode.setEditable(true);
+        postcode.setSelectedItem(dto.getPostcode());
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 3;
+        c.gridy = 4;
+        c.weightx = 1;
+        c.gridwidth = 1;
+        editPanel.add(postcode, c);
+
+        // street
+        streetEnabled = new JCheckBox();
+        streetEnabled.setFocusable(false);
+        streetEnabled.setSelected(dto.isSaveStreet());
+        streetEnabled.setToolTipText(APPLY_CHANGES);
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 0;
+        c.gridy = 5;
+        c.weightx = 0;
+        c.gridwidth = 1;
+        editPanel.add(streetEnabled, c);
+
+        streetRadio = new JRadioButton(TAG_ADDR_STREET);
+        streetRadio.setToolTipText(TAG_STREET_OR_PLACE);
+        streetRadio.setSelected(dto.isTagStreet());
+        streetRadio.addItemListener(new RadioChangeListener());
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 1;
+        c.gridy = 5;
+        c.weightx = 0;
+        c.gridwidth = 1;
+        editPanel.add(streetRadio, c);
+
+        placeRadio = new JRadioButton("addr:place");
+        placeRadio.setToolTipText(TAG_STREET_OR_PLACE);
+        placeRadio.setSelected(!dto.isTagStreet());
+        placeRadio.addItemListener(new RadioChangeListener());
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 2;
+        c.gridy = 5;
+        c.weightx = 0;
+        c.gridwidth = 1;
+        editPanel.add(placeRadio, c);
+
+        ButtonGroup g = new ButtonGroup();
+        g.add( streetRadio );
+        g.add( placeRadio );
+
+        street = new AutoCompletingComboBox();
+        if (dto.isTagStreet()) {
+            street.setPossibleItems(getPossibleStreets());
+        } else {
+            street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE));
+        }
+        street.setPreferredSize(new Dimension(200, 24));
+        street.setEditable(true);
+        street.setSelectedItem(dto.getStreet());
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 3;
+        c.gridy = 5;
+        c.weightx = 1;
+        c.gridwidth = 1;
+        editPanel.add(street, c);
+
+        // housenumber
+        housenumberEnabled = new JCheckBox(TAG_ADDR_HOUSENUMBER);
+        housenumberEnabled.setFocusable(false);
+        housenumberEnabled.setSelected(dto.isSaveHousenumber());
+        housenumberEnabled.setToolTipText(APPLY_CHANGES);
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 0;
+        c.gridy = 6;
+        c.weightx = 0;
+        c.gridwidth = 3;
+        editPanel.add(housenumberEnabled, c);
+
+        housnumber = new JTextField();
+        housnumber.setPreferredSize(new Dimension(200, 24));
+
+        int number = 0;
+        try {
+            number = Integer.valueOf(dto.getHousenumber()) + dto.getHousenumberChangeValue();
+        } catch (NumberFormatException e)  {
+            // Do nothing
+        }
+        if (number > 0) {
+            housnumber.setText(String.valueOf(number));
+        }
+
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 3;
+        c.gridy = 6;
+        c.weightx = 1;
+        c.gridwidth = 1;
+        editPanel.add(housnumber, c);
+
+        JLabel seqLabel = new JLabel(tr("House number increment:"));
+        c.fill = GridBagConstraints.HORIZONTAL;
+        c.gridx = 0;
+        c.gridy = 7;
+        c.weightx = 0;
+        c.gridwidth = 3;
+        editPanel.add(seqLabel, c);
+
+        housenumberChangeSequence = new JSlider(JSlider.HORIZONTAL,  FPS_MIN, FPS_MAX, dto.getHousenumberChangeValue());
+        housenumberChangeSequence.setPaintTicks(true);
+        housenumberChangeSequence.setMajorTickSpacing(1);
+        housenumberChangeSequence.setMinorTickSpacing(1);
+        housenumberChangeSequence.setPaintLabels(true);
+        housenumberChangeSequence.setSnapToTicks(true);
+        c.gridx = 3;
+        c.gridy = 7;
+        c.weightx = 1;
+        c.gridwidth = 1;
+        editPanel.add(housenumberChangeSequence, c);
+
+        return editPanel;
+    }
+
+    @Override
+    protected void buttonAction(int buttonIndex, ActionEvent evt) {
+        if (buttonIndex == 0) {
+            Dto dto = new Dto();
+            dto.setSaveBuilding(buildingEnabled.isSelected());
+            dto.setSaveCity(cityEnabled.isSelected());
+            dto.setSaveCountry(countryEnabled.isSelected());
+            dto.setSaveState(stateEnabled.isSelected());
+            dto.setSaveHousenumber(housenumberEnabled.isSelected());
+            dto.setSavePostcode(zipEnabled.isSelected());
+            dto.setSaveStreet(streetEnabled.isSelected());
+            dto.setTagStreet(streetRadio.isSelected());
+
+            dto.setBuilding((String) building.getSelectedItem());
+            dto.setCity(getAutoCompletingComboBoxValue(city));
+            dto.setCountry(getAutoCompletingComboBoxValue(country));
+            dto.setHousenumber(housnumber.getText());
+            dto.setPostcode(getAutoCompletingComboBoxValue(postcode));
+            dto.setStreet(getAutoCompletingComboBoxValue(street));
+            dto.setState(getAutoCompletingComboBoxValue(state));
+            dto.setHousenumberChangeValue(housenumberChangeSequence.getValue());
+
+            updateJOSMSelection(selection, dto);
+            saveDto(dto);
+        }
+        setVisible(false);
+    }
+
+    private String getAutoCompletingComboBoxValue(AutoCompletingComboBox box) {
+        Object item = box.getSelectedItem();
+        if (item != null) {
+            if (item instanceof String) {
+                return (String) item;
+            }
+            if (item instanceof AutoCompletionListItem) {
+                return ((AutoCompletionListItem) item).getValue();
+            }
+            return item.toString();
+        } else {
+            return "";
+        }
+    }
+
+    protected void saveDto(Dto dto) {
+        File path = new File(pluginDir);
+        File fileName = new File(pluginDir + TagDialog.TEMPLATE_DATA);
+
+        try {
+            path.mkdirs();
+            try (
+                FileOutputStream file = new FileOutputStream(fileName);
+                ObjectOutputStream o = new ObjectOutputStream(file)
+            ) {
+                o.writeObject(dto);
+            }
+        } catch (Exception ex) {
+            LOGGER.log(Level.SEVERE, ex.getMessage());
+            fileName.delete();
+        }
+    }
+
+    protected void updateJOSMSelection(OsmPrimitive selection, Dto dto) {
+        List<Command> commands = new ArrayList<>();
+
+        if (dto.isSaveBuilding()) {
+            String value = selection.get(TagDialog.TAG_BUILDING);
+            if (value == null || (value != null && !value.equals(dto.getBuilding()))) {
+                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_BUILDING, dto.getBuilding());
+                commands.add(command);
+            }
+        }
+
+        if (dto.isSaveCity()) {
+            String value = selection.get(TagDialog.TAG_ADDR_CITY);
+            if (value == null || (value != null && !value.equals(dto.getCity()))) {
+                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_CITY, dto.getCity());
+                commands.add(command);
+            }
+        }
+
+        if (dto.isSaveCountry())  {
+            String value = selection.get(TagDialog.TAG_ADDR_COUNTRY);
+            if (value == null || (value != null && !value.equals(dto.getCountry()))) {
+                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_COUNTRY, dto.getCountry());
+                commands.add(command);
+            }
+        }
+
+        if (dto.isSaveHousenumber())  {
+            String value = selection.get(TagDialog.TAG_ADDR_HOUSENUMBER);
+            if (value == null || (value != null && !value.equals(dto.getHousenumber()))) {
+                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_HOUSENUMBER, dto.getHousenumber());
+                commands.add(command);
+            }
+        }
+
+        if (dto.isSavePostcode()) {
+            String value = selection.get(TagDialog.TAG_ADDR_POSTCODE);
+            if (value == null || (value != null && !value.equals(dto.getPostcode()))) {
+                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_POSTCODE, dto.getPostcode());
+                commands.add(command);
+            }
+        }
+
+        if (dto.isSaveStreet()) {
+            if (dto.isTagStreet()) {
                 String value = selection.get(TagDialog.TAG_ADDR_STREET);
-                if (value == null || (value != null && !value.equals(dto.getStreet())))
-                {
+                if (value == null || (value != null && !value.equals(dto.getStreet()))) {
                     ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, dto.getStreet());
                     commands.add(command);
 
                     // remove old place-tag
-                    if (selection.get(TagDialog.TAG_ADDR_PLACE) != null)
-                    {
+                    if (selection.get(TagDialog.TAG_ADDR_PLACE) != null) {
                         ChangePropertyCommand command2 = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, null);
                         commands.add(command2);
                     }
                 }
-            }
-            else
-            {
+            } else {
                 String value = selection.get(TagDialog.TAG_ADDR_PLACE);
-                if (value == null || (value != null && !value.equals(dto.getStreet())))
-                {
+                if (value == null || (value != null && !value.equals(dto.getStreet()))) {
                     ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_PLACE, dto.getStreet());
                     commands.add(command);
 
                     // remove old place-tag
-                    if (selection.get(TagDialog.TAG_ADDR_STREET) != null)
-                    {
+                    if (selection.get(TagDialog.TAG_ADDR_STREET) != null) {
                         ChangePropertyCommand command2 = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STREET, null);
                         commands.add(command2);
@@ -504,34 +489,34 @@
         }
 
-      if (dto.isSaveState()) {
-         String value = selection.get(TagDialog.TAG_ADDR_STATE);
-         if (value == null || (value != null && !value.equals(dto.getState())))  {
-            ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STATE, dto.getState());
-            commands.add(command);
-         }
-      }
-
-      if (commands.size() > 0) {
-         SequenceCommand sequenceCommand = new SequenceCommand(trn("Updating properties of up to {0} object", "Updating properties of up to {0} objects", commands.size(), commands.size()), commands);
-
-         // executes the commands and adds them to the undo/redo chains
-         Main.main.undoRedo.add(sequenceCommand);
-      }
-   }
-
-   private Collection<String> getPossibleStreets() {
-      /**
-       * Generates a list of all visible names of highways in order to do autocompletion on the road name.
-       */
-      TreeSet<String> names = new TreeSet<>();
-      for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedPrimitives())
-      {
-         if (osm.getKeys() != null && osm.keySet().contains("highway") && osm.keySet().contains("name"))
-         {
-            names.add(osm.get("name"));
-         }
-      }
-      return names;
-   }
+        if (dto.isSaveState()) {
+            String value = selection.get(TagDialog.TAG_ADDR_STATE);
+            if (value == null || (value != null && !value.equals(dto.getState())))  {
+                ChangePropertyCommand command = new ChangePropertyCommand(selection, TagDialog.TAG_ADDR_STATE, dto.getState());
+                commands.add(command);
+            }
+        }
+
+        if (!commands.isEmpty()) {
+            SequenceCommand sequenceCommand = new SequenceCommand(
+                 trn("Updating properties of up to {0} object", 
+                     "Updating properties of up to {0} objects", commands.size(), commands.size()), commands);
+
+            // executes the commands and adds them to the undo/redo chains
+            Main.main.undoRedo.add(sequenceCommand);
+        }
+    }
+
+    private Collection<String> getPossibleStreets() {
+        /**
+         * Generates a list of all visible names of highways in order to do autocompletion on the road name.
+         */
+        Set<String> names = new TreeSet<>();
+        for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedPrimitives()) {
+            if (osm.getKeys() != null && osm.keySet().contains("highway") && osm.keySet().contains("name")) {
+                names.add(osm.get("name"));
+            }
+        }
+        return names;
+    }
 
     private Dto loadDto() {
@@ -542,19 +527,19 @@
             if (fileName.exists()) {
                 try (
-					FileInputStream file = new FileInputStream(fileName);
-					ObjectInputStream o = new ObjectInputStream(file);
+                    FileInputStream file = new FileInputStream(fileName);
+                    ObjectInputStream o = new ObjectInputStream(file);
                 ) {
-                	dto = (Dto) o.readObject();
+                    dto = (Dto) o.readObject();
                 }
             } else {
-	            dto.setCity(selection.get(TagDialog.TAG_ADDR_CITY));
-	            dto.setCountry(selection.get(TagDialog.TAG_ADDR_COUNTRY));
-	            dto.setHousenumber(selection.get(TagDialog.TAG_ADDR_HOUSENUMBER));
-	            dto.setPostcode(selection.get(TagDialog.TAG_ADDR_POSTCODE));
-	            dto.setStreet(selection.get(TagDialog.TAG_ADDR_STREET));
-	            dto.setState(selection.get(TagDialog.TAG_ADDR_STATE));
+                dto.setCity(selection.get(TagDialog.TAG_ADDR_CITY));
+                dto.setCountry(selection.get(TagDialog.TAG_ADDR_COUNTRY));
+                dto.setHousenumber(selection.get(TagDialog.TAG_ADDR_HOUSENUMBER));
+                dto.setPostcode(selection.get(TagDialog.TAG_ADDR_POSTCODE));
+                dto.setStreet(selection.get(TagDialog.TAG_ADDR_STREET));
+                dto.setState(selection.get(TagDialog.TAG_ADDR_STATE));
             }
         } catch (Exception ex) {
-            logger.log(Level.SEVERE, ex.getMessage());
+            LOGGER.log(Level.SEVERE, ex.getMessage());
             fileName.delete();
         }
@@ -564,17 +549,12 @@
     class RadioChangeListener implements ItemListener {
 
-         @Override
-        public void itemStateChanged(ItemEvent e)
-        {
-            if (streetRadio.isSelected())
-            {
+        @Override
+        public void itemStateChanged(ItemEvent e) {
+            if (streetRadio.isSelected()) {
                 street.setPossibleItems(getPossibleStreets());
-            }
-            else
-            {
+            } else {
                 street.setPossibleACItems(acm.getValues(TAG_ADDR_PLACE));
             }
         }
-
     }
 }
