1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2009 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.ISelectionChangedListener;
|
15
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
16
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
17
|
import org.eclipse.osgi.util.NLS;
|
18
|
import org.eclipse.swt.widgets.Label;
|
19
|
import org.eclipse.ui.internal.navigator.CommonNavigatorMessages;
|
20
|
import org.eclipse.ui.navigator.ICommonFilterDescriptor;
|
21
|
import org.eclipse.ui.navigator.INavigatorContentDescriptor;
|
22
|
|
23
|
/**
|
24
|
* @since 3.2
|
25
|
*
|
26
|
*/
|
27
|
public class FilterDialogSelectionListener implements ISelectionChangedListener {
|
28
|
|
29
|
|
30
|
private Label descriptionText;
|
31
|
|
32
|
protected FilterDialogSelectionListener(Label aDescriptionText) {
|
33
|
descriptionText = aDescriptionText;
|
34
|
|
35
|
}
|
36
|
|
37
|
/*
|
38
|
* (non-Javadoc)
|
39
|
*
|
40
|
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
|
41
|
*/
|
42
|
public void selectionChanged(SelectionChangedEvent event) {
|
43
|
|
44
|
IStructuredSelection structuredSelection = (IStructuredSelection) event
|
45
|
.getSelection();
|
46
|
Object element = structuredSelection.getFirstElement();
|
47
|
if (element instanceof INavigatorContentDescriptor) {
|
48
|
INavigatorContentDescriptor ncd = (INavigatorContentDescriptor) element;
|
49
|
String desc = NLS
|
50
|
.bind(
|
51
|
CommonNavigatorMessages.CommonFilterSelectionDialog_Hides_all_content_associated,
|
52
|
new Object[] { ncd.getName() });
|
53
|
descriptionText.setText(desc);
|
54
|
} else if (element instanceof ICommonFilterDescriptor) {
|
55
|
ICommonFilterDescriptor cfd = (ICommonFilterDescriptor) element;
|
56
|
String description = cfd.getDescription();
|
57
|
if(description != null)
|
58
|
descriptionText.setText(description);
|
59
|
else
|
60
|
descriptionText.setText(NLS.bind(CommonNavigatorMessages.FilterDialogSelectionListener_Enable_the_0_filter_, cfd.getName()));
|
61
|
}
|
62
|
|
63
|
}
|
64
|
|
65
|
}
|