1 /*
2 * (C) 2002 David Carr david@carr.name
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package net.sourceforge.mflow.config;
20
21 import java.awt.Choice;
22 import java.awt.event.ItemEvent;
23 import java.awt.event.ItemListener;
24 import java.beans.PropertyEditor;
25
26 /***
27 * Class to coordinate a Choice with a PropertyEditor
28 *
29 * @author <a href="mailto:david@carr.name">David Carr</a>
30 * @version $Revision: 1.4 $
31 */
32 class PropertySelector extends Choice implements ItemListener {
33 /***
34 * Private reference to the property editor
35 */
36 PropertyEditor editor;
37
38 /***
39 * Constructor, takes a property editor as a parameter
40 *
41 * @param pe the property editor
42 */
43 PropertySelector(PropertyEditor pe) {
44 this.editor = pe;
45 String tags[] = this.editor.getTags();
46 for (int i = 0; i < tags.length; i++) {
47 addItem(tags[i]);
48 }
49 select(0);
50 // This is a noop if the getAsText is not a tag.
51 select(this.editor.getAsText());
52 addItemListener(this);
53 }
54
55 /***
56 * Updates the property editor when the selected item changes
57 *
58 * @param evt the event
59 */
60 public void itemStateChanged(ItemEvent evt) {
61 String s = getSelectedItem();
62 this.editor.setAsText(s);
63 }
64
65 /***
66 * Repaints the object
67 */
68 public void repaint() {
69 select(this.editor.getAsText());
70 }
71 }
This page was automatically generated by Maven