- Timestamp:
- 07/29/11 14:33:59 (13 years ago)
- Location:
- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swing/DlgInsert.java
r134 r139 29 29 30 30 public class DlgInsert extends JDialog { 31 31 32 32 /** 33 33 * Id for object serialization. … … 43 43 * Launch the application. 44 44 */ 45 public static void showDialog(List<Event<?>> sequences, int selectedIndex, final boolean insertBefore) { 45 public static void showDialog(List<Event<?>> sequences, int selectedIndex, 46 final boolean insertBefore) { 46 47 try { 47 DlgInsert dialog = new DlgInsert(sequences, selectedIndex, insertBefore); 48 DlgInsert dialog = new DlgInsert(sequences, selectedIndex, 49 insertBefore); 48 50 dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 49 51 dialog.setVisible(true); … … 56 58 * Create the dialog. 57 59 */ 58 public DlgInsert(final List<Event<?>> sequences, final int selectedIndex, final boolean insertBefore) { 59 60 public DlgInsert(final List<Event<?>> sequences, final int selectedIndex, 61 final boolean insertBefore) { 62 60 63 final javax.swing.DefaultListModel modelListTargets = new javax.swing.DefaultListModel(); 61 64 62 65 setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 63 66 setTitle("Insert testcase"); 64 65 67 66 68 setModal(true); 67 69 setBounds(100, 100, 522, 482); … … 73 75 final JPanel panelTextEquals = new JPanel(); 74 76 final JPanel panelFileEquals = new JPanel(); 75 76 77 77 78 // JComboBox: comboBoxTestcase 78 79 comboBoxTestcase.addActionListener(new ActionListener() { 79 80 public void actionPerformed(ActionEvent arg0) { 80 81 if ("comboBoxChanged".equals(arg0.getActionCommand())) { 81 82 // TextEquals83 if (comboBoxTestcase.getSelectedIndex() == 0) {82 83 // TextEquals 84 if (comboBoxTestcase.getSelectedIndex() == 0) { 84 85 panelTextEquals.setVisible(true); 85 86 panelFileEquals.setVisible(false); 86 87 } 87 // FileEquals88 else if (comboBoxTestcase.getSelectedIndex() == 1) {88 // FileEquals 89 else if (comboBoxTestcase.getSelectedIndex() == 1) { 89 90 panelTextEquals.setVisible(false); 90 91 panelFileEquals.setVisible(true); … … 93 94 } 94 95 }); 95 comboBoxTestcase.setModel(new DefaultComboBoxModel(new String[] {"TextEquals", "OutputFileEquals"})); 96 comboBoxTestcase.setModel(new DefaultComboBoxModel(new String[] { 97 "TextEquals", "OutputFileEquals" })); 96 98 comboBoxTestcase.setSelectedIndex(0); 97 99 comboBoxTestcase.setBounds(128, 11, 178, 20); 98 100 contentPanel.add(comboBoxTestcase); 99 101 // *** 100 101 102 // JLabel 102 103 // JLabel 103 104 JLabel label = new JLabel("Testcase:"); 104 105 label.setBounds(10, 14, 86, 14); 105 106 contentPanel.add(label); 106 107 107 108 JLabel label_1 = new JLabel("Expected value:"); 108 109 label_1.setBounds(10, 11, 83, 14); 109 110 110 111 JLabel label_2 = new JLabel("Target:"); 111 112 label_2.setBounds(10, 38, 86, 14); 112 113 // *** 113 114 114 115 115 // JTextField: textFieldExpectedValue 116 116 textFieldExpectedValue = new JTextField(); … … 118 118 textFieldExpectedValue.setBounds(116, 8, 368, 20); 119 119 // *** 120 121 120 122 121 // JPanel: panel 123 122 panelTextEquals.setLayout(null); … … 127 126 panelTextEquals.add(label_2); 128 127 panelTextEquals.add(textFieldExpectedValue); 129 128 130 129 JScrollPane scrollPane = new JScrollPane(); 131 130 scrollPane.setBounds(116, 36, 368, 163); 132 131 panelTextEquals.add(scrollPane); 133 132 134 133 final JList listTargets = new JList(modelListTargets); 135 134 scrollPane.setViewportView(listTargets); 136 137 for(int i=0; i<sequences.size(); i++) { 138 if(sequences.get(i).getTarget() != " ") modelListTargets.addElement(sequences.get(i).getTarget()); 135 136 for (int i = 0; i < sequences.size(); i++) { 137 if (sequences.get(i).getTarget() != " ") 138 modelListTargets.addElement(sequences.get(i).getTarget()); 139 139 } 140 140 listTargets.setSelectedIndex(0); 141 142 141 143 142 panelFileEquals.setBounds(10, 260, 494, 140); 144 143 contentPanel.add(panelFileEquals); 145 144 panelFileEquals.setLayout(null); 146 145 panelFileEquals.setVisible(false); 147 146 148 147 JLabel lblNewLabel = new JLabel("Actual file:"); 149 148 lblNewLabel.setBounds(10, 11, 89, 14); 150 149 panelFileEquals.add(lblNewLabel); 151 150 152 151 textFieldActualFile = new JTextField(); 153 152 textFieldActualFile.setBounds(10, 36, 474, 20); 154 153 panelFileEquals.add(textFieldActualFile); 155 154 textFieldActualFile.setColumns(10); 156 155 157 156 JButton btnNewButton = new JButton("Search file"); 158 157 btnNewButton.addMouseListener(new MouseAdapter() { 159 158 public void mouseClicked(MouseEvent arg0) { 160 159 final JFileChooser fc = new JFileChooser(); 161 if(fc.showOpenDialog(contentPanel) == 0) { textFieldExpectedFile.setText(fc.getSelectedFile().getAbsolutePath()); } 160 if (fc.showOpenDialog(contentPanel) == 0) { 161 textFieldExpectedFile.setText(fc.getSelectedFile() 162 .getAbsolutePath()); 163 } 162 164 } 163 165 }); 164 166 btnNewButton.setBounds(99, 80, 89, 23); 165 167 panelFileEquals.add(btnNewButton); 166 168 167 169 JLabel lblNewLabel_1 = new JLabel("Expected file:"); 168 170 lblNewLabel_1.setBounds(10, 84, 89, 14); 169 171 panelFileEquals.add(lblNewLabel_1); 170 172 171 173 textFieldExpectedFile = new JTextField(); 172 174 textFieldExpectedFile.setColumns(10); … … 182 184 okButton.addMouseListener(new MouseAdapter() { 183 185 public void mouseClicked(MouseEvent arg0) { 184 185 //FileEquals 186 if(panelFileEquals.isVisible()) { 187 if(textFieldActualFile.getText().length() == 0) JOptionPane.showMessageDialog(null, "Please declare an actual file.", "No actual file declared", JOptionPane.OK_OPTION); 188 else if(! new File(textFieldExpectedFile.getText()).exists()) { 189 if(textFieldExpectedFile.getText().length() == 0) JOptionPane.showMessageDialog(null, "Please choose an expected file.", "No expected file chosen", JOptionPane.OK_OPTION); 190 else JOptionPane.showMessageDialog(null, "The expected file \"" + textFieldActualFile.getText() + "\" does not exist.", "Expected file does not exist", JOptionPane.OK_OPTION); 186 187 // FileEquals 188 if (panelFileEquals.isVisible()) { 189 if (textFieldActualFile.getText().length() == 0) 190 JOptionPane.showMessageDialog(null, 191 "Please declare an actual file.", 192 "No actual file declared", 193 JOptionPane.OK_OPTION); 194 else if (!new File(textFieldExpectedFile.getText()) 195 .exists()) { 196 if (textFieldExpectedFile.getText().length() == 0) 197 JOptionPane.showMessageDialog(null, 198 "Please choose an expected file.", 199 "No expected file chosen", 200 JOptionPane.OK_OPTION); 201 else 202 JOptionPane.showMessageDialog( 203 null, 204 "The expected file \"" 205 + textFieldActualFile 206 .getText() 207 + "\" does not exist.", 208 "Expected file does not exist", 209 JOptionPane.OK_OPTION); 191 210 return; 192 } 193 else { 211 } else { 194 212 FileEqualsReplay file = new FileEqualsReplay(); 195 file.setActualFile(textFieldActualFile.getText()); 196 file.setExpectedFile(textFieldExpectedFile.getText()); 197 198 AssertEvent<FileEqualsReplay> e = new AssertEvent<FileEqualsReplay>("FileEquals"); 213 file.setActualFile(textFieldActualFile 214 .getText()); 215 file.setExpectedFile(textFieldExpectedFile 216 .getText()); 217 218 AssertEvent<FileEqualsReplay> e = new AssertEvent<FileEqualsReplay>( 219 "FileEquals"); 199 220 e.addReplayEvent(file); 200 221 e.setTarget(" "); 201 if(insertBefore) sequences.add(selectedIndex, e); 202 else sequences.add(selectedIndex+1, e); 222 if (insertBefore) 223 sequences.add(selectedIndex, e); 224 else 225 sequences.add(selectedIndex + 1, e); 203 226 } 204 227 } 205 // TextEquals228 // TextEquals 206 229 else { 207 if(textFieldExpectedValue.getText().length() == 0) { 208 JOptionPane.showMessageDialog(null, "\"Expected value\" is missing.", "Expected value", JOptionPane.OK_OPTION); 230 if (textFieldExpectedValue.getText().length() == 0) { 231 JOptionPane 232 .showMessageDialog( 233 null, 234 "\"Expected value\" is missing.", 235 "Expected value", 236 JOptionPane.OK_OPTION); 209 237 return; 210 } 211 else if(listTargets.getSelectedIndex() == -1) { 212 JOptionPane.showMessageDialog(null, "Please select a target.", "No target selected", JOptionPane.OK_OPTION); 238 } else if (listTargets.getSelectedIndex() == -1) { 239 JOptionPane.showMessageDialog(null, 240 "Please select a target.", 241 "No target selected", 242 JOptionPane.OK_OPTION); 213 243 return; 214 } 215 else { 244 } else { 216 245 TextEqualsReplay text = new TextEqualsReplay(); 217 text.setExpectedValue(textFieldExpectedValue.getText()); 218 text.setTarget(modelListTargets.get(listTargets.getSelectedIndex()).toString()); 219 220 AssertEvent<TextEqualsReplay> e = new AssertEvent<TextEqualsReplay>("TextEquals"); 246 text.setExpectedValue(textFieldExpectedValue 247 .getText()); 248 text.setTarget(modelListTargets.get( 249 listTargets.getSelectedIndex()) 250 .toString()); 251 252 AssertEvent<TextEqualsReplay> e = new AssertEvent<TextEqualsReplay>( 253 "TextEquals"); 221 254 e.addReplayEvent(text); 222 255 e.setTarget(" "); 223 if(insertBefore) sequences.add(selectedIndex, e); 224 else sequences.add(selectedIndex+1, e); 256 if (insertBefore) 257 sequences.add(selectedIndex, e); 258 else 259 sequences.add(selectedIndex + 1, e); 225 260 } 226 261 } 227 262 228 263 dispose(); 229 264 } … … 234 269 // *** 235 270 } 236 271 237 272 { 238 273 // JButton: cancelButton 239 274 JButton cancelButton = new JButton("Cancel"); 240 275 cancelButton.addMouseListener(new MouseAdapter() { 241 242 public void mouseClicked(MouseEvent arg0) { dispose(); } 276 277 public void mouseClicked(MouseEvent arg0) { 278 dispose(); 279 } 243 280 }); 244 281 cancelButton.setActionCommand("Cancel"); -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swing/DlgSequenceDetails.java
r134 r139 1 1 package de.ugoe.cs.eventbench.swing; 2 2 3 import java.awt.EventQueue; 3 4 … … 23 24 import javax.swing.border.EtchedBorder; 24 25 25 26 26 public class DlgSequenceDetails { 27 27 … … 30 30 31 31 /** 32 * Launch the application, the index of the sequence to work on is stored in sequenceIndex 32 * Launch the application, the index of the sequence to work on is stored in 33 * sequenceIndex 33 34 */ 34 35 public void showDialog(JFrame parent, final List<Event<?>> events) { 35 36 frmParent = parent; 36 37 37 38 EventQueue.invokeLater(new Runnable() { 38 39 public void run() { 39 40 try { 40 DlgSequenceDetails window = new DlgSequenceDetails(frmParent, events); 41 DlgSequenceDetails window = new DlgSequenceDetails( 42 frmParent, events); 41 43 window.frmEvents.setVisible(true); 42 44 } catch (Exception e) { … … 59 61 */ 60 62 private void initialize(final List<Event<?>> events) { 61 62 63 63 64 final javax.swing.DefaultListModel modelListEvents = new javax.swing.DefaultListModel(); 64 65 final javax.swing.DefaultListModel modelListTargets = new javax.swing.DefaultListModel(); … … 66 67 final JList listTargets = new JList(modelListTargets); 67 68 // *** 68 69 69 70 70 // JFrame: frmEvents 71 71 frmEvents = new JFrame(); … … 82 82 } 83 83 }); 84 84 85 85 updateLists(events, modelListEvents, modelListTargets); 86 86 87 87 JPanel panel = new JPanel(); 88 88 panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); … … 94 94 panel.add(btnInsertBefore); 95 95 // *** 96 97 96 98 97 // JButton: btnInsertBefore *** 99 98 btnInsertBefore.addMouseListener(new MouseAdapter() { 100 99 public void mouseClicked(MouseEvent arg0) { 101 if(!btnInsertBefore.isEnabled()) return; 102 100 if (!btnInsertBefore.isEnabled()) 101 return; 102 103 103 int selectedIndex = listSequences.getSelectedIndex(); 104 DlgInsert dlgInsert = new DlgInsert(events, selectedIndex, true); 105 dlgInsert.showDialog(events, selectedIndex, true); 106 104 DlgInsert.showDialog(events, selectedIndex, true); 105 107 106 updateLists(events, modelListEvents, modelListTargets); 108 107 listSequences.setSelectedIndex(selectedIndex); 109 108 } 110 109 }); 111 110 112 111 btnInsertBefore.setEnabled(false); 113 112 final JButton btnInsertAfter = new JButton("Insert after"); … … 115 114 panel.add(btnInsertAfter); 116 115 // *** 117 118 116 119 117 // JButton: btnInsertAfter 120 118 btnInsertAfter.addMouseListener(new MouseAdapter() { 121 119 public void mouseClicked(MouseEvent arg0) { 122 if(!btnInsertAfter.isEnabled()) return; 123 120 if (!btnInsertAfter.isEnabled()) 121 return; 122 124 123 int selectedIndex = listSequences.getSelectedIndex(); 125 DlgInsert dlgInsert = new DlgInsert(events, selectedIndex, false); 126 dlgInsert.showDialog(events, selectedIndex, false); 127 124 DlgInsert.showDialog(events, selectedIndex, false); 125 128 126 updateLists(events, modelListEvents, modelListTargets); 129 listSequences.setSelectedIndex(selectedIndex +1);130 } 131 }); 132 127 listSequences.setSelectedIndex(selectedIndex + 1); 128 } 129 }); 130 133 131 btnInsertAfter.setEnabled(false); 134 132 135 133 final JButton btnClose = new JButton("Back to sequences"); 136 134 btnClose.setBounds(505, 11, 124, 31); 137 135 panel.add(btnClose); 138 136 139 137 JPanel panel_1 = new JPanel(); 140 138 panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); … … 142 140 frmEvents.getContentPane().add(panel_1); 143 141 panel_1.setLayout(null); 144 142 145 143 JScrollPane scrollPane_1 = new JScrollPane(); 146 144 scrollPane_1.setBounds(10, 29, 309, 339); … … 148 146 scrollPane_1.setViewportView(listSequences); 149 147 // *** 150 151 148 152 149 // JList: listSequences *** 153 listSequences.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null)); 150 listSequences.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, 151 null, null, null)); 154 152 listSequences.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 155 156 153 157 154 // JScrollPane: scrollPane 158 155 JScrollPane scrollPane = new JScrollPane(); 159 156 scrollPane.setBounds(329, 29, 298, 339); 160 157 panel_1.add(scrollPane); 161 158 162 159 listTargets.addListSelectionListener(new ListSelectionListener() { 163 160 public void valueChanged(ListSelectionEvent arg0) { 164 if(listTargets.getSelectedIndex() > -1) { 165 listSequences.setSelectedIndex(listTargets.getSelectedIndex()); 161 if (listTargets.getSelectedIndex() > -1) { 162 listSequences.setSelectedIndex(listTargets 163 .getSelectedIndex()); 166 164 btnInsertAfter.setEnabled(true); 167 168 if(listTargets.getSelectedIndex() == 0) { 169 btnInsertBefore.setEnabled(false); 170 } 171 else { 165 166 if (listTargets.getSelectedIndex() == 0) { 167 btnInsertBefore.setEnabled(false); 168 } else { 172 169 btnInsertBefore.setEnabled(true); 173 170 } … … 177 174 scrollPane.setViewportView(listTargets); 178 175 // *** 179 180 181 // JList for targets ***182 listTargets.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null,null, null, null));176 177 // JList for targets *** 178 listTargets.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, 179 null, null, null)); 183 180 listTargets.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 184 181 185 182 JLabel lblEvents = new JLabel("Events:"); 186 183 lblEvents.setBounds(10, 11, 46, 14); 187 184 panel_1.add(lblEvents); 188 185 189 186 JLabel lblTargets = new JLabel("Targets:"); 190 187 lblTargets.setBounds(329, 11, 58, 14); 191 188 panel_1.add(lblTargets); 192 189 193 190 listSequences.addListSelectionListener(new ListSelectionListener() { 194 191 public void valueChanged(ListSelectionEvent arg0) { 195 if(listSequences.getSelectedIndex() > -1) { 196 listTargets.setSelectedIndex(listSequences.getSelectedIndex()); 197 198 if(listSequences.getSelectedIndex() == 0) { 192 if (listSequences.getSelectedIndex() > -1) { 193 listTargets.setSelectedIndex(listSequences 194 .getSelectedIndex()); 195 196 if (listSequences.getSelectedIndex() == 0) { 199 197 btnInsertBefore.setEnabled(false); 200 198 btnInsertAfter.setEnabled(true); 201 } 202 else { 199 } else { 203 200 btnInsertBefore.setEnabled(true); 204 201 btnInsertAfter.setEnabled(true); … … 208 205 }); 209 206 // *** 210 211 207 212 208 // JButton: btnClose *** 213 209 btnClose.addMouseListener(new MouseAdapter() { … … 223 219 final javax.swing.DefaultListModel modelListEvents, 224 220 final javax.swing.DefaultListModel modelListTargets) { 225 221 226 222 modelListEvents.clear(); 227 223 modelListTargets.clear(); 228 for (int i=0; i<events.size(); i++) {224 for (int i = 0; i < events.size(); i++) { 229 225 modelListEvents.addElement(events.get(i).getType()); 230 226 modelListTargets.addElement(events.get(i).getTarget());
Note: See TracChangeset
for help on using the changeset viewer.