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-113
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(); |
Lines 117-132
Link Here
|
117 |
} |
124 |
} |
118 |
|
125 |
|
119 |
private void resetChildIndex() { |
126 |
private void resetChildIndex() { |
|
|
127 |
if (! (entry instanceof AbstractEntry)) { |
128 |
return; |
129 |
} |
130 |
|
131 |
if (entryChildren == null) |
132 |
return; |
133 |
|
134 |
LogEntry thisEntry = (LogEntry) entry; |
135 |
|
120 |
for (int i = 0; i < entryChildren.length; i++) { |
136 |
for (int i = 0; i < entryChildren.length; i++) { |
121 |
if (equal(entryChildren[i].getMessage(), entry.getMessage()) |
137 |
if (entryChildren[i] instanceof LogEntry) { |
122 |
&& equal(entryChildren[i].getDate(), entry.getDate()) |
138 |
|
123 |
&& equal(entryChildren[i].getPluginId(), entry |
139 |
LogEntry logEntry = (LogEntry) entryChildren[i]; |
124 |
.getPluginId()) |
140 |
|
125 |
&& entryChildren[i].getSeverity() == entry.getSeverity() |
141 |
if (equal(logEntry.getMessage(), thisEntry.getMessage()) |
126 |
&& equal(entryChildren[i].getSeverityText(), entry |
142 |
&& equal(logEntry.getDate(), thisEntry.getDate()) |
127 |
.getSeverityText())) { |
143 |
&& equal(logEntry.getPluginId(), thisEntry |
128 |
childIndex = i; |
144 |
.getPluginId()) |
129 |
break; |
145 |
&& logEntry.getSeverity() == thisEntry.getSeverity() |
|
|
146 |
&& equal(logEntry.getSeverityText(), thisEntry |
147 |
.getSeverityText())) { |
148 |
childIndex = i; |
149 |
break; |
150 |
} |
130 |
} |
151 |
} |
131 |
} |
152 |
} |
132 |
} |
153 |
} |
Lines 144-150
Link Here
|
144 |
return d1.equals(d2); |
165 |
return d1.equals(d2); |
145 |
} |
166 |
} |
146 |
|
167 |
|
147 |
private boolean isChild(LogEntry entry) { |
168 |
private boolean isChild(AbstractEntry entry) { |
148 |
return entry.getParent(entry) != null; |
169 |
return entry.getParent(entry) != null; |
149 |
} |
170 |
} |
150 |
|
171 |
|
Lines 306-313
Link Here
|
306 |
updateProperties(); |
327 |
updateProperties(); |
307 |
return; |
328 |
return; |
308 |
} |
329 |
} |
309 |
if (selectedEntry instanceof LogEntry) { |
330 |
if (selectedEntry instanceof AbstractEntry) { |
310 |
entry = (LogEntry)selectedEntry; |
331 |
entry = (AbstractEntry)selectedEntry; |
311 |
initialize(); |
332 |
initialize(); |
312 |
updateProperties(); |
333 |
updateProperties(); |
313 |
} |
334 |
} |
Lines 325-331
Link Here
|
325 |
|
346 |
|
326 |
public void updateProperties() { |
347 |
public void updateProperties() { |
327 |
if (isChild(entry)){ |
348 |
if (isChild(entry)){ |
328 |
parentEntry = (LogEntry) entry.getParent(entry); |
349 |
parentEntry = (AbstractEntry) entry.getParent(entry); |
329 |
setEntryChildren(parentEntry); |
350 |
setEntryChildren(parentEntry); |
330 |
resetChildIndex(); |
351 |
resetChildIndex(); |
331 |
if (childIndex == entryChildren.length - 1) |
352 |
if (childIndex == entryChildren.length - 1) |
Lines 334-354
Link Here
|
334 |
|
355 |
|
335 |
resetTotalElementCount(); |
356 |
resetTotalElementCount(); |
336 |
|
357 |
|
337 |
String strDate = entry.getFormattedDate(); |
358 |
LogSession session = null; |
338 |
dateLabel.setText(strDate); |
359 |
|
339 |
severityImageLabel.setImage(labelProvider.getColumnImage(entry, 0)); |
360 |
if (entry instanceof LogEntry) { |
340 |
severityLabel.setText(entry.getSeverityText()); |
361 |
LogEntry logEntry = (LogEntry) entry; |
341 |
msgText.setText(entry.getMessage() != null ? entry.getMessage() : ""); //$NON-NLS-1$ |
362 |
|
342 |
String stack = entry.getStack(); |
363 |
String strDate = logEntry.getFormattedDate(); |
343 |
if (stack != null) { |
364 |
dateLabel.setText(strDate); |
344 |
stackTraceText.setText(stack); |
365 |
severityImageLabel.setImage(labelProvider.getColumnImage(entry, 0)); |
345 |
} else { |
366 |
severityLabel.setText(logEntry.getSeverityText()); |
346 |
stackTraceText.setText(Messages.EventDetailsDialog_noStack); |
367 |
msgText.setText(logEntry.getMessage() != null ? logEntry.getMessage() : ""); //$NON-NLS-1$ |
|
|
368 |
String stack = logEntry.getStack(); |
369 |
if (stack != null) { |
370 |
stackTraceText.setText(stack); |
371 |
} else { |
372 |
stackTraceText.setText(Messages.EventDetailsDialog_noStack); |
373 |
} |
374 |
session = logEntry.getSession(); |
375 |
|
376 |
} else if (entry instanceof LogSession) { |
377 |
session = (LogSession) entry; |
378 |
|
379 |
dateLabel.setText(""); //$NON-NLS-1$ |
380 |
severityImageLabel.setImage(null); |
381 |
severityLabel.setText(""); //$NON-NLS-1$ |
382 |
msgText.setText(""); //$NON-NLS-1$ |
383 |
stackTraceText.setText(""); //$NON-NLS-1$ |
347 |
} |
384 |
} |
348 |
LogSession session = entry.getSession(); |
385 |
|
349 |
if (session != null && session.getSessionData() != null) |
386 |
if (session != null && session.getSessionData() != null) |
350 |
sessionDataText.setText(session.getSessionData()); |
387 |
sessionDataText.setText(session.getSessionData()); |
351 |
|
388 |
|
352 |
updateButtons(); |
389 |
updateButtons(); |
353 |
} |
390 |
} |
354 |
|
391 |
|
Lines 363-377
Link Here
|
363 |
} |
400 |
} |
364 |
} |
401 |
} |
365 |
|
402 |
|
366 |
private void findNextSelectedChild(LogEntry originalEntry){ |
403 |
private void findNextSelectedChild(AbstractEntry originalEntry){ |
367 |
if (isChild (parentEntry)){ |
404 |
if (isChild (parentEntry)){ |
368 |
// we're at the end of the child list; find next parent |
405 |
// 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 |
406 |
// to select. If the parent is a child at the end of the child |
370 |
// list, find its next parent entry to select, etc. |
407 |
// list, find its next parent entry to select, etc. |
371 |
|
408 |
|
372 |
entry = parentEntry; |
409 |
entry = parentEntry; |
373 |
setEntryChildren((LogEntry)parentEntry.getParent(parentEntry)); |
410 |
setEntryChildren((AbstractEntry)parentEntry.getParent(parentEntry)); |
374 |
parentEntry = (LogEntry)parentEntry.getParent(parentEntry); |
411 |
parentEntry = (AbstractEntry)parentEntry.getParent(parentEntry); |
375 |
resetChildIndex(); |
412 |
resetChildIndex(); |
376 |
isLastChild = childIndex == entryChildren.length-1; |
413 |
isLastChild = childIndex == entryChildren.length-1; |
377 |
if (isLastChild){ |
414 |
if (isLastChild){ |
Lines 386-400
Link Here
|
386 |
} |
423 |
} |
387 |
} |
424 |
} |
388 |
|
425 |
|
389 |
private boolean nextChildExists(LogEntry originalEntry, LogEntry originalParent, LogEntry[] originalEntries){ |
426 |
private boolean nextChildExists(AbstractEntry originalEntry, AbstractEntry originalParent, AbstractEntry[] originalEntries){ |
390 |
if (isChild (parentEntry)){ |
427 |
if (isChild (parentEntry)){ |
391 |
// we're at the end of the child list; find next parent |
428 |
// 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 |
429 |
// to select. If the parent is a child at the end of the child |
393 |
// list, find its next parent entry to select, etc. |
430 |
// list, find its next parent entry to select, etc. |
394 |
|
431 |
|
395 |
entry = parentEntry; |
432 |
entry = parentEntry; |
396 |
setEntryChildren((LogEntry)parentEntry.getParent(parentEntry)); |
433 |
setEntryChildren((AbstractEntry)parentEntry.getParent(parentEntry)); |
397 |
parentEntry = (LogEntry)parentEntry.getParent(parentEntry); |
434 |
parentEntry = (AbstractEntry)parentEntry.getParent(parentEntry); |
398 |
resetChildIndex(); |
435 |
resetChildIndex(); |
399 |
if (childIndex == entryChildren.length-1){ |
436 |
if (childIndex == entryChildren.length-1){ |
400 |
nextChildExists(originalEntry, originalParent, originalEntries); |
437 |
nextChildExists(originalEntry, originalParent, originalEntries); |
Lines 413-451
Link Here
|
413 |
return false; |
450 |
return false; |
414 |
|
451 |
|
415 |
} |
452 |
} |
|
|
453 |
|
454 |
/** |
455 |
* Sets entry children (Prev-Next navigable) to top-level elements |
456 |
*/ |
416 |
private void setEntryChildren(){ |
457 |
private void setEntryChildren(){ |
417 |
Object[] children = ((LogViewContentProvider)provider.getContentProvider()).getElements(null); |
458 |
AbstractEntry[] children = getElements(); |
418 |
|
459 |
|
419 |
if (comparator != null) |
460 |
if (comparator != null) |
420 |
Arrays.sort(children, comparator); |
461 |
Arrays.sort(children, comparator); |
421 |
entryChildren = new LogEntry[children.length]; |
462 |
entryChildren = new AbstractEntry[children.length]; |
422 |
|
463 |
|
423 |
System.arraycopy(children,0,entryChildren,0,children.length); |
464 |
System.arraycopy(children,0,entryChildren,0,children.length); |
424 |
} |
465 |
} |
425 |
|
466 |
|
426 |
private void resetTotalElementCount(){ |
467 |
private void resetTotalElementCount(){ |
427 |
totalElementCount = entry.getSession().getEntries().size(); |
468 |
AbstractEntry parent = ((AbstractEntry)entry.getParent(entry)); |
|
|
469 |
if (parent == null) { |
470 |
totalElementCount = getElements().length; |
471 |
} else { |
472 |
totalElementCount = parent.getChildren(parent).length; |
473 |
} |
428 |
} |
474 |
} |
429 |
|
475 |
|
430 |
private void setEntryChildren(LogEntry entry){ |
476 |
/** |
431 |
LogSession session = entry.getSession(); |
477 |
* Sets entry children (Prev-Next navigable) to children of given entry |
432 |
if (session == null) |
478 |
*/ |
433 |
return; |
479 |
private void setEntryChildren(AbstractEntry entry){ |
|
|
480 |
Object[] children = entry.getChildren(entry); |
434 |
|
481 |
|
435 |
List children = session.getEntries(); |
|
|
436 |
if (comparator != null) |
482 |
if (comparator != null) |
437 |
Collections.sort(children, comparator); |
483 |
Arrays.sort(children, comparator); |
438 |
entryChildren = (LogEntry[])children.toArray(new LogEntry[children.size()]); |
484 |
|
|
|
485 |
List result = new ArrayList(); |
486 |
for (int i = 0; i < children.length; i++) { |
487 |
if (children[i] instanceof AbstractEntry) { |
488 |
result.add(children[i]); |
489 |
} |
490 |
} |
491 |
|
492 |
entryChildren = (AbstractEntry[])result.toArray(new AbstractEntry[result.size()]); |
439 |
} |
493 |
} |
440 |
|
494 |
|
|
|
495 |
/** |
496 |
* Returns number of children of current parent node. |
497 |
* @return |
498 |
*/ |
441 |
private int getParentElementNum(){ |
499 |
private int getParentElementNum(){ |
442 |
LogEntry itemEntry = (LogEntry)((IStructuredSelection)provider.getSelection()).getFirstElement(); |
500 |
AbstractEntry itemEntry = (AbstractEntry)((IStructuredSelection)provider.getSelection()).getFirstElement(); |
443 |
itemEntry = getRootEntry(itemEntry); |
501 |
|
|
|
502 |
//itemEntry = getRootEntry(itemEntry); |
503 |
|
504 |
AbstractEntry itemParent = (AbstractEntry) itemEntry.getParent(itemEntry); |
505 |
if (itemParent != null) { |
506 |
setEntryChildren(itemEntry); |
507 |
} else { |
508 |
setEntryChildren(); // if at top level, the children are top-level |
509 |
} |
444 |
|
510 |
|
445 |
setEntryChildren(itemEntry); |
|
|
446 |
for (int i = 0; i<entryChildren.length; i++){ |
511 |
for (int i = 0; i<entryChildren.length; i++){ |
447 |
try { |
512 |
try { |
448 |
LogEntry littleEntry = entryChildren[i]; |
513 |
AbstractEntry littleEntry = entryChildren[i]; |
449 |
if (itemEntry.equals(littleEntry)){ |
514 |
if (itemEntry.equals(littleEntry)){ |
450 |
return i; |
515 |
return i; |
451 |
} |
516 |
} |
Lines 456-467
Link Here
|
456 |
return 0; |
521 |
return 0; |
457 |
} |
522 |
} |
458 |
|
523 |
|
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(){ |
524 |
public SashForm getSashForm(){ |
466 |
return sashForm; |
525 |
return sashForm; |
467 |
} |
526 |
} |
Lines 696-699
Link Here
|
696 |
s.put("sashWidth1", sashWeights[0]); //$NON-NLS-1$ |
755 |
s.put("sashWidth1", sashWeights[0]); //$NON-NLS-1$ |
697 |
s.put("sashWidth2", sashWeights[1]); //$NON-NLS-1$ |
756 |
s.put("sashWidth2", sashWeights[1]); //$NON-NLS-1$ |
698 |
} |
757 |
} |
|
|
758 |
|
759 |
/** |
760 |
* Utility method to get all top level elements of the Log View |
761 |
* @return top level elements of the Log View |
762 |
*/ |
763 |
private AbstractEntry[] getElements() { |
764 |
return (AbstractEntry[])((ITreeContentProvider)provider.getContentProvider()).getElements(null); |
765 |
} |
699 |
} |
766 |
} |