void (@Nullable Project project, @NotNull T scheme, @NotNull String exporterName) { SchemeExporter<T> exporter = SchemeExporterEP.getExporter(exporterName, getSchemeType()); if (exporter != null) { Object config = null; if (exporter instanceof ConfigurableSchemeExporter) { //noinspection unchecked config = ((ConfigurableSchemeExporter)exporter).getConfiguration(mySchemesPanel, scheme); if (config == null) return; } String ext = exporter.getExtension(); FileSaverDialog saver = FileChooserFactory.getInstance() .createSaveFileDialog(new FileSaverDescriptor( ApplicationBundle.message("scheme.exporter.ui.file.chooser.title"), ApplicationBundle.message("scheme.exporter.ui.file.chooser.message"), ext), getSchemesPanel()); VirtualFileWrapper target = saver.save(exporter.getDefaultDir(project), exporter.getDefaultFileName(scheme.getDisplayName()) + "." + ext); if (target != null) { VirtualFile targetFile = target.getVirtualFile(true); String message; MessageType messageType; if (targetFile != null) { try { Object finalConfig = config; WriteAction.run(() -> { try (OutputStream outputStream = targetFile.getOutputStream(this)) { if (exporter instanceof ConfigurableSchemeExporter) { //noinspection unchecked ((ConfigurableSchemeExporter)exporter).exportScheme(scheme, outputStream, finalConfig); } exporter.exportScheme(project, scheme, outputStream); } }); message = ApplicationBundle .message("scheme.exporter.ui.scheme.exported.message", scheme.getName(), getSchemesPanel().getSchemeTypeName(), targetFile.getPresentableUrl()); messageType = MessageType.INFO; } catch (Exception e) { message = ApplicationBundle.message("scheme.exporter.ui.export.failed", e.getMessage()); messageType = MessageType.ERROR; } } else { message = ApplicationBundle.message("scheme.exporter.ui.cannot.write.message"); messageType = MessageType.ERROR; } getSchemesPanel().showStatus(message, messageType); } } }