use of com.intellij.openapi.wm.impl.commands.FinalizableCommand in project intellij-community by JetBrains.
the class ToolWindowImpl method getReady.
@NotNull
@Override
public ActionCallback getReady(@NotNull final Object requestor) {
final ActionCallback result = new ActionCallback();
myShowing.getReady(this).doWhenDone(() -> {
ArrayList<FinalizableCommand> cmd = new ArrayList<>();
cmd.add(new FinalizableCommand(null) {
@Override
public void run() {
IdeFocusManager.getInstance(myToolWindowManager.getProject()).doWhenFocusSettlesDown(() -> {
if (myContentManager.isDisposed())
return;
myContentManager.getReady(requestor).notify(result);
});
}
});
myToolWindowManager.execute(cmd);
});
return result;
}
use of com.intellij.openapi.wm.impl.commands.FinalizableCommand in project intellij-community by JetBrains.
the class CommandProcessor method run.
private boolean run(boolean synchronously) {
synchronized (myLock) {
final CommandGroup commandGroup = getNextCommandGroup();
if (commandGroup == null || commandGroup.isEmpty())
return false;
final Condition conditionForGroup = commandGroup.getExpireCondition();
final FinalizableCommand command = commandGroup.takeNextCommand();
myCommandCount--;
Condition expire = command.getExpireCondition() != null ? command.getExpireCondition() : conditionForGroup;
if (expire == null)
expire = ApplicationManager.getApplication().getDisposed();
if (expire.value(null))
return true;
if (LOG.isDebugEnabled()) {
LOG.debug("CommandProcessor.run " + command);
}
if (synchronously) {
command.run();
return true;
}
// max. I'm not actually quite sure this should have NON_MODAL modality but it should
// definitely have some since runnables in command list may (and do) request some PSI activity
final boolean queueNext = myCommandCount > 0;
Application application = ApplicationManager.getApplication();
ModalityState modalityState = Registry.is("ide.perProjectModality") ? ModalityState.current() : ModalityState.NON_MODAL;
application.getInvokator().invokeLater(command, modalityState, expire).doWhenDone(() -> {
if (queueNext) {
run(false);
}
});
return true;
}
}
Aggregations