X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2FPasteCoordinates.java;h=7587949b25c893e5a4c9565d69d6a723ae603ec2;hb=4d5796d02a15808311c09448d79e6e7d1de9d636;hp=1106001ad3f10abaec76c3b17a73f24d4ac543fd;hpb=1ee49ae3c8ef3aa2e63eadd458531e5f8bd4f92c;p=GpsPrune.git diff --git a/tim/prune/function/PasteCoordinates.java b/tim/prune/function/PasteCoordinates.java index 1106001..7587949 100644 --- a/tim/prune/function/PasteCoordinates.java +++ b/tim/prune/function/PasteCoordinates.java @@ -8,6 +8,7 @@ import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import javax.swing.BorderFactory; import javax.swing.JButton; @@ -74,8 +75,8 @@ public class PasteCoordinates extends GenericFunction // MAYBE: Paste clipboard into the edit field _coordField.setText(""); _nameField.setText(""); - boolean metric = Config.getConfigBoolean(Config.KEY_METRIC_UNITS); - _altUnitsDropDown.setSelectedIndex(metric?0:1); + boolean useMetres = (Config.getUnitSet().getDefaultAltitudeFormat() == Altitude.Format.METRES); + _altUnitsDropDown.setSelectedIndex(useMetres?0:1); enableOK(); _dialog.setVisible(true); } @@ -96,12 +97,15 @@ public class PasteCoordinates extends GenericFunction // Listeners to enable/disable ok button KeyAdapter keyListener = new KeyAdapter() { /** Key released */ - public void keyReleased(KeyEvent arg0) { + public void keyReleased(KeyEvent inE) { enableOK(); + if (inE.getKeyCode() == KeyEvent.VK_ESCAPE) { + _dialog.dispose(); + } } }; MouseAdapter mouseListener = new MouseAdapter() { - public void mouseReleased(java.awt.event.MouseEvent arg0) { + public void mouseReleased(MouseEvent inE) { enableOK(); }; }; @@ -132,7 +136,7 @@ public class PasteCoordinates extends GenericFunction ActionListener okListener = new ActionListener() { public void actionPerformed(ActionEvent e) { - finish(); + if (_okButton.isEnabled()) {finish();} } }; _okButton.addActionListener(okListener); @@ -159,7 +163,7 @@ public class PasteCoordinates extends GenericFunction private void enableOK() { String text = _coordField.getText(); - _okButton.setEnabled(text != null && text.length() > 10 + _okButton.setEnabled(text != null && text.length() > 6 && (text.indexOf(' ') >= 0 || text.indexOf(',') >= 0)); }