01: package com.xoetrope.carousel.survey;
02:
03: import com.xoetrope.survey.QuestionGroup;
04: import com.xoetrope.survey.Survey;
05: import com.xoetrope.survey.SurveyManager;
06: import java.awt.BorderLayout;
07: import java.awt.Container;
08: import java.awt.Dimension;
09: import java.util.Observable;
10: import java.util.Observer;
11: import java.util.Vector;
12: import javax.swing.BorderFactory;
13: import javax.swing.ImageIcon;
14: import javax.swing.JButton;
15: import javax.swing.JComboBox;
16: import javax.swing.JLabel;
17: import javax.swing.JPanel;
18: import javax.swing.JScrollPane;
19: import javax.swing.JToolBar;
20: import javax.swing.border.EmptyBorder;
21: import javax.swing.border.TitledBorder;
22: import net.xoetrope.xui.XProject;
23: import net.xoetrope.xui.XProjectManager;
24:
25: /**
26: * A panel containing question groups table.
27: *
28: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
29: * the GNU Public License (GPL), please see license.txt for more details. If
30: * you make commercial use of this software you must purchase a commercial
31: * license from Xoetrope.</p>
32: * <p> $Revision: 1.5 $</p>
33: */
34: public class XGroupsPanel extends JPanel {
35: protected JButton addGroupB, deleteGroupB, moveGroupUpB,
36: moveGroupDownB;
37: protected XGroupsTableModel groupsTableModel;
38: protected XSurveyEditorFrame editorFrame;
39:
40: public XGroupsPanel() {
41: super ();
42:
43: XProject project = XProjectManager.getCurrentProject();
44: editorFrame = (XSurveyEditorFrame) project
45: .getObject("EditorFrame");
46:
47: init();
48: }
49:
50: protected void init() {
51: setLayout(new BorderLayout());
52:
53: XTable groupsTable = new XTable();
54: groupsTable.setBorder(new EmptyBorder(0, 0, 0, 0));
55: groupsTableModel = new XGroupsTableModel(groupsTable);
56: JScrollPane scrollPaneGroups = new JScrollPane(groupsTable);
57: TitledBorder groupsBorder = BorderFactory
58: .createTitledBorder("Question groups");
59: scrollPaneGroups.setBorder(groupsBorder);
60:
61: JToolBar groupsToolBar = new JToolBar();
62: addGroupB = editorFrame.addButton("addGroup.png",
63: "add new group", groupsToolBar);
64: deleteGroupB = editorFrame.addButton("deleteGroup.png",
65: "delete group", groupsToolBar);
66: moveGroupUpB = editorFrame.addButton("moveGroupUp.png",
67: "move up", groupsToolBar);
68: moveGroupDownB = editorFrame.addButton("moveGroupDown.png",
69: "move down", groupsToolBar);
70:
71: deleteGroupB.setEnabled(false);
72: moveGroupUpB.setEnabled(false);
73: moveGroupDownB.setEnabled(false);
74:
75: add(groupsToolBar, BorderLayout.NORTH);
76: add(scrollPaneGroups, BorderLayout.CENTER);
77:
78: groupsTableModel.getNotifier().addObserver(new Observer() {
79: public void update(Observable o, Object arg) {
80: boolean state = (arg != null);
81: deleteGroupB.setEnabled(state);
82: moveGroupUpB.setEnabled(state);
83: moveGroupDownB.setEnabled(state);
84: }
85: });
86:
87: addGroupB.addActionListener(groupsTableModel.getAddGroup());
88: deleteGroupB.addActionListener(groupsTableModel
89: .getDeleteGroup());
90: moveGroupUpB.addActionListener(groupsTableModel
91: .getMoveGroupUp());
92: moveGroupDownB.addActionListener(groupsTableModel
93: .getMoveGroupDown());
94: }
95:
96: public XGroupsTableModel getGroupsTableModel() {
97: return groupsTableModel;
98: }
99: }
|