Search in sources :

Example 6 with Update

use of com.intellij.util.ui.update.Update in project intellij-community by JetBrains.

the class FileTextFieldImpl method setText.

public final void setText(final String text, boolean now, @Nullable final Runnable onDone) {
    final Update update = new Update("pathFromTree") {

        public void run() {
            myPathIsUpdating = true;
            getField().setText(text);
            myPathIsUpdating = false;
            if (onDone != null) {
                onDone.run();
            }
        }
    };
    if (now) {
        update.run();
    } else {
        myUiUpdater.queue(update);
    }
}
Also used : Update(com.intellij.util.ui.update.Update)

Example 7 with Update

use of com.intellij.util.ui.update.Update in project intellij-community by JetBrains.

the class SMTestRunnerResultsForm method _addTestOrSuite.

private void _addTestOrSuite(@NotNull final SMTestProxy newTestOrSuite) {
    final SMTestProxy parentSuite = newTestOrSuite.getParent();
    assert parentSuite != null;
    // Tree
    final Update update = new Update(parentSuite) {

        @Override
        public void run() {
            myRequests.remove(this);
            myTreeBuilder.updateTestsSubtree(parentSuite);
        }
    };
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        update.run();
    } else if (myRequests.add(update) && !myDisposed) {
        JobScheduler.getScheduler().schedule(update, 100, TimeUnit.MILLISECONDS);
    }
    myTreeBuilder.repaintWithParents(newTestOrSuite);
    myAnimator.setCurrentTestCase(newTestOrSuite);
    if (TestConsoleProperties.TRACK_RUNNING_TEST.value(myProperties)) {
        if (myLastSelected == null || myLastSelected == newTestOrSuite) {
            myLastSelected = null;
            selectAndNotify(newTestOrSuite);
        }
    }
}
Also used : Update(com.intellij.util.ui.update.Update)

Example 8 with Update

use of com.intellij.util.ui.update.Update in project intellij-community by JetBrains.

the class SettingsTreeView method select.

ActionCallback select(@Nullable final Configurable configurable) {
    if (myBuilder.isSelectionBeingAdjusted()) {
        return ActionCallback.REJECTED;
    }
    final ActionCallback callback = new ActionCallback();
    myQueuedConfigurable = configurable;
    myQueue.queue(new Update(this) {

        public void run() {
            if (configurable == myQueuedConfigurable) {
                if (configurable == null) {
                    fireSelected(null, callback);
                } else {
                    myBuilder.getReady(this).doWhenDone(() -> {
                        if (configurable != myQueuedConfigurable)
                            return;
                        MyNode editorNode = findNode(configurable);
                        FilteringTreeStructure.FilteringNode editorUiNode = myBuilder.getVisibleNodeFor(editorNode);
                        if (editorUiNode == null)
                            return;
                        if (!myBuilder.getSelectedElements().contains(editorUiNode)) {
                            myBuilder.select(editorUiNode, () -> fireSelected(configurable, callback));
                        } else {
                            myBuilder.scrollSelectionToVisible(() -> fireSelected(configurable, callback), false);
                        }
                    });
                }
            }
        }

        @Override
        public void setRejected() {
            super.setRejected();
            callback.setRejected();
        }
    });
    return callback;
}
Also used : ActionCallback(com.intellij.openapi.util.ActionCallback) Update(com.intellij.util.ui.update.Update)

Example 9 with Update

use of com.intellij.util.ui.update.Update in project intellij-community by JetBrains.

the class ConfigurableEditor method requestUpdate.

private void requestUpdate() {
    final Configurable configurable = myConfigurable;
    myQueue.queue(new Update(this) {

        @Override
        public void run() {
            updateIfCurrent(configurable);
        }

        @Override
        public boolean isExpired() {
            return myConfigurable != configurable;
        }
    });
}
Also used : Configurable(com.intellij.openapi.options.Configurable) BaseConfigurable(com.intellij.openapi.options.BaseConfigurable) Update(com.intellij.util.ui.update.Update)

Example 10 with Update

use of com.intellij.util.ui.update.Update in project android by JetBrains.

the class NlPreviewManager method processFileEditorChange.

private void processFileEditorChange(@Nullable final TextEditor newEditor) {
    if (myPendingShowComponent != null) {
        myPendingShowComponent.removeHierarchyListener(myHierarchyListener);
        myPendingShowComponent = null;
    }
    myToolWindowUpdateQueue.cancelAllUpdates();
    myToolWindowUpdateQueue.queue(new Update("update") {

        @Override
        public void run() {
            if (!myToolWindowReady || myToolWindowDisposed) {
                return;
            }
            boolean renderImmediately = myRenderImmediately;
            myRenderImmediately = false;
            final Editor activeEditor = newEditor != null ? newEditor.getEditor() : null;
            if (myToolWindow == null) {
                if (activeEditor == null) {
                    return;
                } else if (!activeEditor.getComponent().isShowing()) {
                    // per project frame.)
                    if (!mySeenEditor) {
                        myPendingShowComponent = activeEditor.getComponent();
                        if (myHierarchyListener == null) {
                            myHierarchyListener = new HierarchyListener() {

                                @Override
                                public void hierarchyChanged(HierarchyEvent hierarchyEvent) {
                                    if ((hierarchyEvent.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                                        if (hierarchyEvent.getComponent() == myPendingShowComponent && myPendingShowComponent.isShowing()) {
                                            myPendingShowComponent.removeHierarchyListener(myHierarchyListener);
                                            mySeenEditor = true;
                                            myPendingShowComponent = null;
                                            processFileEditorChange(getActiveLayoutXmlEditor());
                                        }
                                    }
                                }
                            };
                        }
                        myPendingShowComponent.addHierarchyListener(myHierarchyListener);
                    }
                    return;
                }
                mySeenEditor = true;
                initToolWindow();
            }
            final AndroidEditorSettings settings = AndroidEditorSettings.getInstance();
            final boolean hideForNonLayoutFiles = settings.getGlobalState().isHideForNonLayoutFiles();
            if (activeEditor == null) {
                myToolWindowForm.setFile(null);
                myToolWindow.setAvailable(!hideForNonLayoutFiles, null);
                return;
            }
            final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(activeEditor.getDocument());
            myToolWindowForm.setFile(psiFile);
            if (psiFile == null) {
                myToolWindow.setAvailable(!hideForNonLayoutFiles, null);
                return;
            }
            myToolWindow.setAvailable(true, null);
            final boolean visible = AndroidEditorSettings.getInstance().getGlobalState().isVisible();
            if (visible) {
                // tool window is shown and the time the render has completed
                if (!myToolWindow.isVisible()) {
                    RenderResult renderResult = myToolWindowForm.getRenderResult();
                    if (renderResult != null && renderResult.getFile() != psiFile) {
                        myToolWindowForm.setRenderResult(RenderResult.createBlank(psiFile));
                    }
                }
                myToolWindow.show(null);
            }
        }
    });
}
Also used : HierarchyEvent(java.awt.event.HierarchyEvent) AndroidEditorSettings(org.jetbrains.android.uipreview.AndroidEditorSettings) RenderResult(com.android.tools.idea.rendering.RenderResult) PsiFile(com.intellij.psi.PsiFile) Update(com.intellij.util.ui.update.Update) com.intellij.openapi.fileEditor(com.intellij.openapi.fileEditor) Editor(com.intellij.openapi.editor.Editor) HierarchyListener(java.awt.event.HierarchyListener)

Aggregations

Update (com.intellij.util.ui.update.Update)35 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)4 Document (com.intellij.openapi.editor.Document)3 ModuleRootListener (com.intellij.openapi.roots.ModuleRootListener)3 MergingUpdateQueue (com.intellij.util.ui.update.MergingUpdateQueue)3 RenderResult (com.android.tools.idea.rendering.RenderResult)2 Editor (com.intellij.openapi.editor.Editor)2 DocumentAdapter (com.intellij.openapi.editor.event.DocumentAdapter)2 DocumentEvent (com.intellij.openapi.editor.event.DocumentEvent)2 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)2 Project (com.intellij.openapi.project.Project)2 ActionCallback (com.intellij.openapi.util.ActionCallback)2 AndroidDebugBridge (com.android.ddmlib.AndroidDebugBridge)1 RenderErrorModel (com.android.tools.idea.rendering.errors.ui.RenderErrorModel)1 NlComponent (com.android.tools.idea.uibuilder.model.NlComponent)1 SelectionModel (com.android.tools.idea.uibuilder.model.SelectionModel)1 ScreenView (com.android.tools.idea.uibuilder.surface.ScreenView)1 FileHyperlinkInfo (com.intellij.execution.filters.FileHyperlinkInfo)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1