public DatasetEditorModel(DatasetEditor datasetEditor) throws SQLException { super(datasetEditor.getConnectionHandler()); this.datasetEditor = datasetEditor; this.datasetRef = DBObjectRef.from(datasetEditor.getDataset()); this.settings = DataEditorSettings.getInstance(datasetEditor.getProject()); setHeader(new DatasetEditorModelHeader(datasetEditor, null)); }
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(); } }; textFieldWithPopup.createValuesListPopup(valuesProvider, false); } } } editorComponent = textFieldWithPopup; } else if (genericDataType.is(GenericDataType.BLOB, GenericDataType.CLOB)) { editorComponent = new TextFieldWithTextEditor(project); } else { editorComponent = new BasicDataEditorComponent(); } } else { editorComponent = new BasicDataEditorComponent(); editorComponent.setEnabled(false); editorComponent.setEditable(false); } valueFieldPanel.add((Component) editorComponent, BorderLayout.CENTER); editorComponent.getTextField().setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); setCell(cell); }