1 |
mojays |
2 |
package appl.parallel.plugin.event; |
2 |
|
|
|
3 |
|
|
import javax.swing.SwingUtilities; |
4 |
|
|
import java.awt.BorderLayout; |
5 |
|
|
import javax.swing.JPanel; |
6 |
|
|
import javax.swing.JFrame; |
7 |
|
|
import javax.swing.JScrollPane; |
8 |
|
|
import javax.swing.JTable; |
9 |
|
|
import javax.swing.JToggleButton; |
10 |
|
|
import java.awt.GridBagLayout; |
11 |
|
|
import java.awt.GridBagConstraints; |
12 |
|
|
import javax.swing.JCheckBox; |
13 |
|
|
import javax.swing.BoxLayout; |
14 |
|
|
|
15 |
|
|
import edu.bonn.xulu.gui.XuluInternalFrame; |
16 |
|
|
|
17 |
|
|
import java.awt.FlowLayout; |
18 |
|
|
import java.awt.GridLayout; |
19 |
|
|
import javax.swing.JTabbedPane; |
20 |
|
|
import java.awt.Dimension; |
21 |
|
|
import java.awt.Button; |
22 |
|
|
import java.awt.CardLayout; |
23 |
|
|
import javax.swing.JLabel; |
24 |
|
|
import java.awt.Insets; |
25 |
|
|
import javax.swing.JTextPane; |
26 |
|
|
import javax.swing.text.html.HTMLDocument; |
27 |
|
|
import javax.swing.text.DefaultStyledDocument; |
28 |
|
|
|
29 |
|
|
/** |
30 |
|
|
* Provides a GUI for the {@link SimpleCommEventMonitorEngine} |
31 |
|
|
* |
32 |
|
|
* @author Dominik Appl |
33 |
|
|
*/ |
34 |
|
|
public class SimpleCommEventMonitor extends XuluInternalFrame { |
35 |
|
|
|
36 |
|
|
private static final long serialVersionUID = 1L; |
37 |
|
|
|
38 |
|
|
JPanel jContentPane = null; |
39 |
|
|
|
40 |
|
|
JScrollPane jScrollPane = null; |
41 |
|
|
|
42 |
|
|
JTable timeEventTable = null; |
43 |
|
|
|
44 |
|
|
JPanel optionsPanel = null; |
45 |
|
|
|
46 |
|
|
JCheckBox timeEventEnabled = null; |
47 |
|
|
|
48 |
|
|
JCheckBox transferEventEnabled = null; |
49 |
|
|
|
50 |
|
|
SimpleCommEventMonitorEngine engine; |
51 |
|
|
|
52 |
|
|
JTabbedPane jTabbedPane = null; |
53 |
|
|
|
54 |
|
|
Button clearButton = null; |
55 |
|
|
|
56 |
|
|
JScrollPane jScrollPane1 = null; |
57 |
|
|
|
58 |
|
|
JTable transferEventTable = null; |
59 |
|
|
|
60 |
|
|
private JTextPane jTextPane = null; |
61 |
|
|
|
62 |
|
|
/** |
63 |
|
|
* This method initializes jScrollPane |
64 |
|
|
* |
65 |
|
|
* @return javax.swing.JScrollPane |
66 |
|
|
*/ |
67 |
|
|
private JScrollPane getJScrollPane() { |
68 |
|
|
if (jScrollPane == null) { |
69 |
|
|
jScrollPane = new JScrollPane(); |
70 |
|
|
jScrollPane.setViewportView(getTimeEventTable()); |
71 |
|
|
} |
72 |
|
|
return jScrollPane; |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
/** |
76 |
|
|
* This method initializes timeEventTable |
77 |
|
|
* |
78 |
|
|
* @return javax.swing.JTable |
79 |
|
|
*/ |
80 |
|
|
private JTable getTimeEventTable() { |
81 |
|
|
if (timeEventTable == null) { |
82 |
|
|
timeEventTable = new JTable(); |
83 |
|
|
timeEventTable.setDoubleBuffered(true); |
84 |
|
|
} |
85 |
|
|
return timeEventTable; |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
/** |
89 |
|
|
* This method initializes optionsPanel |
90 |
|
|
* |
91 |
|
|
* @return javax.swing.JPanel |
92 |
|
|
*/ |
93 |
|
|
private JPanel getOptionsPanel() { |
94 |
|
|
if (optionsPanel == null) { |
95 |
|
|
GridBagConstraints gridBagConstraints8 = new GridBagConstraints(); |
96 |
|
|
gridBagConstraints8.fill = GridBagConstraints.BOTH; |
97 |
|
|
gridBagConstraints8.gridy = 0; |
98 |
|
|
gridBagConstraints8.weightx = 1.0; |
99 |
|
|
gridBagConstraints8.weighty = 0.0; |
100 |
|
|
gridBagConstraints8.gridwidth = 1; |
101 |
|
|
gridBagConstraints8.gridheight = 1; |
102 |
|
|
gridBagConstraints8.anchor = GridBagConstraints.EAST; |
103 |
|
|
gridBagConstraints8.insets = new Insets(0, 0, 0, 0); |
104 |
|
|
gridBagConstraints8.ipadx = 1; |
105 |
|
|
gridBagConstraints8.ipady = 0; |
106 |
|
|
gridBagConstraints8.gridx = 9; |
107 |
|
|
GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); |
108 |
|
|
gridBagConstraints6.insets = new Insets(5, 5, 5, 5); |
109 |
|
|
gridBagConstraints6.gridy = 0; |
110 |
|
|
gridBagConstraints6.anchor = GridBagConstraints.WEST; |
111 |
|
|
gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL; |
112 |
|
|
gridBagConstraints6.gridx = 8; |
113 |
|
|
GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); |
114 |
|
|
gridBagConstraints5.insets = new Insets(5, 5, 5, 2); |
115 |
|
|
gridBagConstraints5.gridy = 0; |
116 |
|
|
gridBagConstraints5.anchor = GridBagConstraints.WEST; |
117 |
|
|
gridBagConstraints5.fill = GridBagConstraints.NONE; |
118 |
|
|
gridBagConstraints5.gridwidth = 1; |
119 |
|
|
gridBagConstraints5.gridx = 7; |
120 |
|
|
GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
121 |
|
|
gridBagConstraints4.insets = new Insets(5, 5, 5, 5); |
122 |
|
|
gridBagConstraints4.gridy = 0; |
123 |
|
|
gridBagConstraints4.anchor = GridBagConstraints.WEST; |
124 |
|
|
gridBagConstraints4.gridwidth = 1; |
125 |
|
|
gridBagConstraints4.gridheight = 1; |
126 |
|
|
gridBagConstraints4.gridx = 1; |
127 |
|
|
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
128 |
|
|
gridBagConstraints.gridx = 0; |
129 |
|
|
gridBagConstraints.gridy = 0; |
130 |
|
|
optionsPanel = new JPanel(); |
131 |
|
|
optionsPanel.setLayout(new GridBagLayout()); |
132 |
|
|
optionsPanel.add(getTimeEventEnabled(), gridBagConstraints4); |
133 |
|
|
optionsPanel.add(getTransferEventEnabled(), gridBagConstraints5); |
134 |
|
|
optionsPanel.add(getClearButton(), gridBagConstraints6); |
135 |
|
|
optionsPanel.add(getJTextPane(), gridBagConstraints8); |
136 |
|
|
} |
137 |
|
|
return optionsPanel; |
138 |
|
|
} |
139 |
|
|
|
140 |
|
|
/** |
141 |
|
|
* This method initializes timeEventEnabled |
142 |
|
|
* |
143 |
|
|
* @return javax.swing.JCheckBox |
144 |
|
|
*/ |
145 |
|
|
private JCheckBox getTimeEventEnabled() { |
146 |
|
|
if (timeEventEnabled == null) { |
147 |
|
|
timeEventEnabled = new JCheckBox(); |
148 |
|
|
timeEventEnabled.setText("log time events"); |
149 |
|
|
timeEventEnabled.setName("timeEventEnabled"); |
150 |
|
|
timeEventEnabled.addActionListener(engine); |
151 |
|
|
} |
152 |
|
|
return timeEventEnabled; |
153 |
|
|
} |
154 |
|
|
|
155 |
|
|
/** |
156 |
|
|
* This method initializes transferEventEnabled |
157 |
|
|
* |
158 |
|
|
* @return javax.swing.JCheckBox |
159 |
|
|
*/ |
160 |
|
|
private JCheckBox getTransferEventEnabled() { |
161 |
|
|
if (transferEventEnabled == null) { |
162 |
|
|
transferEventEnabled = new JCheckBox(); |
163 |
|
|
transferEventEnabled.setText("log transferEvents"); |
164 |
|
|
transferEventEnabled.setName("transferEventEnabled"); |
165 |
|
|
transferEventEnabled.addActionListener(engine); |
166 |
|
|
} |
167 |
|
|
return transferEventEnabled; |
168 |
|
|
} |
169 |
|
|
|
170 |
|
|
/** |
171 |
|
|
* This is the default constructor |
172 |
|
|
* @param engine the engine responsible for event handling |
173 |
|
|
*/ |
174 |
|
|
public SimpleCommEventMonitor(SimpleCommEventMonitorEngine engine) { |
175 |
|
|
super("Simple Communication Event Monitor"); |
176 |
|
|
this.setClosable(true); |
177 |
|
|
this.setDefaultCloseOperation(HIDE_ON_CLOSE); |
178 |
|
|
this.engine = engine; |
179 |
|
|
initialize(); |
180 |
|
|
} |
181 |
|
|
|
182 |
|
|
/** |
183 |
|
|
* This method initializes this class |
184 |
|
|
* |
185 |
|
|
*/ |
186 |
|
|
private void initialize() { |
187 |
|
|
this.setSize(608, 326); |
188 |
|
|
this.setContentPane(getJContentPane()); |
189 |
|
|
this.setTitle("Communication Monitor"); |
190 |
|
|
} |
191 |
|
|
|
192 |
|
|
/** |
193 |
|
|
* This method initializes jContentPane |
194 |
|
|
* |
195 |
|
|
* @return javax.swing.JPanel |
196 |
|
|
*/ |
197 |
|
|
private JPanel getJContentPane() { |
198 |
|
|
if (jContentPane == null) { |
199 |
|
|
jContentPane = new JPanel(); |
200 |
|
|
jContentPane.setLayout(new BoxLayout(getJContentPane(), |
201 |
|
|
BoxLayout.Y_AXIS)); |
202 |
|
|
jContentPane.add(getJTabbedPane(), null); |
203 |
|
|
jContentPane.add(getOptionsPanel(), null); |
204 |
|
|
} |
205 |
|
|
return jContentPane; |
206 |
|
|
} |
207 |
|
|
|
208 |
|
|
/* (non-Javadoc) |
209 |
|
|
* @see edu.bonn.xulu.gui.XuluInternalFrame#refresh() |
210 |
|
|
*/ |
211 |
|
|
@Override |
212 |
|
|
public void refresh() { |
213 |
|
|
// TODO Auto-generated method stub |
214 |
|
|
|
215 |
|
|
} |
216 |
|
|
|
217 |
|
|
/** |
218 |
|
|
* This method initializes jTabbedPane |
219 |
|
|
* |
220 |
|
|
* @return javax.swing.JTabbedPane |
221 |
|
|
*/ |
222 |
|
|
private JTabbedPane getJTabbedPane() { |
223 |
|
|
if (jTabbedPane == null) { |
224 |
|
|
jTabbedPane = new JTabbedPane(); |
225 |
|
|
jTabbedPane.addTab("Time Events", null, getJScrollPane(), null); |
226 |
|
|
jTabbedPane |
227 |
|
|
.addTab("Transfer Events", null, getJScrollPane1(), null); |
228 |
|
|
} |
229 |
|
|
return jTabbedPane; |
230 |
|
|
} |
231 |
|
|
|
232 |
|
|
/** |
233 |
|
|
* This method initializes clearButton |
234 |
|
|
* |
235 |
|
|
* @return java.awt.Button |
236 |
|
|
*/ |
237 |
|
|
private Button getClearButton() { |
238 |
|
|
if (clearButton == null) { |
239 |
|
|
clearButton = new Button(); |
240 |
|
|
clearButton.setLabel("Clear all"); |
241 |
|
|
clearButton.setMinimumSize(new Dimension(100, 20)); |
242 |
|
|
clearButton.setName("clearButton"); |
243 |
|
|
clearButton.addActionListener(engine); |
244 |
|
|
} |
245 |
|
|
return clearButton; |
246 |
|
|
} |
247 |
|
|
|
248 |
|
|
/** |
249 |
|
|
* This method initializes jScrollPane1 |
250 |
|
|
* |
251 |
|
|
* @return javax.swing.JScrollPane |
252 |
|
|
*/ |
253 |
|
|
private JScrollPane getJScrollPane1() { |
254 |
|
|
if (jScrollPane1 == null) { |
255 |
|
|
jScrollPane1 = new JScrollPane(); |
256 |
|
|
jScrollPane1.setViewportView(getTransferEventTable()); |
257 |
|
|
} |
258 |
|
|
return jScrollPane1; |
259 |
|
|
} |
260 |
|
|
|
261 |
|
|
/** |
262 |
|
|
* This method initializes transferEventTable |
263 |
|
|
* |
264 |
|
|
* @return javax.swing.JTable |
265 |
|
|
*/ |
266 |
|
|
private JTable getTransferEventTable() { |
267 |
|
|
if (transferEventTable == null) { |
268 |
|
|
transferEventTable = new JTable(); |
269 |
|
|
transferEventTable.setDoubleBuffered(true); |
270 |
|
|
} |
271 |
|
|
return transferEventTable; |
272 |
|
|
} |
273 |
|
|
|
274 |
|
|
/** |
275 |
|
|
* This method initializes jTextPane |
276 |
|
|
* |
277 |
|
|
* @return javax.swing.JTextPane |
278 |
|
|
*/ |
279 |
|
|
private JTextPane getJTextPane() { |
280 |
|
|
if (jTextPane == null) { |
281 |
|
|
jTextPane = new JTextPane(); |
282 |
|
|
jTextPane |
283 |
|
|
.setText("Hint: Hold CTRL while clicking on a table header for secondary sorting"); |
284 |
|
|
jTextPane.setMaximumSize(new Dimension(100, 50)); |
285 |
|
|
} |
286 |
|
|
return jTextPane; |
287 |
|
|
} |
288 |
|
|
|
289 |
|
|
} // @jve:decl-index=0:visual-constraint="10,10" |