如何解决SWT / Jface单元格文本未保存在模型中
我问了一个与我以前遇到的问题有关的问题,但是出现了一个新问题。最初,我希望能够通过单击突出显示表格中的一行,并通过双击来编辑单元格。 greg-449给了我解决该问题的方法(摆脱FocusCellManager并简单地将EditingSupport与我拥有的其他类一起使用,并设置editorActivationStrategy使其具有MOUSE_DOUBLE_CLICK_SELECTIOn位。但是,现在当我在单元格中键入文本时,文本不会保存到我的模型中;另一方面,当我使用FocusCellManager时,文本确实已保存。
现在,我必须使用CellEditors,因为已经为特定的列设置了很长的CellEditor列表。我不确定是否可以将EditingSupport与CellEditor一起使用,或者根本不需要。我要附上一些摘要。
DatumTableViewer.java的相关部分:
FocusCellOwnerDrawHighlighter drawHighlighter = new FocusCellOwnerDrawHighlighter(this); //removed this to fix the highlighting issue
final TableViewerFocusCellManager mgr = new TableViewerFocusCellManager(this,drawHighlighter); //removed this to fix the highlighting issue.
final ColumnViewerEditorActivationStrategy editorActivationSupport = getEditorActivationStrategy();
int tableKeyboardTraversalFeature = getKeyboardTraversalFeature();
TableViewerEditor.create(this,mgr,editorActivationSupport,tableKeyboardActivationFeature);
DatumColumnEmnum[] tableColumnsAsArray = getTableColumnsAsArray();
createTable(this.getTable(),tableColumnsAsArray);
setColumnProperties(properties.getPresentedColumnNames); //properties is passed into constructor
setCellEditors(tableColumnsAsArray); //I think this doesn't work properly without FocusCellManager
DatumCellModifier modifier = new DatumCellModifier(this,properties,myExpressionDataProvider); // myExpressionDataProvider is passed into constructor)
setCellModifier(modifier);
setContentProvider(contentProvider);
setInput(_myDatumList); // myDatumList set before this snippet
}
setCellEditors:
private void setCellEditors(DatumColumnEnum[] columns)
{
cellEditor[] editors = new CellEditor[columns.length];
for(int i = 0; i < columns.length; i++){
DatumColumnEnum columnID = columns[i];
switch(columnID) // cases have been trimmed to shorten this snippet
{
case DATUM_ID_COLUMN:
case DATUM_NUMBER_COLUMN:
case DATUM_NAME_COLUMN:
editors[i] = new TextCellEditor(this.getTable());
((Text) editors[i].getControl()).setTextLimit(60);
break;
}
}
this.setCellEditors(editors);
}
我怀疑这些代码片段包含问题,但是如果没有,请告诉我,我还将添加其他功能。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。