use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class MacMainFrameDecorator method toggleFullScreen.
@Override
public ActionCallback toggleFullScreen(final boolean state) {
if (!SystemInfo.isMacOSLion || myFrame == null || myInFullScreen == state)
return ActionCallback.REJECTED;
final ActionCallback callback = new ActionCallback();
myDispatcher.addListener(new FSAdapter() {
@Override
public void windowExitedFullScreen(AppEvent.FullScreenEvent event) {
callback.setDone();
myDispatcher.removeListener(this);
}
@Override
public void windowEnteredFullScreen(AppEvent.FullScreenEvent event) {
callback.setDone();
myDispatcher.removeListener(this);
}
});
myFullscreenQueue.runOrEnqueue(() -> toggleFullScreenNow());
return callback;
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class AbstractProjectViewPSIPane method updateFromRoot.
@NotNull
@Override
public final ActionCallback updateFromRoot(boolean restoreExpandedPaths) {
final ArrayList<Object> pathsToExpand = new ArrayList<>();
final ArrayList<Object> selectionPaths = new ArrayList<>();
Runnable afterUpdate;
final ActionCallback cb = new ActionCallback();
if (restoreExpandedPaths) {
TreeBuilderUtil.storePaths(getTreeBuilder(), (DefaultMutableTreeNode) myTree.getModel().getRoot(), pathsToExpand, selectionPaths, true);
afterUpdate = () -> {
if (myTree != null && getTreeBuilder() != null && !getTreeBuilder().isDisposed()) {
myTree.setSelectionPaths(new TreePath[0]);
TreeBuilderUtil.restorePaths(getTreeBuilder(), pathsToExpand, selectionPaths, true);
}
cb.setDone();
};
} else {
afterUpdate = cb.createSetDoneRunnable();
}
if (getTreeBuilder() != null) {
getTreeBuilder().addSubtreeToUpdate(getTreeBuilder().getRootNode(), afterUpdate);
}
//myTreeBuilder.updateFromRoot();
return cb;
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class RequestFocusInToolWindowCmd method requestFocus.
@NotNull
private ActionCallback requestFocus(@NotNull final Component c) {
final ActionCallback result = new ActionCallback();
final Alarm checkerAlarm = new Alarm(result);
Runnable checker = new Runnable() {
final long startTime = System.currentTimeMillis();
@Override
public void run() {
if (System.currentTimeMillis() - startTime > 10000) {
result.setRejected();
return;
}
if (c.isShowing()) {
final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
if (owner != null && owner == c) {
myManager.getFocusManager().requestFocus(new FocusCommand() {
@Override
@NotNull
public ActionCallback run() {
return ActionCallback.DONE;
}
}, false).doWhenProcessed(() -> updateToolWindow(c)).notify(result);
} else {
myManager.getFocusManager().requestFocus(new FocusCommand.ByComponent(c, myToolWindow.getComponent(), myProject, new Exception()), false).doWhenProcessed(() -> updateToolWindow(c)).notify(result);
}
} else {
checkerAlarm.addRequest(this, 100);
}
}
};
checkerAlarm.addRequest(checker, 0);
return result;
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class History method goThere.
private void goThere(final int nextPos) {
myNavigatedNow = true;
final Place next = myHistory.get(nextPos);
final Place from = getCurrent();
fireStarted(from, next);
try {
final ActionCallback callback = myRoot.navigateTo(next, false);
callback.doWhenDone(() -> myCurrentPos = nextPos).doWhenProcessed(() -> {
myNavigatedNow = false;
fireFinished(from, next);
});
} catch (Throwable e) {
myNavigatedNow = false;
throw new RuntimeException(e);
}
}
use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.
the class JBSlidingPanel method applySlide.
private ActionCallback applySlide(JBCardLayout.SwipeDirection direction) {
final ActionCallback callback = new ActionCallback();
getLayout().swipe(this, mySlides.get(mySelectedIndex).first, direction, () -> callback.setDone());
return callback;
}
Aggregations