Search in sources :

Example 46 with ActionCallback

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;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback)

Example 47 with ActionCallback

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;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 48 with ActionCallback

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;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) Alarm(com.intellij.util.Alarm) FocusCommand(com.intellij.openapi.wm.FocusCommand) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 49 with ActionCallback

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);
    }
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback)

Example 50 with ActionCallback

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;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback)

Aggregations

ActionCallback (com.intellij.openapi.util.ActionCallback)70 NotNull (org.jetbrains.annotations.NotNull)16 IOException (java.io.IOException)5 Notification (com.intellij.notification.Notification)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrayList (java.util.ArrayList)4 ProjectView (com.intellij.ide.projectView.ProjectView)3 Configurable (com.intellij.openapi.options.Configurable)3 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)3 AsyncResult (com.intellij.openapi.util.AsyncResult)3 RelativePoint (com.intellij.ui.awt.RelativePoint)3 DocumentInfo (com.intellij.flex.uiDesigner.DocumentFactoryManager.DocumentInfo)2 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Task (com.intellij.openapi.progress.Task)2 Project (com.intellij.openapi.project.Project)2 LibraryOrderEntry (com.intellij.openapi.roots.LibraryOrderEntry)2 MasterDetailsComponent (com.intellij.openapi.ui.MasterDetailsComponent)2 NamedConfigurable (com.intellij.openapi.ui.NamedConfigurable)2 TypingTarget (com.intellij.openapi.ui.TypingTarget)2 FocusCommand (com.intellij.openapi.wm.FocusCommand)2