KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > navigator > filters > FilterDialogSelectionListener


1 /*******************************************************************************
2  * Copyright (c) 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
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.Text;
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 Text descriptionText;
31
32     protected FilterDialogSelectionListener(Text 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 JavaDoc element = structuredSelection.getFirstElement();
47         if (element instanceof INavigatorContentDescriptor) {
48             INavigatorContentDescriptor ncd = (INavigatorContentDescriptor) element;
49             String JavaDoc desc = NLS
50                     .bind(
51                             CommonNavigatorMessages.CommonFilterSelectionDialog_Hides_all_content_associated,
52                             new Object JavaDoc[] { ncd.getName() });
53             descriptionText.setText(desc);
54         } else if (element instanceof ICommonFilterDescriptor) {
55             ICommonFilterDescriptor cfd = (ICommonFilterDescriptor) element;
56             String JavaDoc 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 }
66
Popular Tags