如何解决RCP 中的复选框状态未更新
我是 RCP 框架的初学者。在这个编辑器中,我制作了一张带有 SWT.Check Table 项目的 SWT 表。我在复选框选择方面遇到了问题。
ReloadView() 函数以一定的时间间隔触发并获取数据库更改并尝试更改数据但它没有反映在视图中。调试代码,发现没有数据问题,但没有更新现有的表/选择。
private static final Button[] checkBoxButton = new Button[size];
public void createPartControl(Composite parent)
{
toolkit = new FormToolkit(parent.getDisplay());
compositeObj = toolkit.createComposite(parent,SWT.NONE);
GridLayout layout = new GridLayout();
compositeObj.setLayout(layout);
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.horizontalSpan = 4;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
Button button = new Button(compositeObj,SWT.PUSH);
button.setLayoutData(new GridData(SWT.BEGINNING,SWT.CENTER,false,false));
button.setText(" Test ");
btsViewer = new TableViewer(compositeObj,SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL |
SWT.FULL_SELECTION| SWT.BORDER );
btsViewer.getControl().setLayoutData(gridData);
final int[] bounds = { 30,80};
for (int i = 0; i < titles.length; i++)
{
TableViewerColumn viewerColumn = new TableViewerColumn(btsViewer,SWT.NONE);
final TableColumn column = viewerColumn.getColumn();
column.setText(titles[i]);
column.setWidth(bounds[i]);
column.setResizable(true);
column.setMoveable(true);
column.pack();
}
table = btsViewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
for (int i = 0; i < titles.length; i++)
new TableItem(table,SWT.NONE);
ReloadView(parent);
}
public final static void ReloadView(Composite parent) {
int Count = 0;
dataProvider = SqlData.collectDetails();
if (dataProvider.size() != 0) {
for (DataProvider data : dataProvider) {
Trigger(parent,data.sTemp,data.bstate,Count);
Count++;
}
}
}
public final static void Trigger(Composite parent,String sTemp,Boolean bstate,final int Index){
TableItem[] items = table.getItems();
Label propertyLabel = null;
editor[index] = new TableEditor(table);
checkBoxButton[index] = toolkit.createButton(table," ",SWT.CHECK);
checkBoxButton[index].pack();
checkBoxButton[index].setSelection(bstate);
editor[index].grabHorizontal = true;
editor[index].setEditor(checkBoxButton[index],items[index],0);
editor[index] = new TableEditor(table);
propertyLabel = toolkit.createLabel(table,sTemp,SWT.CENTER);
editor[index].grabHorizontal = true;
editor[index].setEditor(propertyLabel,1);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。