mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup default option searching
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,8 +45,10 @@ import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import icons.JetgroovyIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl;
|
||||
@@ -157,13 +159,19 @@ public abstract class GroovyShellActionBase extends DumbAwareAction {
|
||||
}
|
||||
};
|
||||
|
||||
for (int i = 0; i < modules.size(); i++) {
|
||||
Module module = modules.get(i);
|
||||
if (module.getName().equals(PropertiesComponent.getInstance(project).getValue(GROOVY_SHELL_LAST_MODULE))) {
|
||||
step.setDefaultOptionIndex(i);
|
||||
break;
|
||||
final String lastModuleName = PropertiesComponent.getInstance(project).getValue(GROOVY_SHELL_LAST_MODULE);
|
||||
if (lastModuleName != null) {
|
||||
int defaultOption = ContainerUtil.indexOf(modules, new Condition<Module>() {
|
||||
@Override
|
||||
public boolean value(Module module) {
|
||||
return module.getName().equals(lastModuleName);
|
||||
}
|
||||
});
|
||||
if (defaultOption >= 0) {
|
||||
step.setDefaultOptionIndex(defaultOption);
|
||||
}
|
||||
}
|
||||
|
||||
JBPopupFactory.getInstance().createListPopup(step).showCenteredInCurrentWindow(project);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user