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 (-25 / +117 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 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
	/**
(-)src/org/eclipse/ui/internal/views/log/FilterDialog.java (-1 / +131 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 = 280;
170
		gd.horizontalIndent = 20;
171
		filterList.setLayoutData(gd);
172
		filterList.addSelectionListener(new SelectionAdapter() {
173
			public void widgetSelected(SelectionEvent e) {
174
				removeFilter.setEnabled(true);
175
			}
176
		});
177
178
		addFilter = new Button(comp, SWT.NONE);
179
		gd = new GridData(GridData.FILL_HORIZONTAL);
180
		addFilter.setLayoutData(gd);
181
		addFilter.setText(Messages.FilterDialog_Add);
182
		addFilter.addSelectionListener(new SelectionAdapter() {
183
			public void widgetSelected(SelectionEvent e) {
184
				addFilter();
185
			}
186
		});
187
188
		removeFilter = new Button(comp, SWT.NONE);
189
		gd = new GridData(GridData.FILL_HORIZONTAL);
190
		removeFilter.setLayoutData(gd);
191
		removeFilter.setText(Messages.FilterDialog_Remove);
192
		removeFilter.setEnabled(false);
193
		removeFilter.addSelectionListener(new SelectionAdapter() {
194
			public void widgetSelected(SelectionEvent e) {
195
				removeFilter();
196
			}
197
		});
198
199
		// load preferences
200
		Boolean enable = memento.getBoolean(EventDetailsDialog.FILTER_ENABLED);
201
		enable = enable == null ? Boolean.FALSE : enable;
202
203
		filterEnabled.setSelection(enable.booleanValue());
204
		setStackTraceFilterEnabled(enable.booleanValue());
205
206
		String filters = memento.getString(EventDetailsDialog.FILTER_LIST);
207
		if (filters != null) {
208
			StringTokenizer st = new StringTokenizer(filters, ";"); //$NON-NLS-1$
209
			while (st.hasMoreElements()) {
210
				filterList.add(st.nextToken());
211
			}
212
		}
213
	}
214
215
	private void addFilter() {
216
		IInputValidator validator = new IInputValidator() {
217
218
			public String isValid(String newText) {
219
				return newText.indexOf(';') >= 0 ? Messages.FilterDialog_FilterShouldntContainSemicolon : null;
220
			}
221
222
		};
223
		InputDialog dialog = new InputDialog(getShell(), Messages.FilterDialog_AddFilterTitle, Messages.FilterDialog_AddFliterLabel, null, validator);
224
		if (dialog.open() == Window.OK) {
225
			String value = dialog.getValue().trim();
226
227
			if (value.length() > 0) {
228
				filterList.add(value);
229
			}
230
		}
231
	}
232
233
	private void removeFilter() {
234
		int index = filterList.getSelectionIndex();
235
		if (index != -1) {
236
			filterList.remove(index);
237
		}
238
239
		removeFilter.setEnabled(false);
240
	}
241
242
	private void setStackTraceFilterEnabled(boolean enabled) {
243
		filterList.setEnabled(enabled);
244
		addFilter.setEnabled(enabled);
245
		removeFilter.setEnabled(enabled && filterList.getSelectionIndex() != -1);
246
	}
247
132
	protected void createButtonsForButtonBar(Composite parent) {
248
	protected void createButtonsForButtonBar(Composite parent) {
133
		okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
249
		okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
134
		createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
250
		createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
Lines 141-146 Link Here
141
		memento.putString(LogView.P_LOG_LIMIT, limitText.getText());
257
		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$
258
		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$
259
		memento.putString(LogView.P_SHOW_ALL_SESSIONS, showAllButton.getSelection() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
260
261
		// store Event Dialog stack trace filter preferences
262
		memento.putBoolean(EventDetailsDialog.FILTER_ENABLED, filterEnabled.getSelection());
263
264
		StringBuffer sb = new StringBuffer();
265
		String[] items = filterList.getItems();
266
		for (int i = 0; i < items.length; i++) {
267
			sb.append(items[i]);
268
			if (i < items.length - 1) {
269
				sb.append(";"); //$NON-NLS-1$
270
			}
271
		}
272
		memento.putString(EventDetailsDialog.FILTER_LIST, sb.toString());
273
144
		super.okPressed();
274
		super.okPressed();
145
	}
275
	}

Return to bug 110836