Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecToggleDialog.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecToggleDialog.java	(revision 31615)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecToggleDialog.java	(revision 31618)
@@ -12,9 +12,7 @@
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -34,7 +32,4 @@
 
 import javax.swing.AbstractAction;
-import static javax.swing.Action.NAME;
-import static javax.swing.Action.SHORT_DESCRIPTION;
-import static javax.swing.Action.SMALL_ICON;
 import javax.swing.JComponent;
 import javax.swing.JLabel;
@@ -126,5 +121,6 @@
  * @author imi
  */
-public class OSMRecToggleDialog extends ToggleDialog implements SelectionChangedListener, MapView.EditLayerChangeListener, DataSetListenerAdapter.Listener {
+public class OSMRecToggleDialog extends ToggleDialog
+implements SelectionChangedListener, MapView.EditLayerChangeListener, DataSetListenerAdapter.Listener {
 
     /**
@@ -162,15 +158,15 @@
 
     // Popup menu handlers
-    private final PopupMenuHandler tagMenuHandler = new PopupMenuHandler(tagMenu);
-    private final PopupMenuHandler membershipMenuHandler = new PopupMenuHandler(membershipMenu);
-    private final PopupMenuHandler blankSpaceMenuHandler = new PopupMenuHandler(blankSpaceMenu);
-
-    private final Map<String, Map<String, Integer>> valueCount = new TreeMap<>();
+    private final transient PopupMenuHandler tagMenuHandler = new PopupMenuHandler(tagMenu);
+    private final transient PopupMenuHandler membershipMenuHandler = new PopupMenuHandler(membershipMenu);
+    private final transient PopupMenuHandler blankSpaceMenuHandler = new PopupMenuHandler(blankSpaceMenu);
+
+    private final transient Map<String, Map<String, Integer>> valueCount = new TreeMap<>();
     /**
      * This sub-object is responsible for all adding and editing of tags
      */
-    private final OSMRecPluginHelper editHelper = new OSMRecPluginHelper(tagData, valueCount);
-
-    private final DataSetListenerAdapter dataChangedAdapter = new DataSetListenerAdapter(this);
+    private final transient OSMRecPluginHelper editHelper = new OSMRecPluginHelper(tagData, valueCount);
+
+    private final transient DataSetListenerAdapter dataChangedAdapter = new DataSetListenerAdapter(this);
     private final HelpAction helpAction = new HelpAction();
     private final PasteValueAction pasteValueAction = new PasteValueAction();
@@ -191,10 +187,11 @@
 
     private final DownloadMembersAction downloadMembersAction = new DownloadMembersAction();
-    private final DownloadSelectedIncompleteMembersAction downloadSelectedIncompleteMembersAction = new DownloadSelectedIncompleteMembersAction();
+    private final DownloadSelectedIncompleteMembersAction downloadSelectedIncompleteMembersAction =
+    		new DownloadSelectedIncompleteMembersAction();
 
     private final SelectMembersAction selectMembersAction = new SelectMembersAction(false);
     private final SelectMembersAction addMembersToSelectionAction = new SelectMembersAction(true);
 
-    private final HighlightHelper highlightHelper= new HighlightHelper();
+    private final transient HighlightHelper highlightHelper= new HighlightHelper();
 
     /**
@@ -221,5 +218,5 @@
             + tr("Select objects or create new objects and get recommendation.") + "</p></html>");
 
-    private final TaggingPresetHandler presetHandler = new TaggingPresetHandler() {
+    private final transient TaggingPresetHandler presetHandler = new TaggingPresetHandler() {
         @Override public void updateTags(List<Tag> tags) {
             Command command = TaggingPreset.createCommand(getSelection(), tags);
@@ -337,5 +334,5 @@
                     return this;
                 Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
-                boolean isDisabledAndHidden = (((Relation)table.getValueAt(row, 0))).isDisabledAndHidden();
+                boolean isDisabledAndHidden = ((Relation) table.getValueAt(row, 0)).isDisabledAndHidden();
                 if (c instanceof JLabel) {
                     JLabel label = (JLabel) c;
@@ -353,5 +350,5 @@
                     boolean isSelected, boolean hasFocus, int row, int column) {
                 Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
-                boolean isDisabledAndHidden = (((Relation)table.getValueAt(row, 0))).isDisabledAndHidden();
+                boolean isDisabledAndHidden = ((Relation) table.getValueAt(row, 0)).isDisabledAndHidden();
                 if (c instanceof JLabel) {
                     JLabel label = (JLabel)c;
@@ -513,5 +510,5 @@
      * is the editor's business.
      *
-     * @param row
+     * @param row position
      */
     private void editMembership(int row) {
@@ -620,5 +617,5 @@
         final Map<String, String> tags = new HashMap<>();
         valueCount.clear();
-        EnumSet<TaggingPresetType> types = EnumSet.noneOf(TaggingPresetType.class);
+        Set<TaggingPresetType> types = EnumSet.noneOf(TaggingPresetType.class);
         for (OsmPrimitive osm : newSel) {
             types.add(TaggingPresetType.forPrimitive(osm));
@@ -631,5 +628,5 @@
                         v.put(value, v.containsKey(value) ? v.get(value) + 1 : 1);
                     } else {
-                        TreeMap<String, Integer> v = new TreeMap<>();
+                        Map<String, Integer> v = new TreeMap<>();
                         v.put(value, 1);
                         valueCount.put(key, v);
@@ -722,5 +719,4 @@
        //end of temp code
         
-        
         int selectedIndex;
         if (selectedTag != null && (selectedIndex = findRow(tagData, selectedTag)) != -1) {
@@ -781,5 +777,5 @@
         int row = tagTable.getSelectedRow();
         if (row == -1) return null;
-        TreeMap<String, Integer> map = (TreeMap<String, Integer>) tagData.getValueAt(row, 1);
+        Map<String, Integer> map = (TreeMap<String, Integer>) tagData.getValueAt(row, 1);
         return new Tag(
                 tagData.getValueAt(row, 0).toString(),
@@ -811,5 +807,6 @@
      */
     public class MouseClickWatch extends MouseAdapter {
-        @Override public void mouseClicked(MouseEvent e) {
+        @Override
+        public void mouseClicked(MouseEvent e) {
             if (e.getClickCount() < 2) {
                 // single click, clear selection in other table not clicked in
@@ -819,10 +816,9 @@
                     tagTable.clearSelection();
                 }
-            }
-            // double click, edit or add tag
-            else if (e.getSource() == tagTable ) {
+            } else if (e.getSource() == tagTable ) {
+                // double click, edit or add tag
                 int row = tagTable.rowAtPoint(e.getPoint());
                 if (row > -1) {
-                    boolean focusOnKey = (tagTable.columnAtPoint(e.getPoint()) == 0);
+                    boolean focusOnKey = tagTable.columnAtPoint(e.getPoint()) == 0;
                     editHelper.editTag(row, focusOnKey);
                 } else {
@@ -835,11 +831,12 @@
                     editMembership(row);
                 }
-            }
-            else {
+            } else {
                 editHelper.addTag();
                 btnAdd.requestFocusInWindow();
             }
         }
-        @Override public void mousePressed(MouseEvent e) {
+
+        @Override
+        public void mousePressed(MouseEvent e) {
             if (e.getSource() == tagTable) {
                 membershipTable.clearSelection();
@@ -855,6 +852,6 @@
         private List<Integer> position = new ArrayList<>();
         private Iterable<OsmPrimitive> selection;
-        private String positionString = null;
-        private String roleString = null;
+        private String positionString;
+        private String roleString;
 
         MemberInfo(Iterable<OsmPrimitive> selection) {
@@ -909,8 +906,10 @@
      */
     public static class ReadOnlyTableModel extends DefaultTableModel {
-        @Override public boolean isCellEditable(int row, int column) {
+        @Override
+        public boolean isCellEditable(int row, int column) {
             return false;
         }
-        @Override public Class<?> getColumnClass(int columnIndex) {
+        @Override
+        public Class<?> getColumnClass(int columnIndex) {
             return String.class;
         }
@@ -922,7 +921,7 @@
     class DeleteAction extends JosmAction implements ListSelectionListener {
 
-        static final String DELETE_FROM_RELATION_PREF = "delete_from_relation";
-
-        public DeleteAction() {
+        private static final String DELETE_FROM_RELATION_PREF = "delete_from_relation";
+
+        DeleteAction() {
             super(tr("Delete"), /* ICON() */ "dialogs/delete", tr("Delete the selected key in all objects"),
                     Shortcut.registerShortcut("properties:delete", tr("Delete Tags"), KeyEvent.VK_D,
@@ -933,5 +932,5 @@
         protected void deleteTags(int[] rows){
             // convert list of rows to HashMap (and find gap for nextKey)
-            HashMap<String, String> tags = new HashMap<>(rows.length);
+            Map<String, String> tags = new HashMap<>(rows.length);
             int nextKeyIndex = rows[0];
             for (int row : rows) {
@@ -972,5 +971,5 @@
             int rowCount = membershipTable.getRowCount();
             if (rowCount > 1) {
-                nextRelation = (Relation)membershipData.getValueAt((row + 1 < rowCount ? row + 1 : row - 1), 0);
+                nextRelation = (Relation) membershipData.getValueAt(row + 1 < rowCount ? row + 1 : row - 1, 0);
             }
 
@@ -978,5 +977,5 @@
                     tr("Change relation"),
                     new String[] {tr("Delete from relation"), tr("Cancel")});
-            ed.setButtonIcons(new String[] {"dialogs/delete.png", "cancel.png"});
+            ed.setButtonIcons(new String[] {"dialogs/delete", "cancel"});
             ed.setContent(tr("Really delete selection from relation {0}?", cur.getDisplayName(DefaultNameFormatter.getInstance())));
             ed.toggleEnable(DELETE_FROM_RELATION_PREF);
@@ -1032,5 +1031,5 @@
      */
     class AddAction extends JosmAction {
-        public AddAction() {
+        AddAction() {
             super(tr("Add Recommendation"), /* ICON() */ "dialogs/add", tr("Add a recommended key/value pair to your object"),
                     Shortcut.registerShortcut("properties:add", tr("Add Tag"), KeyEvent.VK_A,
@@ -1040,5 +1039,4 @@
         @Override
         public void actionPerformed(ActionEvent e) {
-            //System.out.println("clicked recommend");
             editHelper.addTag();
             btnAdd.requestFocusInWindow();            
@@ -1051,15 +1049,8 @@
      */
     class EditActionTrain extends JosmAction implements ListSelectionListener {
-        public EditActionTrain() {            
-//            super(tr("Train a Model"), /* ICON() */ "dialogs/edit", tr("Start the training engine!"),
-//                    Shortcut.registerShortcut("properties:edit", tr("Edit Tags"), KeyEvent.VK_S,
-//                            Shortcut.ALT), false);
-            
+        EditActionTrain() {            
             super(tr("Train a Model"), /* ICON() */ "dialogs/fix", tr("Start the training engine!"),
                     Shortcut.registerShortcut("properties:edit", tr("Edit Tags"), KeyEvent.VK_S,
                             Shortcut.ALT), false);
-            
-            //images/dialogs/train.png
-            //System.out.println("icon");
             setEnabled(true);
             updateEnabledState(); 
@@ -1075,6 +1066,4 @@
             } else if (membershipTable.getSelectedRowCount() == 1) {
                 int row = membershipTable.getSelectedRow();
-                //System.out.println("tagTable: " + tagTable);
-                //System.out.println("membershipTable: " + membershipTable);                
                 editHelper.editTag(row, false);
                 //editMembership(row);
@@ -1101,5 +1090,5 @@
 
     class HelpAction extends AbstractAction {
-        public HelpAction() {
+        HelpAction() {
             putValue(NAME, tr("Go to OSM wiki for tag help (F1)"));
             putValue(SHORT_DESCRIPTION, tr("Launch browser with wiki help for selected object"));
@@ -1116,8 +1105,8 @@
                 if (tagTable.getSelectedRowCount() == 1) {
                     row = tagTable.getSelectedRow();
-                    String key = URLEncoder.encode(tagData.getValueAt(row, 0).toString(), "UTF-8");
+                    String key = Utils.encodeUrl(tagData.getValueAt(row, 0).toString());
                     @SuppressWarnings("unchecked")
                     Map<String, Integer> m = (Map<String, Integer>) tagData.getValueAt(row, 1);
-                    String val = URLEncoder.encode(m.entrySet().iterator().next().getKey(), "UTF-8");
+                    String val = Utils.encodeUrl(m.entrySet().iterator().next().getKey());
 
                     uris.add(new URI(String.format("%s%sTag:%s=%s", base, lang, key, val)));
@@ -1131,5 +1120,5 @@
                     String type = ((Relation)membershipData.getValueAt(row, 0)).get("type");
                     if (type != null) {
-                        type = URLEncoder.encode(type, "UTF-8");
+                        type = Utils.encodeUrl(type);
                     }
 
@@ -1192,5 +1181,5 @@
                     }
                 });
-            } catch (URISyntaxException | UnsupportedEncodingException e1) {
+            } catch (URISyntaxException e1) {
                 Main.error(e1);
             }
@@ -1199,5 +1188,5 @@
 
     class PasteValueAction extends AbstractAction {
-        public PasteValueAction() {
+        PasteValueAction() {
             putValue(NAME, tr("Paste Value"));
             putValue(SHORT_DESCRIPTION, tr("Paste the value of the selected tag from clipboard"));
@@ -1247,5 +1236,8 @@
     class CopyValueAction extends AbstractCopyAction {
 
-        public CopyValueAction() {
+        /**
+         * Constructs a new {@code CopyValueAction}.
+         */
+        CopyValueAction() {
             putValue(NAME, tr("Copy Value"));
             putValue(SHORT_DESCRIPTION, tr("Copy the value of the selected tag to clipboard"));
@@ -1261,5 +1253,5 @@
     class CopyKeyValueAction extends AbstractCopyAction {
 
-        public CopyKeyValueAction() {
+        CopyKeyValueAction() {
             putValue(NAME, tr("Copy selected Key(s)/Value(s)"));
             putValue(SHORT_DESCRIPTION, tr("Copy the key and value of the selected tag(s) to clipboard"));
@@ -1275,5 +1267,5 @@
     class CopyAllKeyValueAction extends AbstractCopyAction {
 
-        public CopyAllKeyValueAction() {
+        CopyAllKeyValueAction() {
             putValue(NAME, tr("Copy all Keys/Values"));
             putValue(SHORT_DESCRIPTION, tr("Copy the key and value of all the tags to clipboard"));
@@ -1291,7 +1283,7 @@
 
     class SearchAction extends AbstractAction {
-        final boolean sameType;
-
-        public SearchAction(boolean sameType) {
+        private final boolean sameType;
+
+        SearchAction(boolean sameType) {
             this.sameType = sameType;
             if (sameType) {
@@ -1329,5 +1321,5 @@
                     t = "type:relation ";
                 }
-                s.append(sep).append("(").append(t).append("\"").append(
+                s.append(sep).append('(').append(t).append('"').append(
                         org.openstreetmap.josm.actions.search.SearchAction.escapeStringForSearch(key)).append("\"=\"").append(
                         org.openstreetmap.josm.actions.search.SearchAction.escapeStringForSearch(val)).append("\")");
@@ -1335,5 +1327,5 @@
             }
 
-            SearchSetting ss = new SearchSetting();
+            final SearchSetting ss = new SearchSetting();
             ss.text = s.toString();
             ss.mode = SearchMode.replace;
