mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
preselect initial text in "Run Rails generator" action
This commit is contained in:
committed by
Dennis Ushakov
parent
abe169eb27
commit
a3d62623aa
@@ -78,6 +78,7 @@ public abstract class ChooseByNameBase{
|
||||
protected final Project myProject;
|
||||
protected final ChooseByNameModel myModel;
|
||||
protected final String myInitialText;
|
||||
private boolean myPreselectInitialText;
|
||||
private final Reference<PsiElement> myContext;
|
||||
|
||||
protected Component myPreviouslyFocusedComponent;
|
||||
@@ -147,6 +148,14 @@ public abstract class ChooseByNameBase{
|
||||
myContext = new WeakReference<PsiElement>(context);
|
||||
}
|
||||
|
||||
public boolean isPreselectInitialText() {
|
||||
return myPreselectInitialText;
|
||||
}
|
||||
|
||||
public void setPreselectInitialText(boolean preselectInitialText) {
|
||||
myPreselectInitialText = preselectInitialText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tool area. The method may be called only before invoke.
|
||||
* @param toolArea a tool area component
|
||||
@@ -321,6 +330,9 @@ public abstract class ChooseByNameBase{
|
||||
myFuture = new ArrayList<Pair<String, Integer>>();
|
||||
myTextField = new MyTextField();
|
||||
myTextField.setText(myInitialText);
|
||||
if (myPreselectInitialText) {
|
||||
myTextField.select(0, myInitialText.length());
|
||||
}
|
||||
|
||||
final ActionMap actionMap = new ActionMap();
|
||||
actionMap.setParent(myTextField.getActionMap());
|
||||
|
||||
@@ -40,6 +40,9 @@ public class ChooseByNamePopup extends ChooseByNameBase implements ChooseByNameP
|
||||
private ChooseByNamePopup(final Project project, final ChooseByNameModel model, final ChooseByNamePopup oldPopup,
|
||||
final PsiElement context, @Nullable final String predefinedText) {
|
||||
super(project, model, oldPopup != null ? oldPopup.getEnteredText() : predefinedText, context);
|
||||
if (oldPopup == null && predefinedText != null) {
|
||||
setPreselectInitialText(true);
|
||||
}
|
||||
if (oldPopup != null) { //inherit old focus owner
|
||||
myOldFocusOwner = oldPopup.myPreviouslyFocusedComponent;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user