KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > launchConfigurations > LaunchConfigurationTypeFilter


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 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.debug.internal.ui.launchConfigurations;
12
13 import org.eclipse.debug.core.ILaunchConfiguration;
14 import org.eclipse.debug.core.ILaunchConfigurationType;
15 import org.eclipse.debug.internal.ui.DebugUIPlugin;
16 import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
17 import org.eclipse.jface.preference.IPreferenceStore;
18 import org.eclipse.jface.viewers.Viewer;
19 import org.eclipse.jface.viewers.ViewerFilter;
20
21 /**
22  * Provides the implementation of the filter for filtering the launch configuration viewer based on the preference
23  * <code>IInternalDebugUIConstants.PREF_FILTER_LAUNCH_TYPES</code>
24  *
25  * @since 3.2
26  */

27 public class LaunchConfigurationTypeFilter extends ViewerFilter {
28
29     /**
30      * Constructor
31      */

32     public LaunchConfigurationTypeFilter() {
33         super();
34     }
35
36     /* (non-Javadoc)
37      * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
38      */

39     public boolean select(Viewer viewer, Object JavaDoc parentElement, Object JavaDoc element) {
40         if(element instanceof ILaunchConfiguration) {
41             return true;
42         }
43         //we only care about launch configuration types
44
if(element instanceof ILaunchConfigurationType) {
45             IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();
46             String JavaDoc[] types = store.getString(IInternalDebugUIConstants.PREF_FILTER_TYPE_LIST).split("\\,"); //$NON-NLS-1$
47
for(int i = 0; i < types.length; i++) {
48                 if(types[i].equals(((ILaunchConfigurationType)element).getIdentifier())) {
49                     return false;
50                 }
51             }
52             return true;
53         }
54         return false;
55     }
56
57 }
58
Popular Tags