final String text = editor != null ? editor.getDocument().getText() : "";
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(project).getCurrentSettings();
MathematicaFormattingModelBuilder modelBuilder = new MathematicaFormattingModelBuilder();
final PsiFile file = PsiFileFactory.getInstance(project).createFileFromText("a.m", MathematicaLanguage.INSTANCE, text);
final FormattingModel model = modelBuilder.createModel(file.getNode().getPsi(), settings);
final Block rootBlock = model.getRootBlock();
final String blockText = printBlock((AbstractBlock) rootBlock, text);
JTextArea textArea = new JTextArea(blockText);
final JScrollPane pane = new JScrollPane(textArea);
dialogBuilder.setCenterPanel(pane);