KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 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 package org.eclipse.jface.viewers;
12
13 import java.util.EventObject JavaDoc;
14
15 /**
16  * Event object describing a label provider state change.
17  *
18  * @see ILabelProviderListener
19  */

20 public class LabelProviderChangedEvent extends EventObject JavaDoc {
21
22     /**
23      * Generated serial version UID for this class.
24      * @since 3.1
25      */

26     private static final long serialVersionUID = 3258410612479309878L;
27     
28     /**
29      * The elements whose labels need to be updated or <code>null</code>.
30      */

31     private Object JavaDoc[] elements;
32
33     /**
34      * Creates a new event for the given source, indicating that all labels
35      * provided by the source are no longer valid and should be updated.
36      *
37      * @param source the label provider
38      */

39     public LabelProviderChangedEvent(IBaseLabelProvider source) {
40         super(source);
41     }
42
43     /**
44      * Creates a new event for the given source, indicating that the label
45      * provided by the source for the given elements is no longer valid and should be updated.
46      *
47      * @param source the label provider
48      * @param elements the element whose labels have changed
49      */

50     public LabelProviderChangedEvent(IBaseLabelProvider source,
51             Object JavaDoc[] elements) {
52         super(source);
53         this.elements = elements;
54     }
55
56     /**
57      * Creates a new event for the given source, indicating that the label
58      * provided by the source for the given element is no longer valid and should be updated.
59      *
60      * @param source the label provider
61      * @param element the element whose label needs to be updated
62      */

63     public LabelProviderChangedEvent(IBaseLabelProvider source, Object JavaDoc element) {
64         super(source);
65         this.elements = new Object JavaDoc[1];
66         this.elements[0] = element;
67     }
68
69     /**
70      * Returns the first element whose label needs to be updated,
71      * or <code>null</code> if all labels need to be updated.
72      *
73      * @return the element whose label needs to be updated or <code>null</code>
74      */

75     public Object JavaDoc getElement() {
76         if (this.elements == null || this.elements.length == 0) {
77             return null;
78         } else {
79             return this.elements[0];
80         }
81     }
82
83     /**
84      * Returns the elements whose labels need to be updated,
85      * or <code>null</code> if all labels need to be updated.
86      *
87      * @return the element whose labels need to be updated or <code>null</code>
88      */

89     public Object JavaDoc[] getElements() {
90         if (this.elements == null) {
91             return null;
92         } else {
93             return this.elements;
94         }
95     }
96 }
97
Popular Tags