final TreeItem item = new TreeItem(tree, SWT.NONE, i);
item.setText(0, descriptor.getDisplayName());
item.setText(1, getStringValue(descriptor, value));
CellEditor cellEditor = descriptor.createPropertyEditor(tree);
CellEditorListener cellEditorListener = null;
if (cellEditor != null) {
cellEditor.setValue(value);
cellEditorListener = new CellEditorListener(item, descriptor, cellEditor);
cellEditor.addListener(cellEditorListener);
CellEditor.LayoutData layout = cellEditor.getLayoutData();
TreeEditor treeEditor = new TreeEditor(tree);
treeEditor.horizontalAlignment = layout.horizontalAlignment;
treeEditor.grabHorizontal = layout.grabHorizontal;
treeEditor.minimumWidth = layout.minimumWidth;
if (cellEditor instanceof ComboBoxCellEditor) {
cellEditor.getControl().setBackground(ColorConstants.white);
cellEditor.setValidator(new ICellEditorValidator() {
public String isValid(Object object) {
if (object instanceof Integer && ((Integer) object).intValue() > -1) {
return null;
}
return "empty";
}
});
}
treeEditor.setEditor(cellEditor.getControl(), item, columnToEdit);
item.setData(CELL_EDITOR_KEY, cellEditor);
item.setData(TREE_EDITOR_KEY, treeEditor);
}
item.setData(PROPERTY_DESCRIPTOR_KEY, descriptor);
item.setData(CELL_EDITOR_LISTENER_KEY, cellEditorListener);