return FINAL_CHOICE;
}
+ public Runnable getFinalRunnable() {
+ return null;
+ }
+
public boolean hasSubstep(Object selectedValue) {
return false;
}
return o1.getAction().getClass() == o2.getAction().getClass() && o1.getText().equals(o2.getText());
}
};
+ private Runnable myFinalRunnable;
IntentionListStep(IntentionHintComponent intentionHintComponent, ShowIntentionsPass.IntentionsInfo intentions, Editor editor, PsiFile file,
Project project) {
return FINAL_CHOICE;
}
+ public Runnable getFinalRunnable() {
+ return myFinalRunnable;
+ }
+
private void applyAction(final IntentionActionWithTextCaching cachedAction) {
- ApplicationManager.getApplication().invokeLater(new Runnable() {
+ myFinalRunnable = new Runnable() {
public void run() {
HintManager.getInstance().hideAllHints();
ApplicationManager.getApplication().invokeLater(new Runnable() {
}
});
}
- });
+ };
}
private PopupStep getSubStep(final IntentionActionWithTextCaching action) {
if (myAction.myEditConfiguration) {
final Object o = wrapper.getValue();
if (o instanceof RunnerAndConfigurationSettingsImpl) {
- SwingUtilities.invokeLater(new Runnable() {
+ return doFinalStep(new Runnable() {
public void run() {
myAction.editConfiguration(myProject, (RunnerAndConfigurationSettingsImpl)o);
}
});
-
- return FINAL_CHOICE;
}
}
assert executor != null;
if (finalChoice && wrapper.available(executor)) {
- SwingUtilities.invokeLater(new Runnable() {
+ return doFinalStep(new Runnable() {
public void run() {
if (executor == myAction.getAlternateExecutor()) {
PropertiesComponent.getInstance().setValue(myAction.getAdKey(), Boolean.toString(true));
wrapper.perform(myProject, executor, DataManager.getInstance().getDataContext());
}
});
-
- return FINAL_CHOICE;
}
else {
return wrapper.getNextStep(myProject, myAction);
@Override
public PopupStep onChosen(final ActionWrapper selectedValue, boolean finalChoice) {
- SwingUtilities.invokeLater(new Runnable() {
+ return doFinalStep(new Runnable() {
public void run() {
selectedValue.perform();
}
});
-
- return FINAL_CHOICE;
}
@Override
protected EventListenerList myListenerList = new EventListenerList();
+ private Runnable myFinalRunnable;
+
public ComboBoxTableRenderer(final T[] values) {
myValues = values;
setFont(UIUtil.getButtonFont());
return value.toString();
}
- protected void onChosen(@NotNull final T value) {
+
+
+ protected Runnable onChosen(@NotNull final T value) {
stopCellEditing(value);
- SwingUtilities.invokeLater(new Runnable() {
+ return new Runnable() {
public void run() {
stopCellEditing(value);
}
- });
+ };
}
@Override
}
public PopupStep onChosen(T selectedValue, boolean finalChoice) {
- ComboBoxTableRenderer.this.onChosen(selectedValue);
+ myFinalRunnable = ComboBoxTableRenderer.this.onChosen(selectedValue);
return FINAL_CHOICE;
}
public void canceled() {
ComboBoxTableRenderer.this.cancelCellEditing();
}
+
+ public Runnable getFinalRunnable() {
+ return myFinalRunnable;
+ }
});
popup.addListener(this);
* @return true if the submenu for the first selectable item should be displayed automatically, false otherwise.
*/
boolean isAutoSelectionEnabled();
+
+ /**
+ * @return runnable to be executed when final step is chosen
+ */
+ @Nullable
+ Runnable getFinalRunnable();
}
public abstract class BaseStep<T> implements PopupStep<T>, SpeedSearchFilter<T>, MnemonicNavigationFilter<T> {
+ private Runnable myFinalRunnable;
+
public boolean isSpeedSearchEnabled() {
return false;
}
public MnemonicNavigationFilter<T> getMnemonicNavigationFilter() {
return this;
}
+
+ public Runnable getFinalRunnable() {
+ return myFinalRunnable;
+ }
+
+ public PopupStep doFinalStep(Runnable runnable) {
+ myFinalRunnable = runnable;
+ return FINAL_CHOICE;
+ }
}
protected InputEvent myDisposeEvent;
+ protected Runnable myFinalRunnable;
+
protected final SpeedSearch mySpeedSearch = new SpeedSearch() {
boolean searchFieldShown = false;
protected void update() {
public void cancel(InputEvent e) {
if (isDisposed()) return;
+ final Runnable finalRunnable = myFinalRunnable;
+ final IdeFocusManager focusManager = IdeFocusManager.findInstanceByComponent(myOwner);
+
if (myPopup != null) {
if (!canClose()) {
return;
}
Disposer.dispose(this, false);
+
+ if (finalRunnable != null) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ focusManager.doWhenFocusSettlesDown(finalRunnable);
+ }
+ });
+ }
}
private final boolean myEnableMnemonics;
private final int myDefaultOptionIndex;
private final boolean myAutoSelectionEnabled;
+ private Runnable myFinalRunnable;
private ActionPopupStep(@NotNull final List<ActionItem> items,
final String title,
return JBPopupFactory.getInstance().createActionsStep((ActionGroup)action, dataContext, myEnableMnemonics, false, null, myContext, false);
}
else {
- // invokeLater is required to get a chance for the popup to hide in case the action called displays modal dialog
- SwingUtilities.invokeLater(new Runnable() {
+ myFinalRunnable = new Runnable() {
public void run() {
- action.actionPerformed(new AnActionEvent(null,
- dataContext,
- ActionPlaces.UNKNOWN,
- (Presentation)action.getTemplatePresentation().clone(),
- ActionManager.getInstance(),
- 0));
+ action.actionPerformed(
+ new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, (Presentation)action.getTemplatePresentation().clone(),
+ ActionManager.getInstance(), 0));
}
- });
+ };
return FINAL_CHOICE;
}
}
+ public Runnable getFinalRunnable() {
+ return myFinalRunnable;
+ }
+
public boolean hasSubstep(final ActionItem selectedValue) {
return selectedValue != null && selectedValue.isEnabled() && selectedValue.getAction() instanceof ActionGroup;
}
}
}
+ protected final void setFinalRunnable(Runnable runnable) {
+ if (getParent() == null) {
+ myFinalRunnable = runnable;
+ } else {
+ getParent().setFinalRunnable(runnable);
+ }
+ }
}
return false;
}
else {
+ setFinalRunnable(myStep.getFinalRunnable());
disposeAllParents(e);
setIndexForShowingChild(-1);
return true;
}
}
+
public void addListSelectionListener(ListSelectionListener listSelectionListener) {
myList.addListSelectionListener(listSelectionListener);
}
final PopupStep queriedStep = myStep.onChosen(userObject, handleFinalChoices);
if (queriedStep == PopupStep.FINAL_CHOICE || !hasNextStep) {
+ setFinalRunnable(myStep.getFinalRunnable());
disposeAllParents(e);
}
else {
return PopupStep.FINAL_CHOICE;
}
+ public Runnable getFinalRunnable() {
+ return null;
+ }
+
public boolean hasSubstep(final ComponentItem selectedValue) {
return false;
}