01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jface.viewers;
11:
12: import java.util.EventObject;
13:
14: /**
15: * Event object describing a label provider state change.
16: *
17: * @see ILabelProviderListener
18: */
19: public class LabelProviderChangedEvent extends EventObject {
20:
21: /**
22: * Generated serial version UID for this class.
23: * @since 3.1
24: */
25: private static final long serialVersionUID = 3258410612479309878L;
26:
27: /**
28: * The elements whose labels need to be updated or <code>null</code>.
29: */
30: private Object[] elements;
31:
32: /**
33: * Creates a new event for the given source, indicating that all labels
34: * provided by the source are no longer valid and should be updated.
35: *
36: * @param source the label provider
37: */
38: public LabelProviderChangedEvent(IBaseLabelProvider source) {
39: super (source);
40: }
41:
42: /**
43: * Creates a new event for the given source, indicating that the label
44: * provided by the source for the given elements is no longer valid and should be updated.
45: *
46: * @param source the label provider
47: * @param elements the element whose labels have changed
48: */
49: public LabelProviderChangedEvent(IBaseLabelProvider source,
50: Object[] elements) {
51: super (source);
52: this .elements = elements;
53: }
54:
55: /**
56: * Creates a new event for the given source, indicating that the label
57: * provided by the source for the given element is no longer valid and should be updated.
58: *
59: * @param source the label provider
60: * @param element the element whose label needs to be updated
61: */
62: public LabelProviderChangedEvent(IBaseLabelProvider source,
63: Object element) {
64: super (source);
65: this .elements = new Object[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 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[] getElements() {
90: if (this.elements == null) {
91: return null;
92: } else {
93: return this.elements;
94: }
95: }
96: }
|