2
我是否應該從EditingSupport.getCellEditor
返回CellEditor
,如果是這樣,我應該怎麼做。我是否應該處理從EditorSupport返回的jface CellEditors
論的JFace TableViewer
教程之一,我看到下面的代碼片段:
public class FirstNameEditingSupport extends EditingSupport {
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(viewer.getTable());
}
所以將這種方法泄漏內存,如果電池被編輯了多次?或者我應該只是懶惰初始化CellEditor
:
public class FirstNameEditingSupport extends EditingSupport {
CellEditor editor;
@Override
protected CellEditor getCellEditor(Object element) {
if(editor == null){
editor = new TextCellEditor(viewer.getTable());
}
return editor;
}
它來自:http://www.vogella.de/articles/EclipseJFaceTable/article.html#viewer – 2011-05-16 20:38:07