001: package com.xoetrope.carousel.survey;
002:
003: import com.xoetrope.survey.QuestionGroup;
004: import com.xoetrope.survey.Survey;
005: import com.xoetrope.survey.SurveyManager;
006: import java.awt.BorderLayout;
007: import java.awt.Container;
008: import java.awt.Dimension;
009: import java.util.Observable;
010: import java.util.Observer;
011: import java.util.Vector;
012: import javax.swing.BorderFactory;
013: import javax.swing.ImageIcon;
014: import javax.swing.JButton;
015: import javax.swing.JComboBox;
016: import javax.swing.JLabel;
017: import javax.swing.JPanel;
018: import javax.swing.JScrollPane;
019: import javax.swing.JToolBar;
020: import javax.swing.border.EmptyBorder;
021: import javax.swing.border.TitledBorder;
022: import net.xoetrope.xui.XProject;
023: import net.xoetrope.xui.XProjectManager;
024:
025: /**
026: * A panel containing options table
027: *
028: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
029: * the GNU Public License (GPL), please see license.txt for more details. If
030: * you make commercial use of this software you must purchase a commercial
031: * license from Xoetrope.</p>
032: * <p> $Revision: 1.5 $</p>
033: */
034: public class XOptionsPanel extends JPanel {
035: protected JButton addOptionB, deleteOptionB, moveOptionUpB,
036: moveOptionDownB;
037: protected XSurveyEditorFrame editorFrame;
038: protected XOptionsTableModel optionsTableModel;
039:
040: public XOptionsPanel() {
041: super ();
042:
043: XProject project = XProjectManager.getCurrentProject();
044: editorFrame = (XSurveyEditorFrame) project
045: .getObject("EditorFrame");
046:
047: init();
048: }
049:
050: protected void init() {
051: setLayout(new BorderLayout());
052:
053: XTable optionsTable = new XTable();
054: optionsTable.setBorder(new EmptyBorder(0, 0, 0, 0));
055: optionsTableModel = new XOptionsTableModel(optionsTable);
056: JScrollPane scrollPaneOptions = new JScrollPane(optionsTable);
057: TitledBorder optionsBorder = BorderFactory
058: .createTitledBorder("Options");
059: scrollPaneOptions.setBorder(optionsBorder);
060:
061: JToolBar optionsToolBar = new JToolBar();
062: addOptionB = editorFrame.addButton("addOption.png",
063: "add option", optionsToolBar);
064: deleteOptionB = editorFrame.addButton("deleteOption.png",
065: "delete option", optionsToolBar);
066: moveOptionUpB = editorFrame.addButton("moveOptionUp.png",
067: "move up", optionsToolBar);
068: moveOptionDownB = editorFrame.addButton("moveOptionDown.png",
069: "move down", optionsToolBar);
070:
071: deleteOptionB.setEnabled(false);
072: moveOptionUpB.setEnabled(false);
073: moveOptionDownB.setEnabled(false);
074:
075: add(optionsToolBar, BorderLayout.NORTH);
076: add(scrollPaneOptions, BorderLayout.CENTER);
077:
078: optionsTableModel.getNotifier().addObserver(new Observer() {
079: public void update(Observable o, Object arg) {
080: boolean state = (arg != null);
081: deleteOptionB.setEnabled(state);
082: moveOptionUpB.setEnabled(state);
083: moveOptionDownB.setEnabled(state);
084: }
085: });
086:
087: addOptionB.addActionListener(optionsTableModel.getAddOption());
088: deleteOptionB.addActionListener(optionsTableModel
089: .getDeleteOption());
090: moveOptionUpB.addActionListener(optionsTableModel
091: .getMoveOptionUp());
092: moveOptionDownB.addActionListener(optionsTableModel
093: .getMoveOptionDown());
094: }
095:
096: public XOptionsTableModel getOptionsTableModel() {
097: return optionsTableModel;
098: }
099:
100: public JButton getAddOptionB() {
101: return addOptionB;
102: }
103: }
|