Changeset 155 for trunk/EventBenchConsole/src/de/ugoe/cs/eventbench
- Timestamp:
- 08/14/11 19:27:53 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/swing/DlgInsert.java
r144 r155 2 2 3 3 import java.awt.BorderLayout; 4 import java. awt.FlowLayout;4 import java.util.ArrayList; 5 5 import java.util.List; 6 6 … … 29 29 import javax.swing.JScrollPane; 30 30 import javax.swing.JList; 31 import javax.swing.border.EtchedBorder; 32 import javax.swing.JTree; 33 import javax.swing.tree.DefaultTreeModel; 34 import javax.swing.tree.DefaultMutableTreeNode; 31 35 32 36 public class DlgInsert extends JDialog { … … 70 74 71 75 setModal(true); 72 setBounds(100, 100, 5 22, 482);76 setBounds(100, 100, 530, 631); 73 77 getContentPane().setLayout(new BorderLayout()); 74 78 contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); … … 77 81 final JComboBox comboBoxTestcase = new JComboBox(); 78 82 final JPanel panelTextEquals = new JPanel(); 83 panelTextEquals.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); 79 84 final JPanel panelFileEquals = new JPanel(); 85 panelFileEquals.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); 80 86 81 87 // JComboBox: comboBoxTestcase … … 100 106 "TextEquals", "OutputFileEquals" })); 101 107 comboBoxTestcase.setSelectedIndex(0); 102 comboBoxTestcase.setBounds( 128, 11, 178, 20);108 comboBoxTestcase.setBounds(91, 11, 178, 20); 103 109 contentPanel.add(comboBoxTestcase); 104 110 // *** … … 106 112 // JLabel 107 113 JLabel label = new JLabel("Testcase:"); 108 label.setBounds(1 0, 14, 86, 14);114 label.setBounds(12, 14, 86, 14); 109 115 contentPanel.add(label); 110 116 111 117 JLabel label_1 = new JLabel("Expected value:"); 112 label_1.setBounds(10, 11, 83, 14);118 label_1.setBounds(10, 11, 96, 14); 113 119 114 120 JLabel label_2 = new JLabel("Target:"); … … 124 130 // JPanel: panel 125 131 panelTextEquals.setLayout(null); 126 panelTextEquals.setBounds(10, 39, 494, 210);132 panelTextEquals.setBounds(10, 39, 494, 350); 127 133 contentPanel.add(panelTextEquals); 128 134 panelTextEquals.add(label_1); … … 131 137 132 138 JScrollPane scrollPane = new JScrollPane(); 133 scrollPane.setBounds( 116, 36, 368, 163);139 scrollPane.setBounds(421, 36, 63, 14); 134 140 panelTextEquals.add(scrollPane); 135 141 136 final JList listTargets = new JList(modelListTargets); 142 final JList listTargets = new JList(modelListTargets); 137 143 scrollPane.setViewportView(listTargets); 138 139 List<String> targets = null;140 144 141 if (GlobalDataContainer.getInstance().getData("ListTargets") == null) { 142 Console.println("There were no Targets found in the GlobalDataContainer"); 143 } else { 144 try { 145 targets = (List<String>) GlobalDataContainer.getInstance() 146 .getData("ListTargets"); 147 } catch (ClassCastException e) { 148 Console.println("Not able to cast Data in GlobalDataContainer to List of Targets (String)"); 149 } 150 151 for (int i = 0; i < targets.size(); i++) { 152 modelListTargets.addElement(targets.get(i).toString()); 153 } 154 } 145 JScrollPane scrollPane_1 = new JScrollPane(); 146 scrollPane_1.setBounds(10, 63, 474, 276); 147 panelTextEquals.add(scrollPane_1); 148 149 //JTree to hold the targets 150 JTree tree = new JTree(); 151 tree.setModel(new DefaultTreeModel( 152 new DefaultMutableTreeNode("Targets") { 153 { 154 List<DefaultMutableTreeNode> nodes = new ArrayList<DefaultMutableTreeNode>(); 155 List<String> listTargets = new ArrayList<String>(); 156 List<String> sortedTargets = new ArrayList<String>(); 157 158 try { 159 listTargets = (List<String>) GlobalDataContainer.getInstance().getData("ListTargets"); 160 } 161 catch (ClassCastException e) { 162 Console.println("Not able to cast data in GlobalDataContainer to List of Strings"); 163 } 164 165 int parts = 1; 166 while(sortedTargets.size() < listTargets.size()) { 167 for(int i=0; i<listTargets.size(); i++) { 168 String splitted[] = listTargets.get(i).split("/>"); 169 if(splitted.length == parts) { 170 sortedTargets.add(listTargets.get(i)); 171 modelListTargets.addElement(listTargets.get(i)); 172 173 //insert in tree 174 boolean inserted = false; 175 for(int j=parts-2; j>=0 && !inserted; j--) { 176 splitted[j] = splitted[j] + "/>"; 177 for(int k=0; k<nodes.size(); k++) { 178 if(nodes.get(k).toString().compareTo(splitted[j]) == 0) { 179 DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(splitted[j+1]); 180 nodes.add(newNode); 181 nodes.get(k).add(newNode); 182 inserted = true; 183 break; 184 } 185 } 186 } 187 188 if(!inserted) { 189 DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(listTargets.get(i).toString()); 190 nodes.add(newNode); 191 add(newNode); 192 } 193 } 194 } 195 196 parts++; 197 } 198 } 199 } 200 )); 201 scrollPane_1.setViewportView(tree); 202 155 203 156 204 if (listTargets.getComponentCount() > 0) 157 205 listTargets.setSelectedIndex(0); 158 206 159 panelFileEquals.setBounds(1 0, 260, 494, 140);207 panelFileEquals.setBounds(12, 400, 494, 120); 160 208 contentPanel.add(panelFileEquals); 161 209 panelFileEquals.setLayout(null); … … 167 215 168 216 textFieldActualFile = new JTextField(); 169 textFieldActualFile.setBounds(10, 3 6, 474, 20);217 textFieldActualFile.setBounds(10, 30, 474, 20); 170 218 panelFileEquals.add(textFieldActualFile); 171 219 textFieldActualFile.setColumns(10); … … 181 229 } 182 230 }); 183 btnNewButton.setBounds(9 9, 80, 89, 23);231 btnNewButton.setBounds(93, 61, 89, 23); 184 232 panelFileEquals.add(btnNewButton); 185 233 186 234 JLabel lblNewLabel_1 = new JLabel("Expected file:"); 187 lblNewLabel_1.setBounds(10, 84, 89, 14);235 lblNewLabel_1.setBounds(10, 70, 89, 14); 188 236 panelFileEquals.add(lblNewLabel_1); 189 237 190 238 textFieldExpectedFile = new JTextField(); 191 239 textFieldExpectedFile.setColumns(10); 192 textFieldExpectedFile.setBounds(10, 109, 474, 20);240 textFieldExpectedFile.setBounds(10, 88, 474, 20); 193 241 panelFileEquals.add(textFieldExpectedFile); 194 242 { 195 243 JPanel buttonPane = new JPanel(); 196 buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); 197 getContentPane().add(buttonPane, BorderLayout.SOUTH); 244 buttonPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); 245 buttonPane.setBounds(12, 531, 494, 51); 246 contentPanel.add(buttonPane); 198 247 { 199 248 // JButton: okButton 200 249 JButton okButton = new JButton("Insert"); 250 okButton.setBounds(349, 11, 135, 31); 201 251 okButton.addMouseListener(new MouseAdapter() { 202 252 public void mouseClicked(MouseEvent arg0) { … … 281 331 } 282 332 }); 333 buttonPane.setLayout(null); 283 334 okButton.setActionCommand("OK"); 284 335 buttonPane.add(okButton); … … 290 341 // JButton: cancelButton 291 342 JButton cancelButton = new JButton("Cancel"); 343 cancelButton.setBounds(10, 11, 135, 31); 292 344 cancelButton.addMouseListener(new MouseAdapter() { 293 345
Note: See TracChangeset
for help on using the changeset viewer.