0
我有一个由两列构成的表,其中包含第一列中的复选框和第二列中的ComboBoxCellEditor。当我在ComboBox中选择某个对象时,相应行状态的复选框应该更改为checked。根据RCP中的ComboBoxCellEditor选择更改复选框选择
tabViewer = new TableViewer(innerTopComp, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK);
而对于ComboBoxCellEditor我已经创建了一个扩展EditingSupport类。
public class ComboEditing extends EditingSupport {
private ComboBoxCellEditor cellEditor;
private String[] comboDataArr;
public ComboEditing(final TableViewer viewer, String[] ComboDataArr) {
super(viewer);
this.comboDataArr = ComboDataArr;
this.cellEditor = new ComboBoxCellEditor(((TableViewer)viewer).getTable(), this.comboDataArr, SWT.DROP_DOWN);
}
@Override
protected CellEditor getCellEditor(Object element) {
// TODO Auto-generated method stub
return cellEditor;
}
@Override
protected boolean canEdit(Object element) {
// TODO Auto-generated method stub
return true;
}
@Override
protected Object getValue(Object element) {
// TODO Auto-generated method stub
return 0;
}
@Override
protected void setValue(Object element, Object value) {
// TODO Auto-generated method stub
if((element instanceof TableData) && (value instanceof Integer)) {
Integer choice = (Integer)value;
String option = comboDataArr[choice];
((TableData)element).setMatches(option);
getViewer().update(element, null);
}
}
}
如何确认与该行的组合框,当某事在ComboBox选中该复选框。
你就不能做到这一点的''EditingSupport'方法setValue'? –
我将如何获取setValue方法中的相应复选框? – user387600
我认为你需要更清楚地解释你有什么以及你想做什么。 –