From 937ffb9a731e209aef7c29253a8cc51d63d233cd Mon Sep 17 00:00:00 2001 From: Sergey Savenko Date: Mon, 16 Feb 2015 14:56:05 +0300 Subject: [PATCH] Scratch: refactor NewScratchFileAction#buildLanguagePopup --- .../com/intellij/ide/scratch/NewScratchFileAction.java | 9 +++++---- .../src/com/intellij/ide/scratch/ScratchWidget.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/scratch/NewScratchFileAction.java b/platform/lang-impl/src/com/intellij/ide/scratch/NewScratchFileAction.java index 57c4b14ddaa1..5fc611db6f06 100644 --- a/platform/lang-impl/src/com/intellij/ide/scratch/NewScratchFileAction.java +++ b/platform/lang-impl/src/com/intellij/ide/scratch/NewScratchFileAction.java @@ -97,7 +97,7 @@ public class NewScratchFileAction extends DumbAwareAction { } final Ref tenMinuteScratch = Ref.create(false); - ListPopup popup = buildLanguagePopup(project, language, new Consumer() { + ListPopup popup = buildLanguageSelectionPopup(project, "New Scratch", language, new Consumer() { @Override public void consume(@NotNull Language language) { openNewFile(project, language, "", tenMinuteScratch.get()); @@ -141,7 +141,8 @@ public class NewScratchFileAction extends DumbAwareAction { } @NotNull - static ListPopup buildLanguagePopup(@NotNull Project project, @Nullable Language context, @NotNull final Consumer onChoosen) { + public static ListPopup buildLanguageSelectionPopup(@NotNull Project project, @NotNull String title, + @Nullable Language context, @NotNull final Consumer onChosen) { List languages = LanguageUtil.getFileLanguages(); final List ids = ContainerUtil.newArrayList(getLastUsedLanguagesIds(project)); if (context != null) { @@ -162,7 +163,7 @@ public class NewScratchFileAction extends DumbAwareAction { } }); BaseListPopupStep step = - new BaseListPopupStep("New Scratch", languages) { + new BaseListPopupStep(title, languages) { @NotNull @Override public String getTextFor(@NotNull Language value) { @@ -176,7 +177,7 @@ public class NewScratchFileAction extends DumbAwareAction { @Override public PopupStep onChosen(Language selectedValue, boolean finalChoice) { - onChoosen.consume(selectedValue); + onChosen.consume(selectedValue); return null; } diff --git a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchWidget.java b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchWidget.java index 4b1124455ffc..4a65bc4cb679 100644 --- a/platform/lang-impl/src/com/intellij/ide/scratch/ScratchWidget.java +++ b/platform/lang-impl/src/com/intellij/ide/scratch/ScratchWidget.java @@ -61,7 +61,7 @@ class ScratchWidget extends EditorBasedWidget implements CustomStatusBarWidget.M if (project == null || editor == null || file == null) return false; final PerFileMappings fileService = ScratchFileService.getInstance().getScratchesMapping(); - ListPopup popup = NewScratchFileAction.buildLanguagePopup(project, fileService.getMapping(file), new Consumer() { + ListPopup popup = NewScratchFileAction.buildLanguageSelectionPopup(project, "Change Language", fileService.getMapping(file), new Consumer() { @Override public void consume(Language language) { fileService.setMapping(file, language);