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.gfpshare.beans.property.editor;
013:
014: import java.util.Locale;
015:
016: import javax.swing.JSpinner;
017: import javax.swing.SpinnerNumberModel;
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 ProxyPortPropertyEditor extends AbstractPropertyEditor {
026:
027: /**
028: * Constructor for JCalendarDatePropertyEditor
029: */
030: public ProxyPortPropertyEditor() {
031: editor = new JSpinner();
032: ((JSpinner) editor).setModel(new SpinnerNumberModel(80, 1,
033: 99999, 1));
034: }
035:
036: /**
037: * Constructor for JCalendarDatePropertyEditor
038: *
039: * @param locale Locale used to display the Date object
040: */
041: public ProxyPortPropertyEditor(Integer value) {
042: this ();
043: if (value < 1)
044: value = 1;
045: ((JSpinner) editor).setValue(value);
046: }
047:
048: /**
049: * Returns the Date of the Calendar
050: *
051: * @return the date choosed as a <b>java.util.Date </b>b> object or null is the date is not set
052: */
053: @Override
054: public Object getValue() {
055: return ((JSpinner) editor).getValue();
056: }
057:
058: /**
059: * Sets the Date of the Calendar
060: *
061: * @param value the Date object
062: */
063: @Override
064: public void setValue(Object value) {
065: if (value != null && value instanceof Integer) {
066: if ((Integer) value < 1)
067: value = 1;
068: ((JSpinner) editor).setValue(value);
069: }
070: }
071:
072: /**
073: * Returns the Date formated with the locale and formatString set.
074: *
075: * @return the choosen Date as String
076: */
077: @Override
078: public String getAsText() {
079: return ((JSpinner) editor).getValue().toString();
080: }
081:
082: /**
083: * Sets the locale.
084: *
085: * @param l The new locale value
086: */
087: public void setLocale(Locale l) {
088: ((JSpinner) editor).setLocale(l);
089: }
090:
091: /**
092: * Returns the Locale used.
093: *
094: * @return the Locale object
095: */
096: public Locale getLocale() {
097: return ((JSpinner) editor).getLocale();
098: }
099:
100: }
|