Search in sources :

Example 26 with Update

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

the class FinderRecursivePanel method updatePanel.

public void updatePanel() {
    if (myUpdateSelectedPathModeActive.get()) {
        return;
    }
    myList.setPaintBusy(true);
    myMergingUpdateQueue.queue(new Update("update") {

        @Override
        public void run() {
            final T oldValue = getSelectedValue();
            final int oldIndex = myList.getSelectedIndex();
            ApplicationManager.getApplication().executeOnPooledThread(() -> DumbService.getInstance(getProject()).runReadActionInSmartMode(() -> {
                try {
                    final List<T> listItems = getListItems();
                    SwingUtilities.invokeLater(() -> {
                        mergeListItems(myListModel, myList, listItems);
                        if (myList.isEmpty()) {
                            createRightComponent(true);
                        } else if (myList.getSelectedIndex() < 0) {
                            myList.setSelectedIndex(myListModel.getSize() > oldIndex ? oldIndex : 0);
                        } else {
                            Object newValue = myList.getSelectedValue();
                            updateRightComponent(oldValue == null || !oldValue.equals(newValue) || myList.isEmpty());
                        }
                    });
                } finally {
                    myList.setPaintBusy(false);
                }
            }));
        }
    });
}
Also used : Update(com.intellij.util.ui.update.Update)

Example 27 with Update

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

the class HistoryDialog method doScheduleUpdate.

private void doScheduleUpdate(int id, final Computable<Runnable> update) {
    myUpdateQueue.queue(new Update(HistoryDialog.this, id) {

        @Override
        public boolean canEat(Update update1) {
            return getPriority() >= update1.getPriority();
        }

        public void run() {
            if (isDisposed() || myProject.isDisposed())
                return;
            invokeAndWait(() -> {
                if (isDisposed() || myProject.isDisposed())
                    return;
                isUpdating = true;
                updateActions();
                myDiffView.startUpdating();
            });
            Runnable apply = null;
            try {
                apply = update.compute();
            } catch (Exception e) {
                LocalHistoryLog.LOG.error(e);
            }
            final Runnable finalApply = apply;
            invokeAndWait(new Runnable() {

                @Override
                public void run() {
                    if (isDisposed() || myProject.isDisposed())
                        return;
                    isUpdating = false;
                    if (finalApply != null) {
                        try {
                            finalApply.run();
                        } catch (Exception e) {
                            LocalHistoryLog.LOG.error(e);
                        }
                    }
                    updateActions();
                    myDiffView.finishUpdating();
                }
            });
        }
    });
}
Also used : Update(com.intellij.util.ui.update.Update) VcsException(com.intellij.openapi.vcs.VcsException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException)

Example 28 with Update

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

the class Updater method update.

public final void update() {
    myQueue.cancelAllUpdates();
    myQueue.queue(new Update("update") {

        @Override
        public void run() {
            update(myPainter);
            if (myPainter.isModified()) {
                myScrollBar.invalidate();
                myScrollBar.repaint();
            }
        }
    });
}
Also used : Update(com.intellij.util.ui.update.Update)

Example 29 with Update

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

the class ServerConnectionEventDispatcher method queueConnectionStatusChanged.

public void queueConnectionStatusChanged(final ServerConnectionImpl<?> connection) {
    myEventsQueue.activate();
    myEventsQueue.queue(new Update(connection) {

        @Override
        public void run() {
            myMessageBus.syncPublisher(ServerConnectionListener.TOPIC).onConnectionStatusChanged(connection);
        }
    });
}
Also used : Update(com.intellij.util.ui.update.Update)

Example 30 with Update

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

the class ExternalSystemProjectsWatcher method onQueued.

@Override
public void onQueued(@NotNull ExternalSystemTaskId id, String workingDir) {
    if (id.getType() == ExternalSystemTaskType.RESOLVE_PROJECT) {
        final ProjectSystemId systemId = id.getProjectSystemId();
        for (String filePath : ContainerUtil.newArrayList(myKnownAffectedFiles.get(workingDir))) {
            VirtualFile file = VfsUtil.findFileByIoFile(new File(filePath), false);
            if (file != null && !file.isDirectory()) {
                file.putUserData(CRC_WITHOUT_SPACES_BEFORE_LAST_IMPORT, file.getUserData(CRC_WITHOUT_SPACES_CURRENT));
            }
        }
        myUpdatesQueue.queue(new Update(Pair.create(systemId, workingDir)) {

            public void run() {
                doUpdateNotifications(true, systemId, workingDir);
            }
        });
    }
}
Also used : ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) Update(com.intellij.util.ui.update.Update) File(java.io.File)

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