Mercurial > projects > dwt-addons
comparison dwtx/core/commands/Category.d @ 104:04b47443bb01
Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections.
These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 07 Aug 2008 15:01:33 +0200 |
parents | ea8ff534f622 |
children |
comparison
equal
deleted
inserted
replaced
103:2d6540440fe6 | 104:04b47443bb01 |
---|---|
10 * Port to the D programming language: | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | 11 * Frank Benoit <benoit@tionex.de> |
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 module dwtx.core.commands.Category; | 13 module dwtx.core.commands.Category; |
14 | 14 |
15 import tango.util.collection.ArraySeq; | |
16 | |
17 import dwtx.core.commands.common.NamedHandleObject; | 15 import dwtx.core.commands.common.NamedHandleObject; |
18 import dwtx.core.internal.commands.util.Util; | 16 import dwtx.core.internal.commands.util.Util; |
19 import dwtx.core.commands.ICategoryListener; | 17 import dwtx.core.commands.ICategoryListener; |
20 import dwtx.core.commands.CategoryEvent; | 18 import dwtx.core.commands.CategoryEvent; |
21 | 19 |
22 import dwt.dwthelper.utils; | 20 import dwt.dwthelper.utils; |
21 import dwtx.dwtxhelper.Collection; | |
23 import tango.text.convert.Format; | 22 import tango.text.convert.Format; |
24 | 23 |
25 /** | 24 /** |
26 * <p> | 25 * <p> |
27 * A logical group for a set of commands. A command belongs to exactly one | 26 * A logical group for a set of commands. A command belongs to exactly one |
35 | 34 |
36 /** | 35 /** |
37 * A collection of objects listening to changes to this category. This | 36 * A collection of objects listening to changes to this category. This |
38 * collection is <code>null</code> if there are no listeners. | 37 * collection is <code>null</code> if there are no listeners. |
39 */ | 38 */ |
40 private ArraySeq!(ICategoryListener) categoryListeners; | 39 private Collection categoryListeners; |
41 | 40 |
42 /** | 41 /** |
43 * Constructs a new instance of <code>Category</code> based on the given | 42 * Constructs a new instance of <code>Category</code> based on the given |
44 * identifier. When a category is first constructed, it is undefined. | 43 * identifier. When a category is first constructed, it is undefined. |
45 * Category should only be constructed by the <code>CommandManager</code> | 44 * Category should only be constructed by the <code>CommandManager</code> |
65 ICategoryListener categoryListener) { | 64 ICategoryListener categoryListener) { |
66 if (categoryListener is null) { | 65 if (categoryListener is null) { |
67 throw new NullPointerException(); | 66 throw new NullPointerException(); |
68 } | 67 } |
69 if (categoryListeners is null) { | 68 if (categoryListeners is null) { |
70 categoryListeners = new ArraySeq!(ICategoryListener); | 69 categoryListeners = new ArrayList(); |
71 } | 70 } |
72 if (!categoryListeners.contains(categoryListener)) { | 71 if (!categoryListeners.contains(cast(Object)categoryListener)) { |
73 categoryListeners.append(categoryListener); | 72 categoryListeners.add(cast(Object)categoryListener); |
74 } | 73 } |
75 } | 74 } |
76 | 75 |
77 /** | 76 /** |
78 * <p> | 77 * <p> |
118 private final void fireCategoryChanged(CategoryEvent categoryEvent) { | 117 private final void fireCategoryChanged(CategoryEvent categoryEvent) { |
119 if (categoryEvent is null) { | 118 if (categoryEvent is null) { |
120 throw new NullPointerException(); | 119 throw new NullPointerException(); |
121 } | 120 } |
122 if (categoryListeners !is null) { | 121 if (categoryListeners !is null) { |
123 foreach( listener; categoryListeners ){ | 122 Iterator listenerItr = categoryListeners.iterator(); |
123 while (listenerItr.hasNext()) { | |
124 ICategoryListener listener = cast(ICategoryListener) listenerItr | |
125 .next(); | |
124 listener.categoryChanged(categoryEvent); | 126 listener.categoryChanged(categoryEvent); |
125 } | 127 } |
126 } | 128 } |
127 } | 129 } |
128 | 130 |
138 if (categoryListener is null) { | 140 if (categoryListener is null) { |
139 throw new NullPointerException(); | 141 throw new NullPointerException(); |
140 } | 142 } |
141 | 143 |
142 if (categoryListeners !is null) { | 144 if (categoryListeners !is null) { |
143 categoryListeners.remove(categoryListener); | 145 categoryListeners.remove(cast(Object)categoryListener); |
144 } | 146 } |
145 } | 147 } |
146 | 148 |
147 /* | 149 /* |
148 * (non-Javadoc) | 150 * (non-Javadoc) |