mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
Scratch: refactor NewScratchFileAction#buildLanguagePopup
This commit is contained in:
@@ -97,7 +97,7 @@ public class NewScratchFileAction extends DumbAwareAction {
|
||||
}
|
||||
|
||||
final Ref<Boolean> tenMinuteScratch = Ref.create(false);
|
||||
ListPopup popup = buildLanguagePopup(project, language, new Consumer<Language>() {
|
||||
ListPopup popup = buildLanguageSelectionPopup(project, "New Scratch", language, new Consumer<Language>() {
|
||||
@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<Language> onChoosen) {
|
||||
public static ListPopup buildLanguageSelectionPopup(@NotNull Project project, @NotNull String title,
|
||||
@Nullable Language context, @NotNull final Consumer<Language> onChosen) {
|
||||
List<Language> languages = LanguageUtil.getFileLanguages();
|
||||
final List<String> ids = ContainerUtil.newArrayList(getLastUsedLanguagesIds(project));
|
||||
if (context != null) {
|
||||
@@ -162,7 +163,7 @@ public class NewScratchFileAction extends DumbAwareAction {
|
||||
}
|
||||
});
|
||||
BaseListPopupStep<Language> step =
|
||||
new BaseListPopupStep<Language>("New Scratch", languages) {
|
||||
new BaseListPopupStep<Language>(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;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class ScratchWidget extends EditorBasedWidget implements CustomStatusBarWidget.M
|
||||
if (project == null || editor == null || file == null) return false;
|
||||
final PerFileMappings<Language> fileService = ScratchFileService.getInstance().getScratchesMapping();
|
||||
|
||||
ListPopup popup = NewScratchFileAction.buildLanguagePopup(project, fileService.getMapping(file), new Consumer<Language>() {
|
||||
ListPopup popup = NewScratchFileAction.buildLanguageSelectionPopup(project, "Change Language", fileService.getMapping(file), new Consumer<Language>() {
|
||||
@Override
|
||||
public void consume(Language language) {
|
||||
fileService.setMapping(file, language);
|
||||
|
||||
Reference in New Issue
Block a user