From e6686754f31022a7d30be0d2dd65318a51a134bf Mon Sep 17 00:00:00 2001 From: "Dmitry.Krasilschikov" Date: Wed, 24 Oct 2018 13:45:37 +0300 Subject: [PATCH] RUBY-22706 provide ability to import scheme file from ide resources rather than from disk --- .../options/colors/ColorSchemeActions.java | 11 ++++++----- .../openapi/options/SchemeImporter.java | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java index e64a3a2643c5..871e4d534ee8 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSchemeActions.java @@ -54,8 +54,11 @@ public abstract class ColorSchemeActions extends AbstractSchemeActions importer = SchemeImporterEP.getImporter(importerName, EditorColorsScheme.class); if (importer != null) { - VirtualFile importSource = - SchemeImportUtil.selectImportSource(importer.getSourceExtensions(), getSchemesPanel(), null, "Choose " + importerName); + VirtualFile importSource = importer.getImportFile(); + if (importSource == null) { + importSource = + SchemeImportUtil.selectImportSource(importer.getSourceExtensions(), getSchemesPanel(), null, "Choose " + importerName); + } if (importSource != null) { if ("jar".equals(importSource.getExtension())) { importFromJar(getSchemesPanel().getToolbar(), importer, importSource); @@ -83,9 +86,7 @@ public abstract class ColorSchemeActions extends AbstractSchemeActions { default String getAdditionalImportInfo(@NotNull T scheme) { return null; } + + /** + * @return File to import scheme. If it's {@code null} than file chooser is shown. + */ + @Nullable + default VirtualFile getImportFile() { + return null; + } + + /** + * @return Message to be shown after successful importing + * @param presentableUrl Url of file that has been imported + * @param newSchemeName New created scheme name + */ + @NotNull + default String getAfterImportMessage(@NotNull String presentableUrl, @NotNull String newSchemeName) { + return ApplicationBundle.message("settings.editor.scheme.import.success", presentableUrl, newSchemeName); + } } \ No newline at end of file