lse if (object instanceof Combo
&& SWTProperties.ITEMS.equals(attribute)) {
return new ComboObservableList((Combo) object);
}
賠汽 20 ?幣栖徭光倖窃議旗鷹頭粁。壓聞喘 ComboObservableValue 怏栽崇癖塘欺 IObservable 峙扮?怏栽崇屡辛參淫根匯倖僉??匆辛參淫根?猟云弌何周匯劔返強補秘議猟云?咀緩 get() 圭隈繍殊臥宸嶽秤趨旺距喘怏栽崇陣周貧議?哘峙栖殊沫峙。窃貌仇?setValue() 圭隈繍殊臥陳倖奉來厮瓜鰯協旺距喘?哘議 setter?隼朔乾窟匯倖峙厚個並周參宥岑湖佶箸議光圭。壓寄謹方糞箭嶄?ComboObservableList 繍溜熔公怏栽崇。add() 才 remove() 吉圭隈頁箭翌?咀葎駅倬幹秀厚個議 Diff 參工壓 firstListChange() 圭隈嶄聞喘。
賠汽 20. ComboObservableValue 才 ComboObservableList 嶄議旗鷹頭粁
public class ComboObservableValue extends AbstractObservableValue {
...
public void setValue(final Object value) {
String oldValue = combo.getText();
try {
updating = true;
if (attribute.equals(SWTProperties.TEXT)) {
String stringValue =
value != null ? value.toString() : ""; //$NON-NLS-1$
combo.setText(stringValue);
} else if (attribute.equals(SWTProperties.SELECTION)) {
String items[] = combo.getItems();
int index = -1;
if (items != null && value != null) {
for (int i = 0; i < items.length; i++) {
if (value.equals(items[i])) {
index = i;
break;
}
}
if (index == -1) {
combo.setText((String) value);
} else {
combo.select(index);
}
}
}
} finally {
updating = false;
}
fireValueChange(Diffs.createValueDiff(oldValue, combo.getText()));
}
public Object doGetValue() {
if (attribute.equals(SWTProperties.TEXT))
return combo.getText();
Assert.isTrue(attribute.equals(SWTProperties.SELECTION),
"unexpected attribute: " + attribute); //$NON-NLS-1$
// The problem with a combo, is that it changes the text and
// fires before it update its selection index
return combo.getText();
}
}
public class ComboObservableList extends SWTObservableList {
priva
|