001    package net.sourceforge.mp3dings.utils;
002    
003    /*
004     *  Mp3dings - manage mp3 meta-information
005     *  Copyright (C) 2003 Moritz Ringler
006     *  $Id: AbstractBeanCustomizer.java,v 1.16 2007/03/29 16:03:02 ringler Exp $
007     *
008     *  This program is free software; you can redistribute it and/or
009     *  modify it under the terms of the GNU General Public License
010     *  as published by the Free Software Foundation; either version 2
011     *  of the License, or (at your option) any later version.
012     *
013     *  This program is distributed in the hope that it will be useful,
014     *  but WITHOUT ANY WARRANTY; without even the implied warranty of
015     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016     *  GNU General Public License for more details.
017     *
018     *  You should have received a copy of the GNU General Public License
019     *  along with this program; if not, write to the Free Software
020     *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021     */
022    import java.awt.Component;
023    import java.awt.event.ActionEvent;
024    import java.awt.event.ActionListener;
025    import java.awt.event.ItemEvent;
026    import java.awt.event.ItemListener;
027    import java.beans.IntrospectionException;
028    import java.beans.PropertyChangeEvent;
029    import java.beans.PropertyChangeListener;
030    import java.beans.PropertyDescriptor;
031    import java.lang.reflect.InvocationTargetException;
032    import java.lang.reflect.Method;
033    import java.util.HashMap;
034    import java.util.Map;
035    import java.util.logging.Logger;
036    import javax.swing.JButton;
037    import javax.swing.JCheckBox;
038    import javax.swing.JComboBox;
039    import javax.swing.JSpinner;
040    import javax.swing.JTextArea;
041    import javax.swing.JTextField;
042    import javax.swing.JComponent;
043    import javax.swing.SpinnerModel;
044    import javax.swing.SpinnerNumberModel;
045    import javax.swing.event.ChangeEvent;
046    import javax.swing.event.ChangeListener;
047    import javax.swing.event.DocumentEvent;
048    import javax.swing.event.DocumentListener;
049    import javax.swing.text.AttributeSet;
050    import javax.swing.text.BadLocationException;
051    import javax.swing.text.Document;
052    import javax.swing.text.PlainDocument;
053    import de.mospace.swing.text.GeneralInputVerifier;
054    
055    /**
056     *  A filter that accepts or rejects a numeric value depending on whether this
057     *  value is inside or outside a given numeric range.
058     *
059     *@author     Moritz Ringler
060     *@version    $Revision: 1.16 $ ($Date: 2007/03/29 16:03:02 $)
061     */
062    public abstract class AbstractBeanCustomizer extends Bean {
063        private static final Logger logger = Logger.getLogger(AbstractBeanCustomizer.class.getPackage().getName());
064        /**  Description of the Field */
065        protected Bean bean;
066        protected BeanUpdater beanUpdater;
067        private EditorUpdater editorUpdater;
068        protected final static String VALUE = "value";
069    
070        //private HashMap<String, Component>
071        protected Map editors = new HashMap();
072    
073    
074        /**
075         *  Constructs a new AbstractBeanCustomizer.
076         *
077         *@param  model  Description of the Parameter
078         */
079        public AbstractBeanCustomizer(Bean model) {
080            this.bean = model;
081            beanUpdater = new BeanUpdater();
082            editorUpdater = new EditorUpdater();
083            bean.addPropertyChangeListener(editorUpdater);
084        }
085    
086    
087        /**
088         *  Gets the propertyEditor attribute of the AbstractBeanCustomizer object
089         *
090         *@param  property     Description of the Parameter
091         *@param  constraints  Description of the Parameter
092         *@return              The propertyEditor value
093         */
094        protected Component getPropertyEditor(String property, final Object constraints[]) {
095            return getPropertyEditor(property, false, constraints);
096        }
097    
098    
099        /**
100         *  Gets the editor attribute of the AbstractBeanCustomizer object
101         *
102         *@param  strval       Description of the Parameter
103         *@param  constr  Description of the Parameter
104         *@return              The editor value
105         */
106        private Component getEditor(String strval, Object[] constr) {
107            JComponent result = null;
108            if (constr == null) {
109                result = new TextControl(strval);
110            } else if (constr.length == 2 &&
111                    constr[0] instanceof Integer &&
112                    constr[1] instanceof Integer) {
113                result = new LongTextControl(
114                        strval,
115                        ((Integer) constr[0]).intValue(),
116                        ((Integer) constr[1]).intValue());
117            } else if (constr instanceof String[]){
118                result = new ComboControl(strval, (String[]) constr);
119            } else if(constr.length == 1 && constr[0] instanceof Class){
120                result = new TextControl(strval);
121                result.setInputVerifier(
122                        new GeneralInputVerifier((Class) constr[0]));
123            } else if(constr.length == 3 &&
124                   constr[0] instanceof Class &&
125                   constr[1] instanceof Comparable &&
126                   constr[2] instanceof Comparable){
127                result.setInputVerifier(new GeneralInputVerifier(
128                        (Class) constr[0],
129                        (Comparable) constr[1],
130                        (Comparable) constr[2]));
131            } else {
132                throw new IllegalArgumentException("Don't know how to handle constraints.");
133            }
134            return result;
135        }
136    
137    
138        /**
139         *  Gets the editor attribute of the AbstractBeanCustomizer object
140         *
141         *@param  intval       Description of the Parameter
142         *@param  constr  Description of the Parameter
143         *@return              The editor value
144         */
145        private Component getEditor(Integer intval, Object[] constr) {
146            SpinnerNumberModel model = (constr == null || constr.length != 3)
147                     ? new SpinnerNumberModel(intval,
148                    new Integer(Integer.MIN_VALUE),
149                    new Integer(Integer.MAX_VALUE),
150                    new Integer(1))
151                     : new SpinnerNumberModel(intval,
152                    (Integer) constr[0],
153                    (Integer) constr[1],
154                    (Integer) constr[2]);
155            return new Spinner(model);
156        }
157    
158    
159        /**
160         *  Gets the editor attribute of the AbstractBeanCustomizer object
161         *
162         *@param  value        Description of the Parameter
163         *@param  constr  Description of the Parameter
164         *@return              The editor value
165         */
166        private Component getEditor(Double value, Object[] constr) {
167            Double doubval = (Double) value;
168            SpinnerNumberModel model =
169                    (constr == null || constr.length != 3)
170                     ? new SpinnerNumberModel(doubval,
171                    new Double(java.lang.Double.NEGATIVE_INFINITY),
172                    new Double(java.lang.Double.POSITIVE_INFINITY),
173                    new Double(1))
174                     : new SpinnerNumberModel(doubval,
175                    (Double) constr[0],
176                    (Double) constr[1],
177                    (Double) constr[2]);
178            return new Spinner(model);
179        }
180    
181    
182        /**
183         *  Gets the editor attribute of the AbstractBeanCustomizer object
184         *
185         *@param  value        Description of the Parameter
186         *@param  constr  Description of the Parameter
187         *@return              The editor value
188         */
189        private Component getEditor(Boolean value, Object[] constr) {
190            Component result = null;
191            boolean boolval = value.booleanValue();
192            if (constr != null &&
193                    constr.length == 2 &&
194                    constr[0] instanceof String &&
195                    constr[1] instanceof String) {
196                result = new BooleanButton(
197                        boolval,
198                        (String) constr[0],
199                        (String) constr[1]);
200            } else if (constr != null &&
201                    constr.length == 1 &&
202                    constr[0] instanceof String) {
203                result = new BooleanBox(
204                        (String) constr[0], boolval);
205            }
206            return result;
207        }
208    
209        private Component getEditor(Long value, Object[] constr){
210            return new LongControl(value.longValue());
211        }
212    
213    
214        /**
215         *  Gets the editor attribute of the AbstractBeanCustomizer object
216         *
217         *@param  o            Description of the Parameter
218         *@param  constr  Description of the Parameter
219         *@return              The editor value
220         */
221        private Component getEditor(Object o, Object[] constr) {
222            Component result = null;
223            if (o instanceof String) {
224                result = getEditor((String) o, constr);
225            } else if (o instanceof Integer) {
226                result = getEditor((Integer) o, constr);
227            } else if (o instanceof Double) {
228                result = getEditor((Double) o, constr);
229            } else if (o instanceof Boolean) {
230                result = getEditor((Boolean) o, constr);
231            } else if (o instanceof Long){
232                result = getEditor((Long) o, constr);
233            }
234            return result;
235        }
236    
237    
238        /**
239         *@param  property     Description of the Parameter
240         *@param  readOnly     Description of the Parameter
241         *@param  constraints  Description of the Parameter
242         *@return              null if the editor could not be created
243         */
244        protected Component getPropertyEditor(String property, boolean readOnly, final Object constraints[]) {
245            Component result = null;
246            if (editors.containsKey(property)) {
247                result = (Component) editors.get(property);
248    
249            } else {
250                Object value = getBeanPropertyValue(property);
251                result = getEditor(value, constraints);
252                if (result != null && !readOnly && result instanceof PropEditor) {
253                    ((PropEditor) result).addPropertyChangeListener(VALUE, beanUpdater);
254                }
255                editors.put(property, result);
256            }
257            return result;
258        }
259    
260    
261        /**
262         *  Gets the beanPropertyValue attribute of the AbstractBeanCustomizer
263         *  object
264         *
265         *@param  property  Description of the Parameter
266         *@return           The beanPropertyValue value
267         */
268        private Object getBeanPropertyValue(String property) {
269            String prop = Character.toUpperCase(property.charAt(0)) + property.substring(1);
270            String readMethodName1 = "get" + prop;
271            String readMethodName2 = "is" + prop;
272            Class beanClass = bean.getClass();
273            Class[] empty = new Class[]{};
274            Method getter = null;
275    
276            try {
277                try {
278                    getter = beanClass.getMethod(readMethodName1, empty);
279                } catch (NoSuchMethodException e) {
280                    getter = beanClass.getMethod(readMethodName2, empty);
281                }
282            } catch (NoSuchMethodException nsme) {
283                logger.severe(nsme.toString());
284                getter = null;
285            }
286    
287            Object value = null;
288            if (getter != null) {
289                try {
290                    value = getter.invoke(bean, empty);
291                } catch (IllegalAccessException iae) {
292                    logger.severe(iae.toString());
293                } catch (InvocationTargetException ite) {
294                    logger.severe(ite.toString());
295                }
296            }
297            return value;
298        }
299    
300    
301        /**
302         *  Gets the model attribute of the AbstractBeanCustomizer object
303         *
304         *@return    The model value
305         */
306        public Bean getModel() {
307            return bean;
308        }
309    
310    
311        /**
312         *@param  model                      The new model value
313         *@throws  NullPointerException      if model is <code>null</code>
314         *@throws  IllegalArgumentException  if the new model's class is not the
315         *      same as or a subclass of the old model's.
316         */
317        protected void setModel(Bean model) {
318            if(bean == model){
319                return;
320            }
321            if (bean.getClass().isAssignableFrom(model.getClass())) {
322                bean.removePropertyChangeListener(editorUpdater);
323                Bean old = bean;
324                bean = model;
325                bean.addPropertyChangeListener(editorUpdater);
326                updateEditorsFromBean();
327                firePropertyChange("model", old, bean);
328            } else {
329                throw new IllegalArgumentException("Model is not of the right type.");
330            }
331        }
332    
333    
334        /**  Description of the Method */
335        private void updateEditorsFromBean() {
336            Object[] properties = editors.keySet().toArray();
337            String p;
338            for (int i = 0; i < properties.length; i++) {
339                p = (String) properties[i];
340                Object val = getBeanPropertyValue(p);
341                bean.firePropertyChange(p, null, val);
342            }
343        }
344    
345    
346        /**
347         *  Gets the uI attribute of the AbstractBeanCustomizer object
348         *
349         *@return    The uI value
350         */
351        public abstract Component getUI();
352    
353    
354        /**
355         *  The PropertyChangeListener that listens to changes in the editors and
356         *  updates the bean.
357         *
358         *@author    ringler
359         */
360        private class BeanUpdater implements PropertyChangeListener {
361            /**  Constructs a new BeanUpdater. */
362            public BeanUpdater() { }
363    
364    
365            /**
366             *  Description of the Method
367             *
368             *@param  e  Description of the Parameter
369             */
370            public void propertyChange(PropertyChangeEvent e) {
371                /*
372                 *  Do nothing if the value hasn't changed
373                 */
374                if (!e.getNewValue().equals(e.getOldValue())) {
375                    Method setter = findSetter(e.getSource());
376                    if (setter != null) {
377                        /*
378                         *  Invoke the setter method
379                         */
380                        Object[] objarg = new Object[]{e.getNewValue()};
381                        try {
382                            setter.invoke(bean, objarg);
383                        } catch (IllegalAccessException iae) {
384                            logger.severe(iae.toString());
385                        } catch (InvocationTargetException ite) {
386                            logger.severe(ite.toString());
387                        }
388                    }
389                }
390            }
391    
392    
393            /**
394             *  Finds the property for which the given object is registered as an
395             *  editor. *
396             *
397             *@param  eventSource  Description of the Parameter
398             *@return              Description of the Return Value
399             */
400            private String findProperty(Object eventSource) {
401                /*
402                 *  See if the event source is one of our editor components
403                 *  and get the property of the bean that we need to
404                 *  change.
405                 */
406                String property = null;
407                Object[] properties = editors.keySet().toArray();
408                for (int i = 0; i < properties.length; i++) {
409                    if (editors.get(properties[i]) == eventSource) {
410                        property = properties[i].toString();
411                    }
412                }
413                return property;
414            }
415    
416    
417            /**
418             *  Finds the method that sets the given property of the bean. *
419             *
420             *@param  property  Description of the Parameter
421             *@return           Description of the Return Value
422             */
423            private Method findSetter(String property) {
424                /*
425                 *  Find the appropriate setter method for this bean property
426                 */
427                PropertyDescriptor pd = null;
428                try {
429                    pd = new PropertyDescriptor(property, bean.getClass());
430                } catch (IntrospectionException ie) {
431                    logger.severe(ie.toString());
432                    pd = null;
433                }
434                return ((pd == null) ? null : pd.getWriteMethod());
435            }
436    
437    
438            /**
439             *  Finds the method that sets the property of the bean that is edited
440             *  by the given object. *
441             *
442             *@param  eventSource  Description of the Parameter
443             *@return              Description of the Return Value
444             */
445            private Method findSetter(Object eventSource) {
446                String property = findProperty(eventSource);
447                return (property == null) ? null : findSetter(property);
448            }
449    
450        }
451        //End of BeanUpdater class
452    
453    
454        /**
455         *  The PropertyChangeListener that listens to changes in the bean and
456         *  updates the property editors.
457         *
458         *@author    ringler
459         */
460        private class EditorUpdater implements PropertyChangeListener {
461            /**  Constructs a new EditorUpdater. */
462            public EditorUpdater() { }
463    
464    
465            /**
466             *  Description of the Method
467             *
468             *@param  e  Description of the Parameter
469             */
470            public void propertyChange(PropertyChangeEvent e) {
471                String property = e.getPropertyName();
472                Component editor = (Component) editors.get(property);
473                if (editor == null) {
474                    return;
475                }
476                if (editor instanceof PropEditor) {
477                    PropEditor pedit = (PropEditor) editor;
478                    if (!e.getNewValue().equals(pedit.getValue())) {
479                        pedit.setValue(e.getNewValue());
480                    }
481                }
482            }
483        }
484        //End of PropEditor Interface
485    
486    
487        /**
488         *  A toggle button for editing boolean values. *
489         *
490         *@author    ringler
491         */
492        private static class BooleanButton extends JButton implements PropEditor {
493            private final String ttrue;
494            private final String tfalse;
495    
496    
497            /**
498             *  Constructs a new BooleanButton.
499             *
500             *@param  initialState  Description of the Parameter
501             *@param  textTrue      Description of the Parameter
502             *@param  textFalse     Description of the Parameter
503             */
504            public BooleanButton(boolean initialState, String textTrue, String textFalse) {
505                super(initialState ? textTrue : textFalse);
506                ttrue = textTrue;
507                tfalse = textFalse;
508                addActionListener(
509                    new ActionListener() {
510                        public void actionPerformed(ActionEvent e) {
511                            setValue(!getBooleanValue());
512                        }
513                    });
514            }
515    
516    
517            /**
518             *  Gets the booleanValue attribute of the BooleanButton object
519             *
520             *@return    The booleanValue value
521             */
522            public boolean getBooleanValue() {
523                return ((Boolean) getValue()).booleanValue();
524            }
525    
526    
527            /**
528             *  Sets the value attribute of the BooleanButton object
529             *
530             *@param  val  The new value value
531             */
532            public void setValue(Object val) {
533                if (!(val instanceof Boolean)) {
534                    throw new IllegalArgumentException("Argument must be a Boolean.");
535                }
536                setValue(((Boolean) val).booleanValue());
537            }
538    
539    
540            /**
541             *  Sets the value attribute of the BooleanButton object
542             *
543             *@param  val  The new value value
544             */
545            public void setValue(boolean val) {
546                /*
547                 *  update only if necessary
548                 */
549                if (val != getBooleanValue()) {
550                    super.setText(val ? ttrue : tfalse);
551                    firePropertyChange(VALUE, !val, val);
552                }
553            }
554    
555    
556            /**
557             *  Gets the value attribute of the BooleanButton object
558             *
559             *@return    The value value
560             */
561            public Object getValue() {
562                return getText().equals(ttrue) ? Boolean.TRUE : Boolean.FALSE;
563            }
564        }
565        //End of BooleanButton class
566    
567    
568        /**
569         *  A toggle button for editing boolean values. *
570         *
571         *@author    ringler
572         */
573        private static class BooleanBox extends JCheckBox implements ItemListener, PropEditor {
574            /**
575             *  Constructs a new BooleanBox.
576             *
577             *@param  label         Description of the Parameter
578             *@param  initialState  Description of the Parameter
579             */
580            public BooleanBox(String label, boolean initialState) {
581                super(label, initialState);
582                addItemListener(this);
583            }
584    
585    
586            /**
587             *  Description of the Method
588             *
589             *@param  e  Description of the Parameter
590             */
591            public void itemStateChanged(ItemEvent e) {
592                BooleanBox bb = (BooleanBox) e.getItemSelectable();
593                boolean b = bb.isSelected();
594                bb.firePropertyChange(VALUE, !b, b);
595            }
596    
597    
598            /**
599             *  Gets the value attribute of the BooleanBox object
600             *
601             *@return    The value value
602             */
603            public Object getValue() {
604                return Boolean.valueOf(isSelected());
605            }
606    
607    
608            /**
609             *  Sets the value attribute of the BooleanBox object
610             *
611             *@param  bool  The new value value
612             */
613            public void setValue(Object bool) {
614                if (!(bool instanceof Boolean)) {
615                    throw new IllegalArgumentException("Argument must be a Boolean.");
616                }
617                setSelected(((Boolean) bool).booleanValue());
618            }
619        }
620        //End of BooleanButton class
621    
622        private static class ComboControl extends JComboBox implements ActionListener, PropEditor {
623            private String oldValue = null;
624    
625            public ComboControl(String initialSelection, String[] selectableItems){
626                super(selectableItems);
627                setSelectedItem(initialSelection);
628                oldValue = initialSelection;
629                setEditable(false);
630                addActionListener(this);
631            }
632    
633            public void actionPerformed(ActionEvent e){
634                firepropchange();
635            }
636    
637            /**  Description of the Method */
638            private void firepropchange() {
639                firePropertyChange(VALUE, oldValue, getValue());
640                oldValue = (String) getValue();
641            }
642    
643            public Object getValue(){
644                return getSelectedItem();
645            }
646    
647            public void setValue(Object o){
648                setSelectedItem(o);
649            }
650        }
651    
652        /**
653         *  Description of the Class
654         *
655         *@author    ringler
656         */
657        static class TextControl extends JTextField implements DocumentListener, PropEditor {
658            private String oldText;
659    
660    
661            /**
662             *  Constructs a new TextControl.
663             *
664             *@param  s  Description of the Parameter
665             */
666            public TextControl(String s) {
667                super(s);
668                oldText = s;
669                getDocument().addDocumentListener(this);
670            }
671    
672    
673            /**
674             *  Description of the Method
675             *
676             *@param  e  Description of the Parameter
677             */
678            public void insertUpdate(DocumentEvent e) {
679                firepropchange();
680            }
681    
682    
683            /**
684             *  Description of the Method
685             *
686             *@param  e  Description of the Parameter
687             */
688            public void removeUpdate(DocumentEvent e) {
689                firepropchange();
690            }
691    
692    
693            /**
694             *  Description of the Method
695             *
696             *@param  e  Description of the Parameter
697             */
698            public void changedUpdate(DocumentEvent e) {
699                firepropchange();
700            }
701    
702    
703            /**  Description of the Method */
704            private void firepropchange() {
705                if(getInputVerifier() == null || getInputVerifier().verify(this)){
706                    firePropertyChange(VALUE, oldText, getText());
707                }
708                oldText = getText();
709            }
710    
711    
712            /**
713             *  Gets the value attribute of the TextControl object
714             *
715             *@return    The value value
716             */
717            public Object getValue() {
718                return getText();
719            }
720    
721    
722            /**
723             *  Sets the value attribute of the TextControl object
724             *
725             *@param  o  The new value value
726             */
727            public void setValue(Object o) {
728                setText(String.valueOf(o));
729            }
730        }
731        //End of TextControl class
732    
733        /**
734         *  Description of the Class
735         *
736         *@author    ringler
737         */
738        static class LongControl extends JTextField implements DocumentListener, PropEditor {
739            private long oldVal;
740    
741            /**
742             *  Constructs a new TextControl.
743             *
744             *@param  s  Description of the Parameter
745             */
746            public LongControl(long l) {
747                super(Math.max(String.valueOf(l).length(), 10));
748                setText(String.valueOf(l));
749                oldVal = l;
750                getDocument().addDocumentListener(this);
751            }
752    
753            protected Document createDefaultModel() {
754                return new DigitOnlyDocument();
755            }
756    
757            //a model that allows only digits.
758            private static class DigitOnlyDocument extends PlainDocument{
759                public void insertString(int offs, String str, AttributeSet a)
760                throws BadLocationException {
761    
762                    if (str == null) {
763                        return;
764                    }
765                    StringBuffer sb = new StringBuffer();
766                    for (int i = 0, len = str.length(); i < len; i++) {
767                        char c = str.charAt(i);
768                        if(Character.isDigit(c)){
769                            sb.append(c);
770                        }
771                    }
772                    super.insertString(offs, sb.toString(), a);
773                }
774            }
775    
776    
777            /**
778             *  Description of the Method
779             *
780             *@param  e  Description of the Parameter
781             */
782            public void insertUpdate(DocumentEvent e) {
783                firepropchange();
784            }
785    
786    
787            /**
788             *  Description of the Method
789             *
790             *@param  e  Description of the Parameter
791             */
792            public void removeUpdate(DocumentEvent e) {
793                firepropchange();
794            }
795    
796    
797            /**
798             *  Description of the Method
799             *
800             *@param  e  Description of the Parameter
801             */
802            public void changedUpdate(DocumentEvent e) {
803                firepropchange();
804            }
805    
806    
807            /**  Description of the Method */
808            private void firepropchange() {
809                long newVal = getLong().longValue();
810                if(newVal != oldVal){
811                    firePropertyChange(VALUE, oldVal, newVal);
812                    oldVal = newVal;
813                }
814            }
815    
816            private Long getLong(){
817                Long result = new Long(0l);
818                String newText = getText();
819                if(newText.length() > 0){
820                    try{
821                        result = Long.valueOf(newText);
822                    } catch (Exception ex){
823                        throw new RuntimeException(ex);
824                    }
825                }
826                return result;
827            }
828    
829            public Object getValue() {
830                return getLong();
831            }
832    
833    
834            public void setValue(Object o) {
835                Long l = (Long) o;
836                setText(String.valueOf(l));
837            }
838        }
839        //End of LongControl class
840    
841    
842        /**
843         *  Description of the Class
844         *
845         *@author    ringler
846         */
847        private static class LongTextControl extends JTextArea implements DocumentListener, PropEditor {
848            private String oldText;
849    
850    
851            /**
852             *  Constructs a new LongTextControl.
853             *
854             *@param  s     Description of the Parameter
855             *@param  rows  Description of the Parameter
856             *@param  cols  Description of the Parameter
857             */
858            public LongTextControl(String s, int rows, int cols) {
859                super(s, rows, cols);
860                oldText = s;
861                getDocument().addDocumentListener(this);
862            }
863    
864    
865            /**
866             *  Description of the Method
867             *
868             *@param  e  Description of the Parameter
869             */
870            public void insertUpdate(DocumentEvent e) {
871                firepropchange();
872            }
873    
874    
875            /**
876             *  Description of the Method
877             *
878             *@param  e  Description of the Parameter
879             */
880            public void removeUpdate(DocumentEvent e) {
881                firepropchange();
882            }
883    
884    
885            /**
886             *  Description of the Method
887             *
888             *@param  e  Description of the Parameter
889             */
890            public void changedUpdate(DocumentEvent e) {
891                firepropchange();
892            }
893    
894    
895            /**  Description of the Method */
896            private void firepropchange() {
897                firePropertyChange(VALUE, oldText, getText());
898                oldText = getText();
899            }
900    
901    
902            /**
903             *  Gets the value attribute of the LongTextControl object
904             *
905             *@return    The value value
906             */
907            public Object getValue() {
908                return getText();
909            }
910    
911    
912            /**
913             *  Sets the value attribute of the LongTextControl object
914             *
915             *@param  o  The new value value
916             */
917            public void setValue(Object o) {
918                setText(String.valueOf(o));
919            }
920        }
921        //End of LongTextControl class
922    
923    
924        /**
925         *  A spinner that emits propertyChangeEvents when its value changes.
926         *
927         *@author    ringler
928         */
929        private static class Spinner extends JSpinner implements ChangeListener, PropEditor {
930            private Object oldValue;
931    
932    
933            /**  Constructs a new Spinner. */
934            public Spinner() {
935                super();
936                init();
937            }
938    
939    
940            /**
941             *  Constructs a new Spinner.
942             *
943             *@param  model  Description of the Parameter
944             */
945            public Spinner(SpinnerModel model) {
946                super(model);
947                init();
948            }
949    
950    
951            /**  Description of the Method */
952            public void init() {
953                oldValue = getValue();
954                addChangeListener(this);
955            }
956    
957    
958            /**
959             *  Description of the Method
960             *
961             *@param  e  Description of the Parameter
962             */
963            public void stateChanged(ChangeEvent e) {
964                firePropertyChange(VALUE, oldValue, getValue());
965                oldValue = getValue();
966            }
967        }
968        //End of EditorUpdater class
969    
970    
971        /**
972         *  Description of the Interface
973         *
974         *@author    ringler
975         */
976        private interface PropEditor {
977            /**
978             *  Gets the value attribute of the PropEditor object
979             *
980             *@return    The value value
981             */
982            Object getValue();
983    
984    
985            /**
986             *  Sets the value attribute of the PropEditor object
987             *
988             *@param  o  The new value value
989             */
990            void setValue(Object o);
991    
992    
993            /**
994             *  Adds a feature to the PropertyChangeListener attribute of the
995             *  PropEditor object
996             *
997             *@param  property  The feature to be added to the
998             *      PropertyChangeListener attribute
999             *@param  pcl       The feature to be added to the
1000             *      PropertyChangeListener attribute
1001             */
1002            void addPropertyChangeListener(String property, PropertyChangeListener pcl);
1003        }
1004        //End of Spinner class
1005    }