01: package com.xoetrope.carousel.survey;
02:
03: import java.awt.Dimension;
04: import java.awt.event.ActionEvent;
05: import java.awt.event.ActionListener;
06: import java.util.Observable;
07: import javax.swing.DefaultComboBoxModel;
08: import javax.swing.JComboBox;
09: import net.xoetrope.editor.project.XEditorProject;
10: import net.xoetrope.xui.XProject;
11: import net.xoetrope.xui.XProjectManager;
12:
13: /**
14: * A combo box that contains question groups from the current survey.
15: *
16: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
17: * the GNU Public License (GPL), please see license.txt for more details. If
18: * you make commercial use of this software you must purchase a commercial
19: * license from Xoetrope.</p>
20: * <p> $Revision: 1.5 $</p>
21: */
22: public class XGroupComboBox extends JComboBox implements ActionListener {
23: protected XSurvey survey;
24: protected Observable notifier;
25:
26: public XGroupComboBox() {
27: super ();
28: XProject project = XProjectManager.getCurrentProject();
29: survey = (XSurvey) project.getObject("Survey");
30: setModel(new DefaultComboBoxModel(survey.getGroups()));
31: notifier = new XNotifier(
32: project instanceof XEditorProject ? (XEditorProject) project
33: : null, false);
34: Dimension size = new Dimension(150, 18);
35: setSize(size);
36: setPreferredSize(size);
37: setMaximumSize(size);
38: addActionListener(this );
39: }
40:
41: public void updateModel() {
42: setModel(new DefaultComboBoxModel(survey.getGroups()));
43: }
44:
45: public Observable getNotifier() {
46: return notifier;
47: }
48:
49: public void actionPerformed(ActionEvent e) {
50: notifier.notifyObservers(getSelectedItem());
51: }
52:
53: }
|