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 536-541
Link Here
|
536 |
private void createDetailsSection(Composite parent) { |
553 |
private void createDetailsSection(Composite parent) { |
537 |
Composite container = new Composite(parent, SWT.NONE); |
554 |
Composite container = new Composite(parent, SWT.NONE); |
538 |
GridLayout layout = new GridLayout(); |
555 |
GridLayout layout = new GridLayout(); |
|
|
556 |
layout.marginWidth = layout.marginHeight = 0; |
539 |
layout.numColumns = 2; |
557 |
layout.numColumns = 2; |
540 |
container.setLayout(layout); |
558 |
container.setLayout(layout); |
541 |
container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
559 |
container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
Lines 581-587
Link Here
|
581 |
|
599 |
|
582 |
private void createStackSection(Composite parent) { |
600 |
private void createStackSection(Composite parent) { |
583 |
Composite container = new Composite(parent, SWT.NONE); |
601 |
Composite container = new Composite(parent, SWT.NONE); |
584 |
GridLayout layout = new GridLayout(); |
602 |
GridLayout layout = new GridLayout(2, false); |
585 |
layout.marginHeight = 0; |
603 |
layout.marginHeight = 0; |
586 |
layout.marginWidth = 6; |
604 |
layout.marginWidth = 6; |
587 |
container.setLayout(layout); |
605 |
container.setLayout(layout); |
Lines 589-603
Link Here
|
589 |
gd.heightHint = 100; |
607 |
gd.heightHint = 100; |
590 |
container.setLayoutData(gd); |
608 |
container.setLayoutData(gd); |
591 |
|
609 |
|
592 |
Label label = new Label(container, SWT.NULL); |
610 |
Label label = new Label(container, SWT.NONE); |
593 |
label.setText(Messages.EventDetailsDialog_exception); |
611 |
label.setText(Messages.EventDetailsDialog_exception); |
594 |
gd = new GridData(GridData.FILL_HORIZONTAL); |
612 |
gd = new GridData(); |
595 |
gd.horizontalSpan = 3; |
613 |
gd.verticalAlignment = SWT.BOTTOM; |
596 |
label.setLayoutData(gd); |
614 |
label.setLayoutData(gd); |
597 |
|
615 |
|
|
|
616 |
Button button = new Button(container, SWT.NONE); |
617 |
button.setImage(SharedImages.getImage(SharedImages.DESC_FILTER)); |
618 |
gd = new GridData(); |
619 |
gd.horizontalAlignment = SWT.RIGHT; |
620 |
button.setLayoutData(gd); |
621 |
button.addSelectionListener(new SelectionAdapter() { |
622 |
public void widgetSelected(SelectionEvent e) { |
623 |
FilterDialog dialog = new FilterDialog(getShell(), memento); |
624 |
dialog.create(); |
625 |
dialog.getShell().setText(Messages.EventDetailsDialog_FilterDialog); |
626 |
if (dialog.open() == Window.OK) |
627 |
// update filters and currently displayed stack trace |
628 |
stackFilterPatterns = getFilters(); |
629 |
updateProperties(); |
630 |
} |
631 |
|
632 |
}); |
633 |
|
598 |
stackTraceText = new Text(container, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); |
634 |
stackTraceText = new Text(container, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); |
599 |
gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); |
635 |
gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); |
600 |
gd.grabExcessHorizontalSpace = true; |
636 |
gd.grabExcessHorizontalSpace = true; |
|
|
637 |
gd.horizontalSpan = 2; |
601 |
stackTraceText.setLayoutData(gd); |
638 |
stackTraceText.setLayoutData(gd); |
602 |
stackTraceText.setEditable(false); |
639 |
stackTraceText.setEditable(false); |
603 |
} |
640 |
} |
Lines 628-633
Link Here
|
628 |
sessionDataText.setEditable(false); |
665 |
sessionDataText.setEditable(false); |
629 |
} |
666 |
} |
630 |
|
667 |
|
|
|
668 |
/** |
669 |
* Loads filters from preferences. |
670 |
* @return filters from preferences or empty array |
671 |
* |
672 |
* @since 3.4 |
673 |
*/ |
674 |
private String[] getFilters() { |
675 |
|
676 |
Boolean filterEnabled = memento.getBoolean(FILTER_ENABLED); |
677 |
|
678 |
String filtersString = memento.getString(FILTER_LIST); |
679 |
|
680 |
if ((filterEnabled == null) || (filterEnabled.booleanValue() == false) || filtersString == null) { |
681 |
return new String[0]; |
682 |
} |
683 |
|
684 |
StringTokenizer st = new StringTokenizer(filtersString, ";"); //$NON-NLS-1$ |
685 |
List filters = new ArrayList(); |
686 |
while (st.hasMoreElements()) { |
687 |
String filter = st.nextToken(); |
688 |
filters.add(filter); |
689 |
} |
690 |
|
691 |
return (String[]) filters.toArray(new String[filters.size()]); |
692 |
} |
693 |
|
694 |
/** |
695 |
* Filters stack trace. |
696 |
* Every stack trace line is compared against all patterns. |
697 |
* If line contains any of pattern strings, it's excluded from output. |
698 |
* |
699 |
* @returns filtered stack trace |
700 |
* @since 3.4 |
701 |
*/ |
702 |
private String filterStack(String stack) { |
703 |
if (stackFilterPatterns.length == 0) { |
704 |
return stack; |
705 |
} |
706 |
|
707 |
StringTokenizer st = new StringTokenizer(stack, "\n"); //$NON-NLS-1$ |
708 |
StringBuffer result = new StringBuffer(); |
709 |
while (st.hasMoreTokens()) { |
710 |
String stackElement = st.nextToken(); |
711 |
|
712 |
boolean filtered = false; |
713 |
int i = 0; |
714 |
while ((!filtered) && (i < stackFilterPatterns.length)) { |
715 |
filtered = stackElement.indexOf(stackFilterPatterns[i]) >= 0; |
716 |
i++; |
717 |
} |
718 |
|
719 |
if (!filtered) { |
720 |
result.append(stackElement).append("\n"); //$NON-NLS-1$ |
721 |
} |
722 |
} |
723 |
|
724 |
return result.toString(); |
725 |
} |
726 |
|
631 |
//--------------- configuration handling -------------- |
727 |
//--------------- configuration handling -------------- |
632 |
|
728 |
|
633 |
/** |
729 |
/** |