1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2003, 2010 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
|
|
12
|
package org.eclipse.ui.internal.navigator.filters;
|
13
|
|
14
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
15
|
import org.eclipse.jface.viewers.Viewer;
|
16
|
import org.eclipse.ui.internal.navigator.NavigatorFilterService;
|
17
|
import org.eclipse.ui.navigator.INavigatorContentService;
|
18
|
|
19
|
/**
|
20
|
*
|
21
|
* <p>
|
22
|
* <strong>EXPERIMENTAL</strong>. This class or interface has been added as part of a work in
|
23
|
* progress. There is a guarantee neither that this API will work nor that it will remain the same.
|
24
|
* Please do not use this API without consulting with the Platform/UI team.
|
25
|
* </p>
|
26
|
*
|
27
|
* @since 3.2
|
28
|
*
|
29
|
*/
|
30
|
public class CommonFilterContentProvider implements IStructuredContentProvider {
|
31
|
|
32
|
private INavigatorContentService contentService;
|
33
|
private Object[] NO_ELEMENTS = new Object[0];
|
34
|
|
35
|
|
36
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
37
|
if (newInput instanceof INavigatorContentService) {
|
38
|
contentService = (INavigatorContentService) newInput;
|
39
|
}
|
40
|
}
|
41
|
|
42
|
/*
|
43
|
* (non-Javadoc)
|
44
|
*
|
45
|
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
46
|
*/
|
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
|
/*
|
57
|
* (non-Javadoc)
|
58
|
*
|
59
|
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
60
|
*/
|
61
|
public void dispose() {
|
62
|
|
63
|
}
|
64
|
|
65
|
}
|