001: /*
002: * Created on 04/01/2005 Swing Components - visit http://sf.net/projects/gfd
003: * Copyright (C) 2004 Igor Regis da Silva Simões This program is free software;
004: * you can redistribute it and/or modify it under the terms of the GNU General
005: * Public License as published by the Free Software Foundation; either version 2
006: * of the License, or (at your option) any later version. This program is
007: * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
008: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
009: * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
010: * should have received a copy of the GNU General Public License along with this
011: * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place -
012: * Suite 330, Boston, MA 02111-1307, USA.
013: */
014: package br.com.igor.beans.property.editor;
015:
016: import java.util.Date;
017: import java.util.Locale;
018:
019: import br.com.igor.beans.ZCalendarTextField;
020:
021: import com.l2fprod.common.beans.editor.AbstractPropertyEditor;
022:
023: /**
024: * Date Property Editor based on <a href="http://sf.net/projects/gfd">GFP
025: * ICalendarChooser </a> component. <br>
026: */
027: public class ICalendarDatePropertyEditor extends AbstractPropertyEditor {
028:
029: /**
030: * Constructor for JCalendarDatePropertyEditor
031: */
032: public ICalendarDatePropertyEditor() {
033: editor = new ZCalendarTextField();
034: }
035:
036: /**
037: * Constructor for JCalendarDatePropertyEditor
038: *
039: * @param dateFormatString
040: * string used to format the Date object, see:
041: * <b>java.text.SimpleDateFormat </b>
042: * @param locale
043: * Locale used to display the Date object
044: */
045: public ICalendarDatePropertyEditor(String dateFormatString,
046: Locale locale) {
047: editor = new ZCalendarTextField();
048: ((ZCalendarTextField) editor).setLocale(locale);
049: }
050:
051: /**
052: * Constructor for JCalendarDatePropertyEditor
053: *
054: * @param locale
055: * Locale used to display the Date object
056: */
057: public ICalendarDatePropertyEditor(Locale locale) {
058: editor = new ZCalendarTextField();
059: ((ZCalendarTextField) editor).setLocale(locale);
060: }
061:
062: /**
063: * Returns the Date of the Calendar
064: *
065: * @return the date choosed as a <b>java.util.Date </b>b> object or null is
066: * the date is not set
067: */
068: @Override
069: public Object getValue() {
070: return ((ZCalendarTextField) editor).getDate();
071: }
072:
073: /**
074: * Sets the Date of the Calendar
075: *
076: * @param value
077: * the Date object
078: */
079: @Override
080: public void setValue(Object value) {
081: if (value != null) {
082: ((ZCalendarTextField) editor).setDate((Date) value);
083: }
084: }
085:
086: /**
087: * Returns the Date formated with the locale and formatString set.
088: *
089: * @return the choosen Date as String
090: */
091: @Override
092: public String getAsText() {
093: return ((ZCalendarTextField) editor).getText();
094: }
095:
096: /**
097: * Sets the locale.
098: *
099: * @param l
100: * The new locale value
101: */
102: public void setLocale(Locale l) {
103: ((ZCalendarTextField) editor).setLocale(l);
104: }
105:
106: /**
107: * Returns the Locale used.
108: *
109: * @return the Locale object
110: */
111: public Locale getLocale() {
112: return ((ZCalendarTextField) editor).getLocale();
113: }
114:
115: }
|