mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RUBY-22706 provide ability to import scheme file from ide resources rather than from disk
This commit is contained in:
+6
-5
@@ -54,8 +54,11 @@ public abstract class ColorSchemeActions extends AbstractSchemeActions<EditorCol
|
||||
}
|
||||
final SchemeImporter<EditorColorsScheme> 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<EditorCol
|
||||
if (imported != null) {
|
||||
getOptions().addImportedScheme(imported);
|
||||
getSchemesPanel()
|
||||
.showStatus(
|
||||
ApplicationBundle.message("settings.editor.scheme.import.success", importSource.getPresentableUrl(), imported.getName()),
|
||||
MessageType.INFO);
|
||||
.showStatus(importer.getAfterImportMessage(importSource.getPresentableUrl(), imported.getName()), MessageType.INFO);
|
||||
}
|
||||
}
|
||||
catch (SchemeImportException e) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.intellij.openapi.options;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -44,4 +45,22 @@ public interface SchemeImporter <T extends Scheme> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user