Lines 15-22
Link Here
|
15 |
import java.io.PrintWriter; |
15 |
import java.io.PrintWriter; |
16 |
import java.io.StringWriter; |
16 |
import java.io.StringWriter; |
17 |
import java.text.Collator; |
17 |
import java.text.Collator; |
|
|
18 |
import java.util.ArrayList; |
18 |
import java.util.Arrays; |
19 |
import java.util.Arrays; |
19 |
import java.util.Collections; |
|
|
20 |
import java.util.Comparator; |
20 |
import java.util.Comparator; |
21 |
import java.util.Date; |
21 |
import java.util.Date; |
22 |
import java.util.List; |
22 |
import java.util.List; |
Lines 29-34
Link Here
|
29 |
import org.eclipse.jface.viewers.ISelection; |
29 |
import org.eclipse.jface.viewers.ISelection; |
30 |
import org.eclipse.jface.viewers.ISelectionProvider; |
30 |
import org.eclipse.jface.viewers.ISelectionProvider; |
31 |
import org.eclipse.jface.viewers.IStructuredSelection; |
31 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
|
32 |
import org.eclipse.jface.viewers.ITreeContentProvider; |
32 |
import org.eclipse.jface.viewers.StructuredSelection; |
33 |
import org.eclipse.jface.viewers.StructuredSelection; |
33 |
import org.eclipse.jface.viewers.TreeViewer; |
34 |
import org.eclipse.jface.viewers.TreeViewer; |
34 |
import org.eclipse.swt.SWT; |
35 |
import org.eclipse.swt.SWT; |
Lines 49-60
Link Here
|
49 |
import org.eclipse.ui.PlatformUI; |
50 |
import org.eclipse.ui.PlatformUI; |
50 |
|
51 |
|
51 |
public class EventDetailsDialog extends TrayDialog { |
52 |
public class EventDetailsDialog extends TrayDialog { |
52 |
private LogEntry entry, parentEntry; |
53 |
private AbstractEntry entry; |
|
|
54 |
private AbstractEntry parentEntry; // parent of the entry |
55 |
private AbstractEntry[] entryChildren; // children of the entry |
56 |
|
53 |
private LogViewLabelProvider labelProvider; |
57 |
private LogViewLabelProvider labelProvider; |
54 |
private static int COPY_ID = 22; |
|
|
55 |
private TreeViewer provider; |
58 |
private TreeViewer provider; |
56 |
private int elementNum, totalElementCount; |
59 |
|
57 |
private LogEntry[] entryChildren; |
60 |
private static int COPY_ID = 22; |
|
|
61 |
|
62 |
private int elementNum; // number of selected element |
63 |
private int totalElementCount; // number of all elements |
64 |
|
58 |
private int childIndex = 0; |
65 |
private int childIndex = 0; |
59 |
private boolean isOpen; |
66 |
private boolean isOpen; |
60 |
private boolean isLastChild; |
67 |
private boolean isLastChild; |
Lines 93-99
Link Here
|
93 |
this.provider = (TreeViewer) provider; |
100 |
this.provider = (TreeViewer) provider; |
94 |
labelProvider = (LogViewLabelProvider)this.provider.getLabelProvider(); |
101 |
labelProvider = (LogViewLabelProvider)this.provider.getLabelProvider(); |
95 |
labelProvider.connect(this); |
102 |
labelProvider.connect(this); |
96 |
this.entry = (LogEntry)selection; |
103 |
this.entry = (AbstractEntry)selection; |
97 |
this.comparator = comparator; |
104 |
this.comparator = comparator; |
98 |
setShellStyle(SWT.MODELESS | SWT.MIN | SWT.MAX | SWT.RESIZE | SWT.CLOSE | SWT.BORDER | SWT.TITLE); |
105 |
setShellStyle(SWT.MODELESS | SWT.MIN | SWT.MAX | SWT.RESIZE | SWT.CLOSE | SWT.BORDER | SWT.TITLE); |
99 |
clipboard = new Clipboard(parentShell.getDisplay()); |
106 |
clipboard = new Clipboard(parentShell.getDisplay()); |
Lines 107-150
Link Here
|
107 |
private void initialize() { |
114 |
private void initialize() { |
108 |
elementNum = getParentElementNum(); |
115 |
elementNum = getParentElementNum(); |
109 |
resetTotalElementCount(); |
116 |
resetTotalElementCount(); |
110 |
parentEntry = (LogEntry) entry.getParent(entry); |
117 |
parentEntry = (AbstractEntry) entry.getParent(entry); |
111 |
if (isChild(entry)){ |
118 |
if (isChild(entry)){ |
112 |
setEntryChildren(parentEntry); |
119 |
setEntryChildren(parentEntry); |
113 |
resetChildIndex(); |
120 |
resetChildIndex(); |
|
|
121 |
} else { |
122 |
setEntryChildren(); |
114 |
} |
123 |
} |
115 |
isLastChild = false; |
124 |
isLastChild = false; |
116 |
isAtEndOfLog = false; |
125 |
isAtEndOfLog = false; |
117 |
} |
126 |
} |
118 |
|
127 |
|
119 |
private void resetChildIndex() { |
128 |
private void resetChildIndex() { |
|
|
129 |
if (! (entry instanceof AbstractEntry)) { |
130 |
return; |
131 |
} |
132 |
|
133 |
if (entryChildren == null) |
134 |
return; |
135 |
|
136 |
LogEntry thisEntry = (LogEntry) entry; |
137 |
|
120 |
for (int i = 0; i < entryChildren.length; i++) { |
138 |
for (int i = 0; i < entryChildren.length; i++) { |
121 |
if (equal(entryChildren[i].getMessage(), entry.getMessage()) |
139 |
if (entryChildren[i] instanceof LogEntry) { |
122 |
&& equal(entryChildren[i].getDate(), entry.getDate()) |
140 |
|
123 |
&& equal(entryChildren[i].getPluginId(), entry |
141 |
LogEntry logEntry = (LogEntry) entryChildren[i]; |
124 |
.getPluginId()) |
142 |
|
125 |
&& entryChildren[i].getSeverity() == entry.getSeverity() |
143 |
if (logEntry == thisEntry) { |
126 |
&& equal(entryChildren[i].getSeverityText(), entry |
144 |
childIndex = i; |
127 |
.getSeverityText())) { |
145 |
return; |
128 |
childIndex = i; |
146 |
} |
129 |
break; |
|
|
130 |
} |
147 |
} |
131 |
} |
148 |
} |
132 |
} |
149 |
} |
133 |
|
150 |
|
134 |
private boolean equal(String str1, String str2) { |
151 |
private boolean isChild(AbstractEntry entry) { |
135 |
if (str1 == null) { |
|
|
136 |
return str1 == str2; |
137 |
} |
138 |
return str1.equals(str2); |
139 |
} |
140 |
|
141 |
private boolean equal(Date d1, Date d2) { |
142 |
if (d1 == null) |
143 |
return d1 == d2; |
144 |
return d1.equals(d2); |
145 |
} |
146 |
|
147 |
private boolean isChild(LogEntry entry) { |
148 |
return entry.getParent(entry) != null; |
152 |
return entry.getParent(entry) != null; |
149 |
} |
153 |
} |
150 |
|
154 |
|
Lines 212-223
Link Here
|
212 |
} |
216 |
} |
213 |
childIndex--; |
217 |
childIndex--; |
214 |
entry = entryChildren[childIndex]; |
218 |
entry = entryChildren[childIndex]; |
215 |
} else |
219 |
} else { |
216 |
entry = parentEntry; |
220 |
if (parentEntry instanceof LogEntry) { |
|
|
221 |
entry = parentEntry; |
222 |
if (isChild(entry)) { |
223 |
setEntryChildren((AbstractEntry)entry.getParent(entry)); |
224 |
} else { |
225 |
setEntryChildren(); |
226 |
} |
227 |
} |
228 |
} |
217 |
} else { |
229 |
} else { |
218 |
if (elementNum - 1 >= 0) |
230 |
if ((elementNum - 1 >= 0) && (entryChildren[elementNum-1] instanceof LogEntry)) { |
219 |
elementNum -= 1; |
231 |
elementNum -= 1; |
220 |
entry = entryChildren[elementNum]; |
232 |
entry = entryChildren[elementNum]; |
|
|
233 |
} |
221 |
} |
234 |
} |
222 |
setEntrySelectionInTable(); |
235 |
setEntrySelectionInTable(); |
223 |
} |
236 |
} |
Lines 229-246
Link Here
|
229 |
isLastChild = childIndex == entryChildren.length - 1; |
242 |
isLastChild = childIndex == entryChildren.length - 1; |
230 |
} else if (isChild(entry) && isLastChild && !isAtEndOfLog){ |
243 |
} else if (isChild(entry) && isLastChild && !isAtEndOfLog){ |
231 |
findNextSelectedChild(entry); |
244 |
findNextSelectedChild(entry); |
232 |
} else if (elementNum + 1 < totalElementCount){ |
245 |
} else if (elementNum + 1 < totalElementCount){ // at end of element, go to next element |
233 |
if (isLastChild){ |
246 |
if (isLastChild){ |
234 |
setEntryChildren(); |
247 |
setEntryChildren(); |
235 |
isLastChild = false; |
248 |
isLastChild = false; |
236 |
} |
249 |
} |
237 |
elementNum += 1; |
250 |
|
238 |
entry = entryChildren[elementNum]; |
251 |
if (entryChildren[elementNum+1] instanceof LogEntry) { |
|
|
252 |
elementNum += 1; |
253 |
entry = entryChildren[elementNum]; |
254 |
} |
239 |
} else { // at end of list but can branch into child elements - bug 58083 |
255 |
} else { // at end of list but can branch into child elements - bug 58083 |
240 |
setEntryChildren(entry); |
256 |
if (entry.hasChildren()) { |
241 |
entry = entryChildren[0]; |
257 |
setEntryChildren(entry); |
242 |
isAtEndOfLog = entryChildren.length == 0; |
258 |
entry = entryChildren[0]; |
243 |
isLastChild = entryChildren.length == 0; |
259 |
isAtEndOfLog = entryChildren.length == 0; |
|
|
260 |
isLastChild = entryChildren.length == 0; |
261 |
} |
244 |
} |
262 |
} |
245 |
setEntrySelectionInTable(); |
263 |
setEntrySelectionInTable(); |
246 |
} |
264 |
} |
Lines 306-313
Link Here
|
306 |
updateProperties(); |
324 |
updateProperties(); |
307 |
return; |
325 |
return; |
308 |
} |
326 |
} |
309 |
if (selectedEntry instanceof LogEntry) { |
327 |
if (selectedEntry instanceof AbstractEntry) { |
310 |
entry = (LogEntry)selectedEntry; |
328 |
entry = (AbstractEntry)selectedEntry; |
311 |
initialize(); |
329 |
initialize(); |
312 |
updateProperties(); |
330 |
updateProperties(); |
313 |
} |
331 |
} |
Lines 325-331
Link Here
|
325 |
|
343 |
|
326 |
public void updateProperties() { |
344 |
public void updateProperties() { |
327 |
if (isChild(entry)){ |
345 |
if (isChild(entry)){ |
328 |
parentEntry = (LogEntry) entry.getParent(entry); |
346 |
parentEntry = (AbstractEntry) entry.getParent(entry); |
329 |
setEntryChildren(parentEntry); |
347 |
setEntryChildren(parentEntry); |
330 |
resetChildIndex(); |
348 |
resetChildIndex(); |
331 |
if (childIndex == entryChildren.length - 1) |
349 |
if (childIndex == entryChildren.length - 1) |
Lines 334-354
Link Here
|
334 |
|
352 |
|
335 |
resetTotalElementCount(); |
353 |
resetTotalElementCount(); |
336 |
|
354 |
|
337 |
String strDate = entry.getFormattedDate(); |
355 |
if (entry instanceof LogEntry) { |
338 |
dateLabel.setText(strDate); |
356 |
LogEntry logEntry = (LogEntry) entry; |
339 |
severityImageLabel.setImage(labelProvider.getColumnImage(entry, 0)); |
357 |
|
340 |
severityLabel.setText(entry.getSeverityText()); |
358 |
String strDate = logEntry.getFormattedDate(); |
341 |
msgText.setText(entry.getMessage() != null ? entry.getMessage() : ""); //$NON-NLS-1$ |
359 |
dateLabel.setText(strDate); |
342 |
String stack = entry.getStack(); |
360 |
severityImageLabel.setImage(labelProvider.getColumnImage(entry, 0)); |
343 |
if (stack != null) { |
361 |
severityLabel.setText(logEntry.getSeverityText()); |
344 |
stackTraceText.setText(stack); |
362 |
msgText.setText(logEntry.getMessage() != null ? logEntry.getMessage() : ""); //$NON-NLS-1$ |
|
|
363 |
String stack = logEntry.getStack(); |
364 |
if (stack != null) { |
365 |
stackTraceText.setText(stack); |
366 |
} else { |
367 |
stackTraceText.setText(Messages.EventDetailsDialog_noStack); |
368 |
} |
369 |
|
370 |
String session = logEntry.getSession().getSessionData(); |
371 |
if (stack != null) { |
372 |
sessionDataText.setText(session); |
373 |
} |
374 |
|
345 |
} else { |
375 |
} else { |
346 |
stackTraceText.setText(Messages.EventDetailsDialog_noStack); |
376 |
dateLabel.setText(""); //$NON-NLS-1$ |
|
|
377 |
severityImageLabel.setImage(null); |
378 |
severityLabel.setText(""); //$NON-NLS-1$ |
379 |
msgText.setText(""); //$NON-NLS-1$ |
380 |
stackTraceText.setText(""); //$NON-NLS-1$ |
381 |
sessionDataText.setText(""); //$NON-NLS-1$ |
347 |
} |
382 |
} |
348 |
LogSession session = entry.getSession(); |
383 |
|
349 |
if (session != null && session.getSessionData() != null) |
|
|
350 |
sessionDataText.setText(session.getSessionData()); |
351 |
|
352 |
updateButtons(); |
384 |
updateButtons(); |
353 |
} |
385 |
} |
354 |
|
386 |
|
Lines 363-377
Link Here
|
363 |
} |
395 |
} |
364 |
} |
396 |
} |
365 |
|
397 |
|
366 |
private void findNextSelectedChild(LogEntry originalEntry){ |
398 |
private void findNextSelectedChild(AbstractEntry originalEntry){ |
367 |
if (isChild (parentEntry)){ |
399 |
if (isChild (parentEntry)){ |
368 |
// we're at the end of the child list; find next parent |
400 |
// we're at the end of the child list; find next parent |
369 |
// to select. If the parent is a child at the end of the child |
401 |
// to select. If the parent is a child at the end of the child |
370 |
// list, find its next parent entry to select, etc. |
402 |
// list, find its next parent entry to select, etc. |
371 |
|
403 |
|
372 |
entry = parentEntry; |
404 |
entry = parentEntry; |
373 |
setEntryChildren((LogEntry)parentEntry.getParent(parentEntry)); |
405 |
setEntryChildren((AbstractEntry)parentEntry.getParent(parentEntry)); |
374 |
parentEntry = (LogEntry)parentEntry.getParent(parentEntry); |
406 |
parentEntry = (AbstractEntry)parentEntry.getParent(parentEntry); |
375 |
resetChildIndex(); |
407 |
resetChildIndex(); |
376 |
isLastChild = childIndex == entryChildren.length-1; |
408 |
isLastChild = childIndex == entryChildren.length-1; |
377 |
if (isLastChild){ |
409 |
if (isLastChild){ |
Lines 386-400
Link Here
|
386 |
} |
418 |
} |
387 |
} |
419 |
} |
388 |
|
420 |
|
389 |
private boolean nextChildExists(LogEntry originalEntry, LogEntry originalParent, LogEntry[] originalEntries){ |
421 |
private boolean nextChildExists(AbstractEntry originalEntry, AbstractEntry originalParent, AbstractEntry[] originalEntries){ |
390 |
if (isChild (parentEntry)){ |
422 |
if (isChild (parentEntry)){ |
391 |
// we're at the end of the child list; find next parent |
423 |
// we're at the end of the child list; find next parent |
392 |
// to select. If the parent is a child at the end of the child |
424 |
// to select. If the parent is a child at the end of the child |
393 |
// list, find its next parent entry to select, etc. |
425 |
// list, find its next parent entry to select, etc. |
394 |
|
426 |
|
395 |
entry = parentEntry; |
427 |
entry = parentEntry; |
396 |
setEntryChildren((LogEntry)parentEntry.getParent(parentEntry)); |
428 |
setEntryChildren((AbstractEntry)parentEntry.getParent(parentEntry)); |
397 |
parentEntry = (LogEntry)parentEntry.getParent(parentEntry); |
429 |
parentEntry = (AbstractEntry)parentEntry.getParent(parentEntry); |
398 |
resetChildIndex(); |
430 |
resetChildIndex(); |
399 |
if (childIndex == entryChildren.length-1){ |
431 |
if (childIndex == entryChildren.length-1){ |
400 |
nextChildExists(originalEntry, originalParent, originalEntries); |
432 |
nextChildExists(originalEntry, originalParent, originalEntries); |
Lines 413-467
Link Here
|
413 |
return false; |
445 |
return false; |
414 |
|
446 |
|
415 |
} |
447 |
} |
|
|
448 |
|
449 |
/** |
450 |
* Sets entry children (Prev-Next navigable) to top-level elements |
451 |
*/ |
416 |
private void setEntryChildren(){ |
452 |
private void setEntryChildren(){ |
417 |
Object[] children = ((LogViewContentProvider)provider.getContentProvider()).getElements(null); |
453 |
AbstractEntry[] children = getElements(); |
418 |
|
454 |
|
419 |
if (comparator != null) |
455 |
if (comparator != null) |
420 |
Arrays.sort(children, comparator); |
456 |
Arrays.sort(children, comparator); |
421 |
entryChildren = new LogEntry[children.length]; |
457 |
entryChildren = new AbstractEntry[children.length]; |
422 |
|
458 |
|
423 |
System.arraycopy(children,0,entryChildren,0,children.length); |
459 |
System.arraycopy(children,0,entryChildren,0,children.length); |
424 |
} |
460 |
} |
425 |
|
461 |
|
426 |
private void resetTotalElementCount(){ |
462 |
private void resetTotalElementCount(){ |
427 |
totalElementCount = entry.getSession().getEntries().size(); |
463 |
totalElementCount = getElements().length; |
428 |
} |
464 |
} |
429 |
|
465 |
|
430 |
private void setEntryChildren(LogEntry entry){ |
466 |
/** |
431 |
LogSession session = entry.getSession(); |
467 |
* Sets entry children (Prev-Next navigable) to children of given entry |
432 |
if (session == null) |
468 |
*/ |
433 |
return; |
469 |
private void setEntryChildren(AbstractEntry entry){ |
|
|
470 |
Object[] children = entry.getChildren(entry); |
434 |
|
471 |
|
435 |
List children = session.getEntries(); |
|
|
436 |
if (comparator != null) |
472 |
if (comparator != null) |
437 |
Collections.sort(children, comparator); |
473 |
Arrays.sort(children, comparator); |
438 |
entryChildren = (LogEntry[])children.toArray(new LogEntry[children.size()]); |
474 |
|
|
|
475 |
List result = new ArrayList(); |
476 |
for (int i = 0; i < children.length; i++) { |
477 |
if (children[i] instanceof AbstractEntry) { |
478 |
result.add(children[i]); |
479 |
} |
480 |
} |
481 |
|
482 |
entryChildren = (AbstractEntry[])result.toArray(new AbstractEntry[result.size()]); |
439 |
} |
483 |
} |
440 |
|
484 |
|
|
|
485 |
/** |
486 |
* Returns the number of top level element containing current entry. |
487 |
* @return |
488 |
*/ |
441 |
private int getParentElementNum(){ |
489 |
private int getParentElementNum(){ |
442 |
LogEntry itemEntry = (LogEntry)((IStructuredSelection)provider.getSelection()).getFirstElement(); |
490 |
AbstractEntry itemEntry = (AbstractEntry)((IStructuredSelection)provider.getSelection()).getFirstElement(); |
443 |
itemEntry = getRootEntry(itemEntry); |
491 |
AbstractEntry topParent = itemEntry; |
444 |
|
492 |
|
445 |
setEntryChildren(itemEntry); |
493 |
while (topParent.getParent(itemEntry) != null) { |
446 |
for (int i = 0; i<entryChildren.length; i++){ |
494 |
topParent = (AbstractEntry) topParent.getParent(itemEntry); |
447 |
try { |
495 |
} |
448 |
LogEntry littleEntry = entryChildren[i]; |
496 |
|
449 |
if (itemEntry.equals(littleEntry)){ |
497 |
AbstractEntry[] topElements = getElements(); |
450 |
return i; |
498 |
if (comparator != null) |
451 |
} |
499 |
Arrays.sort(topElements, comparator); |
452 |
} catch (Exception e){ |
500 |
|
453 |
|
501 |
for (int i = 0; i < topElements.length; i++ ) { |
|
|
502 |
if (topElements[i].equals(topParent)) { |
503 |
return i; |
454 |
} |
504 |
} |
455 |
} |
505 |
} |
|
|
506 |
|
456 |
return 0; |
507 |
return 0; |
457 |
} |
508 |
} |
458 |
|
509 |
|
459 |
private LogEntry getRootEntry(LogEntry entry){ |
|
|
460 |
if (!isChild(entry)) |
461 |
return entry; |
462 |
return getRootEntry((LogEntry)entry.getParent(entry)); |
463 |
} |
464 |
|
465 |
public SashForm getSashForm(){ |
510 |
public SashForm getSashForm(){ |
466 |
return sashForm; |
511 |
return sashForm; |
467 |
} |
512 |
} |
Lines 696-699
Link Here
|
696 |
s.put("sashWidth1", sashWeights[0]); //$NON-NLS-1$ |
741 |
s.put("sashWidth1", sashWeights[0]); //$NON-NLS-1$ |
697 |
s.put("sashWidth2", sashWeights[1]); //$NON-NLS-1$ |
742 |
s.put("sashWidth2", sashWeights[1]); //$NON-NLS-1$ |
698 |
} |
743 |
} |
|
|
744 |
|
745 |
/** |
746 |
* Utility method to get all top level elements of the Log View |
747 |
* @return top level elements of the Log View |
748 |
*/ |
749 |
private AbstractEntry[] getElements() { |
750 |
return (AbstractEntry[])((ITreeContentProvider)provider.getContentProvider()).getElements(null); |
751 |
} |
699 |
} |
752 |
} |