private RegionalSettings regionalSettings;
public DatasetRecordEditorColumnForm(DatasetRecordEditorForm parentForm, DatasetEditorModelCell cell) {
this.parentForm = parentForm;
final DatasetEditorColumnInfo columnInfo = cell.getColumnInfo();
DBColumn column = columnInfo.getColumn();
DBDataType dataType = column.getDataType();
Project project = column.getProject();
regionalSettings = RegionalSettings.getInstance(project);
columnLabel.setIcon(column.getIcon());
columnLabel.setText(column.getName());
dataTypeLabel.setText(dataType.getQualifiedName());
dataTypeLabel.setForeground(UIUtil.getInactiveTextColor());
DBNativeDataType nativeDataType = dataType.getNativeDataType();
if (nativeDataType != null) {
DataTypeDefinition dataTypeDefinition = nativeDataType.getDataTypeDefinition();
GenericDataType genericDataType = dataTypeDefinition.getGenericDataType();
DataEditorSettings dataEditorSettings = DataEditorSettings.getInstance(project);
long dataLength = dataType.getLength();
if (genericDataType.is(GenericDataType.DATE_TIME, GenericDataType.LITERAL)) {
TextFieldWithPopup textFieldWithPopup = new TextFieldWithPopup(project);
textFieldWithPopup.setPreferredSize(new Dimension(200, -1));
JTextField valueTextField = textFieldWithPopup.getTextField();
valueTextField.getDocument().addDocumentListener(documentListener);
valueTextField.addKeyListener(keyAdapter);
valueTextField.addFocusListener(focusListener);
if (cell.getRow().getModel().isEditable()) {
if (genericDataType == GenericDataType.DATE_TIME) {
textFieldWithPopup.createCalendarPopup(false);
}
if (genericDataType == GenericDataType.LITERAL) {
if (dataLength > 20 && !column.isPrimaryKey() && !column.isForeignKey())
textFieldWithPopup.createTextAreaPopup(false);
DataEditorValueListPopupSettings valueListPopupSettings = dataEditorSettings.getValueListPopupSettings();
if (column.isForeignKey() || (dataLength <= valueListPopupSettings.getDataLengthThreshold() &&
(!column.isSinglePrimaryKey() || valueListPopupSettings.isActiveForPrimaryKeyColumns()))) {
ListPopupValuesProvider valuesProvider = new ListPopupValuesProvider() {
public List<String> getValues() {
return columnInfo.getPossibleValues();
}
};