| 1 | package tmcsim.paramicscommunicator.gui; |
|---|
| 2 | |
|---|
| 3 | import java.awt.Dimension; |
|---|
| 4 | |
|---|
| 5 | import javax.swing.BorderFactory; |
|---|
| 6 | import javax.swing.Box; |
|---|
| 7 | import javax.swing.BoxLayout; |
|---|
| 8 | import javax.swing.JLabel; |
|---|
| 9 | import javax.swing.JPanel; |
|---|
| 10 | import javax.swing.JScrollPane; |
|---|
| 11 | import javax.swing.JTable; |
|---|
| 12 | import javax.swing.JTextField; |
|---|
| 13 | |
|---|
| 14 | import tmcsim.paramicscommunicator.FileRegUpdate; |
|---|
| 15 | import tmcsim.paramicscommunicator.FileIOUpdate.IO_TYPE; |
|---|
| 16 | import tmcsim.paramicscommunicator.FileRegUpdate.REG_TYPE; |
|---|
| 17 | |
|---|
| 18 | /** |
|---|
| 19 | * ParamicsIOInfoPanel is a JPanel used in the ParamicsCommunicatorGUI to |
|---|
| 20 | * display registration and I/O operations performed for a specific |
|---|
| 21 | * Paramics FileReader or FileWriter. |
|---|
| 22 | * |
|---|
| 23 | * @author Matthew Cechini |
|---|
| 24 | * @version |
|---|
| 25 | */ |
|---|
| 26 | @SuppressWarnings("serial") |
|---|
| 27 | public class ParamicsIOInfoPanel extends JPanel { |
|---|
| 28 | |
|---|
| 29 | /** |
|---|
| 30 | * Constructor. Initialie the GUI elements for this panel. |
|---|
| 31 | * |
|---|
| 32 | * @param update Initial FileRegUpdate object. |
|---|
| 33 | * @param tableModel TableModel to be displayed on panel. |
|---|
| 34 | */ |
|---|
| 35 | public ParamicsIOInfoPanel(FileRegUpdate update, FileIOTableModel tableModel) { |
|---|
| 36 | |
|---|
| 37 | Box infoBox = new Box(BoxLayout.Y_AXIS); |
|---|
| 38 | infoBox.setAlignmentY(Box.CENTER_ALIGNMENT); |
|---|
| 39 | infoBox.add(Box.createVerticalGlue()); |
|---|
| 40 | |
|---|
| 41 | idLbl = new JLabel("ID:"); |
|---|
| 42 | idLbl.setAlignmentX(Box.LEFT_ALIGNMENT); |
|---|
| 43 | idTF = new JTextField(update.ioID); |
|---|
| 44 | idTF.setAlignmentX(Box.LEFT_ALIGNMENT); |
|---|
| 45 | idTF.setMinimumSize(new Dimension(150, 25)); |
|---|
| 46 | idTF.setPreferredSize(new Dimension(150, 25)); |
|---|
| 47 | idTF.setMaximumSize(new Dimension(200, 25)); |
|---|
| 48 | idTF.setEditable(false); |
|---|
| 49 | infoBox.add(idLbl); |
|---|
| 50 | infoBox.add(idTF); |
|---|
| 51 | infoBox.add(Box.createVerticalStrut(5)); |
|---|
| 52 | |
|---|
| 53 | targetFileLbl = new JLabel("Target File:"); |
|---|
| 54 | targetFileLbl.setAlignmentX(Box.LEFT_ALIGNMENT); |
|---|
| 55 | targetFileTF = new JTextField(update.targetFile); |
|---|
| 56 | targetFileTF.setAlignmentX(Box.LEFT_ALIGNMENT); |
|---|
| 57 | targetFileTF.setMinimumSize(new Dimension(150, 25)); |
|---|
| 58 | targetFileTF.setPreferredSize(new Dimension(150, 25)); |
|---|
| 59 | targetFileTF.setMaximumSize(new Dimension(200, 25)); |
|---|
| 60 | targetFileTF.setEditable(false); |
|---|
| 61 | infoBox.add(targetFileLbl); |
|---|
| 62 | infoBox.add(targetFileTF); |
|---|
| 63 | |
|---|
| 64 | if(update.ioType == IO_TYPE.READ) { |
|---|
| 65 | intervalLbl = new JLabel("Interval: "); |
|---|
| 66 | intervalLbl.setAlignmentX(Box.LEFT_ALIGNMENT); |
|---|
| 67 | intervalTF = new JTextField(String.valueOf(update.ioInterval)); |
|---|
| 68 | intervalTF.setAlignmentX(Box.LEFT_ALIGNMENT); |
|---|
| 69 | intervalTF.setMinimumSize(new Dimension(150, 25)); |
|---|
| 70 | intervalTF.setPreferredSize(new Dimension(150, 25)); |
|---|
| 71 | intervalTF.setMaximumSize(new Dimension(200, 25)); |
|---|
| 72 | intervalTF.setEditable(false); |
|---|
| 73 | |
|---|
| 74 | infoBox.add(Box.createVerticalStrut(5)); |
|---|
| 75 | infoBox.add(intervalLbl); |
|---|
| 76 | infoBox.add(intervalTF); |
|---|
| 77 | } |
|---|
| 78 | infoBox.add(Box.createVerticalGlue()); |
|---|
| 79 | infoBox.setMinimumSize(new Dimension(150, 200)); |
|---|
| 80 | infoBox.setPreferredSize(new Dimension(150, 200)); |
|---|
| 81 | infoBox.setMaximumSize(new Dimension(200, 200)); |
|---|
| 82 | infoBox.setBorder(BorderFactory.createCompoundBorder( |
|---|
| 83 | BorderFactory.createTitledBorder( |
|---|
| 84 | BorderFactory.createRaisedBevelBorder(), "Information"), |
|---|
| 85 | BorderFactory.createEmptyBorder(5,5,5,5))); |
|---|
| 86 | |
|---|
| 87 | ioUpdateTable = new JTable(tableModel); |
|---|
| 88 | ioUpdateTable.getTableHeader().setReorderingAllowed(false); |
|---|
| 89 | ioUpdatePane = new JScrollPane(); |
|---|
| 90 | ioUpdatePane.setMinimumSize(new Dimension(200, 400)); |
|---|
| 91 | ioUpdatePane.setPreferredSize(new Dimension(200, 400)); |
|---|
| 92 | ioUpdatePane.setMaximumSize(new Dimension(200, 400)); |
|---|
| 93 | ioUpdatePane.setViewportView(ioUpdateTable); |
|---|
| 94 | ioUpdatePane.setAlignmentY(Box.CENTER_ALIGNMENT); |
|---|
| 95 | |
|---|
| 96 | Box panelBox = new Box(BoxLayout.X_AXIS); |
|---|
| 97 | panelBox.add(ioUpdatePane); |
|---|
| 98 | panelBox.add(Box.createHorizontalStrut(20)); |
|---|
| 99 | panelBox.add(infoBox); |
|---|
| 100 | panelBox.add(Box.createHorizontalGlue()); |
|---|
| 101 | |
|---|
| 102 | add(panelBox); |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | public IO_TYPE ioType; |
|---|
| 107 | public REG_TYPE regType; |
|---|
| 108 | public String ioID; |
|---|
| 109 | public String targetFile; |
|---|
| 110 | public Integer ioInterval; |
|---|
| 111 | |
|---|
| 112 | private JLabel idLbl; |
|---|
| 113 | private JLabel targetFileLbl; |
|---|
| 114 | private JLabel intervalLbl; |
|---|
| 115 | |
|---|
| 116 | private JTextField idTF; |
|---|
| 117 | private JTextField targetFileTF; |
|---|
| 118 | private JTextField intervalTF; |
|---|
| 119 | |
|---|
| 120 | private JTable ioUpdateTable; |
|---|
| 121 | private JScrollPane ioUpdatePane; |
|---|
| 122 | } |
|---|