- Timestamp:
- 07/27/11 18:32:43 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swing/DlgInsert.java
r132 r134 4 4 import java.awt.FlowLayout; 5 5 import java.util.List; 6 import de.ugoe.cs.util.console.Console; 6 7 import de.ugoe.cs.eventbench.assertions.AssertEvent; 8 import de.ugoe.cs.eventbench.assertions.FileEqualsReplay; 9 import de.ugoe.cs.eventbench.assertions.TextEqualsReplay; 7 10 import de.ugoe.cs.eventbench.data.Event; 8 import de.ugoe.cs.eventbench.data.GlobalDataContainer;9 11 10 12 import javax.swing.JButton; … … 13 15 import javax.swing.border.EmptyBorder; 14 16 import javax.swing.JComboBox; 15 import javax.swing.ComboBoxModel;16 17 import javax.swing.JLabel; 17 18 import javax.swing.JTextField; … … 21 22 import java.awt.event.MouseAdapter; 22 23 import java.awt.event.MouseEvent; 23 import java.beans.PropertyChangeListener;24 import java.beans.PropertyChangeEvent;25 24 import java.io.File; 26 25 import java.awt.event.ActionListener; 27 26 import java.awt.event.ActionEvent; 28 import java.awt.event.KeyAdapter;29 import java.awt.event.KeyEvent;30 27 import javax.swing.JScrollPane; 31 28 import javax.swing.JList; 32 29 33 30 public class DlgInsert extends JDialog { 31 32 /** 33 * Id for object serialization. 34 */ 35 private static final long serialVersionUID = 1L; 34 36 35 37 private final JPanel contentPanel = new JPanel(); 36 38 private JTextField textFieldExpectedValue; 37 private JTextField textField TestFile;38 private JTextField textField MatchingFile;39 private JTextField textFieldActualFile; 40 private JTextField textFieldExpectedFile; 39 41 40 42 /** 41 43 * Launch the application. 42 44 */ 43 public static void ShowDialog(List<Event<?>> sequences, int selectedIndex, final boolean insertBefore) {45 public static void showDialog(List<Event<?>> sequences, int selectedIndex, final boolean insertBefore) { 44 46 try { 45 47 DlgInsert dialog = new DlgInsert(sequences, selectedIndex, insertBefore); … … 130 132 panelTextEquals.add(scrollPane); 131 133 132 JList listTargets = new JList(modelListTargets);134 final JList listTargets = new JList(modelListTargets); 133 135 scrollPane.setViewportView(listTargets); 134 136 135 137 for(int i=0; i<sequences.size(); i++) { 136 modelListTargets.addElement(sequences.get(i).getTarget());138 if(sequences.get(i).getTarget() != " ") modelListTargets.addElement(sequences.get(i).getTarget()); 137 139 } 140 listTargets.setSelectedIndex(0); 138 141 139 142 … … 143 146 panelFileEquals.setVisible(false); 144 147 145 JLabel lblNewLabel = new JLabel(" Testfile:");146 lblNewLabel.setBounds(10, 11, 46, 14);148 JLabel lblNewLabel = new JLabel("Actual file:"); 149 lblNewLabel.setBounds(10, 11, 89, 14); 147 150 panelFileEquals.add(lblNewLabel); 148 151 149 textField TestFile = new JTextField();150 textField TestFile.setBounds(10, 36, 474, 20);151 panelFileEquals.add(textField TestFile);152 textField TestFile.setColumns(10);152 textFieldActualFile = new JTextField(); 153 textFieldActualFile.setBounds(10, 36, 474, 20); 154 panelFileEquals.add(textFieldActualFile); 155 textFieldActualFile.setColumns(10); 153 156 154 157 JButton btnNewButton = new JButton("Search file"); … … 156 159 public void mouseClicked(MouseEvent arg0) { 157 160 final JFileChooser fc = new JFileChooser(); 158 if(fc.showOpenDialog(contentPanel) == 0) { textField MatchingFile.setText(fc.getSelectedFile().getAbsolutePath()); }161 if(fc.showOpenDialog(contentPanel) == 0) { textFieldExpectedFile.setText(fc.getSelectedFile().getAbsolutePath()); } 159 162 } 160 163 }); … … 162 165 panelFileEquals.add(btnNewButton); 163 166 164 JLabel lblNewLabel_1 = new JLabel(" Matchingfile:");167 JLabel lblNewLabel_1 = new JLabel("Expected file:"); 165 168 lblNewLabel_1.setBounds(10, 84, 89, 14); 166 169 panelFileEquals.add(lblNewLabel_1); 167 170 168 textField MatchingFile = new JTextField();169 textField MatchingFile.setColumns(10);170 textField MatchingFile.setBounds(10, 109, 474, 20);171 panelFileEquals.add(textField MatchingFile);171 textFieldExpectedFile = new JTextField(); 172 textFieldExpectedFile.setColumns(10); 173 textFieldExpectedFile.setBounds(10, 109, 474, 20); 174 panelFileEquals.add(textFieldExpectedFile); 172 175 { 173 176 JPanel buttonPane = new JPanel(); … … 182 185 //FileEquals 183 186 if(panelFileEquals.isVisible()) { 184 if(! new File(textFieldTestFile.getText()).exists()) { 185 if(textFieldTestFile.getText().length() == 0) JOptionPane.showMessageDialog(null, "Please choose a test file.", "No test file chosen", JOptionPane.OK_OPTION); 186 else JOptionPane.showMessageDialog(null, "The test file \"" + textFieldTestFile.getText() + "\" does not exist.", "Test file does not exist", JOptionPane.OK_OPTION); 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); 187 191 return; 188 192 } 189 else if(! new File(textFieldMatchingFile.getText()).exists()) {190 if(textFieldMatchingFile.getText().length() == 0) JOptionPane.showMessageDialog(null, "Please choose a matching file.", "No matching file chosen", JOptionPane.OK_OPTION);191 else JOptionPane.showMessageDialog(null, "The matching file \"" + textFieldTestFile.getText() + "\" does not exist.", "Matching file does not exist", JOptionPane.OK_OPTION);192 return;193 }194 193 else { 195 Event<?> e = new Event("FileEquals"); 194 FileEqualsReplay file = new FileEqualsReplay(); 195 file.setActualFile(textFieldActualFile.getText()); 196 file.setExpectedFile(textFieldExpectedFile.getText()); 197 198 AssertEvent<FileEqualsReplay> e = new AssertEvent<FileEqualsReplay>("FileEquals"); 199 e.addReplayEvent(file); 196 200 e.setTarget(" "); 197 201 if(insertBefore) sequences.add(selectedIndex, e); … … 205 209 return; 206 210 } 211 else if(listTargets.getSelectedIndex() == -1) { 212 JOptionPane.showMessageDialog(null, "Please select a target.", "No target selected", JOptionPane.OK_OPTION); 213 return; 214 } 207 215 else { 208 Event<?> e = new Event("TextEquals"); 216 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"); 221 e.addReplayEvent(text); 209 222 e.setTarget(" "); 210 223 if(insertBefore) sequences.add(selectedIndex, e);
Note: See TracChangeset
for help on using the changeset viewer.