View | Details | Raw Unified | Return to bug 110836 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/views/log/messages.properties (+8 lines)
Lines 61-66 Link Here
61
LogViewLabelProvider_truncatedMessage=... (Open log entry details for full message)
61
LogViewLabelProvider_truncatedMessage=... (Open log entry details for full message)
62
LogViewLabelProvider_Session=Session
62
LogViewLabelProvider_Session=Session
63
63
64
EventDetailsDialog_ConfigureFiltersLink=<a>Configure filters...</a>
64
EventDetailsDialog_title= Event Details
65
EventDetailsDialog_title= Event Details
65
EventDetailsDialog_date=Date:
66
EventDetailsDialog_date=Date:
66
EventDetailsDialog_severity=Severity:
67
EventDetailsDialog_severity=Severity:
Lines 71-76 Link Here
71
EventDetailsDialog_previous=View Details Of Previous Event
72
EventDetailsDialog_previous=View Details Of Previous Event
72
EventDetailsDialog_next=View Details Of Next Event
73
EventDetailsDialog_next=View Details Of Next Event
73
EventDetailsDialog_copy=Copy Event Details To Clipboard
74
EventDetailsDialog_copy=Copy Event Details To Clipboard
75
EventDetailsDialog_FilterDialog=Filter dialog
76
EventDetailsStackFilterDialog_AddFilter=Add filter
77
EventDetailsStackFilterDialog_AddFilterTitle=Add filter...
78
EventDetailsStackFilterDialog_EnableFilters=Enable filters
79
EventDetailsStackFilterDialog_FilterShouldntContainSemicolon=Filter shouldn't contain semicolon
80
EventDetailsStackFilterDialog_FiltersLabel=Filters let you hide selected stack trace entries.
81
EventDetailsStackFilterDialog_Remove=Remove...
74
82
75
OpenLogDialog_title=Error Log
83
OpenLogDialog_title=Error Log
76
OpenLogDialog_message=Opening log...
84
OpenLogDialog_message=Opening log...
(-)src/org/eclipse/ui/internal/views/log/Messages.java (+8 lines)
Lines 68-73 Link Here
68
	public static String LogViewLabelProvider_Session;
68
	public static String LogViewLabelProvider_Session;
69
	public static String LogViewLabelProvider_truncatedMessage;
69
	public static String LogViewLabelProvider_truncatedMessage;
70
70
71
	public static String EventDetailsDialog_ConfigureFiltersLink;
71
	public static String EventDetailsDialog_title;
72
	public static String EventDetailsDialog_title;
72
	public static String EventDetailsDialog_date;
73
	public static String EventDetailsDialog_date;
73
	public static String EventDetailsDialog_severity;
74
	public static String EventDetailsDialog_severity;
Lines 78-84 Link Here
78
	public static String EventDetailsDialog_previous;
79
	public static String EventDetailsDialog_previous;
79
	public static String EventDetailsDialog_next;
80
	public static String EventDetailsDialog_next;
80
	public static String EventDetailsDialog_copy;
81
	public static String EventDetailsDialog_copy;
82
	public static String EventDetailsDialog_FilterDialog;
81
83
84
	public static String EventDetailsStackFilterDialog_AddFilter;
85
	public static String EventDetailsStackFilterDialog_AddFilterTitle;
86
	public static String EventDetailsStackFilterDialog_EnableFilters;
87
	public static String EventDetailsStackFilterDialog_FilterShouldntContainSemicolon;
88
	public static String EventDetailsStackFilterDialog_FiltersLabel;
89
	public static String EventDetailsStackFilterDialog_Remove;
82
	public static String OpenLogDialog_title;
90
	public static String OpenLogDialog_title;
83
	public static String OpenLogDialog_message;
91
	public static String OpenLogDialog_message;
84
	public static String OpenLogDialog_cannotDisplay;
92
	public static String OpenLogDialog_cannotDisplay;
(-)src/org/eclipse/ui/internal/views/log/EventDetailsDialog.java (-10 / +85 lines)
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 16-27 Link Here
16
import java.util.*;
16
import java.util.*;
17
import java.util.List;
17
import java.util.List;
18
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.Preferences;
19
import org.eclipse.jface.dialogs.*;
20
import org.eclipse.jface.dialogs.*;
20
import org.eclipse.jface.dialogs.Dialog;
21
import org.eclipse.jface.dialogs.Dialog;
21
import org.eclipse.jface.viewers.*;
22
import org.eclipse.jface.viewers.*;
23
import org.eclipse.jface.window.Window;
22
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.custom.SashForm;
25
import org.eclipse.swt.custom.SashForm;
24
import org.eclipse.swt.dnd.*;
26
import org.eclipse.swt.dnd.*;
27
import org.eclipse.swt.events.SelectionAdapter;
28
import org.eclipse.swt.events.SelectionEvent;
25
import org.eclipse.swt.graphics.Point;
29
import org.eclipse.swt.graphics.Point;
26
import org.eclipse.swt.layout.GridData;
30
import org.eclipse.swt.layout.GridData;
27
import org.eclipse.swt.layout.GridLayout;
31
import org.eclipse.swt.layout.GridLayout;
Lines 60-65 Link Here
60
	private Comparator comparator = null;
64
	private Comparator comparator = null;
61
	Collator collator;
65
	Collator collator;
62
66
67
	// patterns for filtering stack traces
68
	private String[] stackFilterPatterns = getFilters();
69
63
	// location configuration
70
	// location configuration
64
	private Point dialogLocation;
71
	private Point dialogLocation;
65
	private Point dialogSize;
72
	private Point dialogSize;
Lines 101-110 Link Here
101
	}
108
	}
102
109
103
	private void resetChildIndex() {
110
	private void resetChildIndex() {
104
		if (!(entry instanceof AbstractEntry)) {
105
			return;
106
		}
107
108
		if (entryChildren == null)
111
		if (entryChildren == null)
109
			return;
112
			return;
110
113
Lines 318-324 Link Here
318
			severityLabel.setText(logEntry.getSeverityText());
321
			severityLabel.setText(logEntry.getSeverityText());
319
			msgText.setText(logEntry.getMessage() != null ? logEntry.getMessage() : ""); //$NON-NLS-1$
322
			msgText.setText(logEntry.getMessage() != null ? logEntry.getMessage() : ""); //$NON-NLS-1$
320
			String stack = logEntry.getStack();
323
			String stack = logEntry.getStack();
324
321
			if (stack != null) {
325
			if (stack != null) {
326
				stack = filterStack(stack);
322
				stackTraceText.setText(stack);
327
				stackTraceText.setText(stack);
323
			} else {
328
			} else {
324
				stackTraceText.setText(Messages.EventDetailsDialog_noStack);
329
				stackTraceText.setText(Messages.EventDetailsDialog_noStack);
Lines 581-587 Link Here
581
586
582
	private void createStackSection(Composite parent) {
587
	private void createStackSection(Composite parent) {
583
		Composite container = new Composite(parent, SWT.NONE);
588
		Composite container = new Composite(parent, SWT.NONE);
584
		GridLayout layout = new GridLayout();
589
		GridLayout layout = new GridLayout(2, false);
585
		layout.marginHeight = 0;
590
		layout.marginHeight = 0;
586
		layout.marginWidth = 6;
591
		layout.marginWidth = 6;
587
		container.setLayout(layout);
592
		container.setLayout(layout);
Lines 589-603 Link Here
589
		gd.heightHint = 100;
594
		gd.heightHint = 100;
590
		container.setLayoutData(gd);
595
		container.setLayoutData(gd);
591
596
592
		Label label = new Label(container, SWT.NULL);
597
		Label label = new Label(container, SWT.NONE);
593
		label.setText(Messages.EventDetailsDialog_exception);
598
		label.setText(Messages.EventDetailsDialog_exception);
594
		gd = new GridData(GridData.FILL_HORIZONTAL);
599
595
		gd.horizontalSpan = 3;
600
		Link link = new Link(container, SWT.NONE);
596
		label.setLayoutData(gd);
601
		link.setText(Messages.EventDetailsDialog_ConfigureFiltersLink);
602
		link.addSelectionListener(new SelectionAdapter() {
603
			public void widgetSelected(SelectionEvent e) {
604
				EventDetailsStackFilterDialog dialog = new EventDetailsStackFilterDialog(getShell());
605
				dialog.create();
606
				dialog.getShell().setText(Messages.EventDetailsDialog_FilterDialog);
607
				if (dialog.open() == Window.OK)
608
					// update filters and currently displayed stack trace
609
					stackFilterPatterns = getFilters();
610
				updateProperties();
611
			}
612
613
		});
597
614
598
		stackTraceText = new Text(container, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
615
		stackTraceText = new Text(container, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
599
		gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL);
616
		gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL);
600
		gd.grabExcessHorizontalSpace = true;
617
		gd.grabExcessHorizontalSpace = true;
618
		gd.horizontalSpan = 2;
601
		stackTraceText.setLayoutData(gd);
619
		stackTraceText.setLayoutData(gd);
602
		stackTraceText.setEditable(false);
620
		stackTraceText.setEditable(false);
603
	}
621
	}
Lines 628-633 Link Here
628
		sessionDataText.setEditable(false);
646
		sessionDataText.setEditable(false);
629
	}
647
	}
630
648
649
	/**
650
	 * Loads filters from preferences.
651
	 * @return filters from preferences or empty array
652
	 * 
653
	 * @since 3.4
654
	 */
655
	private String[] getFilters() {
656
		Preferences prefs = Activator.getDefault().getPluginPreferences();
657
658
		if (!prefs.getBoolean(EventDetailsStackFilterDialog.FILTER_ENABLED)) {
659
			return new String[0];
660
		}
661
662
		String filtersString = prefs.getString(EventDetailsStackFilterDialog.FILTER_LIST);
663
		StringTokenizer st = new StringTokenizer(filtersString, ";"); //$NON-NLS-1$
664
		List filters = new ArrayList();
665
		while (st.hasMoreElements()) {
666
			String filter = st.nextToken();
667
			filters.add(filter);
668
		}
669
670
		return (String[]) filters.toArray(new String[filters.size()]);
671
	}
672
673
	/**
674
	 * Filters stack trace.
675
	 * Every stack trace line is compared against all patterns.
676
	 * If line contains any of pattern strings, it's excluded from output.
677
	 * 
678
	 * @returns filtered stack trace
679
	 * @since 3.4
680
	 */
681
	private String filterStack(String stack) {
682
		if (stackFilterPatterns.length == 0) {
683
			return stack;
684
		}
685
686
		StringTokenizer st = new StringTokenizer(stack, "\n"); //$NON-NLS-1$
687
		StringBuffer result = new StringBuffer();
688
		while (st.hasMoreTokens()) {
689
			String stackElement = st.nextToken();
690
691
			boolean filtered = false;
692
			int i = 0;
693
			while ((!filtered) && (i < stackFilterPatterns.length)) {
694
				filtered = stackElement.indexOf(stackFilterPatterns[i]) >= 0;
695
				i++;
696
			}
697
698
			if (!filtered) {
699
				result.append(stackElement).append("\n"); //$NON-NLS-1$
700
			}
701
		}
702
703
		return result.toString();
704
	}
705
631
	//--------------- configuration handling --------------
706
	//--------------- configuration handling --------------
632
707
633
	/**
708
	/**
(-)src/org/eclipse/ui/internal/views/log/EventDetailsStackFilterDialog.java (+173 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.views.log;
12
13
import java.util.StringTokenizer;
14
import org.eclipse.core.runtime.Preferences;
15
import org.eclipse.jface.dialogs.*;
16
import org.eclipse.jface.dialogs.Dialog;
17
import org.eclipse.jface.window.Window;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.events.SelectionAdapter;
20
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.layout.GridLayout;
23
import org.eclipse.swt.widgets.*;
24
25
/**
26
 * Event Details Stack Filter dialog.
27
 * Allows user to define patterns for filtering stack trace elements in Event Details dialog.
28
 *
29
 * @since 3.4
30
 */
31
public class EventDetailsStackFilterDialog extends TrayDialog {
32
33
	public static final String FILTER_ENABLED = "detailsStackFilterEnabled"; //$NON-NLS-1$
34
	public static final String FILTER_LIST = "detailsStackFilterList"; //$NON-NLS-1$
35
36
	Button okButton;
37
	private Button filterEnabled;
38
	private Button addFilter;
39
	private Button removeFilter;
40
	private List filterList;
41
42
	public EventDetailsStackFilterDialog(Shell parentShell) {
43
		super(parentShell);
44
	}
45
46
	protected Control createDialogArea(Composite parent) {
47
		Composite container = (Composite) super.createDialogArea(parent);
48
		createFilterSection(container);
49
		Dialog.applyDialogFont(container);
50
		return container;
51
	}
52
53
	private void createFilterSection(Composite parent) {
54
		Composite comp = new Composite(parent, SWT.NONE);
55
		GridLayout layout = new GridLayout(2, false);
56
		comp.setLayout(layout);
57
		comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
58
59
		Label label = new Label(comp, SWT.NONE);
60
		label.setText(Messages.EventDetailsStackFilterDialog_FiltersLabel);
61
		GridData gd = new GridData();
62
		gd.horizontalSpan = 2;
63
		label.setLayoutData(gd);
64
65
		filterEnabled = new Button(comp, SWT.CHECK);
66
		filterEnabled.setText(Messages.EventDetailsStackFilterDialog_EnableFilters);
67
		gd = new GridData();
68
		gd.horizontalSpan = 2;
69
		filterEnabled.setLayoutData(gd);
70
		filterEnabled.addSelectionListener(new SelectionAdapter() {
71
			public void widgetSelected(SelectionEvent e) {
72
				setEnabled(filterEnabled.getSelection());
73
			}
74
75
		});
76
77
		filterList = new List(comp, SWT.BORDER);
78
		gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
79
		gd.verticalSpan = 3;
80
		gd.widthHint = 300;
81
		filterList.setLayoutData(gd);
82
		filterList.addSelectionListener(new SelectionAdapter() {
83
			public void widgetSelected(SelectionEvent e) {
84
				removeFilter.setEnabled(true);
85
			}
86
		});
87
88
		addFilter = new Button(comp, SWT.NONE);
89
		addFilter.setText(Messages.EventDetailsStackFilterDialog_AddFilterTitle);
90
		addFilter.addSelectionListener(new SelectionAdapter() {
91
			public void widgetSelected(SelectionEvent e) {
92
				addFilter();
93
			}
94
		});
95
96
		removeFilter = new Button(comp, SWT.NONE);
97
		removeFilter.setText(Messages.EventDetailsStackFilterDialog_Remove);
98
		removeFilter.setEnabled(false);
99
		removeFilter.addSelectionListener(new SelectionAdapter() {
100
			public void widgetSelected(SelectionEvent e) {
101
				removeFilter();
102
			}
103
		});
104
105
		// load preferences
106
		Preferences prefs = Activator.getDefault().getPluginPreferences();
107
		filterEnabled.setSelection(prefs.getBoolean(FILTER_ENABLED));
108
		setEnabled(prefs.getBoolean(FILTER_ENABLED));
109
		String filters = prefs.getString(FILTER_LIST);
110
		StringTokenizer st = new StringTokenizer(filters, ";"); //$NON-NLS-1$
111
		while (st.hasMoreElements()) {
112
			filterList.add(st.nextToken());
113
		}
114
	}
115
116
	private void addFilter() {
117
		IInputValidator validator = new IInputValidator() {
118
119
			public String isValid(String newText) {
120
				return newText.indexOf(';') >= 0 ? Messages.EventDetailsStackFilterDialog_FilterShouldntContainSemicolon : null;
121
			}
122
123
		};
124
		InputDialog dialog = new InputDialog(getShell(), Messages.EventDetailsStackFilterDialog_AddFilterTitle, Messages.EventDetailsStackFilterDialog_AddFilter, null, validator);
125
		if (dialog.open() == Window.OK) {
126
			String value = dialog.getValue().trim();
127
128
			if (value.length() > 0) {
129
				filterList.add(value);
130
			}
131
		}
132
	}
133
134
	private void removeFilter() {
135
		int index = filterList.getSelectionIndex();
136
		if (index != -1) {
137
			filterList.remove(index);
138
		}
139
140
		removeFilter.setEnabled(false);
141
	}
142
143
	private void setEnabled(boolean enabled) {
144
		filterList.setEnabled(enabled);
145
		addFilter.setEnabled(enabled);
146
		removeFilter.setEnabled(enabled && filterList.getSelectionIndex() != -1);
147
	}
148
149
	protected void createButtonsForButtonBar(Composite parent) {
150
		okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
151
		createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
152
	}
153
154
	protected void okPressed() {
155
		// store preferences
156
		Preferences prefs = Activator.getDefault().getPluginPreferences();
157
158
		prefs.setValue(FILTER_ENABLED, filterEnabled.getSelection());
159
160
		StringBuffer sb = new StringBuffer();
161
		String[] items = filterList.getItems();
162
		for (int i = 0; i < items.length; i++) {
163
			sb.append(items[i]);
164
			if (i < items.length - 1) {
165
				sb.append(";"); //$NON-NLS-1$
166
			}
167
		}
168
		prefs.setValue(FILTER_LIST, sb.toString());
169
170
		super.okPressed();
171
	}
172
173
}

Return to bug 110836