Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 315876578e52cca01379d9fb0ff495cd1303beae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*******************************************************************************
 * Copyright (c) 2008, 2015 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 ******************************************************************************/

package org.eclipse.ui.internal.views.markers;

import org.eclipse.core.resources.IMarker;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.views.markers.MarkerFieldFilter;
import org.eclipse.ui.views.markers.MarkerItem;

/**
 * AllMarkersSeverityAndDescriptionFieldFilter is a
 * {@link SeverityAndDescriptionFieldFilter} that handles the no severity case.
 *
 * @since 3.4
 *
 */
public class AllMarkersSeverityAndDescriptionFieldFilter extends
		SeverityAndDescriptionFieldFilter {

	private boolean filterOnSeverity = false;
	private static String FILTER_ON_SEVERITY = "FILTER_ON_SEVERITY"; //$NON-NLS-1$

	/**
	 * Create a new instance of the receiver.
	 */
	public AllMarkersSeverityAndDescriptionFieldFilter() {
		super();
	}

	@Override
	public boolean select(MarkerItem item) {
		if (filterOnSeverity) {

			IMarker marker = item.getMarker();
			if (marker == null)
				return false;

			if (!checkSeverity(item.getAttributeValue(IMarker.SEVERITY, -1)))
				return false;
		}
		return super.select(item);
	}

	/**
	 * Return whether or not we are filtering on severity.
	 *
	 * @return boolean
	 */
	boolean getFilterOnSeverity() {
		return filterOnSeverity;
	}

	/**
	 * Set the whether or not we are filtering on severity
	 *
	 * @param filter
	 */
	void setFilterOnSeverity(boolean filter) {
		filterOnSeverity = filter;

	}

	@Override
	public void loadSettings(IMemento memento) {
		super.loadSettings(memento);

		Boolean filtering = memento.getBoolean(FILTER_ON_SEVERITY);
		if (filtering != null)
			filterOnSeverity = filtering.booleanValue();
	}

	@Override
	public void saveSettings(IMemento memento) {
		super.saveSettings(memento);
		memento.putBoolean(FILTER_ON_SEVERITY, filterOnSeverity);
	}

	@Override
	public void populateWorkingCopy(MarkerFieldFilter copy) {
		super.populateWorkingCopy(copy);
		((AllMarkersSeverityAndDescriptionFieldFilter) copy).filterOnSeverity = filterOnSeverity;
	}

}

Back to the top