KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > viewers > BaseLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 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.jface.viewers;
13
14 import org.eclipse.core.commands.common.EventManager;
15 import org.eclipse.jface.util.SafeRunnable;
16
17 /**
18  * BaseLabelProvider is a default concrete implementation of
19  * {@link IBaseLabelProvider}
20  *
21  * @since 3.3
22  *
23  */

24 public class BaseLabelProvider extends EventManager implements IBaseLabelProvider {
25     
26     /* (non-Javadoc)
27      * Method declared on IBaseLabelProvider.
28      */

29     public void addListener(ILabelProviderListener listener) {
30         addListenerObject(listener);
31     }
32
33     /**
34      * The <code>BaseLabelProvider</code> implementation of this
35      * <code>IBaseLabelProvider</code> method clears its internal listener list.
36      * Subclasses may extend but should call the super implementation.
37      */

38     public void dispose() {
39         clearListeners();
40     }
41     
42     /**
43      * The <code>BaseLabelProvider</code> implementation of this
44      * <code>IBaseLabelProvider</code> method returns <code>true</code>. Subclasses may
45      * override.
46      */

47     public boolean isLabelProperty(Object JavaDoc element, String JavaDoc property) {
48         return true;
49     }
50
51     
52     /* (non-Javadoc)
53      * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
54      */

55     public void removeListener(ILabelProviderListener listener) {
56         removeListenerObject(listener);
57     }
58     
59     /**
60      * Fires a label provider changed event to all registered listeners Only
61      * listeners registered at the time this method is called are notified.
62      *
63      * @param event
64      * a label provider changed event
65      *
66      * @see ILabelProviderListener#labelProviderChanged
67      */

68     protected void fireLabelProviderChanged(final LabelProviderChangedEvent event) {
69         Object JavaDoc[] listeners = getListeners();
70         for (int i = 0; i < listeners.length; ++i) {
71             final ILabelProviderListener l = (ILabelProviderListener) listeners[i];
72             SafeRunnable.run(new SafeRunnable() {
73                 public void run() {
74                     l.labelProviderChanged(event);
75                 }
76             });
77
78         }
79     }
80 }
81
Popular Tags