jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1717954 - in /jmeter/trunk: src/core/org/apache/jmeter/gui/util/JDateField.java xdocs/changes.xml
Date Fri, 04 Dec 2015 12:38:22 GMT
Author: pmouawad
Date: Fri Dec  4 12:38:22 2015
New Revision: 1717954

URL: http://svn.apache.org/viewvc?rev=1717954&view=rev
Log:
Bug 58685 - JDatefield : Make the modification of the date with up/down arrow work
Bugzilla Id: 58685

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/util/JDateField.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/util/JDateField.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/util/JDateField.java?rev=1717954&r1=1717953&r2=1717954&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/util/JDateField.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/util/JDateField.java Fri Dec  4 12:38:22 2015
@@ -29,16 +29,16 @@ import java.util.Calendar;
 import java.util.Date;
 
 import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
 
 /**
  * This is Date mask control. Using this control we can pop up our date in the
- * text field. And this control is Devloped basically for JDK1.3 and lower
- * version support. This control is similer to JSpinner control this is
+ * text field. And this control is developed basically for JDK1.3 and lower
+ * version support. This control is similar to JSpinner control this is
  * available in JDK1.4 and above only.
  * <p>
  * This will set the date "yyyy/MM/dd HH:mm:ss" in this format only.
  * </p>
- *
  */
 public class JDateField extends JTextField {
 
@@ -118,14 +118,6 @@ public class JDateField extends JTextFie
             return dateFormat.parse(getText());
         } catch (ParseException e) {
             return new Date();
-        } catch (Exception e) {
-            // DateFormat.parse has some bugs (up to JDK 1.4.2) by which it
-            // throws unchecked exceptions. E.g. see:
-            // http://developer.java.sun.com/developer/bugParade/bugs/4699765.html
-            //
-            // To avoid problems with such situations, we'll catch all
-            // exceptions here and act just as for ParseException above:
-            return new Date();
         }
     }
 
@@ -173,13 +165,17 @@ public class JDateField extends JTextFie
         if (pos > newDate.length()) {
             pos = newDate.length();
         }
-        setCaretPosition(pos);// Restore position
-
+        final int newPosition = pos;
+        SwingUtilities.invokeLater(new Runnable() {
+            @Override
+            public void run() {
+                setCaretPosition(newPosition);// Restore position
+            }
+        });
     }
 
     class KeyFocus extends KeyAdapter {
-        KeyFocus() {
-        }
+        KeyFocus() {}
 
         @Override
         public void keyPressed(KeyEvent e) {
@@ -192,15 +188,16 @@ public class JDateField extends JTextFie
     }
 
     class FocusClass implements FocusListener {
-        FocusClass() {
-        }
+        FocusClass() {}
 
         @Override
-        public void focusGained(FocusEvent e) {
-        }
+        public void focusGained(FocusEvent e) {}
 
         @Override
         public void focusLost(FocusEvent e) {
+            if(getText() == null || getText().isEmpty()) {
+                return;
+            }
             try {
                 dateFormat.parse(getText());
             } catch (ParseException e1) {

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1717954&r1=1717953&r2=1717954&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Fri Dec  4 12:38:22 2015
@@ -214,6 +214,7 @@ Summary
     <li><bug>57731</bug>TESTSTART.MS has always the value of the first
Test started in Server mode in NON GUI Distributed testing</li>
     <li><bug>58016</bug> Error type casting using external SSL Provider.
Contributed by Kirill Yankov (myworkpostbox at gmail.com)</li>
     <li><bug>58293</bug>SOAP/XML-RPC Sampler file browser generates NullPointerException</li>
+    <li><bug>58685</bug>JDatefield : Make the modification of the date
with up/down arrow work. Contributed by Benoit Wiart (benoit dot wiart at gmail.com)</li>
 </ul>
 
  <!--  =================== Thanks =================== -->



Mime
View raw message