Search in sources :

Example 36 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project android by JetBrains.

the class DependenciesTreeBuilder method reset.

public void reset(@Nullable Runnable onDone) {
    AbstractTreeStructure treeStructure = getTreeStructure();
    if (treeStructure instanceof DependenciesTreeStructure) {
        ((DependenciesTreeStructure) treeStructure).reset();
        ActionCallback callback = queueUpdate();
        if (onDone != null) {
            callback.doWhenDone(onDone);
        }
    }
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) AbstractTreeStructure(com.intellij.ide.util.treeView.AbstractTreeStructure)

Example 37 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project intellij-plugins by JetBrains.

the class Client method updatePropertyOrStyle.

public ActionCallback updatePropertyOrStyle(int documentId, int componentId, Consumer<AmfOutputStream> streamConsumer) {
    final ActionCallback callback = new ActionCallback("updatePropertyOrStyle");
    boolean hasError = true;
    try {
        beginMessage(ClientMethod.updatePropertyOrStyle, callback);
        out.writeUInt29(documentId);
        out.writeUInt29(componentId);
        streamConsumer.consume(out);
        hasError = false;
    } finally {
        finalizeMessageAndFlush(hasError, callback);
    }
    return callback;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback)

Example 38 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project intellij-plugins by JetBrains.

the class Client method renderDocument.

/**
   * final, full render document - responsible for handle problemsHolder and assetCounter - you must not do it
   */
public AsyncResult<DocumentInfo> renderDocument(Module module, XmlFile psiFile, ProblemsHolder problemsHolder) {
    VirtualFile virtualFile = psiFile.getVirtualFile();
    final int factoryId = registerDocumentFactoryIfNeed(module, psiFile, virtualFile, false, problemsHolder);
    final AsyncResult<DocumentInfo> result = new AsyncResult<>();
    if (factoryId == -1) {
        result.setRejected();
        return result;
    }
    FlexLibrarySet flexLibrarySet = registeredModules.getInfo(module).getFlexLibrarySet();
    if (flexLibrarySet != null) {
        fillAssetClassPoolIfNeed(flexLibrarySet);
    }
    if (!problemsHolder.isEmpty()) {
        DocumentProblemManager.getInstance().report(module.getProject(), problemsHolder);
    }
    final ActionCallback callback = new ActionCallback("renderDocument");
    boolean hasError = true;
    try {
        beginMessage(ClientMethod.renderDocument, callback, result, () -> result.setDone(DocumentFactoryManager.getInstance().getInfo(factoryId)));
        out.writeShort(factoryId);
        hasError = false;
    } finally {
        finalizeMessageAndFlush(hasError);
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ActionCallback(com.intellij.openapi.util.ActionCallback) AsyncResult(com.intellij.openapi.util.AsyncResult) DocumentInfo(com.intellij.flex.uiDesigner.DocumentFactoryManager.DocumentInfo)

Example 39 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project intellij-plugins by JetBrains.

the class TestClient method test.

public ActionCallback test(@Nullable Module module, int documentId, String method, int classId) throws IOException {
    // method called only and only after openDocument and shouldn't be any calls between
    // in non-tests the same agreement, except must be flush after openDocument always
    //blockOut.end();
    ActionCallback callback = new ActionCallback("test");
    out.write(CLASS);
    out.write(SocketInputHandler.getInstance().addCallback(callback));
    out.write(classId);
    if (module == null) {
        out.writeShort(-1);
    } else {
        writeId(module, out);
    }
    out.writeShort(documentId);
    out.writeAmfUtf(method, false);
    flush();
    return callback;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback)

Example 40 with ActionCallback

use of com.intellij.openapi.util.ActionCallback in project intellij-community by JetBrains.

the class FrameWrapper method show.

public void show(boolean restoreBounds) {
    myFocusedCallback = new ActionCallback();
    if (myProject != null) {
        IdeFocusManager.getInstance(myProject).typeAheadUntil(myFocusedCallback);
    }
    final Window frame = getFrame();
    if (myStatusBar != null) {
        myStatusBar.install((IdeFrame) frame);
    }
    myFocusTrackback = new FocusTrackback(this, IdeFocusManager.findInstance().getFocusOwner(), true);
    if (frame instanceof JFrame) {
        ((JFrame) frame).setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    } else {
        ((JDialog) frame).setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    }
    final WindowAdapter focusListener = new WindowAdapter() {

        public void windowOpened(WindowEvent e) {
            IdeFocusManager fm = IdeFocusManager.getInstance(myProject);
            JComponent toFocus = getPreferredFocusedComponent();
            if (toFocus == null) {
                toFocus = fm.getFocusTargetFor(myComponent);
            }
            if (toFocus != null) {
                fm.requestFocus(toFocus, true).notify(myFocusedCallback);
            } else {
                myFocusedCallback.setRejected();
            }
        }
    };
    frame.addWindowListener(focusListener);
    if (Registry.is("ide.perProjectModality")) {
        frame.setAlwaysOnTop(true);
    }
    Disposer.register(this, new Disposable() {

        @Override
        public void dispose() {
            frame.removeWindowListener(focusListener);
        }
    });
    if (myCloseOnEsc)
        addCloseOnEsc((RootPaneContainer) frame);
    ((RootPaneContainer) frame).getContentPane().add(myComponent, BorderLayout.CENTER);
    if (frame instanceof JFrame) {
        ((JFrame) frame).setTitle(myTitle);
    } else {
        ((JDialog) frame).setTitle(myTitle);
    }
    if (myImageWasChanged && myImage != null) {
        // unwrap the image before setting as frame's icon
        frame.setIconImage(ImageUtil.toBufferedImage(myImage));
    } else {
        AppUIUtil.updateWindowIcon(myFrame);
    }
    if (restoreBounds) {
        loadFrameState();
    }
    myFocusWatcher = new FocusWatcher() {

        protected void focusLostImpl(final FocusEvent e) {
            myFocusTrackback.consume();
        }
    };
    myFocusWatcher.install(myComponent);
    myShown = true;
    frame.setVisible(true);
    if (UIUtil.isUnderAlloyLookAndFeel() && frame instanceof JFrame) {
        //please ask [kb] before remove it
        ((JFrame) frame).setMaximizedBounds(null);
    }
}
Also used : Disposable(com.intellij.openapi.Disposable) ActionCallback(com.intellij.openapi.util.ActionCallback) FocusTrackback(com.intellij.ui.FocusTrackback)

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