1 /*******************************************************************************
2  * Copyright (c) 2003, 2015 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 
15 package org.eclipse.ui.internal.navigator.filters;
16 
17 import org.eclipse.jface.viewers.IStructuredContentProvider;
18 import org.eclipse.jface.viewers.Viewer;
19 import org.eclipse.ui.internal.navigator.NavigatorFilterService;
20 import org.eclipse.ui.navigator.INavigatorContentService;
21 
22 /**
23  *
24  * <p>
25  * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in
26  * progress. There is a guarantee neither that this API will work nor that it will remain the same.
27  * Please do not use this API without consulting with the Platform/UI team.
28  * </p>
29  *
30  * @since 3.2
31  *
32  */
33 public class CommonFilterContentProvider implements IStructuredContentProvider {
34 
35 	private INavigatorContentService contentService;
36 	private Object[] NO_ELEMENTS = new Object[0];
37 
38 
39 	@Override
inputChanged(Viewer viewer, Object oldInput, Object newInput)40 	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
41 		if (newInput instanceof INavigatorContentService) {
42 			contentService = (INavigatorContentService) newInput;
43 		}
44 	}
45 
46 	@Override
getElements(Object inputElement)47 	public Object[] getElements(Object inputElement) {
48 		if(contentService != null) {
49 			NavigatorFilterService filterService = (NavigatorFilterService) contentService.getFilterService();
50 			return filterService.getVisibleFilterDescriptorsForUI();
51 		}
52 		return NO_ELEMENTS ;
53 
54 	}
55 
56 	@Override
dispose()57 	public void dispose() {
58 
59 	}
60 
61 }
62