Mercurial > projects > dwt-addons
annotate dwtx/jface/internal/provisional/action/ToolBarManager2.d @ 43:ea8ff534f622
Fix override and super aliases
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 11 Apr 2008 01:24:25 +0200 |
parents | ef4534de0cf9 |
children |
rev | line source |
---|---|
35 | 1 /******************************************************************************* |
2 * Copyright (c) 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 | |
14 module dwtx.jface.internal.provisional.action.ToolBarManager2; | |
15 | |
16 import dwtx.jface.internal.provisional.action.IToolBarManager2; | |
17 import dwtx.jface.action.IContributionManagerOverrides; | |
18 | |
19 import dwt.widgets.Composite; | |
20 import dwt.widgets.Control; | |
21 import dwt.widgets.ToolBar; | |
22 import dwtx.core.runtime.ListenerList; | |
23 import dwtx.jface.action.ToolBarManager; | |
24 import dwtx.jface.util.IPropertyChangeListener; | |
25 import dwtx.jface.util.PropertyChangeEvent; | |
26 | |
27 import dwt.dwthelper.utils; | |
28 | |
29 /** | |
30 * Extends <code>ToolBarManager</code> to implement <code>IToolBarManager2</code>. | |
31 * | |
32 * <p> | |
33 * <strong>EXPERIMENTAL</strong>. This class or interface has been added as | |
34 * part of a work in progress. There is a guarantee neither that this API will | |
35 * work nor that it will remain the same. Please do not use this API without | |
36 * consulting with the Platform/UI team. | |
37 * </p> | |
38 * | |
39 * @since 3.2 | |
40 */ | |
41 public class ToolBarManager2 : ToolBarManager, IToolBarManager2 { | |
42 | |
43 // delegate to super | |
44 public ToolBar createControl(Composite parent) { | |
45 return super.createControl(parent); | |
46 } | |
47 public ToolBar getControl() { | |
48 return super.getControl(); | |
49 } | |
50 public void dispose() { | |
51 super.dispose(); | |
52 } | |
53 public void setOverrides(IContributionManagerOverrides newOverrides) { | |
54 super.setOverrides(newOverrides); | |
55 } | |
56 | |
57 /** | |
58 * A collection of objects listening to changes to this manager. This | |
59 * collection is <code>null</code> if there are no listeners. | |
60 */ | |
61 private /+transient+/ ListenerList listenerList = null; | |
62 | |
63 /** | |
64 * Creates a new tool bar manager with the default DWT button style. Use the | |
65 * <code>createControl</code> method to create the tool bar control. | |
66 */ | |
67 public this() { | |
68 super(); | |
69 } | |
70 | |
71 /** | |
72 * Creates a tool bar manager with the given DWT button style. Use the | |
73 * <code>createControl</code> method to create the tool bar control. | |
74 * | |
75 * @param style | |
76 * the tool bar item style | |
77 * @see dwt.widgets.ToolBar for valid style bits | |
78 */ | |
79 public this(int style) { | |
80 super(style); | |
81 } | |
82 | |
83 /** | |
84 * Creates a tool bar manager for an existing tool bar control. This manager | |
85 * becomes responsible for the control, and will dispose of it when the | |
86 * manager is disposed. | |
87 * | |
88 * @param toolbar | |
89 * the tool bar control | |
90 */ | |
91 public this(ToolBar toolbar) { | |
92 super(toolbar); | |
93 } | |
94 | |
95 /* (non-Javadoc) | |
96 * @see dwtx.jface.action.IToolBarManager2#createControl2(dwt.widgets.Composite) | |
97 */ | |
98 public Control createControl2(Composite parent) { | |
99 return createControl(parent); | |
100 } | |
101 | |
102 /* (non-Javadoc) | |
103 * @see dwtx.jface.action.IToolBarManager2#getControl2() | |
104 */ | |
105 public Control getControl2() { | |
106 return getControl(); | |
107 } | |
108 | |
109 /* (non-Javadoc) | |
110 * @see dwtx.jface.action.IToolBarManager2#getItemCount() | |
111 */ | |
112 public int getItemCount() { | |
113 ToolBar toolBar = getControl(); | |
114 if (toolBar is null || toolBar.isDisposed()) { | |
115 return 0; | |
116 } | |
117 return toolBar.getItemCount(); | |
118 } | |
119 | |
120 /* (non-Javadoc) | |
121 * @see dwtx.jface.action.IToolBarManager2#addPropertyChangeListener(dwtx.jface.util.IPropertyChangeListener) | |
122 */ | |
123 public void addPropertyChangeListener(IPropertyChangeListener listener) { | |
124 if (listenerList is null) { | |
125 listenerList = new ListenerList(ListenerList.IDENTITY); | |
126 } | |
127 | |
128 listenerList.add(cast(Object)listener); | |
129 } | |
130 | |
131 /* (non-Javadoc) | |
132 * @see dwtx.jface.action.IToolBarManager2#removePropertyChangeListener(dwtx.jface.util.IPropertyChangeListener) | |
133 */ | |
134 public void removePropertyChangeListener(IPropertyChangeListener listener) { | |
135 if (listenerList !is null) { | |
136 listenerList.remove(cast(Object)listener); | |
137 | |
138 if (listenerList.isEmpty()) { | |
139 listenerList = null; | |
140 } | |
141 } | |
142 } | |
143 | |
144 /** | |
145 * @return the listeners attached to this event manager. | |
146 * The listeners currently attached; may be empty, but never | |
147 * null. | |
148 * | |
149 */ | |
150 protected final Object[] getListeners() { | |
151 final ListenerList list = listenerList; | |
152 if (list is null) { | |
153 return new Object[0]; | |
154 } | |
155 | |
156 return list.getListeners(); | |
157 } | |
158 | |
159 /* | |
160 * Notifies any property change listeners that a property has changed. Only | |
161 * listeners registered at the time this method is called are notified. | |
162 */ | |
163 private void firePropertyChange(PropertyChangeEvent event) { | |
164 Object[] list = getListeners(); | |
165 for (int i = 0; i < list.length; ++i) { | |
166 (cast(IPropertyChangeListener) list[i]).propertyChange(event); | |
167 } | |
168 } | |
169 | |
170 /* | |
171 * Notifies any property change listeners that a property has changed. Only | |
172 * listeners registered at the time this method is called are notified. This | |
173 * method avoids creating an event object if there are no listeners | |
174 * registered, but calls firePropertyChange(PropertyChangeEvent) if there are. | |
175 */ | |
176 private void firePropertyChange(String propertyName, | |
177 Object oldValue, Object newValue) { | |
178 if (listenerList !is null) { | |
179 firePropertyChange(new PropertyChangeEvent(this, propertyName, | |
180 oldValue, newValue)); | |
181 } | |
182 } | |
183 | |
184 /* (non-Javadoc) | |
185 * @see dwtx.jface.action.ToolBarManager#relayout(dwt.widgets.ToolBar, int, int) | |
186 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
35
diff
changeset
|
187 protected override void relayout(ToolBar layoutBar, int oldCount, int newCount) { |
35 | 188 super.relayout(layoutBar, oldCount, newCount); |
189 firePropertyChange(PROP_LAYOUT, new Integer(oldCount), new Integer(newCount)); | |
190 } | |
191 } |