Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2008 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 19-35
Link Here
|
19 |
import org.eclipse.jface.dialogs.*; |
19 |
import org.eclipse.jface.dialogs.*; |
20 |
import org.eclipse.jface.dialogs.Dialog; |
20 |
import org.eclipse.jface.dialogs.Dialog; |
21 |
import org.eclipse.jface.viewers.*; |
21 |
import org.eclipse.jface.viewers.*; |
|
|
22 |
import org.eclipse.jface.window.Window; |
22 |
import org.eclipse.swt.SWT; |
23 |
import org.eclipse.swt.SWT; |
23 |
import org.eclipse.swt.custom.SashForm; |
24 |
import org.eclipse.swt.custom.SashForm; |
24 |
import org.eclipse.swt.dnd.*; |
25 |
import org.eclipse.swt.dnd.*; |
|
|
26 |
import org.eclipse.swt.events.SelectionAdapter; |
27 |
import org.eclipse.swt.events.SelectionEvent; |
25 |
import org.eclipse.swt.graphics.Point; |
28 |
import org.eclipse.swt.graphics.Point; |
26 |
import org.eclipse.swt.layout.GridData; |
29 |
import org.eclipse.swt.layout.GridData; |
27 |
import org.eclipse.swt.layout.GridLayout; |
30 |
import org.eclipse.swt.layout.GridLayout; |
28 |
import org.eclipse.swt.widgets.*; |
31 |
import org.eclipse.swt.widgets.*; |
29 |
import org.eclipse.ui.ISharedImages; |
32 |
import org.eclipse.ui.*; |
30 |
import org.eclipse.ui.PlatformUI; |
|
|
31 |
|
33 |
|
|
|
34 |
/** |
35 |
* Displays details about Log Entry. |
36 |
* Event information is split in three sections: details, stack trace and session. Details |
37 |
* contain event date, message and severity. Stack trace is displayed if an exception is bound |
38 |
* to event. Stack trace entries can be filtered. |
39 |
*/ |
32 |
public class EventDetailsDialog extends TrayDialog { |
40 |
public class EventDetailsDialog extends TrayDialog { |
|
|
41 |
|
42 |
public static final String FILTER_ENABLED = "detailsStackFilterEnabled"; //$NON-NLS-1$ |
43 |
public static final String FILTER_LIST = "detailsStackFilterList"; //$NON-NLS-1$ |
44 |
|
45 |
private IMemento memento; |
46 |
|
33 |
private AbstractEntry entry; |
47 |
private AbstractEntry entry; |
34 |
private AbstractEntry parentEntry; // parent of the entry |
48 |
private AbstractEntry parentEntry; // parent of the entry |
35 |
private AbstractEntry[] entryChildren; // children of the entry |
49 |
private AbstractEntry[] entryChildren; // children of the entry |
Lines 60-65
Link Here
|
60 |
private Comparator comparator = null; |
74 |
private Comparator comparator = null; |
61 |
Collator collator; |
75 |
Collator collator; |
62 |
|
76 |
|
|
|
77 |
// patterns for filtering stack traces |
78 |
private String[] stackFilterPatterns = null; |
79 |
|
63 |
// location configuration |
80 |
// location configuration |
64 |
private Point dialogLocation; |
81 |
private Point dialogLocation; |
65 |
private Point dialogSize; |
82 |
private Point dialogSize; |
Lines 72-84
Link Here
|
72 |
* @param provider viewer |
89 |
* @param provider viewer |
73 |
* @param comparator comparator used to order all entries |
90 |
* @param comparator comparator used to order all entries |
74 |
*/ |
91 |
*/ |
75 |
protected EventDetailsDialog(Shell parentShell, IAdaptable selection, ISelectionProvider provider, Comparator comparator) { |
92 |
protected EventDetailsDialog(Shell parentShell, IAdaptable selection, ISelectionProvider provider, Comparator comparator, IMemento memento) { |
76 |
super(parentShell); |
93 |
super(parentShell); |
77 |
this.provider = (TreeViewer) provider; |
94 |
this.provider = (TreeViewer) provider; |
78 |
labelProvider = (LogViewLabelProvider) this.provider.getLabelProvider(); |
95 |
labelProvider = (LogViewLabelProvider) this.provider.getLabelProvider(); |
79 |
labelProvider.connect(this); |
96 |
labelProvider.connect(this); |
80 |
this.entry = (AbstractEntry) selection; |
97 |
this.entry = (AbstractEntry) selection; |
81 |
this.comparator = comparator; |
98 |
this.comparator = comparator; |
|
|
99 |
this.memento = memento; |
82 |
setShellStyle(SWT.MODELESS | SWT.MIN | SWT.MAX | SWT.RESIZE | SWT.CLOSE | SWT.BORDER | SWT.TITLE); |
100 |
setShellStyle(SWT.MODELESS | SWT.MIN | SWT.MAX | SWT.RESIZE | SWT.CLOSE | SWT.BORDER | SWT.TITLE); |
83 |
clipboard = new Clipboard(parentShell.getDisplay()); |
101 |
clipboard = new Clipboard(parentShell.getDisplay()); |
84 |
initialize(); |
102 |
initialize(); |
Lines 86-91
Link Here
|
86 |
readConfiguration(); |
104 |
readConfiguration(); |
87 |
isLastChild = false; |
105 |
isLastChild = false; |
88 |
isAtEndOfLog = false; |
106 |
isAtEndOfLog = false; |
|
|
107 |
stackFilterPatterns = getFilters(); |
89 |
} |
108 |
} |
90 |
|
109 |
|
91 |
private void initialize() { |
110 |
private void initialize() { |
Lines 101-110
Link Here
|
101 |
} |
120 |
} |
102 |
|
121 |
|
103 |
private void resetChildIndex() { |
122 |
private void resetChildIndex() { |
104 |
if (!(entry instanceof AbstractEntry)) { |
|
|
105 |
return; |
106 |
} |
107 |
|
108 |
if (entryChildren == null) |
123 |
if (entryChildren == null) |
109 |
return; |
124 |
return; |
110 |
|
125 |
|
Lines 318-324
Link Here
|
318 |
severityLabel.setText(logEntry.getSeverityText()); |
333 |
severityLabel.setText(logEntry.getSeverityText()); |
319 |
msgText.setText(logEntry.getMessage() != null ? logEntry.getMessage() : ""); //$NON-NLS-1$ |
334 |
msgText.setText(logEntry.getMessage() != null ? logEntry.getMessage() : ""); //$NON-NLS-1$ |
320 |
String stack = logEntry.getStack(); |
335 |
String stack = logEntry.getStack(); |
|
|
336 |
|
321 |
if (stack != null) { |
337 |
if (stack != null) { |
|
|
338 |
stack = filterStack(stack); |
322 |
stackTraceText.setText(stack); |
339 |
stackTraceText.setText(stack); |
323 |
} else { |
340 |
} else { |
324 |
stackTraceText.setText(Messages.EventDetailsDialog_noStack); |
341 |
stackTraceText.setText(Messages.EventDetailsDialog_noStack); |
Lines 491-531
Link Here
|
491 |
Composite comp = new Composite(parent, SWT.NONE); |
508 |
Composite comp = new Composite(parent, SWT.NONE); |
492 |
GridLayout layout = new GridLayout(); |
509 |
GridLayout layout = new GridLayout(); |
493 |
layout.marginWidth = layout.marginHeight = 0; |
510 |
layout.marginWidth = layout.marginHeight = 0; |
494 |
layout.numColumns = 1; |
511 |
//layout.numColumns = 1; |
495 |
comp.setLayout(layout); |
512 |
comp.setLayout(layout); |
496 |
comp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); |
513 |
comp.setLayoutData(new GridData(GridData.FILL_VERTICAL)); |
|
|
514 |
((GridData) comp.getLayoutData()).verticalAlignment = SWT.BOTTOM; |
497 |
|
515 |
|
498 |
Composite container = new Composite(comp, SWT.NONE); |
516 |
Composite container = new Composite(comp, SWT.NONE); |
499 |
layout = new GridLayout(); |
517 |
layout = new GridLayout(); |
500 |
layout.marginWidth = 0; |
518 |
layout.marginWidth = 0; |
501 |
layout.marginHeight = 10; |
519 |
layout.marginHeight = 0; |
502 |
layout.numColumns = 1; |
|
|
503 |
container.setLayout(layout); |
520 |
container.setLayout(layout); |
504 |
container.setLayoutData(new GridData(GridData.FILL_BOTH)); |
521 |
container.setLayoutData(new GridData(GridData.FILL_BOTH)); |
505 |
|
522 |
|
506 |
backButton = createButton(container, IDialogConstants.BACK_ID, "", false); //$NON-NLS-1$ |
523 |
backButton = createButton(container, IDialogConstants.BACK_ID, "", false); //$NON-NLS-1$ |
507 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
524 |
GridData gd = new GridData(GridData.FILL_HORIZONTAL); |
508 |
gd.horizontalSpan = 3; |
|
|
509 |
gd.verticalSpan = 1; |
510 |
backButton.setLayoutData(gd); |
525 |
backButton.setLayoutData(gd); |
511 |
backButton.setToolTipText(Messages.EventDetailsDialog_previous); |
526 |
backButton.setToolTipText(Messages.EventDetailsDialog_previous); |
512 |
backButton.setImage(SharedImages.getImage(SharedImages.DESC_PREV_EVENT)); |
527 |
backButton.setImage(SharedImages.getImage(SharedImages.DESC_PREV_EVENT)); |
513 |
|
528 |
|
|
|
529 |
copyButton = createButton(container, COPY_ID, "", false); //$NON-NLS-1$ |
530 |
gd = new GridData(); |
531 |
copyButton.setLayoutData(gd); |
532 |
copyButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_COPY)); |
533 |
copyButton.setToolTipText(Messages.EventDetailsDialog_copy); |
534 |
|
514 |
nextButton = createButton(container, IDialogConstants.NEXT_ID, "", false); //$NON-NLS-1$ |
535 |
nextButton = createButton(container, IDialogConstants.NEXT_ID, "", false); //$NON-NLS-1$ |
515 |
gd = new GridData(); |
536 |
gd = new GridData(); |
516 |
gd.horizontalSpan = 3; |
|
|
517 |
gd.verticalSpan = 1; |
518 |
nextButton.setLayoutData(gd); |
537 |
nextButton.setLayoutData(gd); |
519 |
nextButton.setToolTipText(Messages.EventDetailsDialog_next); |
538 |
nextButton.setToolTipText(Messages.EventDetailsDialog_next); |
520 |
nextButton.setImage(SharedImages.getImage(SharedImages.DESC_NEXT_EVENT)); |
539 |
nextButton.setImage(SharedImages.getImage(SharedImages.DESC_NEXT_EVENT)); |
521 |
|
540 |
|
522 |
copyButton = createButton(container, COPY_ID, "", false); //$NON-NLS-1$ |
541 |
Button button = new Button(container, SWT.NONE); |
|
|
542 |
button.setImage(SharedImages.getImage(SharedImages.DESC_FILTER)); |
523 |
gd = new GridData(); |
543 |
gd = new GridData(); |
524 |
gd.horizontalSpan = 3; |
544 |
gd.horizontalAlignment = SWT.RIGHT; |
525 |
gd.verticalSpan = 1; |
545 |
button.setLayoutData(gd); |
526 |
copyButton.setLayoutData(gd); |
546 |
button.addSelectionListener(new SelectionAdapter() { |
527 |
copyButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_COPY)); |
547 |
public void widgetSelected(SelectionEvent e) { |
528 |
copyButton.setToolTipText(Messages.EventDetailsDialog_copy); |
548 |
FilterDialog dialog = new FilterDialog(getShell(), memento); |
|
|
549 |
dialog.create(); |
550 |
dialog.getShell().setText(Messages.EventDetailsDialog_FilterDialog); |
551 |
if (dialog.open() == Window.OK) |
552 |
// update filters and currently displayed stack trace |
553 |
stackFilterPatterns = getFilters(); |
554 |
updateProperties(); |
555 |
} |
556 |
}); |
557 |
|
558 |
// set numColumns at the end, after all createButton() calls, which change this value |
559 |
layout.numColumns = 2; |
529 |
} |
560 |
} |
530 |
|
561 |
|
531 |
protected void createButtonsForButtonBar(Composite parent) { |
562 |
protected void createButtonsForButtonBar(Composite parent) { |
Lines 536-541
Link Here
|
536 |
private void createDetailsSection(Composite parent) { |
567 |
private void createDetailsSection(Composite parent) { |
537 |
Composite container = new Composite(parent, SWT.NONE); |
568 |
Composite container = new Composite(parent, SWT.NONE); |
538 |
GridLayout layout = new GridLayout(); |
569 |
GridLayout layout = new GridLayout(); |
|
|
570 |
layout.marginWidth = layout.marginHeight = 0; |
539 |
layout.numColumns = 2; |
571 |
layout.numColumns = 2; |
540 |
container.setLayout(layout); |
572 |
container.setLayout(layout); |
541 |
container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
573 |
container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
Lines 581-587
Link Here
|
581 |
|
613 |
|
582 |
private void createStackSection(Composite parent) { |
614 |
private void createStackSection(Composite parent) { |
583 |
Composite container = new Composite(parent, SWT.NONE); |
615 |
Composite container = new Composite(parent, SWT.NONE); |
584 |
GridLayout layout = new GridLayout(); |
616 |
GridLayout layout = new GridLayout(2, false); |
585 |
layout.marginHeight = 0; |
617 |
layout.marginHeight = 0; |
586 |
layout.marginWidth = 6; |
618 |
layout.marginWidth = 6; |
587 |
container.setLayout(layout); |
619 |
container.setLayout(layout); |
Lines 589-603
Link Here
|
589 |
gd.heightHint = 100; |
621 |
gd.heightHint = 100; |
590 |
container.setLayoutData(gd); |
622 |
container.setLayoutData(gd); |
591 |
|
623 |
|
592 |
Label label = new Label(container, SWT.NULL); |
624 |
Label label = new Label(container, SWT.NONE); |
593 |
label.setText(Messages.EventDetailsDialog_exception); |
625 |
label.setText(Messages.EventDetailsDialog_exception); |
594 |
gd = new GridData(GridData.FILL_HORIZONTAL); |
626 |
gd = new GridData(); |
595 |
gd.horizontalSpan = 3; |
627 |
gd.verticalAlignment = SWT.BOTTOM; |
596 |
label.setLayoutData(gd); |
628 |
label.setLayoutData(gd); |
597 |
|
629 |
|
598 |
stackTraceText = new Text(container, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); |
630 |
stackTraceText = new Text(container, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); |
599 |
gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); |
631 |
gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); |
600 |
gd.grabExcessHorizontalSpace = true; |
632 |
gd.grabExcessHorizontalSpace = true; |
|
|
633 |
gd.horizontalSpan = 2; |
601 |
stackTraceText.setLayoutData(gd); |
634 |
stackTraceText.setLayoutData(gd); |
602 |
stackTraceText.setEditable(false); |
635 |
stackTraceText.setEditable(false); |
603 |
} |
636 |
} |
Lines 628-633
Link Here
|
628 |
sessionDataText.setEditable(false); |
661 |
sessionDataText.setEditable(false); |
629 |
} |
662 |
} |
630 |
|
663 |
|
|
|
664 |
/** |
665 |
* Loads filters from preferences. |
666 |
* @return filters from preferences or empty array |
667 |
* |
668 |
* @since 3.4 |
669 |
*/ |
670 |
private String[] getFilters() { |
671 |
|
672 |
Boolean filterEnabled = memento.getBoolean(FILTER_ENABLED); |
673 |
|
674 |
String filtersString = memento.getString(FILTER_LIST); |
675 |
|
676 |
if ((filterEnabled == null) || (filterEnabled.booleanValue() == false) || filtersString == null) { |
677 |
return new String[0]; |
678 |
} |
679 |
|
680 |
StringTokenizer st = new StringTokenizer(filtersString, ";"); //$NON-NLS-1$ |
681 |
List filters = new ArrayList(); |
682 |
while (st.hasMoreElements()) { |
683 |
String filter = st.nextToken(); |
684 |
filters.add(filter); |
685 |
} |
686 |
|
687 |
return (String[]) filters.toArray(new String[filters.size()]); |
688 |
} |
689 |
|
690 |
/** |
691 |
* Filters stack trace. |
692 |
* Every stack trace line is compared against all patterns. |
693 |
* If line contains any of pattern strings, it's excluded from output. |
694 |
* |
695 |
* @returns filtered stack trace |
696 |
* @since 3.4 |
697 |
*/ |
698 |
private String filterStack(String stack) { |
699 |
if (stackFilterPatterns.length == 0) { |
700 |
return stack; |
701 |
} |
702 |
|
703 |
StringTokenizer st = new StringTokenizer(stack, "\n"); //$NON-NLS-1$ |
704 |
StringBuffer result = new StringBuffer(); |
705 |
while (st.hasMoreTokens()) { |
706 |
String stackElement = st.nextToken(); |
707 |
|
708 |
boolean filtered = false; |
709 |
int i = 0; |
710 |
while ((!filtered) && (i < stackFilterPatterns.length)) { |
711 |
filtered = stackElement.indexOf(stackFilterPatterns[i]) >= 0; |
712 |
i++; |
713 |
} |
714 |
|
715 |
if (!filtered) { |
716 |
result.append(stackElement).append("\n"); //$NON-NLS-1$ |
717 |
} |
718 |
} |
719 |
|
720 |
return result.toString(); |
721 |
} |
722 |
|
631 |
//--------------- configuration handling -------------- |
723 |
//--------------- configuration handling -------------- |
632 |
|
724 |
|
633 |
/** |
725 |
/** |