nameTextField.setForeground(Color.GRAY);
}
}
public void updateNameAndPreview() {
DBDataset dataset = this.getDataset();
if (dataset != null) {
updateGeneratedName();
final StringBuilder selectStatement = new StringBuilder("select * from ");
selectStatement.append(dataset.getSchema().getQuotedName(false)).append('.');
selectStatement.append(dataset.getQuotedName(false));
selectStatement.append(" where\n ");
boolean addJoin = false;
for (DatasetBasicFilterConditionForm conditionForm : conditionForms) {
DatasetBasicFilterCondition condition = conditionForm.getCondition();
if (conditionForm.isActive()) {
if (addJoin) {
selectStatement.append(joinAndRadioButton.isSelected() ? " and\n " : " or\n ");
}
addJoin = true;
condition.appendConditionString(selectStatement, dataset);
}
}
if (previewDocument == null) {
PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(dataset.getProject());
SQLFile selectStatementFile = (SQLFile)
psiFileFactory.createFileFromText(
"filter.sql",
dataset.getLanguageDialect(SQLLanguage.INSTANCE),
selectStatement.toString());
selectStatementFile.setActiveConnection(dataset.getConnectionHandler());
selectStatementFile.setCurrentSchema(dataset.getSchema());
previewDocument = DocumentUtil.getDocument(selectStatementFile);
viewer = (EditorEx) EditorFactory.getInstance().createViewer(previewDocument, dataset.getProject());
viewer.setEmbeddedIntoDialogWrapper(true);
JScrollPane viewerScrollPane = viewer.getScrollPane();
SyntaxHighlighter syntaxHighlighter = dataset.getLanguageDialect(SQLLanguage.INSTANCE).getSyntaxHighlighter();
EditorColorsScheme colorsScheme = viewer.getColorsScheme();
viewer.setHighlighter(HighlighterFactory.createHighlighter(syntaxHighlighter, colorsScheme));
viewer.setBackgroundColor(colorsScheme.getColor(ColorKey.find("CARET_ROW_COLOR")));
viewerScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
viewerScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);