comparison org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/viewers/CheckableCheckedElementsObservableSet.d @ 85:6be48cf9f95c

Work on databinding
author Frank Benoit <benoit@tionex.de>
date Sat, 18 Apr 2009 13:54:50 +0200
parents 0a55d2d5a946
children
comparison
equal deleted inserted replaced
84:fcf926c91ca4 85:6be48cf9f95c
8 * Contributors: 8 * Contributors:
9 * Matthew Hall - initial API and implementation (bug 124684) 9 * Matthew Hall - initial API and implementation (bug 124684)
10 ******************************************************************************/ 10 ******************************************************************************/
11 11
12 module org.eclipse.jface.internal.databinding.viewers.CheckableCheckedElementsObservableSet; 12 module org.eclipse.jface.internal.databinding.viewers.CheckableCheckedElementsObservableSet;
13 import org.eclipse.jface.internal.databinding.viewers.ViewerElementSet;
13 14
14 import java.lang.all; 15 import java.lang.all;
15 16
16 import java.util.Collection; 17 import java.util.Collection;
17 import java.util.Collections; 18 import java.util.Collections;
66 * the set being wrapped 67 * the set being wrapped
67 */ 68 */
68 public this(Realm realm, 69 public this(Realm realm,
69 ICheckable checkable, Object elementType, Set wrappedSet) { 70 ICheckable checkable, Object elementType, Set wrappedSet) {
70 super(realm); 71 super(realm);
71 Assert.isNotNull(checkable, "Checkable cannot be null"); //$NON-NLS-1$ 72 Assert.isNotNull(cast(Object)checkable, "Checkable cannot be null"); //$NON-NLS-1$
72 Assert.isNotNull(wrappedSet, "Wrapped set cannot be null"); //$NON-NLS-1$ 73 Assert.isNotNull(cast(Object)wrappedSet, "Wrapped set cannot be null"); //$NON-NLS-1$
73 this.checkable = checkable; 74 this.checkable = checkable;
74 this.wrappedSet = wrappedSet; 75 this.wrappedSet = wrappedSet;
75 this.elementType = elementType; 76 this.elementType = elementType;
76 77
77 listener = new class(wrappedSet) ICheckStateListener { 78 listener = new class(wrappedSet) ICheckStateListener {
104 105
105 public Object getElementType() { 106 public Object getElementType() {
106 return elementType; 107 return elementType;
107 } 108 }
108 109
110 public bool add(String o) {
111 return add(stringcast(o));
112 }
109 public bool add(Object o) { 113 public bool add(Object o) {
110 getterCalled(); 114 getterCalled();
111 bool added = wrappedSet.add(o); 115 bool added = wrappedSet.add(o);
112 if (added) { 116 if (added) {
113 checkable.setChecked(o, true); 117 checkable.setChecked(o, true);
115 Collections.EMPTY_SET)); 119 Collections.EMPTY_SET));
116 } 120 }
117 return added; 121 return added;
118 } 122 }
119 123
124 alias AbstractObservableSet.remove remove;
125 public bool remove(String o) {
126 return remove(stringcast(o));
127 }
120 public bool remove(Object o) { 128 public bool remove(Object o) {
121 getterCalled(); 129 getterCalled();
122 bool removed = wrappedSet.remove(o); 130 bool removed = wrappedSet.remove(o);
123 if (removed) { 131 if (removed) {
124 checkable.setChecked(o, false); 132 checkable.setChecked(o, false);