Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 24508bd84032f89789afba29eeb2c17f145e1fe3 (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
/*******************************************************************************
 * Copyright (c) 2005, 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.launchConfigurations;

import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;

/**
 * Provides the implementation of the filter for filtering the launch configuration viewer based on the preference
 * <code>IInternalDebugUIConstants.PREF_FILTER_LAUNCH_TYPES</code>
 *
 * @since 3.2
 */
public class LaunchConfigurationTypeFilter extends ViewerFilter {

	/**
	 * Constructor
	 */
	public LaunchConfigurationTypeFilter() {
		super();
	}

	@Override
	public boolean select(Viewer viewer, Object parentElement, Object element) {
		if(element instanceof ILaunchConfiguration) {
			return true;
		}
		//we only care about launch configuration types
		if(element instanceof ILaunchConfigurationType) {
			IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
			String[] types = store.getString(IInternalDebugUIConstants.PREF_FILTER_TYPE_LIST).split("\\,"); //$NON-NLS-1$
			for (String type : types) {
				if (type.equals(((ILaunchConfigurationType)element).getIdentifier())) {
					return false;
				}
			}
			return true;
		}
		return false;
	}

}

Back to the top