From cf1765165bbb707bf1729046e96835e4360c3f5f Mon Sep 17 00:00:00 2001 From: Teppo Kurki Date: Thu, 15 Jan 2009 11:33:59 +0000 Subject: [PATCH] Adding DateField examples for Sampler. svn changeset:6549/svn branch:trunk --- .../toolkit/demo/sampler/ExampleUtil.java | 26 +++++++ .../toolkit/demo/sampler/FeatureSet.java | 17 +++++ .../sampler/features/dates/DateInline.java | 43 +++++++++++ .../sampler/features/dates/DateInline.png | Bin 0 -> 1684 bytes .../features/dates/DateInlineExample.java | 40 ++++++++++ .../sampler/features/dates/DateLocale.java | 46 ++++++++++++ .../sampler/features/dates/DateLocale.png | Bin 0 -> 1984 bytes .../features/dates/DateLocaleExample.java | 48 ++++++++++++ .../sampler/features/dates/DatePopup.java | 42 +++++++++++ .../demo/sampler/features/dates/DatePopup.png | Bin 0 -> 2020 bytes .../features/dates/DatePopupExample.java | 40 ++++++++++ .../features/dates/DateResolution.java | 43 +++++++++++ .../sampler/features/dates/DateResolution.png | Bin 0 -> 1728 bytes .../features/dates/DateResolutionExample.java | 69 ++++++++++++++++++ 14 files changed, 414 insertions(+) create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DateInline.java create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DateInline.png create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DateInlineExample.java create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DateLocale.java create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DateLocale.png create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DateLocaleExample.java create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DatePopup.java create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DatePopup.png create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DatePopupExample.java create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DateResolution.java create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DateResolution.png create mode 100644 src/com/itmill/toolkit/demo/sampler/features/dates/DateResolutionExample.java diff --git a/src/com/itmill/toolkit/demo/sampler/ExampleUtil.java b/src/com/itmill/toolkit/demo/sampler/ExampleUtil.java index 36bbb09a12..e612e91a2e 100644 --- a/src/com/itmill/toolkit/demo/sampler/ExampleUtil.java +++ b/src/com/itmill/toolkit/demo/sampler/ExampleUtil.java @@ -1,5 +1,7 @@ package com.itmill.toolkit.demo.sampler; +import java.util.Locale; + import com.itmill.toolkit.data.Container; import com.itmill.toolkit.data.Item; import com.itmill.toolkit.data.util.HierarchicalContainer; @@ -117,6 +119,26 @@ public final class ExampleUtil { } } + public static final Object locale_PROPERTY_LOCALE = "locale"; + public static final Object locale_PROPERTY_NAME = "name"; + private static final String[][] locales = { { "fi", "FI", "Finnish" }, + { "de", "DE", "German" }, { "en", "US", "US - English" }, + { "sv", "SE", "Swedish" } }; + private static final IndexedContainer localeContainer = new IndexedContainer(); + static { + localeContainer.addContainerProperty(locale_PROPERTY_LOCALE, + Locale.class, null); + localeContainer.addContainerProperty(locale_PROPERTY_NAME, + String.class, null); + for (int i = 0; i < locales.length; i++) { + String id = locales[i][2]; + Item item = localeContainer.addItem(id); + item.getItemProperty(locale_PROPERTY_LOCALE).setValue( + new Locale(locales[i][0], locales[i][1])); + item.getItemProperty(locale_PROPERTY_NAME).setValue(locales[i][2]); + } + } + private static final String[][] hardware = { // { "Desktops", "Dell OptiPlex GX240", "Dell OptiPlex GX260", "Dell OptiPlex GX280" }, @@ -124,6 +146,10 @@ public final class ExampleUtil { { "Laptops", "IBM ThinkPad T40", "IBM ThinkPad T43", "IBM ThinkPad T60" } }; + public static IndexedContainer getLocaleContainer() { + return localeContainer; + } + public static IndexedContainer getISO3166Container() { return iso3166Container; } diff --git a/src/com/itmill/toolkit/demo/sampler/FeatureSet.java b/src/com/itmill/toolkit/demo/sampler/FeatureSet.java index 7746eccb77..619940cff4 100644 --- a/src/com/itmill/toolkit/demo/sampler/FeatureSet.java +++ b/src/com/itmill/toolkit/demo/sampler/FeatureSet.java @@ -16,6 +16,10 @@ import com.itmill.toolkit.demo.sampler.features.commons.Errors; import com.itmill.toolkit.demo.sampler.features.commons.Icons; import com.itmill.toolkit.demo.sampler.features.commons.Tooltips; import com.itmill.toolkit.demo.sampler.features.commons.Validation; +import com.itmill.toolkit.demo.sampler.features.dates.DateInline; +import com.itmill.toolkit.demo.sampler.features.dates.DateLocale; +import com.itmill.toolkit.demo.sampler.features.dates.DatePopup; +import com.itmill.toolkit.demo.sampler.features.dates.DateResolution; import com.itmill.toolkit.demo.sampler.features.form.FormBasic; import com.itmill.toolkit.demo.sampler.features.layouts.HorizontalLayoutBasic; import com.itmill.toolkit.demo.sampler.features.layouts.LayoutAlignment; @@ -119,6 +123,7 @@ public class FeatureSet extends Feature { new Tables(),// new Texts(), // new Trees(), // + new Dates(), // }); } } @@ -302,6 +307,18 @@ public class FeatureSet extends Feature { } } + public static class Dates extends FeatureSet { + public Dates() { + super("Dates", new Feature[] { + // + new DatePopup(), // + new DateInline(), // + new DateLocale(), // + new DateResolution(), // + }); + } + } + // ---------------------------------------------------------- /* * FeatureSet implementation follows. diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DateInline.java b/src/com/itmill/toolkit/demo/sampler/features/dates/DateInline.java new file mode 100644 index 0000000000..6b2b41216c --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/dates/DateInline.java @@ -0,0 +1,43 @@ +package com.itmill.toolkit.demo.sampler.features.dates; + +import com.itmill.toolkit.demo.sampler.APIResource; +import com.itmill.toolkit.demo.sampler.Feature; +import com.itmill.toolkit.demo.sampler.NamedExternalResource; +import com.itmill.toolkit.ui.DateField; +import com.itmill.toolkit.ui.InlineDateField; + +public class DateInline extends Feature { + @Override + public String getName() { + return "Date selection inline"; + } + + @Override + public String getDescription() { + return "The DateField component can be used to produce various" + + " date and time input fields with different resolutions." + + " The date and time format used with this component is" + + " reported to the Toolkit by the browser." + + "
In this example, the resolution is set to be one day" + + " and the DateField component is shown as an inline calendar" + + " component."; + } + + @Override + public APIResource[] getRelatedAPI() { + return new APIResource[] { new APIResource(DateField.class), + new APIResource(InlineDateField.class) }; + } + + @Override + public Class[] getRelatedFeatures() { + return new Class[] { DatePopup.class, DateLocale.class, + DateResolution.class }; + } + + @Override + public NamedExternalResource[] getRelatedResources() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DateInline.png b/src/com/itmill/toolkit/demo/sampler/features/dates/DateInline.png new file mode 100644 index 0000000000000000000000000000000000000000..852a12df04214977271dc063fc3162be9ee9641c GIT binary patch literal 1684 zcmb7FeK^w#8~$O&tT7?9u@Oa*lWgT9v&3vnKH|J5*&&=G<*Ue|Y=#iq>BBc;EMCk? zy>i5nkGFT~oDQ4g_!v@zjeKSDt+Vsr`~LG@SI>1l&wbs`pU-{W_mk!2Nr0*CR|5b5 zMsz#lBS-4rt*R)WP2h@jIVfE7A)E#t^&q8k0{Rh8#sk2UpP<{p%5shlaq}SqK;l6F zpr--ArhG-006_dV05BT_0Ct4{pc_-#;_Uzc;Jw5%_;XaseCc=;5~D5n?ZA@Hs6T^8 zS=xJxPSI(0tpknfKwRoxmZ$APj7*Fm+Qk>pchWN9Aaht{t@t4sF_cSQ?=sK7+)H&R zn{@tp$DjLZaB%Yt%Nzf%S{2Bdj1MFAA+O95j}B@nm;m< zKjYi4Zu;>|TH|L;xjMEySLZi@QGMt2<9y%fdEfPz(EP$@ykc%lGguoDVRuuWB)Q?O zwIFt%?T13IW7Stg*r)|3_aadAp^;KhweI&-R-ivwS|u$Sr_}RFIAyl-#pRQ`p2KO{C!ntBMJ(wCDg9Y+B{z$gm3SWW+rrWxR%15 z#8{{p)W_`UUwvtRbf=#U$RMmSe6oDeobhzDS9SlF9=xV*m+THogDo={x zVfdurXMNd|W~r2xq&{axWcY{>|Tlwh-8mRIy# zIm>Xg&LhNaD0*OEJb5ONZzG;KDePRcis0zB@9xWu4Gdi0O9cIV{tv`n?DFpq{1cOr zw}c4`Z%YDpNoJFqamk|gwog`T?;kr=MGvjh;P0ZOFAc}X#++}5)7Ey#Qo_tU+hE%T zacVaNFI2r^b5G)I4Fvjg@|?r;QZ2job$vRt`oOz!;K(y2DDz8}Yt&u@y#< zwYF@fQN4DBU#VUSvgrZ-S;wuePIg(qQZzKv=BfHQwJtE{7!B#at2?_(7hIpA>)GUc zVecqPmZ>)r5;Tq{V8rc~=ss0DFLTwoko(2J3N}%=_z{CPJaQRgt1RS-B=Xu#-5IX( zYk1+%u05)5CCr5LWUvuw_j{#_!WxIc>FIb=B138=WX3y18i@d!&4{{M*| zXM;y*esjNq3lV41@4W%pZwAf6F8rr-xAb|#mw}>*?k&fYL=Iu@UmD}~b3dGf%i0Dh zfJGn;5qzsyK#pMGnFEJoF|E3Lu5E{ zjq0(nED(>6;O3qlRj^duz5!n7FgiXOi{%6>4_6x>Dr$v9u=CSdp7eZ@aZ(It@`@Am zyNB~<51aY^8=C1T!Io(BVkpm3pin!q~c+4|mWtZg=bj8m0tPJxs?d zUuP9Zf|V*-FRCPR-ezx~#3T5QUvca`247*)|J7-a!KoC^nAKp*_to{svPhjfA5zDs z{EE`6xfVuCGndc`&-WjG0BR9zBgW1In this example, you can select a different locale" + + " from the combo box and see how the calendar component" + + " will be localized."; + } + + @Override + public APIResource[] getRelatedAPI() { + return new APIResource[] { new APIResource(DateField.class), + new APIResource(InlineDateField.class), + new APIResource(Locale.class) }; + } + + @Override + public Class[] getRelatedFeatures() { + return new Class[] { DateInline.class, DatePopup.class, + DateResolution.class }; + } + + @Override + public NamedExternalResource[] getRelatedResources() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DateLocale.png b/src/com/itmill/toolkit/demo/sampler/features/dates/DateLocale.png new file mode 100644 index 0000000000000000000000000000000000000000..dad35b72a0349d2c1c09d659faccdb8e1236f696 GIT binary patch literal 1984 zcmd5-=_AvP1OLi3cg|(bgr*_M;~2}fW^a)c;n9=|`~_wM)NbH4k$`dq`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E{xhPt!eS)KIyNDKGRQeY2^Hyaw5}+HKt9}=b7KALcEpx8%uM5FMU9(Aw=n+43^d4^xo9OL`6wFS=6xqUfyYLUFxCJL{5F>gQ99z*Xc icV}`zthWU3DgN?qv)}f<|1*|OWG0kY7jDG>CT9{M- literal 0 HcmV?d00001 diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DateLocaleExample.java b/src/com/itmill/toolkit/demo/sampler/features/dates/DateLocaleExample.java new file mode 100644 index 0000000000..bc368acd15 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/dates/DateLocaleExample.java @@ -0,0 +1,48 @@ +package com.itmill.toolkit.demo.sampler.features.dates; + +import java.util.Locale; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.data.Property; +import com.itmill.toolkit.data.Property.ValueChangeEvent; +import com.itmill.toolkit.demo.sampler.ExampleUtil; +import com.itmill.toolkit.ui.ComboBox; +import com.itmill.toolkit.ui.InlineDateField; +import com.itmill.toolkit.ui.VerticalLayout; + +public class DateLocaleExample extends VerticalLayout implements + Property.ValueChangeListener { + + private InlineDateField datetime; + private ComboBox localeSelection; + + public DateLocaleExample() { + setSpacing(true); + + datetime = new InlineDateField("Please select the starting time:"); + + // Set the value of the PopupDateField to current date + datetime.setValue(new java.util.Date()); + + // Set the correct resolution + datetime.setResolution(InlineDateField.RESOLUTION_MIN); + datetime.setImmediate(true); + + // Create selection and fill it with locales + localeSelection = new ComboBox("Select date format:"); + localeSelection.addListener(this); + localeSelection.setImmediate(true); + localeSelection + .setContainerDataSource(ExampleUtil.getLocaleContainer()); + + addComponent(datetime); + addComponent(localeSelection); + } + + public void valueChange(ValueChangeEvent event) { + Item selected = localeSelection.getItem(event.getProperty().getValue()); + datetime.setLocale((Locale) selected.getItemProperty( + ExampleUtil.locale_PROPERTY_LOCALE).getValue()); + datetime.requestRepaint(); + } +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopup.java b/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopup.java new file mode 100644 index 0000000000..373f2bfc34 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopup.java @@ -0,0 +1,42 @@ +package com.itmill.toolkit.demo.sampler.features.dates; + +import com.itmill.toolkit.demo.sampler.APIResource; +import com.itmill.toolkit.demo.sampler.Feature; +import com.itmill.toolkit.demo.sampler.NamedExternalResource; +import com.itmill.toolkit.ui.DateField; +import com.itmill.toolkit.ui.PopupDateField; + +public class DatePopup extends Feature { + @Override + public String getName() { + return "Date selection pop-up"; + } + + @Override + public String getDescription() { + return "The DateField component can be used to produce various" + + " date and time input fields with different resolutions." + + " The date and time format used with this component is" + + " reported to the Toolkit by the browser." + + "
In this example, the resolution is set to be one day" + + " and the DateField component is shown as a calendar pop-up."; + } + + @Override + public APIResource[] getRelatedAPI() { + return new APIResource[] { new APIResource(DateField.class), + new APIResource(PopupDateField.class) }; + } + + @Override + public Class[] getRelatedFeatures() { + return new Class[] { DateInline.class, DateLocale.class, + DateResolution.class }; + } + + @Override + public NamedExternalResource[] getRelatedResources() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopup.png b/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopup.png new file mode 100644 index 0000000000000000000000000000000000000000..14af990fe7ff79bc73ba06f4db722d5f2cd872df GIT binary patch literal 2020 zcmb7_c{J3E9>9N%k+F=Clxd88PnHqaxi+9tC0c<-I}{(k3kzUw*P@ArJq_m6L`r-utv3Lymm0MyMD z>%D6e_5=dj)ouIlW$l`M(cUhO0CNyIw;O;%9dHf+&{QD3g%{tA)h@Yu;{f2A4gjQO z0>H*@Doq3cu_gd89|Qo_w*f$rNbmHr0RV}MZdivi34u%WcUKjB6<%)YiYj`pXT!DK z^`6UJND|^C5x5m{v7EO+9F_g4U#>Bt@Qo*y3rDGG_}%k%KTl{!Pc+9&jB5l=Zp&{{TPKVXlt2^DZlO1;xg=n+(VMB^>Z8LtRi{1bJ z5og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q>E|IGT!vcvOQQB2{#P@`tn zWc&wB18bA`Rkd>ui1)|CF04y5EB+Eg>G(V`Kl^k_-K>wi`eY3SCwr7`BCAhFm;HX? zD8X_W^A7qwb4!ZiL_C`=zOxiuoes`qQ4@(VmocU~ZTDW`N{WJ6&s^=VC^=jINsG%0oWwgILH5w?{TbA7^&DF?;`7irShG8_Q0Q2TR+ti#7b(oqp=_|VIbq$-&qb8Q z;B`*gg`y#3{?{VY*H;b@Kn)9DPPUc2Z~ClXy~ijs$FAzmGN-1%Hlox?tXTHnWFG$S c0c&RLr(1u$2^Qbs?Y?2a?W6~m=@^v$Pk#QprT_o{ literal 0 HcmV?d00001 diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopupExample.java b/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopupExample.java new file mode 100644 index 0000000000..46c0163068 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/dates/DatePopupExample.java @@ -0,0 +1,40 @@ +package com.itmill.toolkit.demo.sampler.features.dates; + +import java.text.DateFormat; + +import com.itmill.toolkit.data.Property; +import com.itmill.toolkit.data.Property.ValueChangeEvent; +import com.itmill.toolkit.ui.PopupDateField; +import com.itmill.toolkit.ui.VerticalLayout; + +public class DatePopupExample extends VerticalLayout implements + Property.ValueChangeListener { + + private PopupDateField datetime; + + public DatePopupExample() { + setSpacing(true); + + datetime = new PopupDateField("Please select the starting time:"); + + // Set the value of the PopupDateField to current date + datetime.setValue(new java.util.Date()); + + // Set the correct resolution + datetime.setResolution(PopupDateField.RESOLUTION_DAY); + + // Add valuechangelistener + datetime.addListener(this); + datetime.setImmediate(true); + + addComponent(datetime); + } + + public void valueChange(ValueChangeEvent event) { + // Get the new value and format it to the current locale + DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT); + String dateOut = dateFormatter.format(event.getProperty().getValue()); + // Show notification + getWindow().showNotification("Starting date: " + dateOut); + } +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DateResolution.java b/src/com/itmill/toolkit/demo/sampler/features/dates/DateResolution.java new file mode 100644 index 0000000000..174d1b2326 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/dates/DateResolution.java @@ -0,0 +1,43 @@ +package com.itmill.toolkit.demo.sampler.features.dates; + +import com.itmill.toolkit.demo.sampler.APIResource; +import com.itmill.toolkit.demo.sampler.Feature; +import com.itmill.toolkit.demo.sampler.NamedExternalResource; +import com.itmill.toolkit.ui.DateField; +import com.itmill.toolkit.ui.InlineDateField; + +public class DateResolution extends Feature { + @Override + public String getName() { + return "Date selection - Resolution"; + } + + @Override + public String getDescription() { + return "The DateField component can be used to produce various" + + " date and time input fields with different resolutions." + + " The date and time format used with this component is" + + " reported to the Toolkit by the browser." + + "
In this example, you can select a different resolution" + + " from the combo box and see how the calendar component" + + " will change."; + } + + @Override + public APIResource[] getRelatedAPI() { + return new APIResource[] { new APIResource(DateField.class), + new APIResource(InlineDateField.class) }; + } + + @Override + public Class[] getRelatedFeatures() { + return new Class[] { DateInline.class, DatePopup.class, + DateLocale.class }; + } + + @Override + public NamedExternalResource[] getRelatedResources() { + // TODO Auto-generated method stub + return null; + } +} diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DateResolution.png b/src/com/itmill/toolkit/demo/sampler/features/dates/DateResolution.png new file mode 100644 index 0000000000000000000000000000000000000000..682a211cbdb686b6565821fab071f077336be041 GIT binary patch literal 1728 zcmb7FX;2g97X3m(SOY{rkfoq8EFw}Mf&@y!VuDKm!H5fwB0ESRtU#q8Em(s>P%s!-V#6W^XgbsPqyOIfanG4^XYQG~GiUBC2=pf+ zG)*)C0Ek0=zClXP`m@wkl=yG>tvn?`(t?QIpmoS>PAOoqUL-F7I!d$@XH}KjGSV-I z1i%F=02r46SXZ_f5&$y32H-iL&8gwARwbjIn8+pP<8cka(5 z-}iRz*}qKQnw3_`hEio~YilZDaF{wq3HyxW@Y4+xMlRwKR%mfCN5I)zG?2wFEOpbW zdNLs*Wfy8b zyZ3_BdTeNW&UI#sy=Zt;BAND1gLD+g`)4b#*q`C3U>*38!w2%b`yQFeoXlTg<8tM0o+v)S<>y&+%vT5`g z4ks3?$Ni*I^RDj03nxj1ry@B)m28Rwi!Z5fE7kfNt{*J+vd%C--JIHKTbF-y6fQEK(u*6_FROJN(EkYk+H`SQivSC#hiD-DJ*Z|-{F0_Z||uOc>Ob*uX zowf;G6}RCVT__4uSgNb;h{@#Ziw6xyR_gn4vIB^u#gD>XE(x^`w$9dP$NcEhbwt#= zB`YMGnD?|}Q?AFqz1!u!nPgu&VXJZ6WW>sz0E=gL?@`m!`KrN{vgESLj$kllt~mq$ z#N$L4zWe=Vv>GiYg+EELWJQ_Z#xx-Cql&qR8C>8hlqKRbj4{>TVKzxY^TnPX9ywiK zuEi`|;P#5}yEU+Z@qW_C>6)oAr#9KH{s_Ew)i7F+0WMOh)bw=u`g4){IaET#qP#&dpU zSMoO1s@`+`k&GBO7H9R%rY9x1JDF#Uwc$RT!Zff)1I52 z8UD6Vt*Wf-zJ^MJEkQ?RcAildH?slhYg?!hBIpk!lBti39=@G z?b@1JdDa$Nea@M+7Wzk))I%f|Qr&fOeCG^@<6)6EhKv#z+6UNrqTO8i`eSCIKr&SY zV{H}NqEnZbz$zE$uV`(iX=^MlYfnsl*Ed=o|Bb*;$vc4fO^uhqeF-j<+cOwFGY>?;A<&n6s?A z2Jj)`1YNi!Gm}j8M{qYw#+yI0Uxgb=j1QY~CPE%J-SF@40}oM0ZOLjvnQN@h($ literal 0 HcmV?d00001 diff --git a/src/com/itmill/toolkit/demo/sampler/features/dates/DateResolutionExample.java b/src/com/itmill/toolkit/demo/sampler/features/dates/DateResolutionExample.java new file mode 100644 index 0000000000..54e53b2ac1 --- /dev/null +++ b/src/com/itmill/toolkit/demo/sampler/features/dates/DateResolutionExample.java @@ -0,0 +1,69 @@ +package com.itmill.toolkit.demo.sampler.features.dates; + +import com.itmill.toolkit.data.Item; +import com.itmill.toolkit.data.Property; +import com.itmill.toolkit.data.Property.ValueChangeEvent; +import com.itmill.toolkit.data.util.IndexedContainer; +import com.itmill.toolkit.ui.ComboBox; +import com.itmill.toolkit.ui.InlineDateField; +import com.itmill.toolkit.ui.VerticalLayout; + +public class DateResolutionExample extends VerticalLayout implements + Property.ValueChangeListener { + + public static final Object resolution_PROPERTY_NAME = "name"; + // Resolution fields from DateField + private static final int[] resolutions = { InlineDateField.RESOLUTION_YEAR, + InlineDateField.RESOLUTION_MONTH, InlineDateField.RESOLUTION_DAY, + InlineDateField.RESOLUTION_HOUR, InlineDateField.RESOLUTION_MIN, + InlineDateField.RESOLUTION_SEC, InlineDateField.RESOLUTION_MSEC }; + private static final String[] resolutionNames = { "Year", "Month", "Day", + "Hour", "Minute", "Second", "Millisecond" }; + + private InlineDateField datetime; + private ComboBox localeSelection; + + public DateResolutionExample() { + setSpacing(true); + + datetime = new InlineDateField("Please select the starting time:"); + + // Set the value of the PopupDateField to current date + datetime.setValue(new java.util.Date()); + + // Set the correct resolution + datetime.setResolution(InlineDateField.RESOLUTION_DAY); + datetime.setImmediate(true); + + // Create selection + localeSelection = new ComboBox("Select resolution:"); + localeSelection.setNullSelectionAllowed(false); + localeSelection.addListener(this); + localeSelection.setImmediate(true); + + // Fill the selection with choices, set captions correctly + localeSelection.setContainerDataSource(getResolutionContainer()); + localeSelection.setItemCaptionPropertyId(resolution_PROPERTY_NAME); + localeSelection.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_PROPERTY); + + addComponent(datetime); + addComponent(localeSelection); + } + + public void valueChange(ValueChangeEvent event) { + datetime.setResolution((Integer) event.getProperty().getValue()); + datetime.requestRepaint(); + } + + private IndexedContainer getResolutionContainer() { + IndexedContainer resolutionContainer = new IndexedContainer(); + resolutionContainer.addContainerProperty(resolution_PROPERTY_NAME, + String.class, null); + for (int i = 0; i < resolutions.length; i++) { + Item added = resolutionContainer.addItem(resolutions[i]); + added.getItemProperty(resolution_PROPERTY_NAME).setValue( + resolutionNames[i]); + } + return resolutionContainer; + } +} -- 2.39.5