You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/07/22 15:40:31 UTC
svn commit: r966652 - in /pivot/trunk: core/src/org/apache/pivot/util/
core/test/org/apache/pivot/util/test/
demos/src/org/apache/pivot/demos/displays/
demos/src/org/apache/pivot/demos/swing/ demos/www/
examples/src/org/apache/pivot/examples/swing/
Author: gbrown
Date: Thu Jul 22 13:40:30 2010
New Revision: 966652
URL: http://svn.apache.org/viewvc?rev=966652&view=rev
Log:
Resolve PIVOT-577; move Pivot/Swing demo to examples project.
Added:
pivot/trunk/examples/src/org/apache/pivot/examples/swing/
- copied from r966599, pivot/trunk/demos/src/org/apache/pivot/demos/swing/
Removed:
pivot/trunk/demos/src/org/apache/pivot/demos/swing/
pivot/trunk/demos/www/swing-demo.html
Modified:
pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java
pivot/trunk/core/src/org/apache/pivot/util/Time.java
pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java
pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml
pivot/trunk/examples/src/org/apache/pivot/examples/swing/SwingDemo.java
Modified: pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java?rev=966652&r1=966651&r2=966652&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/util/CalendarDate.java Thu Jul 22 13:40:30 2010
@@ -20,8 +20,6 @@ import java.io.Serializable;
import java.text.NumberFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.pivot.collections.Dictionary;
import org.apache.pivot.json.JSONSerializer;
@@ -434,16 +432,15 @@ public final class CalendarDate implemen
* A string in the form of <tt>[YYYY]-[MM]-[DD]</tt> (e.g. 2008-07-23).
*/
public static CalendarDate decode(String value) {
- Pattern pattern = Pattern.compile("^(\\d{4})-(\\d{2})-(\\d{2})$");
- Matcher matcher = pattern.matcher(value);
+ String[] components = value.split("-");
- if (!matcher.matches()) {
+ if (components.length != 3) {
throw new IllegalArgumentException("Invalid date format: " + value);
}
- int year = Integer.parseInt(matcher.group(1));
- int month = Integer.parseInt(matcher.group(2)) - 1;
- int day = Integer.parseInt(matcher.group(3)) - 1;
+ int year = Integer.parseInt(components[0]);
+ int month = Integer.parseInt(components[1]) - 1;
+ int day = Integer.parseInt(components[2]) - 1;
return new CalendarDate(year, month, day);
}
Modified: pivot/trunk/core/src/org/apache/pivot/util/Time.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/Time.java?rev=966652&r1=966651&r2=966652&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/util/Time.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/util/Time.java Thu Jul 22 13:40:30 2010
@@ -20,8 +20,6 @@ import java.io.Serializable;
import java.text.NumberFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.apache.pivot.collections.Dictionary;
import org.apache.pivot.json.JSONSerializer;
@@ -381,22 +379,22 @@ public final class Time implements Compa
* A string in the form of <tt>[hh]:[mm]:[ss]</tt> or
* <tt>[hh]:[mm]:[ss].[nnn]</tt> (e.g. 17:19:20 or 17:19:20.412).
*/
-
public static Time decode(String value) {
- Pattern pattern = Pattern.compile("^(\\d{2}):(\\d{2}):(\\d{2})(\\.(\\d{3}))?$");
- Matcher matcher = pattern.matcher(value);
+ String[] components = value.split(":");
- if (!matcher.matches()) {
+ if (components.length != 3) {
throw new IllegalArgumentException("Invalid time format: " + value);
}
- int hour = Integer.parseInt(matcher.group(1));
- int minute = Integer.parseInt(matcher.group(2));
- int second = Integer.parseInt(matcher.group(3));
+ int hour = Integer.parseInt(components[0]);
+ int minute = Integer.parseInt(components[1]);
+
+ String[] secondComponents = components[2].split("\\.");
+ int second = Integer.parseInt(secondComponents[0]);
int millisecond;
- if (matcher.groupCount() == 5) {
- millisecond = Integer.parseInt(matcher.group(4).substring(1));
+ if (secondComponents.length > 1) {
+ millisecond = Integer.parseInt(secondComponents[1]);
} else {
millisecond = 0;
}
Modified: pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java?rev=966652&r1=966651&r2=966652&view=diff
==============================================================================
--- pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java (original)
+++ pivot/trunk/core/test/org/apache/pivot/util/test/TimeTest.java Thu Jul 22 13:40:30 2010
@@ -42,5 +42,20 @@ public class TimeTest {
System.out.println(time.add(-Time.MILLISECONDS_PER_DAY - 1));
System.out.println(time.add(1000));
System.out.println(time.add(-1000));
+
+ time = Time.decode("00:00:00.000");
+ System.out.println(time);
+
+ time = Time.decode("00:00:00.00");
+ System.out.println(time);
+
+ time = Time.decode("00:00:00");
+ System.out.println(time);
+
+ try {
+ time = Time.decode("00:00");
+ } catch (IllegalArgumentException exception) {
+ System.out.println(exception);
+ }
}
}
Modified: pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml
URL: http://svn.apache.org/viewvc/pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml?rev=966652&r1=966651&r2=966652&view=diff
==============================================================================
--- pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml (original)
+++ pivot/trunk/demos/src/org/apache/pivot/demos/displays/multiple_display_demo.bxml Thu Jul 22 13:40:30 2010
@@ -22,7 +22,7 @@ limitations under the License.
<bxml:define>
<Window bxml:id="secondaryDisplayWindow" title="Secondary Display Window" maximized="true">
<BoxPane orientation="vertical" styles="{padding:8}">
- <Label text="I am a secondary display!"/>
+ <Label text="I am a modal secondary display!"/>
<PushButton buttonData="Close">
<buttonPressListeners>
function buttonPressed(button) {
Modified: pivot/trunk/examples/src/org/apache/pivot/examples/swing/SwingDemo.java
URL: http://svn.apache.org/viewvc/pivot/trunk/examples/src/org/apache/pivot/examples/swing/SwingDemo.java?rev=966652&r1=966599&r2=966652&view=diff
==============================================================================
--- pivot/trunk/examples/src/org/apache/pivot/examples/swing/SwingDemo.java (original)
+++ pivot/trunk/examples/src/org/apache/pivot/examples/swing/SwingDemo.java Thu Jul 22 13:40:30 2010
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.pivot.demos.swing;
+package org.apache.pivot.examples.swing;
import java.beans.PropertyVetoException;
import java.io.IOException;