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