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 (-1 / +8 lines)
Lines 1-5 Link Here
1
###############################################################################
1
###############################################################################
2
# Copyright (c) 2007 IBM Corporation and others.
2
# Copyright (c) 2007, 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 71-76 Link Here
71
EventDetailsDialog_previous=View Details Of Previous Event
71
EventDetailsDialog_previous=View Details Of Previous Event
72
EventDetailsDialog_next=View Details Of Next Event
72
EventDetailsDialog_next=View Details Of Next Event
73
EventDetailsDialog_copy=Copy Event Details To Clipboard
73
EventDetailsDialog_copy=Copy Event Details To Clipboard
74
EventDetailsDialog_FilterDialog=Filters
75
FilterDialog_Add=Add...
76
FilterDialog_AddFilterTitle=Add filter
77
FilterDialog_AddFliterLabel=Add filter:
78
FilterDialog_EnableFiltersCheckbox=Enable filters to hide stack trace elements in Event Details dialog.
79
FilterDialog_FilterShouldntContainSemicolon=Filter shouldn't contain semicolon
80
FilterDialog_Remove=Remove...
74
81
75
OpenLogDialog_title=Error Log
82
OpenLogDialog_title=Error Log
76
OpenLogDialog_message=Opening log...
83
OpenLogDialog_message=Opening log...
(-)src/org/eclipse/ui/internal/views/log/Messages.java (+7 lines)
Lines 78-84 Link Here
78
	public static String EventDetailsDialog_previous;
78
	public static String EventDetailsDialog_previous;
79
	public static String EventDetailsDialog_next;
79
	public static String EventDetailsDialog_next;
80
	public static String EventDetailsDialog_copy;
80
	public static String EventDetailsDialog_copy;
81
	public static String EventDetailsDialog_FilterDialog;
81
82
83
	public static String FilterDialog_Add;
84
	public static String FilterDialog_AddFilterTitle;
85
	public static String FilterDialog_AddFliterLabel;
86
	public static String FilterDialog_EnableFiltersCheckbox;
87
	public static String FilterDialog_FilterShouldntContainSemicolon;
88
	public static String FilterDialog_Remove;
82
	public static String OpenLogDialog_title;
89
	public static String OpenLogDialog_title;
83
	public static String OpenLogDialog_message;
90
	public static String OpenLogDialog_message;
84
	public static String OpenLogDialog_cannotDisplay;
91
	public static String OpenLogDialog_cannotDisplay;
(-)src/org/eclipse/ui/internal/views/log/LogView.java (-84 / +14 lines)
Lines 15-121 Link Here
15
15
16
package org.eclipse.ui.internal.views.log;
16
package org.eclipse.ui.internal.views.log;
17
17
18
import java.io.BufferedReader;
18
import com.ibm.icu.text.DateFormat;
19
import java.io.BufferedWriter;
19
import com.ibm.icu.text.SimpleDateFormat;
20
import java.io.File;
20
import java.io.*;
21
import java.io.FileInputStream;
22
import java.io.FileOutputStream;
23
import java.io.IOException;
24
import java.io.InputStreamReader;
25
import java.io.OutputStreamWriter;
26
import java.io.PrintWriter;
27
import java.io.StringWriter;
28
import java.lang.reflect.InvocationTargetException;
21
import java.lang.reflect.InvocationTargetException;
29
import java.util.ArrayList;
22
import java.util.*;
30
import java.util.Arrays;
31
import java.util.Collections;
32
import java.util.Comparator;
33
import java.util.Date;
34
import java.util.HashMap;
35
import java.util.Iterator;
36
import java.util.List;
23
import java.util.List;
37
import java.util.Map;
24
import org.eclipse.core.runtime.*;
38
39
import org.eclipse.core.runtime.ILogListener;
40
import org.eclipse.core.runtime.IProgressMonitor;
41
import org.eclipse.core.runtime.IStatus;
42
import org.eclipse.core.runtime.Path;
25
import org.eclipse.core.runtime.Path;
43
import org.eclipse.core.runtime.Platform;
44
import org.eclipse.core.runtime.Preferences;
45
import org.eclipse.core.runtime.Status;
46
import org.eclipse.core.runtime.jobs.Job;
26
import org.eclipse.core.runtime.jobs.Job;
47
import org.eclipse.jface.action.Action;
27
import org.eclipse.jface.action.*;
48
import org.eclipse.jface.action.IContributionItem;
28
import org.eclipse.jface.dialogs.*;
49
import org.eclipse.jface.action.IMenuListener;
50
import org.eclipse.jface.action.IMenuManager;
51
import org.eclipse.jface.action.IStatusLineManager;
52
import org.eclipse.jface.action.IToolBarManager;
53
import org.eclipse.jface.action.MenuManager;
54
import org.eclipse.jface.action.Separator;
55
import org.eclipse.jface.dialogs.IDialogSettings;
56
import org.eclipse.jface.dialogs.MessageDialog;
57
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
58
import org.eclipse.jface.operation.IRunnableWithProgress;
29
import org.eclipse.jface.operation.IRunnableWithProgress;
59
import org.eclipse.jface.util.Policy;
30
import org.eclipse.jface.util.Policy;
60
import org.eclipse.jface.viewers.DoubleClickEvent;
31
import org.eclipse.jface.viewers.*;
61
import org.eclipse.jface.viewers.IDoubleClickListener;
62
import org.eclipse.jface.viewers.ISelection;
63
import org.eclipse.jface.viewers.ISelectionChangedListener;
64
import org.eclipse.jface.viewers.IStructuredSelection;
65
import org.eclipse.jface.viewers.SelectionChangedEvent;
66
import org.eclipse.jface.viewers.Viewer;
67
import org.eclipse.jface.viewers.ViewerComparator;
68
import org.eclipse.jface.window.Window;
32
import org.eclipse.jface.window.Window;
69
import org.eclipse.osgi.util.NLS;
33
import org.eclipse.osgi.util.NLS;
70
import org.eclipse.swt.SWT;
34
import org.eclipse.swt.SWT;
71
import org.eclipse.swt.custom.BusyIndicator;
35
import org.eclipse.swt.custom.BusyIndicator;
72
import org.eclipse.swt.dnd.Clipboard;
36
import org.eclipse.swt.dnd.*;
73
import org.eclipse.swt.dnd.TextTransfer;
37
import org.eclipse.swt.events.*;
74
import org.eclipse.swt.dnd.Transfer;
38
import org.eclipse.swt.graphics.*;
75
import org.eclipse.swt.events.DisposeEvent;
76
import org.eclipse.swt.events.DisposeListener;
77
import org.eclipse.swt.events.SelectionAdapter;
78
import org.eclipse.swt.events.SelectionEvent;
79
import org.eclipse.swt.graphics.Color;
80
import org.eclipse.swt.graphics.Image;
81
import org.eclipse.swt.graphics.Point;
82
import org.eclipse.swt.graphics.Rectangle;
83
import org.eclipse.swt.layout.GridData;
39
import org.eclipse.swt.layout.GridData;
84
import org.eclipse.swt.layout.GridLayout;
40
import org.eclipse.swt.layout.GridLayout;
85
import org.eclipse.swt.program.Program;
41
import org.eclipse.swt.program.Program;
86
import org.eclipse.swt.widgets.Composite;
42
import org.eclipse.swt.widgets.*;
87
import org.eclipse.swt.widgets.Display;
43
import org.eclipse.ui.*;
88
import org.eclipse.swt.widgets.Event;
89
import org.eclipse.swt.widgets.FileDialog;
90
import org.eclipse.swt.widgets.Listener;
91
import org.eclipse.swt.widgets.Menu;
92
import org.eclipse.swt.widgets.Shell;
93
import org.eclipse.swt.widgets.Text;
94
import org.eclipse.swt.widgets.Tree;
95
import org.eclipse.swt.widgets.TreeColumn;
96
import org.eclipse.swt.widgets.TreeItem;
97
import org.eclipse.ui.IActionBars;
98
import org.eclipse.ui.IMemento;
99
import org.eclipse.ui.IPerspectiveDescriptor;
100
import org.eclipse.ui.IPerspectiveListener2;
101
import org.eclipse.ui.ISharedImages;
102
import org.eclipse.ui.IViewReference;
103
import org.eclipse.ui.IViewSite;
104
import org.eclipse.ui.IWorkbenchActionConstants;
105
import org.eclipse.ui.IWorkbenchPage;
106
import org.eclipse.ui.IWorkbenchPart;
107
import org.eclipse.ui.IWorkbenchPartReference;
108
import org.eclipse.ui.PartInitException;
109
import org.eclipse.ui.PlatformUI;
110
import org.eclipse.ui.XMLMemento;
111
import org.eclipse.ui.actions.ActionFactory;
44
import org.eclipse.ui.actions.ActionFactory;
112
import org.eclipse.ui.dialogs.FilteredTree;
45
import org.eclipse.ui.dialogs.FilteredTree;
113
import org.eclipse.ui.dialogs.PatternFilter;
46
import org.eclipse.ui.dialogs.PatternFilter;
114
import org.eclipse.ui.part.ViewPart;
47
import org.eclipse.ui.part.ViewPart;
115
48
116
import com.ibm.icu.text.DateFormat;
117
import com.ibm.icu.text.SimpleDateFormat;
118
119
public class LogView extends ViewPart implements ILogListener {
49
public class LogView extends ViewPart implements ILogListener {
120
	public static final String P_LOG_WARNING = "warning"; //$NON-NLS-1$
50
	public static final String P_LOG_WARNING = "warning"; //$NON-NLS-1$
121
	public static final String P_LOG_ERROR = "error"; //$NON-NLS-1$
51
	public static final String P_LOG_ERROR = "error"; //$NON-NLS-1$
Lines 470-476 Link Here
470
	}
400
	}
471
401
472
	private void createPropertiesAction() {
402
	private void createPropertiesAction() {
473
		fPropertiesAction = new EventDetailsDialogAction(fTree.getShell(), fFilteredTree.getViewer());
403
		fPropertiesAction = new EventDetailsDialogAction(fTree.getShell(), fFilteredTree.getViewer(), fMemento);
474
		fPropertiesAction.setImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_PROPERTIES));
404
		fPropertiesAction.setImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_PROPERTIES));
475
		fPropertiesAction.setDisabledImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_PROPERTIES_DISABLED));
405
		fPropertiesAction.setDisabledImageDescriptor(SharedImages.getImageDescriptor(SharedImages.DESC_PROPERTIES_DISABLED));
476
		fPropertiesAction.setToolTipText(Messages.LogView_properties_tooltip);
406
		fPropertiesAction.setToolTipText(Messages.LogView_properties_tooltip);
(-)src/org/eclipse/ui/internal/views/log/EventDetailsDialogAction.java (-4 / +10 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 12-24 Link Here
12
package org.eclipse.ui.internal.views.log;
12
package org.eclipse.ui.internal.views.log;
13
13
14
import java.util.Comparator;
14
import java.util.Comparator;
15
16
import org.eclipse.core.runtime.Assert;
15
import org.eclipse.core.runtime.Assert;
17
import org.eclipse.core.runtime.IAdaptable;
16
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.jface.viewers.ISelectionProvider;
17
import org.eclipse.jface.viewers.ISelectionProvider;
19
import org.eclipse.swt.widgets.Shell;
18
import org.eclipse.swt.widgets.Shell;
19
import org.eclipse.ui.IMemento;
20
import org.eclipse.ui.actions.SelectionProviderAction;
20
import org.eclipse.ui.actions.SelectionProviderAction;
21
21
22
/**
23
 * Opens EventDetailsDialog
24
 */
22
public class EventDetailsDialogAction extends SelectionProviderAction {
25
public class EventDetailsDialogAction extends SelectionProviderAction {
23
26
24
	/**
27
	/**
Lines 28-46 Link Here
28
	private ISelectionProvider provider;
31
	private ISelectionProvider provider;
29
	private EventDetailsDialog propertyDialog;
32
	private EventDetailsDialog propertyDialog;
30
	private Comparator comparator;
33
	private Comparator comparator;
34
	private IMemento memento;
31
35
32
	/**
36
	/**
33
	 * Creates a new action for opening a property dialog
37
	 * Creates a new action for opening a property dialog
34
	 * on the elements from the given selection provider
38
	 * on the elements from the given selection provider
35
	 * @param shell - the shell in which the dialog will open
39
	 * @param shell - the shell in which the dialog will open
36
	 * @param provider - the selection provider whose elements
40
	 * @param provider - the selection provider whose elements
41
	 * @param memento - memento with EventDetails dialog options
37
	 * the property dialog will describe
42
	 * the property dialog will describe
38
	 */
43
	 */
39
	public EventDetailsDialogAction(Shell shell, ISelectionProvider provider) {
44
	public EventDetailsDialogAction(Shell shell, ISelectionProvider provider, IMemento memento) {
40
		super(provider, Messages.EventDetailsDialog_title);
45
		super(provider, Messages.EventDetailsDialog_title);
41
		Assert.isNotNull(shell);
46
		Assert.isNotNull(shell);
42
		this.shell = shell;
47
		this.shell = shell;
43
		this.provider = provider;
48
		this.provider = provider;
49
		this.memento = memento;
44
		// setToolTipText
50
		// setToolTipText
45
		//WorkbenchHelp.setHelp
51
		//WorkbenchHelp.setHelp
46
	}
52
	}
Lines 86-92 Link Here
86
		if ((element == null) || (!(element instanceof LogEntry)))
92
		if ((element == null) || (!(element instanceof LogEntry)))
87
			return;
93
			return;
88
94
89
		propertyDialog = new EventDetailsDialog(shell, element, provider, comparator);
95
		propertyDialog = new EventDetailsDialog(shell, element, provider, comparator, memento);
90
		propertyDialog.create();
96
		propertyDialog.create();
91
		propertyDialog.getShell().setText(Messages.EventDetailsDialog_title);
97
		propertyDialog.getShell().setText(Messages.EventDetailsDialog_title);
92
		propertyDialog.open();
98
		propertyDialog.open();
(-)src/org/eclipse/ui/internal/views/log/EventDetailsDialog.java (-12 / +108 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 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
	/**
(-)src/org/eclipse/ui/internal/views/log/FilterDialog.java (-1 / +130 lines)
Lines 10-17 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.views.log;
11
package org.eclipse.ui.internal.views.log;
12
12
13
import java.util.StringTokenizer;
13
import org.eclipse.jface.dialogs.*;
14
import org.eclipse.jface.dialogs.*;
14
import org.eclipse.jface.dialogs.Dialog;
15
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.jface.window.Window;
15
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.*;
18
import org.eclipse.swt.events.*;
17
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.layout.GridData;
Lines 21-34 Link Here
21
import org.eclipse.ui.IMemento;
23
import org.eclipse.ui.IMemento;
22
24
23
public class FilterDialog extends TrayDialog {
25
public class FilterDialog extends TrayDialog {
26
27
	Button okButton;
28
29
	// entries count limit
24
	private Button limit;
30
	private Button limit;
25
	Text limitText;
31
	Text limitText;
26
32
27
	Button okButton;
33
	// entry types filter
28
	private Button errorButton;
34
	private Button errorButton;
29
	private Button warningButton;
35
	private Button warningButton;
30
	private Button infoButton;
36
	private Button infoButton;
37
38
	// show all sessions
31
	private Button showAllButton;
39
	private Button showAllButton;
40
41
	// filter stack trace elements in EventDetailsDialog
42
	private Button filterEnabled;
43
	private Button addFilter;
44
	private Button removeFilter;
45
	private List filterList;
46
32
	private IMemento memento;
47
	private IMemento memento;
33
48
34
	public FilterDialog(Shell parentShell, IMemento memento) {
49
	public FilterDialog(Shell parentShell, IMemento memento) {
Lines 41-46 Link Here
41
		createEventTypesGroup(container);
56
		createEventTypesGroup(container);
42
		createLimitSection(container);
57
		createLimitSection(container);
43
		createSessionSection(container);
58
		createSessionSection(container);
59
		createFilterSection(container);
44
60
45
		Dialog.applyDialogFont(container);
61
		Dialog.applyDialogFont(container);
46
		return container;
62
		return container;
Lines 129-134 Link Here
129
		}
145
		}
130
	}
146
	}
131
147
148
	private void createFilterSection(Composite parent) {
149
		Composite comp = new Composite(parent, SWT.NONE);
150
		GridLayout layout = new GridLayout(2, false);
151
		comp.setLayout(layout);
152
		comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
153
154
		filterEnabled = new Button(comp, SWT.CHECK);
155
		filterEnabled.setText(Messages.FilterDialog_EnableFiltersCheckbox);
156
		GridData gd = new GridData();
157
		gd.horizontalSpan = 2;
158
		filterEnabled.setLayoutData(gd);
159
		filterEnabled.addSelectionListener(new SelectionAdapter() {
160
			public void widgetSelected(SelectionEvent e) {
161
				setStackTraceFilterEnabled(filterEnabled.getSelection());
162
			}
163
164
		});
165
166
		filterList = new List(comp, SWT.BORDER);
167
		gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
168
		gd.verticalSpan = 3;
169
		gd.widthHint = 300;
170
		filterList.setLayoutData(gd);
171
		filterList.addSelectionListener(new SelectionAdapter() {
172
			public void widgetSelected(SelectionEvent e) {
173
				removeFilter.setEnabled(true);
174
			}
175
		});
176
177
		addFilter = new Button(comp, SWT.NONE);
178
		gd = new GridData(GridData.FILL_HORIZONTAL);
179
		addFilter.setLayoutData(gd);
180
		addFilter.setText(Messages.FilterDialog_Add);
181
		addFilter.addSelectionListener(new SelectionAdapter() {
182
			public void widgetSelected(SelectionEvent e) {
183
				addFilter();
184
			}
185
		});
186
187
		removeFilter = new Button(comp, SWT.NONE);
188
		gd = new GridData(GridData.FILL_HORIZONTAL);
189
		removeFilter.setLayoutData(gd);
190
		removeFilter.setText(Messages.FilterDialog_Remove);
191
		removeFilter.setEnabled(false);
192
		removeFilter.addSelectionListener(new SelectionAdapter() {
193
			public void widgetSelected(SelectionEvent e) {
194
				removeFilter();
195
			}
196
		});
197
198
		// load preferences
199
		Boolean enable = memento.getBoolean(EventDetailsDialog.FILTER_ENABLED);
200
		enable = enable == null ? Boolean.FALSE : enable;
201
202
		filterEnabled.setSelection(enable.booleanValue());
203
		setStackTraceFilterEnabled(enable.booleanValue());
204
205
		String filters = memento.getString(EventDetailsDialog.FILTER_LIST);
206
		if (filters != null) {
207
			StringTokenizer st = new StringTokenizer(filters, ";"); //$NON-NLS-1$
208
			while (st.hasMoreElements()) {
209
				filterList.add(st.nextToken());
210
			}
211
		}
212
	}
213
214
	private void addFilter() {
215
		IInputValidator validator = new IInputValidator() {
216
217
			public String isValid(String newText) {
218
				return newText.indexOf(';') >= 0 ? Messages.FilterDialog_FilterShouldntContainSemicolon : null;
219
			}
220
221
		};
222
		InputDialog dialog = new InputDialog(getShell(), Messages.FilterDialog_AddFilterTitle, Messages.FilterDialog_AddFliterLabel, null, validator);
223
		if (dialog.open() == Window.OK) {
224
			String value = dialog.getValue().trim();
225
226
			if (value.length() > 0) {
227
				filterList.add(value);
228
			}
229
		}
230
	}
231
232
	private void removeFilter() {
233
		int index = filterList.getSelectionIndex();
234
		if (index != -1) {
235
			filterList.remove(index);
236
		}
237
238
		removeFilter.setEnabled(false);
239
	}
240
241
	private void setStackTraceFilterEnabled(boolean enabled) {
242
		filterList.setEnabled(enabled);
243
		addFilter.setEnabled(enabled);
244
		removeFilter.setEnabled(enabled && filterList.getSelectionIndex() != -1);
245
	}
246
132
	protected void createButtonsForButtonBar(Composite parent) {
247
	protected void createButtonsForButtonBar(Composite parent) {
133
		okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
248
		okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
134
		createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
249
		createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
Lines 141-146 Link Here
141
		memento.putString(LogView.P_LOG_LIMIT, limitText.getText());
256
		memento.putString(LogView.P_LOG_LIMIT, limitText.getText());
142
		memento.putString(LogView.P_USE_LIMIT, limit.getSelection() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
257
		memento.putString(LogView.P_USE_LIMIT, limit.getSelection() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
143
		memento.putString(LogView.P_SHOW_ALL_SESSIONS, showAllButton.getSelection() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
258
		memento.putString(LogView.P_SHOW_ALL_SESSIONS, showAllButton.getSelection() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
259
260
		// store Event Dialog stack trace filter preferences
261
		memento.putBoolean(EventDetailsDialog.FILTER_ENABLED, filterEnabled.getSelection());
262
263
		StringBuffer sb = new StringBuffer();
264
		String[] items = filterList.getItems();
265
		for (int i = 0; i < items.length; i++) {
266
			sb.append(items[i]);
267
			if (i < items.length - 1) {
268
				sb.append(";"); //$NON-NLS-1$
269
			}
270
		}
271
		memento.putString(EventDetailsDialog.FILTER_LIST, sb.toString());
272
144
		super.okPressed();
273
		super.okPressed();
145
	}
274
	}

Return to bug 110836