SWT 위젯에 DataBinding을 사용하려고합니다.콤보에서 데이터 바인딩 사용
Combo Box을 모델의 기본 String에 연결하는 방법이 있는지 궁금합니다. 그래서 모델에 String, 내보기에 Combo이 있습니까? 표준 방식으로
가 작동하지 않습니다 ://View
DataBindingContext ctx = new DataBindingContext();
IObservableValue target1 = WidgetProperties.singleSelectionIndex().observe(combo);
IObservableValue model1 = BeanProperties.value(OutputVariable.class, "type").observe(outputVariable);
ctx.bindValue(target1, model1);
//Model
public void setType(String type) {
//TYPES is a constant with the possible Combo values
if (contains(TYPES, type)) {
String oldType = this.type;
this.type = type;
firePropertyChange("type", oldType, this.type);
}else {
throw new IllegalArgumentException();
}
}
나도 일을하지 않았다 fireIndexedPropertyChangeMethod을 사용했습니다.
둘을 연결하는 방법이 있습니까? 다른 WidgetProperties 또는 BeanProperties 방법을 사용해야합니까?
해결 방법으로는 콤보 선택 색인을 정의하고 Combo에 연결하고이 색인의 변경 사항을 유형 속성으로 이전하거나 그 반대의 경우에도 새 속성을 사용할 수 있습니다. 그러나 그것은 저에게 큰 해결책으로 보이지 않습니다.
편집 : selectionIndex 속성이있는 솔루션이 작동합니다. 그러나 모델의 type 속성 변경은 selectionIndex를 재설정해야하고, 그 반대로도 이제는 더 깨끗한 메소드가 유용 할 것입니다.