diff --git a/.gitignore b/.gitignore index 791d9a970..6625bb58c 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ build.xml /_lib /gradlew_release.cmd /gradle_localOverride.cmd +/gradlew_updateWrapper.cmd +/gradlew_repairHeaders.cmd diff --git a/build.gradle b/build.gradle index 135f348c4..b17647af2 100644 --- a/build.gradle +++ b/build.gradle @@ -11,6 +11,10 @@ buildscript { maven { url "https://oss.sonatype.org/content/repositories/snapshots" } + dependencies { + classpath "eu.mihosoft.vrl.vlicense-header-util:VLicenseHeaderUtil:0.1-r2-SNAPSHOT" + classpath "eu.mihosoft.vrl.vlicense-header-util.gradle:vlicense-header-plugin:0.1-r2-SNAPSHOT" + } } final javaHome = System.env['JAVA_HOME'] @@ -69,7 +73,7 @@ task buildTimestamped(type: Copy, dependsOn: 'build') { } task wrapper(type: Wrapper) { - gradleVersion = '1.0-rc-3' + gradleVersion = '1.7' } signArchives.onlyIf { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e457cca77..9fde8c8d7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sun Jun 03 10:11:31 MDT 2012 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-1.0-rc-3-bin.zip +#Sun Sep 15 18:45:24 CEST 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-1.7-bin.zip diff --git a/license-template.txt b/license-template.txt index 4035c7434..b6a3f12d2 100644 --- a/license-template.txt +++ b/license-template.txt @@ -11,7 +11,7 @@ * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * * Neither the name of the nor the + * * Neither the name of the organization nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 000000000..53f0bc45f --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'jfxtras-labs' \ No newline at end of file diff --git a/src/main/java/jfxtras/labs/scene/control/CalendarTextField.java b/src/main/java/jfxtras/labs/scene/control/CalendarTextField.java index 5cc39749d..35f42d03c 100644 --- a/src/main/java/jfxtras/labs/scene/control/CalendarTextField.java +++ b/src/main/java/jfxtras/labs/scene/control/CalendarTextField.java @@ -29,19 +29,20 @@ package jfxtras.labs.scene.control; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Locale; - -import javafx.beans.property.ListProperty; -import javafx.beans.property.ObjectProperty; -import javafx.beans.property.SimpleListProperty; -import javafx.beans.property.SimpleObjectProperty; -import javafx.collections.ObservableList; -import javafx.scene.control.Control; -import javafx.util.Callback; +import java.lang.reflect.Field; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Locale; + +import javafx.beans.property.ListProperty; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleListProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.collections.ObservableList; +import javafx.scene.control.Control; +import javafx.util.Callback; /** * A textField with displays a calendar (date) with a icon to popup the CalendarPicker @@ -101,7 +102,10 @@ private void construct() public void setCalendar(Calendar value) { calendarObjectProperty.setValue(value); } public CalendarTextField withCalendar(Calendar value) { setCalendar(value); return this; } - /** Locale: the locale is used to determine first-day-of-week, weekday labels, etc */ + /** Locale: the locale is used to determine first-day-of-week, weekday labels, etc + * If possible, the locale will be derived from the DateFormat when it is set. + * Since it is not formally possible to extract the Locale from a DateFormat, the coder is responsible for making sure the dateformat's Locale and this Locale are the same. + */ public ObjectProperty localeProperty() { return localeObjectProperty; } final private ObjectProperty localeObjectProperty = new SimpleObjectProperty(Locale.getDefault()) { @@ -110,7 +114,7 @@ public void set(Locale value) super.set(value); if (dateFormatManual == false) { - setDateFormat( SimpleDateFormat.getDateInstance(DateFormat.LONG, value) ); + setDateFormat( SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, value) ); } } }; @@ -123,12 +127,29 @@ public void set(Locale value) * It is allow to show time as well for example by SimpleDateFormat.getDateTimeInstance(). */ public ObjectProperty dateFormatProperty() { return dateFormatObjectProperty; } - final private ObjectProperty dateFormatObjectProperty = new SimpleObjectProperty(this, "dateFormat", SimpleDateFormat.getDateInstance(DateFormat.LONG, getLocale())) + final private ObjectProperty dateFormatObjectProperty = new SimpleObjectProperty(this, "dateFormat", SimpleDateFormat.getDateInstance(DateFormat.MEDIUM, getLocale())) { public void set(DateFormat value) { super.set(value); dateFormatManual = true; + + // see if we can extract the locale + if (value != null) + { + try + { + Field field = value.getClass().getDeclaredField("locale"); + field.setAccessible(true); + Locale lLocale = (Locale)field.get(value); + if (lLocale != null) + { + setLocale(lLocale); + } + } + catch (NoSuchFieldException e) { } // ignored on purpose + catch (IllegalAccessException e) { } // ignored on purpose + } } }; public DateFormat getDateFormat() { return dateFormatObjectProperty.getValue(); } diff --git a/src/test/java/jfxtras/labs/scene/control/CalendarPickerTrail2.xml b/src/test/java/jfxtras/labs/scene/control/CalendarPickerTrial2.xml similarity index 100% rename from src/test/java/jfxtras/labs/scene/control/CalendarPickerTrail2.xml rename to src/test/java/jfxtras/labs/scene/control/CalendarPickerTrial2.xml diff --git a/src/test/java/jfxtras/labs/scene/control/CalendarTextFieldTrial1.java b/src/test/java/jfxtras/labs/scene/control/CalendarTextFieldTrial1.java index b69cf2dd4..87592d9a2 100644 --- a/src/test/java/jfxtras/labs/scene/control/CalendarTextFieldTrial1.java +++ b/src/test/java/jfxtras/labs/scene/control/CalendarTextFieldTrial1.java @@ -29,23 +29,26 @@ package jfxtras.labs.scene.control; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.GregorianCalendar; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; import java.util.Locale; - -import javafx.application.Application; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.geometry.Insets; -import javafx.scene.Scene; -import javafx.scene.control.Label; -import javafx.scene.control.TextField; -import javafx.scene.control.Tooltip; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.HBox; -import javafx.stage.Stage; -import javafx.util.Callback; + +import javafx.application.Application; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.control.Tooltip; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; +import javafx.stage.Stage; +import javafx.util.Callback; /** * @author Tom Eugelink @@ -159,14 +162,35 @@ public void changed(ObservableValue observableValue, Calenda // locale DE { - lGridPane.add(new Label("locale DE"), 0, lRowIdx); + lGridPane.add(new Label("locale FR"), 0, lRowIdx); CalendarTextField lCalendarTextField = new CalendarTextField(); - lCalendarTextField.setLocale(Locale.GERMAN); + lCalendarTextField.setLocale(Locale.FRANCE); lGridPane.add(lCalendarTextField, 1, lRowIdx++); lCalendarTextField.calendarProperty().set(new GregorianCalendar(2011, 2, 01)); // set a value } + // locale DE button + { + lGridPane.add(new Label("locale FR"), 0, lRowIdx); + final CalendarTextField lCalendarTextField = new CalendarTextField(); + lCalendarTextField.setLocale(Locale.FRANCE); + lGridPane.add(lCalendarTextField, 1, lRowIdx); + + Button lButton = new Button("set"); + lButton.onMouseClickedProperty().set(new EventHandler() + { + @Override + public void handle(Event arg0) + { + lCalendarTextField.setCalendar(new GregorianCalendar(2011, 2, 01)); + } + }); + lGridPane.add(lButton, 2, lRowIdx++); + + lCalendarTextField.calendarProperty().set(new GregorianCalendar()); // set a value + } + // disabled { lGridPane.add(new Label("custom icon disabled"), 0, lRowIdx); diff --git a/src/test/java/jfxtras/labs/scene/control/CalendarTextFieldTrial2.xml b/src/test/java/jfxtras/labs/scene/control/CalendarTextFieldTrial2.xml index 7de4235d3..8acdf72dc 100644 --- a/src/test/java/jfxtras/labs/scene/control/CalendarTextFieldTrial2.xml +++ b/src/test/java/jfxtras/labs/scene/control/CalendarTextFieldTrial2.xml @@ -5,7 +5,7 @@ - - + + \ No newline at end of file