001: /* *************************************************************************
002:
003: Millstone(TM)
004: Open Sourced User Interface Library for
005: Internet Development with Java
006:
007: Millstone is a registered trademark of IT Mill Ltd
008: Copyright (C) 2000-2005 IT Mill Ltd
009:
010: *************************************************************************
011:
012: This library is free software; you can redistribute it and/or
013: modify it under the terms of the GNU Lesser General Public
014: license version 2.1 as published by the Free Software Foundation.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: *************************************************************************
026:
027: For more information, contact:
028:
029: IT Mill Ltd phone: +358 2 4802 7180
030: Ruukinkatu 2-4 fax: +358 2 4802 7181
031: 20540, Turku email: info@itmill.com
032: Finland company www: www.itmill.com
033:
034: Primary source for MillStone information and releases: www.millstone.org
035:
036: ********************************************************************** */
037:
038: package org.millstone.examples.features;
039:
040: import java.util.Locale;
041:
042: import org.millstone.base.data.util.IndexedContainer;
043: import org.millstone.base.data.util.MethodProperty;
044: import org.millstone.base.ui.*;
045:
046: public class FeatureDateField extends Feature {
047:
048: static private IndexedContainer localeContainer;
049: static {
050: localeContainer = new IndexedContainer();
051: localeContainer.addContainerProperty("name", String.class, "");
052: Locale[] locales = Locale.getAvailableLocales();
053: for (int i = 0; i < locales.length; i++)
054: localeContainer.addItem(locales[i]).getItemProperty("name")
055: .setValue(locales[i].getDisplayName());
056: }
057:
058: public FeatureDateField() {
059: super ();
060: }
061:
062: protected Component getDemoComponent() {
063:
064: OrderedLayout l = new OrderedLayout();
065:
066: // Example panel
067: Panel show = new Panel("DateField component");
068: DateField df = new DateField("Caption");
069: df.setValue(new java.util.Date());
070: show.addComponent(df);
071: l.addComponent(show);
072:
073: // Create locale selector
074: Select selector = new Select("Application Locale",
075: localeContainer);
076: selector.setItemCaptionPropertyId("name");
077: selector.setImmediate(true);
078: selector.setPropertyDataSource(new MethodProperty(this
079: .getApplication(), "locale"));
080: l.addComponent(selector);
081:
082: // Properties
083: PropertyPanel p = new PropertyPanel(df);
084: Form ap = p
085: .createBeanPropertySet(new String[] { "resolution" });
086: ap.replaceWithSelect("resolution", new Object[] {
087: new Integer(DateField.RESOLUTION_YEAR),
088: new Integer(DateField.RESOLUTION_MONTH),
089: new Integer(DateField.RESOLUTION_DAY),
090: new Integer(DateField.RESOLUTION_HOUR),
091: new Integer(DateField.RESOLUTION_MIN),
092: new Integer(DateField.RESOLUTION_SEC),
093: new Integer(DateField.RESOLUTION_MSEC) }, new Object[] {
094: "Year", "Month", "Day", "Hour", "Minute", "Second",
095: "Millisecond" });
096: Select themes = (Select) p.getField("style");
097: themes.addItem("text").getItemProperty(
098: themes.getItemCaptionPropertyId()).setValue("text");
099: themes.addItem("calendar").getItemProperty(
100: themes.getItemCaptionPropertyId()).setValue("calendar");
101: p.addProperties("DateField Properties", ap);
102: l.addComponent(p);
103:
104: return l;
105: }
106:
107: protected String getExampleSrc() {
108: return "DateField df = new DateField(\"Caption\");\n"
109: + "df.setValue(new java.util.Date());\n";
110:
111: }
112:
113: protected String getDescriptionXHTML() {
114: return "<p>Representing Dates and times and providing a way to select "
115: + "or enter some specific date and/or time is an typical need in "
116: + "data-entry userinterfaces. Millstone provides a DateField "
117: + "component that is intuitive to use and yet controllable through "
118: + "its properties.</p>"
119: + "<p>The calendar-style allows point-and-click selection "
120: + "of dates while text-style shows only minimalistic user interface."
121: + "Validators may be bound to the component to check and "
122: + "validate the given input.</p>"
123: + "<p>On the demo tab you can try out how the different properties affect the "
124: + "presentation of the component.</p>";
125: }
126:
127: protected String getImage() {
128: return "datefield.jpg";
129: }
130:
131: protected String getTitle() {
132: return "DateField";
133: }
134:
135: }
|