comparison org.eclipse.jface/src/org/eclipse/jface/util/ListenerList.d @ 12:bc29606a740c

Added dwt-addons in original directory structure of eclipse.org
author Frank Benoit <benoit@tionex.de>
date Sat, 14 Mar 2009 18:23:29 +0100
parents
children
comparison
equal deleted inserted replaced
11:43904fec5dca 12:bc29606a740c
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 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module org.eclipse.jface.util.ListenerList;
14
15 static import org.eclipse.core.runtime.ListenerList;
16
17 import java.lang.all;
18
19 /**
20 * This class is used to maintain a list of listeners, and is used in the
21 * implementations of several classes within JFace which allow you to register
22 * listeners of various kinds. It is a fairly lightweight object, occupying
23 * minimal space when no listeners are registered.
24 * <p>
25 * Note that the <code>add</code> method checks for and eliminates duplicates
26 * based on identity (not equality). Likewise, the <code>remove</code> method
27 * compares based on identity.
28 * </p>
29 * <p>
30 * Use the <code>getListeners</code> method when notifying listeners. Note
31 * that no garbage is created if no listeners are registered. The recommended
32 * code sequence for notifying all registered listeners of say,
33 * <code>FooListener.eventHappened</code>, is:
34 *
35 * <pre>
36 * Object[] listeners = myListenerList.getListeners();
37 * for (int i = 0; i &lt; listeners.length; ++i) {
38 * ((FooListener) listeners[i]).eventHappened(event);
39 * }
40 * </pre>
41 *
42 * </p>
43 *
44 * @deprecated Please use {@link org.eclipse.core.runtime.ListenerList} instead.
45 * Please note that the {@link #ListenerList(int)} and
46 * {@link org.eclipse.core.runtime.ListenerList#ListenerList(int)}
47 * constructors have different semantics. Please read the javadoc
48 * carefully. Also note that the equivalent of
49 * {@link #ListenerList()} is actually
50 * {@link org.eclipse.core.runtime.ListenerList#ListenerList(int)}
51 * with {@link org.eclipse.core.runtime.ListenerList#IDENTITY} as
52 * the argument.
53 */
54 public class ListenerList : org.eclipse.core.runtime.ListenerList.ListenerList {
55
56 /**
57 * Creates a listener list with an initial capacity of 1.
58 */
59 public this() {
60 super(IDENTITY);
61 }
62
63 /**
64 * Creates a listener list with the given initial capacity.
65 *
66 * @param capacity
67 * the number of listeners which this list can initially accept
68 * without growing its internal representation; must be at least
69 * 1
70 */
71 public this(int capacity) {
72 // the runtime ListenerList does not support capacity
73 this();
74 }
75 }