A Control that shows its parameters in a JTable. Custom buttons can be added. @author Wolfgang Christian @version 1.0
| 46 | * @version 1.0 |
| 47 | */ |
| 48 | public class OSPControl extends ControlFrame implements PropertyChangeListener, MainFrame { |
| 49 | OSPControlTable table = new OSPControlTable(new XMLControlElement()); |
| 50 | JScrollPane controlScrollPane = new JScrollPane(table); |
| 51 | JTextArea messageTextArea; |
| 52 | JLabel clearLabel, messageLabel, inputLabel; |
| 53 | JSplitPane splitPane; |
| 54 | static final Color PANEL_BACKGROUND = javax.swing.UIManager.getColor("Panel.background"); //$NON-NLS-1$ |
| 55 | |
| 56 | /** |
| 57 | * Constructs an OSPControl. |
| 58 | * |
| 59 | * @param _model |
| 60 | */ |
| 61 | public OSPControl(Object _model) { |
| 62 | super(ControlsRes.getString("OSPControl.Default_Title")); //$NON-NLS-1$ |
| 63 | // table = new OSPControlTable(new XMLControlElement()); |
| 64 | model = _model; |
| 65 | if (model != null) { |
| 66 | // added by D Brown 2006-09-10 |
| 67 | // modified by D Brown 2007-10-17 |
| 68 | if (OSPRuntime.loadTranslatorTool) { |
| 69 | OSPRuntime.getTranslator().associate(this, model.getClass()); |
| 70 | } |
| 71 | String name = model.getClass().getName(); |
| 72 | setTitle(name.substring(1 + name.lastIndexOf(".")) + ControlsRes.getString("OSPControl.Controller")); //$NON-NLS-1$ //$NON-NLS-2$ |
| 73 | } |
| 74 | Font labelFont = new Font("Dialog", Font.BOLD, 12); //$NON-NLS-1$ |
| 75 | inputLabel = new JLabel(ControlsRes.getString("OSPControl.Input_Parameters"), SwingConstants.CENTER); //$NON-NLS-1$ |
| 76 | inputLabel.setFont(labelFont); |
| 77 | messageTextArea = GUIUtils.newJTextArea(); |
| 78 | messageTextArea.setRows(5); |
| 79 | messageTextArea.setColumns(5); |
| 80 | JScrollPane messageScrollPane = new JScrollPane(messageTextArea); |
| 81 | // contains a view of the control |
| 82 | JPanel topPanel = new JPanel(new BorderLayout()); |
| 83 | topPanel.add(inputLabel, BorderLayout.NORTH); |
| 84 | topPanel.add(controlScrollPane, BorderLayout.CENTER); |
| 85 | buttonPanel.setVisible(true); |
| 86 | topPanel.add(buttonPanel, BorderLayout.SOUTH); // buttons are added using addButton method. |
| 87 | // clear panel acts like a button to clear the message area |
| 88 | JPanel clearPanel = new JPanel(new BorderLayout()); |
| 89 | clearPanel.addMouseListener(new ClearMouseAdapter()); |
| 90 | clearLabel = new JLabel(ControlsRes.getString("OSPControl.Clear")); //$NON-NLS-1$ |
| 91 | clearLabel.setFont(new Font(clearLabel.getFont().getFamily(), Font.PLAIN, 9)); |
| 92 | clearLabel.setForeground(Color.black); |
| 93 | clearPanel.add(clearLabel, BorderLayout.WEST); |
| 94 | // contains the messages |
| 95 | JPanel bottomPanel = new JPanel(new BorderLayout()); |
| 96 | messageLabel = new JLabel(ControlsRes.getString("OSPControl.Messages"), SwingConstants.CENTER); //$NON-NLS-1$ |
| 97 | messageLabel.setFont(labelFont); |
| 98 | bottomPanel.add(messageLabel, BorderLayout.NORTH); |
| 99 | bottomPanel.add(messageScrollPane, BorderLayout.CENTER); |
| 100 | bottomPanel.add(clearPanel, BorderLayout.SOUTH); |
| 101 | Container cp = getContentPane(); |
| 102 | splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel); |
| 103 | splitPane.setOneTouchExpandable(true); |
| 104 | cp.add(splitPane, BorderLayout.CENTER); |
| 105 | messageTextArea.setEditable(false); |