private static void setupEditorDefault(EditorEx editor) {
    ConsoleViewUtil.setupConsoleEditor(editor, false, false);
    editor.getContentComponent().setFocusCycleRoot(false);
    editor.setHorizontalScrollbarVisible(false);
    editor.setVerticalScrollbarVisible(true);
    editor.setBorder(null);

    final EditorSettings editorSettings = editor.getSettings();
    editorSettings.setAdditionalLinesCount(0);
    editorSettings.setAdditionalColumnsCount(1);
    editorSettings.setRightMarginShown(false);
  }
  private static void reinitSettings(final EditorEx editor) {
    EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
    editor.setColorsScheme(scheme);
    EditorSettings settings = editor.getSettings();
    settings.setLineNumbersShown(false);
    settings.setWhitespacesShown(false);
    settings.setLineMarkerAreaShown(false);
    settings.setIndentGuidesShown(false);
    settings.setFoldingOutlineShown(false);
    settings.setAdditionalColumnsCount(0);
    settings.setAdditionalLinesCount(0);
    settings.setRightMarginShown(true);
    settings.setRightMargin(60);
    settings.setVirtualSpace(false);

    editor.setHighlighter(new LexerEditorHighlighter(new PropertiesValueHighlighter(), scheme));
    editor.setVerticalScrollbarVisible(true);
  }
  private void updatePreview() {
    ConnectionHandler connectionHandler = variablesBundle.getActiveConnection();
    Project project = connectionHandler.getProject();

    String previewText =
        variablesBundle.prepareStatementText(connectionHandler, this.statementText, true);

    for (StatementExecutionVariableValueForm variableValueForm : variableValueForms) {
      String errorText = variablesBundle.getError(variableValueForm.getVariable());
      if (errorText == null) variableValueForm.hideErrorLabel();
      else variableValueForm.showErrorLabel(errorText);
    }

    if (previewDocument == null) {
      PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(project);

      SQLFile selectStatementFile =
          (SQLFile)
              psiFileFactory.createFileFromText(
                  "filter.sql",
                  connectionHandler.getLanguageDialect(SQLLanguage.INSTANCE),
                  previewText);

      selectStatementFile.setActiveConnection(connectionHandler);
      selectStatementFile.setCurrentSchema(variablesBundle.getCurrentSchema());
      previewDocument = DocumentUtil.getDocument(selectStatementFile);

      viewer = (EditorEx) EditorFactory.getInstance().createViewer(previewDocument, project);
      viewer.setEmbeddedIntoDialogWrapper(true);
      JScrollPane viewerScrollPane = viewer.getScrollPane();
      SyntaxHighlighter syntaxHighlighter =
          connectionHandler.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);
      // viewerScrollPane.setBorder(null);
      viewerScrollPane.setViewportBorder(
          new LineBorder(CompatibilityUtil.getEditorBackgroundColor(viewer), 4, false));

      EditorSettings settings = viewer.getSettings();
      settings.setFoldingOutlineShown(false);
      settings.setLineMarkerAreaShown(false);
      settings.setLineNumbersShown(false);
      settings.setVirtualSpace(false);
      settings.setDndEnabled(false);
      settings.setAdditionalLinesCount(2);
      settings.setRightMarginShown(false);
      previewPanel.add(viewer.getComponent(), BorderLayout.CENTER);

    } else {
      final String finalPreviewText = previewText;

      new WriteActionRunner() {
        public void run() {
          previewDocument.setText(finalPreviewText);
        }
      }.start();
    }
  }