comparison org.eclipse.jface/src/org/eclipse/jface/action/AbstractAction.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) 2005, 2007 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 org.eclipse.jface.action.AbstractAction;
15
16 import org.eclipse.jface.action.IAction;
17
18 import org.eclipse.core.commands.common.EventManager;
19 import org.eclipse.jface.util.IPropertyChangeListener;
20 import org.eclipse.jface.util.PropertyChangeEvent;
21
22 import java.lang.all;
23
24 /**
25 * <p>
26 * Some common functionality to share between implementations of
27 * <code>IAction</code>. This functionality deals with the property change
28 * event mechanism.
29 * </p>
30 * <p>
31 * Clients may neither instantiate nor extend this class.
32 * </p>
33 *
34 * @since 3.2
35 */
36 public abstract class AbstractAction : EventManager, IAction {
37
38 public void addPropertyChangeListener(IPropertyChangeListener listener) {
39 addListenerObject(cast(Object)listener);
40 }
41
42 /**
43 * Notifies any property change listeners that a property has changed. Only
44 * listeners registered at the time this method is called are notified.
45 *
46 * @param event
47 * the property change event
48 *
49 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(PropertyChangeEvent)
50 */
51 protected final void firePropertyChange(PropertyChangeEvent event) {
52 final Object[] list = getListeners();
53 for (int i = 0; i < list.length; ++i) {
54 (cast(IPropertyChangeListener) list[i]).propertyChange(event);
55 }
56 }
57
58 /**
59 * Notifies any property change listeners that a property has changed. Only
60 * listeners registered at the time this method is called are notified. This
61 * method avoids creating an event object if there are no listeners
62 * registered, but calls
63 * <code>firePropertyChange(PropertyChangeEvent)</code> if there are.
64 *
65 * @param propertyName
66 * the name of the property that has changed
67 * @param oldValue
68 * the old value of the property, or <code>null</code> if none
69 * @param newValue
70 * the new value of the property, or <code>null</code> if none
71 *
72 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(PropertyChangeEvent)
73 */
74 protected final void firePropertyChange(String propertyName,
75 Object oldValue, Object newValue) {
76 if (isListenerAttached()) {
77 firePropertyChange(new PropertyChangeEvent(this, propertyName,
78 oldValue, newValue));
79 }
80 }
81
82 public void removePropertyChangeListener(
83 IPropertyChangeListener listener) {
84 removeListenerObject(cast(Object)listener);
85 }
86
87 }