Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2007, 2009 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 27-33
Link Here
|
27 |
Shell shell; |
27 |
Shell shell; |
28 |
List list; |
28 |
List list; |
29 |
Canvas canvas; |
29 |
Canvas canvas; |
30 |
Button start, stop, check; |
30 |
Button start, stop, check, print; |
31 |
Text text; |
31 |
Text text; |
32 |
Label label; |
32 |
Label label; |
33 |
|
33 |
|
Lines 90-95
Link Here
|
90 |
start.addListener (SWT.Selection, new Listener () { |
90 |
start.addListener (SWT.Selection, new Listener () { |
91 |
public void handleEvent (Event event) { |
91 |
public void handleEvent (Event event) { |
92 |
refreshAll (); |
92 |
refreshAll (); |
|
|
93 |
if (print.getSelection()) |
94 |
exportDifference (); |
93 |
} |
95 |
} |
94 |
}); |
96 |
}); |
95 |
stop = new Button (shell, SWT.PUSH); |
97 |
stop = new Button (shell, SWT.PUSH); |
Lines 97-104
Link Here
|
97 |
stop.addListener (SWT.Selection, new Listener () { |
99 |
stop.addListener (SWT.Selection, new Listener () { |
98 |
public void handleEvent (Event event) { |
100 |
public void handleEvent (Event event) { |
99 |
refreshDifference (); |
101 |
refreshDifference (); |
|
|
102 |
if (print.getSelection()) |
103 |
exportDifference (); |
100 |
} |
104 |
} |
101 |
}); |
105 |
}); |
|
|
106 |
print = new Button (shell, SWT.CHECK); |
107 |
print.setText ("Dump to file"); |
108 |
print.setToolTipText ("Dumps Snaps/Diffs stack traces to file"); |
102 |
label = new Label (shell, SWT.BORDER); |
109 |
label = new Label (shell, SWT.BORDER); |
103 |
label.setText ("0 object(s)"); |
110 |
label.setText ("0 object(s)"); |
104 |
shell.addListener (SWT.Resize, new Listener () { |
111 |
shell.addListener (SWT.Resize, new Listener () { |
Lines 185-190
Link Here
|
185 |
layout (); |
192 |
layout (); |
186 |
} |
193 |
} |
187 |
|
194 |
|
|
|
195 |
void exportDifference () { |
196 |
File file = new File(Long.toString(System.currentTimeMillis()) + ".sleakdump"); |
197 |
PrintStream pw = null; |
198 |
try { |
199 |
pw = new PrintStream(new FileOutputStream(file)); |
200 |
} catch (FileNotFoundException e) { |
201 |
MessageBox dialog = new MessageBox (shell, SWT.ICON_WARNING | SWT.OK); |
202 |
dialog.setText (shell.getText ()); |
203 |
dialog.setMessage (e.getMessage()+" Difference will be printed to standard output."); |
204 |
dialog.open (); |
205 |
pw = System.out; |
206 |
} |
207 |
try { |
208 |
for (int i=0; i<objects.length; i++) { |
209 |
pw.println(objects [i].toString()); |
210 |
errors[i].printStackTrace(pw); |
211 |
pw.println(); |
212 |
} |
213 |
} finally { |
214 |
if (pw != null && pw != System.out) |
215 |
pw.close(); |
216 |
} |
217 |
|
218 |
MessageBox dialog = new MessageBox (shell, SWT.ICON_WARNING | SWT.OK); |
219 |
dialog.setText (shell.getText ()); |
220 |
dialog.setMessage ("Difference exported to file "+file.getAbsolutePath()); |
221 |
dialog.open (); |
222 |
} |
223 |
|
188 |
void toggleStackTrace () { |
224 |
void toggleStackTrace () { |
189 |
refreshObject (); |
225 |
refreshObject (); |
190 |
layout (); |
226 |
layout (); |
Lines 304-316
Link Here
|
304 |
Point size2 = stop.computeSize (SWT.DEFAULT, SWT.DEFAULT); |
340 |
Point size2 = stop.computeSize (SWT.DEFAULT, SWT.DEFAULT); |
305 |
Point size3 = check.computeSize (SWT.DEFAULT, SWT.DEFAULT); |
341 |
Point size3 = check.computeSize (SWT.DEFAULT, SWT.DEFAULT); |
306 |
Point size4 = label.computeSize (SWT.DEFAULT, SWT.DEFAULT); |
342 |
Point size4 = label.computeSize (SWT.DEFAULT, SWT.DEFAULT); |
307 |
width = Math.max (size1.x, Math.max (size2.x, Math.max (size3.x, width))); |
343 |
Point size5 = print.computeSize(SWT.DEFAULT, SWT.DEFAULT); |
|
|
344 |
width = Math.max (size1.x, Math.max (size2.x, Math.max (size3.x, Math.max(size5.x, width)))); |
308 |
width = Math.max (64, Math.max (size4.x, list.computeSize (width, SWT.DEFAULT).x)); |
345 |
width = Math.max (64, Math.max (size4.x, list.computeSize (width, SWT.DEFAULT).x)); |
309 |
start.setBounds (0, 0, width, size1.y); |
346 |
start.setBounds (0, 0, width, size1.y); |
310 |
stop.setBounds (0, size1.y, width, size2.y); |
347 |
stop.setBounds (0, size1.y, width, size2.y); |
311 |
check.setBounds (0, size1.y + size2.y, width, size3.y); |
348 |
print.setBounds(0, size1.y + size2.y, width, size5.y); |
|
|
349 |
check.setBounds (0, size1.y + size2.y + size5.y, width, size3.y); |
312 |
label.setBounds (0, rect.height - size4.y, width, size4.y); |
350 |
label.setBounds (0, rect.height - size4.y, width, size4.y); |
313 |
int height = size1.y + size2.y + size3.y; |
351 |
int height = size1.y + size2.y + size3.y + size5.y; |
314 |
list.setBounds (0, height, width, rect.height - height - size4.y); |
352 |
list.setBounds (0, height, width, rect.height - height - size4.y); |
315 |
text.setBounds (width, 0, rect.width - width, rect.height); |
353 |
text.setBounds (width, 0, rect.width - width, rect.height); |
316 |
canvas.setBounds (width, 0, rect.width - width, rect.height); |
354 |
canvas.setBounds (width, 0, rect.width - width, rect.height); |