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.CountryEditor;
017: import br.com.igor.beans.LanguageEditor;
018:
019: import com.l2fprod.common.beans.editor.AbstractPropertyEditor;
020:
021: /**
022: * Date Property Editor based on <a href="http://sf.net/projects/gfd">GFP ICalendarChooser </a> component.
023: * <br>
024: */
025: public class CountryPropertyEditor extends AbstractPropertyEditor {
026:
027: /**
028: * Constructor for JCalendarDatePropertyEditor
029: */
030: public CountryPropertyEditor() {
031: editor = new CountryEditor();
032: }
033:
034: /**
035: * Constructor for JCalendarDatePropertyEditor
036: *
037: * @param dateFormatString string used to format the Date object, see: <b>java.text.SimpleDateFormat </b>
038: * @param locale Locale used to display the Date object
039: */
040: public CountryPropertyEditor(String dateFormatString, Locale locale) {
041: editor = new CountryEditor();
042: ((CountryEditor) editor).setLocale(locale);
043: }
044:
045: /**
046: * Constructor for JCalendarDatePropertyEditor
047: *
048: * @param locale Locale used to display the Date object
049: */
050: public CountryPropertyEditor(Locale locale) {
051: editor = new LanguageEditor();
052: ((CountryEditor) editor).setLocale(locale);
053: }
054:
055: /**
056: * Returns the Date of the Calendar
057: *
058: * @return the date choosed as a <b>java.util.Date </b>b> object or null is the date is not set
059: */
060: @Override
061: public Object getValue() {
062: return ((CountryEditor) editor).getSelectedItem();
063: }
064:
065: /**
066: * Sets the Date of the Calendar
067: *
068: * @param value the Date object
069: */
070: @Override
071: public void setValue(Object value) {
072: if (value != null && value instanceof String) {
073: ((CountryEditor) editor).setSelectedItem(value);
074: }
075: }
076:
077: /**
078: * Returns the Date formated with the locale and formatString set.
079: *
080: * @return the choosen Date as String
081: */
082: @Override
083: public String getAsText() {
084: return ((CountryEditor) editor).getSelectedItem().toString();
085: }
086:
087: /**
088: * Sets the locale.
089: *
090: * @param l The new locale value
091: */
092: public void setLocale(Locale l) {
093: ((CountryEditor) editor).setLocale(l);
094: }
095:
096: /**
097: * Returns the Locale used.
098: *
099: * @return the Locale object
100: */
101: public Locale getLocale() {
102: return ((CountryEditor) editor).getLocale();
103: }
104:
105: }
|