问题描述
我问了一个与我以前遇到的问题有关的问题,但是出现了一个新问题。最初,我希望能够通过单击突出显示表格中的一行,并通过双击来编辑单元格。 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 (将#修改为@)