- Timestamp:
- 07/29/11 14:33:59 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.