Index: applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/OhePlugin.java
===================================================================
--- applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/OhePlugin.java	(revision 25955)
+++ applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/OhePlugin.java	(revision 26002)
@@ -2,17 +2,24 @@
 
 import static org.openstreetmap.josm.tools.I18n.tr;
-
+import static org.openstreetmap.josm.tools.I18n.trn;
+
+import java.awt.Component;
+import java.awt.Font;
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
 import java.util.Vector;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import javax.swing.AbstractAction;
 import javax.swing.ButtonGroup;
 import javax.swing.JDialog;
+import javax.swing.JLabel;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
@@ -22,4 +29,6 @@
 import javax.swing.JTextField;
 import javax.swing.ListSelectionModel;
+import javax.swing.table.DefaultTableCellRenderer;
+import javax.swing.table.DefaultTableModel;
 
 import org.openstreetmap.josm.Main;
@@ -37,21 +46,18 @@
 
 public class OhePlugin extends Plugin {
-
-    // Strings for choosing which key of an object with given tags should be
-    // edited
-    // the order is referencing the preference of the keys
-    // String[] -> {key, value, to-editing-key} key and value can contain regexp
-    private final String[][] TAG_EDIT_STRINGS = new String[][] {
-            { "opening_hours", ".*", "opening_hours" },
+    /**
+     * Strings for choosing which key of an object with given tags should be
+     * edited, the order is referencing the preference of the keys, String[] ->
+     * {key, value, key-to-edit} key and value can contain regular expressions
+     */
+    private final String[][] TAG_EDIT_STRINGS = new String[][] { { "opening_hours", ".*", "opening_hours" },
             { "collection_times", ".*", "collection_times" },
-            { "collection_times:local", ".*", "collection_times:local" },
-            { "lit", ".*", "lit" },
-            { "amenity", "post_box", "collection_times" },
-            { "amenity", ".*", "opening_hours" },
-            { "shop", ".*", "opening_hours" }, { "highway", ".*", "lit" } };
+            { "collection_times:local", ".*", "collection_times:local" }, { "shop", ".*", "opening_hours" },
+            { "amenity", "post_box", "collection_times" }, { "amenity", ".*", "opening_hours" },
+            { "lit", ".*", "lit" }, { "highway", ".*", "lit" } };
 
     /**
      * Will be invoked by JOSM to bootstrap the plugin
-     *
+     * 
      * @param info
      *            information about the plugin and its local installation
@@ -62,13 +68,18 @@
     }
 
+    /**
+     * this Action is used for calling the OpeningsHourEditor, the selected
+     * objects in the active datalayer are edited
+     * 
+     * @author boman
+     */
     class OheMenuAction extends JosmAction {
+        private static final long serialVersionUID = 1456257438391417756L;
+
         public OheMenuAction() {
-            super(
-                    tr("Edit opening hours"),
-                    "opening_hours.png",
-                    tr("Edit time-tag of selected element in a graphical interface"),
-                    Shortcut.registerShortcut("tools:opening_hourseditor", tr(
-                            "Tool: {0}", tr("Edit opening hours")),
-                            KeyEvent.VK_T, Shortcut.GROUP_MENU), false);
+            super(tr("Edit opening hours"), "opening_hours.png",
+                    tr("Edit time-tag of selected element in a graphical interface"), Shortcut.registerShortcut(
+                            "tools:opening_hourseditor", tr("Tool: {0}", tr("Edit opening hours")), KeyEvent.VK_T,
+                            Shortcut.GROUP_MENU), false);
         }
 
@@ -76,4 +87,5 @@
         protected void updateEnabledState() {
             if (getCurrentDataSet() == null) {
+                // if there is no current dataset, then the action is disabled
                 setEnabled(false);
             } else {
@@ -83,6 +95,6 @@
 
         @Override
-        protected void updateEnabledState(
-                Collection<? extends OsmPrimitive> selection) {
+        protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
+            // only enable the action if something is selected
             setEnabled(selection != null && !selection.isEmpty());
         }
@@ -91,187 +103,223 @@
             // fetch active Layer
             OsmDataLayer osmlayer = Main.main.getEditLayer();
-            if (osmlayer != null) {
-                Collection<OsmPrimitive> selection = osmlayer.data
-                        .getSelected();
-                if (selection.size() == 1) { // one object selected
-                    OsmPrimitive object = selection.iterator().next();
-                    String[] keyValuePair = editTimeTags(object.getKeys());
-                    if (keyValuePair != null) {
-                        String key = keyValuePair[0].trim();
-                        String newkey = keyValuePair[1].trim();
-                        String value = keyValuePair[2].trim();
-
-                        if (value.equals("")) {
-                            value = null; // delete the key
+            if (osmlayer == null)
+                return;
+            Collection<OsmPrimitive> selection = osmlayer.data.getSelected();
+
+            // handling of multiple objects and their tags
+            // copied from
+            // org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog[rev4079][line802]
+            Map<String, Integer> keyCount = new HashMap<String, Integer>();
+            Map<String, Map<String, Integer>> valueCount = new TreeMap<String, Map<String, Integer>>();
+            for (OsmPrimitive osm : selection) {
+                for (String key : osm.keySet()) {
+                    String value = osm.get(key);
+                    keyCount.put(key, keyCount.containsKey(key) ? keyCount.get(key) + 1 : 1);
+                    if (valueCount.containsKey(key)) {
+                        Map<String, Integer> v = valueCount.get(key);
+                        v.put(value, v.containsKey(value) ? v.get(value) + 1 : 1);
+                    } else {
+                        TreeMap<String, Integer> v = new TreeMap<String, Integer>();
+                        v.put(value, 1);
+                        valueCount.put(key, v);
+                    }
+                }
+            }
+
+            DefaultTableModel propertyData = new DefaultTableModel() {
+                @Override
+                public boolean isCellEditable(int row, int column) {
+                    return false;
+                }
+
+                @Override
+                public Class<?> getColumnClass(int columnIndex) {
+                    return String.class;
+                }
+            };
+            propertyData.setColumnIdentifiers(new String[] { tr("Key"), tr("Value") });
+            for (Entry<String, Map<String, Integer>> e : valueCount.entrySet()) {
+                int count = 0;
+                for (Entry<String, Integer> e1 : e.getValue().entrySet()) {
+                    count += e1.getValue();
+                }
+                if (count < selection.size()) {
+                    e.getValue().put("", selection.size() - count);
+                }
+                propertyData.addRow(new Object[] { e.getKey(), e.getValue() });
+            }
+            final JTable propertyTable = new JTable(propertyData);
+            propertyTable.getColumnModel().getColumn(1).setCellRenderer(new DefaultTableCellRenderer() {
+                @Override
+                public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
+                        boolean hasFocus, int row, int column) {
+                    Component c = super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
+                    if (value == null)
+                        return this;
+                    if (c instanceof JLabel) {
+                        String str = null;
+                        if (value instanceof String) {
+                            str = (String) value;
+                        } else if (value instanceof Map<?, ?>) {
+                            Map<?, ?> v = (Map<?, ?>) value;
+                            if (v.size() != 1) {
+                                str = tr("<different>");
+                                c.setFont(c.getFont().deriveFont(Font.ITALIC));
+                            } else {
+                                final Map.Entry<?, ?> entry = v.entrySet().iterator().next();
+                                str = (String) entry.getKey();
+                            }
                         }
-                        if (newkey.equals("")) {
-                            newkey = key;
-                            value = null; // delete the key instead
+                        ((JLabel) c).setText(str);
+                    }
+                    return c;
+                }
+            });
+            // end copy
+
+            // showing the tags in a dialog
+            propertyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+            JScrollPane sp = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+            sp.setViewportView(propertyTable);
+
+            final JTextField newTagField = new JTextField();
+
+            JRadioButton editButton = new JRadioButton(new AbstractAction(tr("edit existing tag")) {
+                @Override
+                public void actionPerformed(ActionEvent e) {
+                    propertyTable.setEnabled(true);
+                    newTagField.setEnabled(false);
+                }
+            });
+            JRadioButton newButton = new JRadioButton(new AbstractAction(tr("edit new tag")) {
+                @Override
+                public void actionPerformed(ActionEvent e) {
+                    propertyTable.setEnabled(false);
+                    newTagField.setEnabled(true);
+                }
+            });
+            ButtonGroup group = new ButtonGroup();
+            group.add(newButton);
+            group.add(editButton);
+
+            // search through the tags and choose which one should be selected
+            String preSelectedKey = "";
+            searchLoop: for (String[] pattern : TAG_EDIT_STRINGS) {
+                Pattern keyPattern = Pattern.compile(pattern[0]);
+                Pattern valuePattern = Pattern.compile(pattern[1]);
+                for (int i = 0; i < propertyData.getRowCount(); ++i) {
+                    Matcher keyMatcher = keyPattern.matcher((String) propertyData.getValueAt(i, 0));
+                    if (keyMatcher.matches()) {
+                        Object value = propertyData.getValueAt(i, 1);
+                        if (value instanceof String && valuePattern.matcher((String) value).matches()) {
+                            preSelectedKey = pattern[2];
+                            break searchLoop;
+                        } else if (value instanceof Map<?, ?>)
+                            for (String v : ((Map<String, Integer>) value).keySet())
+                                if (valuePattern.matcher(v).matches()) {
+                                    preSelectedKey = pattern[2];
+                                    break searchLoop;
+                                }
+                    }
+                }
+            }
+            int preSelectedRow = -1;
+            for (int i = 0; i < propertyData.getRowCount(); ++i)
+                if (preSelectedKey.equals(propertyData.getValueAt(i, 0)))
+                    preSelectedRow = i;
+            if (preSelectedRow != -1) {
+                propertyTable.setEnabled(true);
+                newTagField.setEnabled(false);
+                propertyTable.setRowSelectionInterval(preSelectedRow, preSelectedRow);
+                editButton.setSelected(true);
+            } else {
+                propertyTable.setEnabled(false);
+                newTagField.setEnabled(true);
+                newTagField.setText(preSelectedKey);
+                newButton.setSelected(true);
+            }
+
+            JPanel dlgPanel = new JPanel(new GridBagLayout());
+            dlgPanel.add(editButton, GBC.std().anchor(GBC.CENTER));
+            dlgPanel.add(sp, GBC.eol().fill(GBC.BOTH));
+            dlgPanel.add(newButton, GBC.std().anchor(GBC.CENTER));
+            dlgPanel.add(newTagField, GBC.eol().fill(GBC.HORIZONTAL));
+
+            JOptionPane optionPane = new JOptionPane(dlgPanel, JOptionPane.QUESTION_MESSAGE,
+                    JOptionPane.OK_CANCEL_OPTION);
+            JDialog dlg = optionPane.createDialog(Main.parent, tr("Choose key"));
+            dlg.pack();
+            dlg.setResizable(true);
+            dlg.setVisible(true);
+
+            Object answer = optionPane.getValue();
+            String keyToEdit = null;
+            Object valuesToEdit = "";
+            if (answer != null && answer != JOptionPane.UNINITIALIZED_VALUE
+                    && (answer instanceof Integer && (Integer) answer == JOptionPane.OK_OPTION))
+                if (editButton.isSelected() && propertyTable.getSelectedRow() != -1) {
+                    keyToEdit = (String) propertyData.getValueAt(propertyTable.getSelectedRow(), 0);
+                    valuesToEdit = propertyData.getValueAt(propertyTable.getSelectedRow(), 1);
+                } else if (newButton.isSelected())
+                    keyToEdit = newTagField.getText();
+            if (keyToEdit == null)
+                return;
+
+            OheDialogPanel panel = new OheDialogPanel(OhePlugin.this, keyToEdit, valuesToEdit);
+
+            optionPane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
+            dlg = optionPane.createDialog(Main.parent, tr("Edit"));
+            dlg.setResizable(true);
+            dlg.setVisible(true);
+
+            String[] changedKeyValuePair = null;
+            answer = optionPane.getValue();
+            if (!(answer == null || answer == JOptionPane.UNINITIALIZED_VALUE || (answer instanceof Integer && (Integer) answer != JOptionPane.OK_OPTION)))
+                changedKeyValuePair = panel.getChangedKeyValuePair();
+            if (changedKeyValuePair == null)
+                return;
+            String key = changedKeyValuePair[0].trim();
+            String newkey = changedKeyValuePair[1].trim();
+            String value = changedKeyValuePair[2].trim();
+
+            if (value.equals("")) {
+                value = null; // delete the key
+            }
+            if (newkey.equals("")) {
+                newkey = key;
+                value = null; // delete the key instead
+            }
+            if (key.equals(newkey) && tr("<different>").equals(value))
+                return;
+            if (key.equals(newkey) || value == null) {
+                Main.main.undoRedo.add(new ChangePropertyCommand(selection, newkey, value));
+            } else {
+                Collection<Command> commands = new Vector<Command>();
+                commands.add(new ChangePropertyCommand(selection, key, null));
+                if (value.equals(tr("<different>"))) {
+                    HashMap<String, Vector<OsmPrimitive>> map = new HashMap<String, Vector<OsmPrimitive>>();
+                    for (OsmPrimitive osm : selection) {
+                        String val = osm.get(key);
+                        if (val != null) {
+                            if (map.containsKey(val)) {
+                                map.get(val).add(osm);
+                            } else {
+                                Vector<OsmPrimitive> v = new Vector<OsmPrimitive>();
+                                v.add(osm);
+                                map.put(val, v);
+                            }
                         }
-                        if (key.equals(newkey)
-                                && tr("<different>").equals(value))
-                            return;
-                        if (key.equals(newkey) || value == null) {
-                            Main.main.undoRedo.add(new ChangePropertyCommand(
-                                    object, newkey, value));
-                        } else {
-                            Collection<Command> commands = new Vector<Command>();
-                            commands.add(new ChangePropertyCommand(object, key,
-                                    null));
-                            commands.add(new ChangePropertyCommand(object,
-                                    newkey, value));
-                            Main.main.undoRedo.add(new SequenceCommand(
-                                    tr("Change properties of 1 object"),
-                                    commands));
-                        }
-                    }
-                } else { // Not possible to edit 0, 2 or more objects
-                    JOptionPane
-                            .showMessageDialog(
-                                    Main.parent,
-                                    tr(
-                                            "You have {0} Elements selected. But you can edit only one element!",
-                                            selection.size()),
-                                    "openingHoursEditor Warning",
-                                    JOptionPane.ERROR_MESSAGE);
-                }
+                    }
+                    for (Entry<String, Vector<OsmPrimitive>> e : map.entrySet()) {
+                        commands.add(new ChangePropertyCommand(e.getValue(), newkey, e.getKey()));
+                    }
+                } else {
+                    commands.add(new ChangePropertyCommand(selection, newkey, value));
+                }
+                Main.main.undoRedo.add(new SequenceCommand(trn("Change properties of up to {0} object",
+                        "Change properties of up to {0} objects", selection.size(), selection.size()), commands));
             }
         }
     }
-
-    // opens up dialogs to change one of the key-value-pairs and returns the
-    // changed pair
-    private String[] editTimeTags(Map<String, String> keyValueMap) {
-        String selectedKey = "";
-
-        if ((selectedKey = tagChooseDialog(keyValueMap)) == null)
-            return null;
-
-        final String value = (keyValueMap.containsKey(selectedKey)) ? keyValueMap
-                .get(selectedKey)
-                : "";
-        OheDialogPanel panel = new OheDialogPanel(this, selectedKey, value);
-
-        final JOptionPane optionPane = new JOptionPane(panel,
-                JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
-        final JDialog dlg = optionPane.createDialog(Main.parent, tr("Edit"));
-
-        dlg.setResizable(true);
-        dlg.setVisible(true);
-
-        Object answer = optionPane.getValue();
-        if (!(answer == null || answer == JOptionPane.UNINITIALIZED_VALUE || (answer instanceof Integer && (Integer) answer != JOptionPane.OK_OPTION)))
-            return panel.getChangedKeyValuePair();
-
-        return null;
-    }
-
-    // opens a dialog for choosing from a set of tags which can be edited
-    // the chosen one is returned
-    private String tagChooseDialog(Map<String, String> keyValueMap) {
-        String preSelectedKey = getPreSelectedKey(keyValueMap);
-        int preSelectedRow = -1;
-
-        String[][] rowData = new String[keyValueMap.size()][2];
-        int cnt = 0;
-        for (Object key : keyValueMap.keySet().toArray()) {
-            rowData[cnt][0] = key.toString();
-            rowData[cnt][1] = keyValueMap.get(key);
-            if (key.toString().equals(preSelectedKey))
-                preSelectedRow = cnt;
-            cnt++;
-        }
-
-        final JTable table = new JTable(rowData,
-                new String[] { "key", "value" }) {
-            public boolean isCellEditable(int rowIndex, int colIndex) {
-                return false; // Disallow the editing of any cell
-            }
-        };
-        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-        JScrollPane sp = new JScrollPane(
-                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
-                JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
-        sp.setViewportView(table);
-
-        final JTextField tf = new JTextField();
-
-        ActionListener al = new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                if (e.getActionCommand().equals("edit")) {
-                    table.setEnabled(true);
-                    tf.setEnabled(false);
-                } else if (e.getActionCommand().equals("new")) {
-                    table.setEnabled(false);
-                    tf.setEnabled(true);
-                }
-            }
-        };
-
-        JRadioButton editButton = new JRadioButton("edit existing tag");
-        editButton.setActionCommand("edit");
-        editButton.addActionListener(al);
-        JRadioButton newButton = new JRadioButton("edit new tag");
-        newButton.setActionCommand("new");
-        newButton.addActionListener(al);
-        ButtonGroup group = new ButtonGroup();
-        group.add(newButton);
-        group.add(editButton);
-
-        if (preSelectedRow != -1) {
-            table.setEnabled(true);
-            tf.setEnabled(false);
-            table.setRowSelectionInterval(preSelectedRow, preSelectedRow);
-            editButton.setSelected(true);
-        } else {
-            table.setEnabled(false);
-            tf.setEnabled(true);
-            tf.setText(preSelectedKey);
-            newButton.setSelected(true);
-        }
-
-        JPanel dlgPanel = new JPanel(new GridBagLayout());
-        dlgPanel.add(editButton, GBC.std().anchor(GBC.CENTER));
-        dlgPanel.add(sp, GBC.eol().fill(GBC.BOTH));
-        dlgPanel.add(newButton, GBC.std().anchor(GBC.CENTER));
-        dlgPanel.add(tf, GBC.eol().fill(GBC.HORIZONTAL));
-
-        JOptionPane optionPane = new JOptionPane(dlgPanel,
-                JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
-        JDialog dlg = optionPane.createDialog(Main.parent, tr("Choose key"));
-
-        dlg.pack();
-        dlg.setResizable(true);
-        dlg.setVisible(true);
-
-        Object answer = optionPane.getValue();
-        if (answer != null
-                && answer != JOptionPane.UNINITIALIZED_VALUE
-                && (answer instanceof Integer && (Integer) answer == JOptionPane.OK_OPTION))
-            if (editButton.isSelected() && table.getSelectedRow() != -1)
-                return rowData[table.getSelectedRow()][0];
-            else if (newButton.isSelected())
-                return tf.getText();
-
-        return null;
-    }
-
-    private String getPreSelectedKey(Map<String, String> keyValueMap) {
-        for (String[] pattern : TAG_EDIT_STRINGS) {
-            Pattern keyPattern = Pattern.compile(pattern[0]);
-            Pattern valuePattern = Pattern.compile(pattern[1]);
-            for (Object key : keyValueMap.keySet().toArray()) {
-                Matcher keyMatcher = keyPattern.matcher(key.toString());
-                if (keyMatcher.matches()) {
-                    Matcher valueMatcher = valuePattern.matcher(keyValueMap
-                            .get(key));
-                    if (valueMatcher.matches()) {
-                        return pattern[2];
-                    }
-                }
-            }
-        }
-        return "";
-    }
 }
Index: applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheDialogPanel.java
===================================================================
--- applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheDialogPanel.java	(revision 25955)
+++ applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheDialogPanel.java	(revision 26002)
@@ -8,4 +8,5 @@
 import java.awt.event.ActionListener;
 import java.util.ArrayList;
+import java.util.Map;
 
 import javax.swing.Box;
@@ -15,4 +16,5 @@
 import javax.swing.JPanel;
 import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
 
 import org.openstreetmap.josm.plugins.ohe.OhePlugin;
@@ -39,8 +41,35 @@
     private final String oldkey;
 
-    public OheDialogPanel(OhePlugin plugin, String key, String value) {
+    /**
+     * The Panel for editing the time-values.
+     * 
+     * @param plugin
+     * @param key
+     * @param valuesToEdit
+     *            can be a String or a Map<String, Integer> which contains
+     *            multiple values and their number of occurences
+     */
+    public OheDialogPanel(OhePlugin plugin, String key, Object valuesToEdit) {
         oldkey = key;
         keyField = new JTextField(key);
 
+        String value = "";
+        if (valuesToEdit instanceof String)
+            value = (String) valuesToEdit;
+        else if (valuesToEdit instanceof Map<?, ?>) {
+            Map<String, Integer> valuesMap = (Map<String, Integer>) valuesToEdit;
+            if (valuesMap.size() == 1)
+                value = valuesMap.keySet().iterator().next();
+            else if (valuesMap.size() > 1) {
+                // TODO let the user choose which value he wants to edit (e.g.
+                // with a combobox)
+                int mostOccurences = 0;
+                for (String v : valuesMap.keySet())
+                    if (valuesMap.get(v) > mostOccurences) {
+                        value = v;
+                        mostOccurences = valuesMap.get(v);
+                    }
+            }
+        }
         valueField = new JTextField(value);
         valueField.addActionListener(new ActionListener() {
@@ -61,5 +90,5 @@
         });
 
-        actualPostionLabel = new JLabel("Mo 00:00");
+        actualPostionLabel = new JLabel("-");
         JPanel toolsPanel = new JPanel(new GridBagLayout());
         toolsPanel.add(twentyfourSevenButton, GBC.std());
@@ -80,5 +109,4 @@
         add(editorPanel, GBC.eol().fill());
 
-        valueField.requestFocus();
         setPreferredSize(new Dimension(480, 520));
     }
@@ -102,16 +130,12 @@
                 if (t instanceof ParseException) {
                     ParseException parserExc = (ParseException) t;
-                    tColumns = new int[] {
-                            parserExc.currentToken.beginColumn - 1,
-                            parserExc.currentToken.endColumn + 1 };
+                    tColumns = new int[] { parserExc.currentToken.beginColumn - 1, parserExc.currentToken.endColumn + 1 };
                 } else if (t instanceof SyntaxException) {
                     SyntaxException syntaxError = (SyntaxException) t;
-                    tColumns = new int[] { syntaxError.getStartColumn(),
-                            syntaxError.getEndColumn() };
+                    tColumns = new int[] { syntaxError.getStartColumn(), syntaxError.getEndColumn() };
                     info = syntaxError.getInfo();
                 } else if (t instanceof TokenMgrError) {
                     TokenMgrError tokenMgrError = (TokenMgrError) t;
-                    tColumns = new int[] { tokenMgrError.errorColumn - 1,
-                            tokenMgrError.errorColumn + 1 };
+                    tColumns = new int[] { tokenMgrError.errorColumn - 1, tokenMgrError.errorColumn + 1 };
                 } else {
                     t.printStackTrace();
@@ -125,16 +149,13 @@
                     String middle = value.substring(first, last);
                     String end = value.substring(last);
-                    String message = "<html>"
-                            + tr("There is something wrong in the value near:")
-                            + "<br>" + begin
-                            + "<span style='background-color:red;'>" + middle
-                            + "</span>" + end;
+                    valueField.setCaretPosition(first);
+                    // TODO focus on the valueField
+                    String message = "<html>" + tr("There is something wrong in the value near:") + "<br>" + begin
+                            + "<span style='background-color:red;'>" + middle + "</span>" + end;
                     if (info != null)
                         message += "<br>" + tr("Info: {0}", tr(info));
-                    message += "<br>"
-                            + tr("Correct the value manually and than press Enter.");
+                    message += "<br>" + tr("Correct the value manually and than press Enter.");
                     message += "</html>";
-                    JOptionPane.showMessageDialog(this, message,
-                            tr("Error in timeformat"),
+                    JOptionPane.showMessageDialog(this, message, tr("Error in timeformat"),
                             JOptionPane.INFORMATION_MESSAGE);
                 }
Index: applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheEditor.java
===================================================================
--- applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheEditor.java	(revision 25955)
+++ applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheEditor.java	(revision 26002)
@@ -20,5 +20,5 @@
 
 public class OheEditor extends JPanel implements MouseListener,
-        MouseMotionListener {
+	MouseMotionListener {
     final OheDialogPanel dialog;
 
@@ -32,210 +32,211 @@
 
     public OheEditor(OheDialogPanel oheDialogPanel) {
-        dialog = oheDialogPanel;
-
-        // the MainPanel for showing the TimeRects
-        contentPanel = new JPanel() {
-            @Override
-            public void setSize(Dimension d) {
-                super.setSize(d);
-                repositionTimeRects();
-            }
-
-            @Override
-            public void paintComponent(Graphics g) {
-                if (OheEditor.this.isEnabled()) {
-                    g.setColor(Color.WHITE);
-                    g.fillRect(0, 0, getWidth(), getHeight());
-
-                    // horizontal Lines
-                    for (int i = 1; i < 24; ++i) {
-                        if (i % 3 == 0)
-                            g.setColor(Color.BLACK);
-                        else
-                            g.setColor(Color.LIGHT_GRAY);
-
-                        g.drawLine(0, getMinutePosition(i * 60), getWidth(),
-                                getMinutePosition(i * 60));
-                    }
-
-                    // vertical Lines
-                    g.setColor(Color.BLACK);
-                    for (int i = 1; i < 7; ++i)
-                        g.drawLine(getDayPosition(i), 0, getDayPosition(i),
-                                getHeight());
-
-                    // if a new Rect is dragged draw it
-                    if (day0 >= 0) {
-                        Graphics2D g2D = (Graphics2D) g;
-
-                        int day2 = Math.min(day0, day1);
-                        int day3 = Math.max(day0, day1);
-                        int minute2 = Math.min(minute0, minute1);
-                        int minute3 = Math.max(minute0, minute1);
-                        Rectangle bounds = getPanelBoundsForTimeinterval(day2,
-                                day3 + 1, minute2, minute3);
-
-                        TimeRect.drawTimeRect(g2D, bounds, minute2 == minute3, false);
-                    }
-                } else {
-                    g.setColor(Color.LIGHT_GRAY);
-                    g.fillRect(0, 0, getWidth(), getHeight());
-                }
-            }
-        };
-        contentPanel.addMouseListener(this);
-        contentPanel.addMouseMotionListener(this);
-        contentPanel.setLayout(null);
-        contentPanel.setPreferredSize(new Dimension(180, 384));
-
-        initTimeRects();
-
-        scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
-                JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
-        scrollPane.setViewportView(contentPanel);
-
-        // the upper Panel for showing Weekdays
-        scrollPane.setColumnHeaderView(new JPanel() {
-            @Override
-            public Dimension getPreferredSize() {
-                return new Dimension(contentPanel.getWidth(), dayAxisHeight);
-            }
-
-            @Override
-            public void paintComponent(Graphics g) {
-                g.setColor(Color.WHITE);
-                g.fillRect(0, 0, getWidth(), getHeight());
-
-                g.setColor(Color.BLACK);
-                for (int i = 0; i < 7; ++i) {
-                    if (i > 0)
-                        g.drawLine(getDayPosition(i) + 1, 0,
-                                getDayPosition(i) + 1, getHeight());
-
-                    String text = OpeningTimeCompiler.WEEKDAYS[i];
-                    g.drawString(text, (int) (getDayPosition(i + 0.5) - g
-                            .getFontMetrics().stringWidth(text) * 0.5),
-                            (int) (dayAxisHeight * 0.5 + g.getFontMetrics()
-                                    .getHeight() * 0.35));
-                }
-            }
-        });
-
-        // the left Panel for showing the hours
-        scrollPane.setRowHeaderView(new JPanel() {
-            @Override
-            public Dimension getPreferredSize() {
-                return new Dimension(timeAxisWidth, contentPanel.getHeight());
-            }
-
-            @Override
-            public void paintComponent(Graphics g) {
-                g.setColor(Color.WHITE);
-                g.fillRect(0, 0, getWidth(), getHeight());
-
-                for (int i = 1; i < 24; ++i) {
-                    if (i % 3 == 0) {
-                        g.setColor(Color.BLACK);
-                        String text = ((i < 10) ? "0" + i : i) + ":00";
-                        g
-                                .drawString(text, timeAxisWidth - 10
-                                        - g.getFontMetrics().stringWidth(text),
-                                        getMinutePosition(i * 60)
-                                                + (int) (g.getFontMetrics()
-                                                        .getHeight() * 0.35));
-                    } else
-                        g.setColor(Color.LIGHT_GRAY);
-
-                    g.drawLine(getWidth() - 4, getMinutePosition(i * 60) + 1,
-                            getWidth(), getMinutePosition(i * 60) + 1);
-                }
-            }
-        });
-
-        setLayout(new BorderLayout());
-        add(scrollPane, BorderLayout.CENTER);
+	dialog = oheDialogPanel;
+
+	// the MainPanel for showing the TimeRects
+	contentPanel = new JPanel() {
+	    @Override
+	    public void setSize(Dimension d) {
+		super.setSize(d);
+		repositionTimeRects();
+	    }
+
+	    @Override
+	    public void paintComponent(Graphics g) {
+		if (OheEditor.this.isEnabled()) {
+		    g.setColor(Color.WHITE);
+		    g.fillRect(0, 0, getWidth(), getHeight());
+
+		    // horizontal Lines
+		    for (int i = 1; i < 24; ++i) {
+			if (i % 3 == 0)
+			    g.setColor(Color.BLACK);
+			else
+			    g.setColor(Color.LIGHT_GRAY);
+
+			g.drawLine(0, getMinutePosition(i * 60), getWidth(),
+				getMinutePosition(i * 60));
+		    }
+
+		    // vertical Lines
+		    g.setColor(Color.BLACK);
+		    for (int i = 1; i < 7; ++i)
+			g.drawLine(getDayPosition(i), 0, getDayPosition(i),
+				getHeight());
+
+		    // if a new Rect is dragged draw it
+		    if (day0 >= 0) {
+			Graphics2D g2D = (Graphics2D) g;
+
+			int day2 = Math.min(day0, day1);
+			int day3 = Math.max(day0, day1);
+			int minute2 = Math.min(minute0, minute1);
+			int minute3 = Math.max(minute0, minute1);
+			Rectangle bounds = getPanelBoundsForTimeinterval(day2,
+				day3 + 1, minute2, minute3);
+
+			TimeRect.drawTimeRect(g2D, bounds, minute2 == minute3,
+				false);
+		    }
+		} else {
+		    g.setColor(Color.LIGHT_GRAY);
+		    g.fillRect(0, 0, getWidth(), getHeight());
+		}
+	    }
+	};
+	contentPanel.addMouseListener(this);
+	contentPanel.addMouseMotionListener(this);
+	contentPanel.setLayout(null);
+	contentPanel.setPreferredSize(new Dimension(180, 384));
+
+	initTimeRects();
+
+	scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+		JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+	scrollPane.setViewportView(contentPanel);
+
+	// the upper Panel for showing Weekdays
+	scrollPane.setColumnHeaderView(new JPanel() {
+	    @Override
+	    public Dimension getPreferredSize() {
+		return new Dimension(contentPanel.getWidth(), dayAxisHeight);
+	    }
+
+	    @Override
+	    public void paintComponent(Graphics g) {
+		g.setColor(Color.WHITE);
+		g.fillRect(0, 0, getWidth(), getHeight());
+
+		g.setColor(Color.BLACK);
+		for (int i = 0; i < 7; ++i) {
+		    if (i > 0)
+			g.drawLine(getDayPosition(i) + 1, 0,
+				getDayPosition(i) + 1, getHeight());
+
+		    String text = OpeningTimeCompiler.WEEKDAYS[i];
+		    g.drawString(text, (int) (getDayPosition(i + 0.5) - g
+			    .getFontMetrics().stringWidth(text) * 0.5),
+			    (int) (dayAxisHeight * 0.5 + g.getFontMetrics()
+				    .getHeight() * 0.35));
+		}
+	    }
+	});
+
+	// the left Panel for showing the hours
+	scrollPane.setRowHeaderView(new JPanel() {
+	    @Override
+	    public Dimension getPreferredSize() {
+		return new Dimension(timeAxisWidth, contentPanel.getHeight());
+	    }
+
+	    @Override
+	    public void paintComponent(Graphics g) {
+		g.setColor(Color.WHITE);
+		g.fillRect(0, 0, getWidth(), getHeight());
+
+		for (int i = 1; i < 24; ++i) {
+		    if (i % 3 == 0) {
+			g.setColor(Color.BLACK);
+			String text = ((i < 10) ? "0" + i : i) + ":00";
+			g.drawString(
+				text,
+				timeAxisWidth - 10
+					- g.getFontMetrics().stringWidth(text),
+				getMinutePosition(i * 60)
+					+ (int) (g.getFontMetrics().getHeight() * 0.35));
+		    } else
+			g.setColor(Color.LIGHT_GRAY);
+
+		    g.drawLine(getWidth() - 4, getMinutePosition(i * 60) + 1,
+			    getWidth(), getMinutePosition(i * 60) + 1);
+		}
+	    }
+	});
+
+	setLayout(new BorderLayout());
+	add(scrollPane, BorderLayout.CENTER);
     }
 
     // update all the TimeRects with new Data
     public void initTimeRects() {
-        contentPanel.removeAll();
-
-        ArrayList<int[]> time;
-        try {
-            time = dialog.getTime();
-        } catch (Exception exc) {
-            setEnabled(false);
-            return;
-        }
-
-        setEnabled(true);
-        timeRects = new ArrayList<TimeRect>();
-        if (time != null) {
-            for (int[] timeRectValues : time) {
-                int day0 = timeRectValues[0];
-                int day1 = timeRectValues[1];
-                int minute0 = timeRectValues[2];
-                int minute1 = timeRectValues[3];
-                TimeRect timeRect = new TimeRect(OheEditor.this, day0, day1,
-                        minute0, minute1);
-                timeRects.add(timeRect);
-                contentPanel.add(timeRect);
-            }
-        }
-
-        repositionTimeRects();
-        repaint();
+	contentPanel.removeAll();
+
+	ArrayList<int[]> time;
+	try {
+	    time = dialog.getTime();
+	} catch (Exception exc) {
+	    setEnabled(false);
+	    return;
+	}
+
+	setEnabled(true);
+	timeRects = new ArrayList<TimeRect>();
+	if (time != null) {
+	    for (int[] timeRectValues : time) {
+		int day0 = timeRectValues[0];
+		int day1 = timeRectValues[1];
+		int minute0 = timeRectValues[2];
+		int minute1 = timeRectValues[3];
+		TimeRect timeRect = new TimeRect(OheEditor.this, day0, day1,
+			minute0, minute1);
+		timeRects.add(timeRect);
+		contentPanel.add(timeRect);
+	    }
+	}
+
+	repositionTimeRects();
+	repaint();
     }
 
     protected void repositionTimeRects() {
-        if (timeRects != null)
-            for (TimeRect timeRect : timeRects)
-                timeRect.reposition();
+	if (timeRects != null)
+	    for (TimeRect timeRect : timeRects)
+		timeRect.reposition();
     }
 
     // returns the physical Borders of the TimeRect on the mainPanel
     public Rectangle getPanelBoundsForTimeinterval(int dayStart, int dayEnd,
-            int minutesStart, int minutesEnd) {
-        int x = getDayPosition(dayStart);
-        int y = getMinutePosition(minutesStart);
-        int width = getDayPosition(dayEnd) - getDayPosition(dayStart);
-        int height = getMinutePosition(minutesEnd)
-                - getMinutePosition(minutesStart);
-
-        // work around openjdk bug
-        if (Main.isOpenjdk) {
-            x++;
-            y++;
-        }
-
-        if (minutesStart == minutesEnd)
-            return new Rectangle(x, y - 2 - TimeRect.verticalNonDrawedPixels,
-                    width, height + 5 + 2 * TimeRect.verticalNonDrawedPixels);
-
-        return new Rectangle(x, y, width, height + 1);
+	    int minutesStart, int minutesEnd) {
+	int x = getDayPosition(dayStart);
+	int y = getMinutePosition(minutesStart);
+	int width = getDayPosition(dayEnd) - getDayPosition(dayStart);
+	int height = getMinutePosition(minutesEnd)
+		- getMinutePosition(minutesStart);
+
+	// work around openjdk bug
+	if (Main.isOpenjdk) {
+	    x++;
+	    y++;
+	}
+
+	if (minutesStart == minutesEnd)
+	    return new Rectangle(x, y - 2 - TimeRect.verticalNonDrawedPixels,
+		    width, height + 5 + 2 * TimeRect.verticalNonDrawedPixels);
+
+	return new Rectangle(x, y, width, height + 1);
     }
 
     public double getDayWidth() {
-        return (contentPanel.getWidth() - 1) / 7.0;
+	return (contentPanel.getWidth() - 1) / 7.0;
     }
 
     public int getDayPosition(double d) {
-        return (int) (d * getDayWidth());
+	return (int) (d * getDayWidth());
     }
 
     public double getMinuteHeight() {
-        return (contentPanel.getHeight() - 1) / (24.0 * 60);
+	return (contentPanel.getHeight() - 1) / (24.0 * 60);
     }
 
     public int getMinutePosition(int minute) {
-        return (int) (minute * getMinuteHeight());
+	return (int) (minute * getMinuteHeight());
     }
 
     // removes the given timerect from the panel and from the arraylist
     public void removeTimeRect(TimeRect timeRectToRemove) {
-        timeRects.remove(timeRectToRemove);
-        contentPanel.remove(timeRectToRemove);
-        dialog.updateValueField(timeRects);
-        repaint();
+	timeRects.remove(timeRectToRemove);
+	contentPanel.remove(timeRectToRemove);
+	dialog.updateValueField(timeRects);
+	repaint();
     }
 
@@ -254,81 +255,87 @@
     @Override
     public void mouseEntered(MouseEvent evt) {
+	mousePositionChanged(0, 0, true);
     }
 
     @Override
     public void mouseExited(MouseEvent evt) {
+	mousePositionChanged(0, 0, false);
     }
 
     @Override
     public void mousePressed(MouseEvent evt) {
-        day0 = (int) Math.floor(evt.getX() / getDayWidth());
-        minute0 = (int) Math.floor(evt.getY()
-                / (getMinuteHeight() * TimeRect.minuteResterize))
-                * TimeRect.minuteResterize;
-        day1 = day0;
-        minute1 = minute0;
-        xDragStart = evt.getX();
-        yDragStart = evt.getY();
+	day0 = (int) Math.floor(evt.getX() / getDayWidth());
+	minute0 = (int) Math.floor(evt.getY()
+		/ (getMinuteHeight() * TimeRect.minuteResterize))
+		* TimeRect.minuteResterize;
+	day1 = day0;
+	minute1 = minute0;
+	xDragStart = evt.getX();
+	yDragStart = evt.getY();
     }
 
     @Override
     public void mouseReleased(MouseEvent evt) {
-        // mouse must be moved 5px before creating a rect
-        if (xDragStart == -1
-                || Math.abs(evt.getX() - xDragStart)
-                        + Math.abs(evt.getY() - yDragStart) > 5) {
-            int day2 = Math.min(day0, day1);
-            int day3 = Math.max(day0, day1);
-            int minute2 = Math.min(minute0, minute1);
-            int minute3 = Math.max(minute0, minute1);
-
-            TimeRect timeRect = new TimeRect(OheEditor.this, day2, day3,
-                    minute2, minute3);
-            timeRects.add(timeRect);
-            contentPanel.add(timeRect);
-            timeRect.reposition();
-            dialog.updateValueField(timeRects);
-
-            day0 = -1;
-            repaint();
-        }
+	// mouse must be moved 5px before creating a rect
+	if (xDragStart == -1
+		|| Math.abs(evt.getX() - xDragStart)
+			+ Math.abs(evt.getY() - yDragStart) > 5) {
+	    int day2 = Math.min(day0, day1);
+	    int day3 = Math.max(day0, day1);
+	    int minute2 = Math.min(minute0, minute1);
+	    int minute3 = Math.max(minute0, minute1);
+
+	    TimeRect timeRect = new TimeRect(OheEditor.this, day2, day3,
+		    minute2, minute3);
+	    timeRects.add(timeRect);
+	    contentPanel.add(timeRect);
+	    timeRect.reposition();
+	    dialog.updateValueField(timeRects);
+
+	    day0 = -1;
+	    repaint();
+	}
     }
 
     @Override
     public void mouseDragged(MouseEvent evt) {
-        // mouse must be moved 5px before drawing a rect
-        if (xDragStart == -1
-                || Math.abs(evt.getX() - xDragStart)
-                        + Math.abs(evt.getY() - yDragStart) > 5) {
-            xDragStart = -1;
-            day1 = (int) Math.floor(evt.getX() / getDayWidth());
-            minute1 = (int) Math.floor(evt.getY()
-                    / (getMinuteHeight() * TimeRect.minuteResterize))
-                    * TimeRect.minuteResterize;
-            
-            // ensure that the new time is in a valid range
-            day1 = Math.max(day1, 0);
-            day1 = Math.min(day1, 6);
-            minute1 = Math.max(minute1, 0);
-            minute1 = Math.min(minute1, 24 * 60);
-            
-            repaint();
-        }
+	// mouse must be moved 5px before drawing a rect
+	if (xDragStart == -1
+		|| Math.abs(evt.getX() - xDragStart)
+			+ Math.abs(evt.getY() - yDragStart) > 5) {
+	    xDragStart = -1;
+	    day1 = (int) Math.floor(evt.getX() / getDayWidth());
+	    minute1 = (int) Math.floor(evt.getY()
+		    / (getMinuteHeight() * TimeRect.minuteResterize))
+		    * TimeRect.minuteResterize;
+
+	    // ensure that the new time is in a valid range
+	    day1 = Math.max(day1, 0);
+	    day1 = Math.min(day1, 6);
+	    minute1 = Math.max(minute1, 0);
+	    minute1 = Math.min(minute1, 24 * 60);
+
+	    repaint();
+	}
+	mousePositionChanged(evt.getX(), evt.getY(), true);
     }
 
     @Override
     public void mouseMoved(MouseEvent evt) {
-        mousePositionChanged(evt.getX(), evt.getY());
-    }
-
-    public void mousePositionChanged(int x, int y) {
-        int actualDay = (int) Math.floor(x / getDayWidth());
-        int minutes = (int) Math.floor(y
-                / (getMinuteHeight() * TimeRect.minuteResterize))
-                * TimeRect.minuteResterize;
-        actualDay = Math.max(0, Math.min(6, actualDay));
-        minutes = Math.max(0, Math.min(24 * 60, minutes));
-        dialog.setMousePositionText(OpeningTimeCompiler.WEEKDAYS[actualDay]
-                + " " + OpeningTimeUtils.timeString(minutes));
+	mousePositionChanged(evt.getX(), evt.getY(), true);
+    }
+
+    public void mousePositionChanged(int x, int y,  boolean mouseInside) {
+	if (mouseInside) {
+	    int actualDay = (int) Math.floor(x / getDayWidth());
+	    int minutes = (int) Math.floor(y
+		    / (getMinuteHeight() * TimeRect.minuteResterize))
+		    * TimeRect.minuteResterize;
+	    actualDay = Math.max(0, Math.min(6, actualDay));
+	    minutes = Math.max(0, Math.min(24 * 60, minutes));
+	    dialog.setMousePositionText(OpeningTimeCompiler.WEEKDAYS[actualDay]
+		    + " " + OpeningTimeUtils.timeString(minutes));
+	} else
+	    dialog.setMousePositionText("-");
     }
 }
Index: applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/TimeRect.java
===================================================================
--- applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/TimeRect.java	(revision 25955)
+++ applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/TimeRect.java	(revision 26002)
@@ -285,5 +285,5 @@
             }
         }
-        editor.mousePositionChanged(evt.getX() + getX(), evt.getY() + getY());
+        editor.mousePositionChanged(evt.getX() + getX(), evt.getY() + getY(), true);
     }
 
@@ -292,5 +292,5 @@
         if (transformType < 0)
             setCursor(new Cursor(transformCursorTypes[getTransformType(evt)]));
-        editor.mousePositionChanged(evt.getX() + getX(), evt.getY() + getY());
+        editor.mousePositionChanged(evt.getX() + getX(), evt.getY() + getY(), true);
     }
 }
