public final void queueSelection(final SelectionRequest request) { queue(new Update("UserSelection", Update.LOW_PRIORITY) { @Override public void run() { request.execute(myTreeBuilder.getUi()); } @Override public boolean isExpired() { return myTreeBuilder.isDisposed(); } @Override public void setRejected() { request.reject(); } }); }
/** * Updates tab title and tab tool tip for the specified <code>file</code> */ void updateFileName(@Nullable final VirtualFile file) { // Queue here is to prevent title flickering when tab is being closed and two events arriving: with component==null and component==next focused tab // only the last event makes sense to handle myQueue.queue(new Update("UpdateFileName " + (file == null ? "" : file.getPath())) { @Override public boolean isExpired() { return myProject.isDisposed() || !myProject.isOpen() || (file == null ? super.isExpired() : !file.isValid()); } @Override public void run() { Set<EditorsSplitters> all = getAllSplitters(); for (EditorsSplitters each : all) { each.updateFileName(file); } } }); }
private void updateTreeFromPath(final String text) { if (!isToShowTextField()) return; if (myPathTextField.isPathUpdating()) return; if (text == null) return; myUiUpdater.queue(new Update("treeFromPath.1") { public void run() { ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { final LocalFsFinder.VfsFile toFind = (LocalFsFinder.VfsFile)myPathTextField.getFile(); if (toFind == null || !toFind.exists()) return; myUiUpdater.queue(new Update("treeFromPath.2") { public void run() { selectInTree(toFind.getFile(), text); } }); } }); } }); }
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); } }
private void bindToDesigner(final DesignerEditorPanelFacade designer) { myWindowQueue.cancelAllUpdates(); myWindowQueue.queue(new Update("update") { @Override public void run() { if (myToolWindowDisposed) { return; } if (myToolWindow == null) { if (designer == null) { return; } initToolWindow(); } updateToolWindow(designer); } }); }
private void queueUpdate(final VirtualFile fileToRefresh, final Function<PsiFile, DefaultMutableTreeNode> rootToReloadGetter, final String scopeName) { if (myProject.isDisposed()) return; AbstractProjectViewPane pane = ProjectView.getInstance(myProject).getCurrentProjectViewPane(); if (pane == null || !ScopeViewPane.ID.equals(pane.getId()) || !scopeName.equals(pane.getSubId())) { return; } myUpdateQueue.queue(new Update(fileToRefresh) { @Override public void run() { if (myProject.isDisposed() || !fileToRefresh.isValid()) return; final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(fileToRefresh); if (psiFile != null) { reload(rootToReloadGetter.fun(psiFile)); } } @Override public boolean isExpired() { return !isTreeShowing(); } }); }
/** * (Re)schedule the background task which updates the preview images. */ private void requestPreviewUpdate() { myUpdateQueue.cancelAllUpdates(); myUpdateQueue.queue(new Update("update") { @Override public void run() { try { myAssetGenerator.generateImages(myImageMap, true, true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updatePreviewImages(); } }); } catch (final ImageGeneratorException e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { setErrorHtml(e.getMessage()); } }); } } }); }
public void scheduleUpdateIndicesList(@Nullable final Consumer<List<MavenIndex>> consumer) { myUpdateQueue.queue(new Update(MavenProjectIndicesManager.this) { public void run() { Set<Pair<String, String>> remoteRepositoriesIdsAndUrls; File localRepository; AccessToken accessToken = ReadAction.start(); try { if (myProject.isDisposed()) return; remoteRepositoriesIdsAndUrls = collectRemoteRepositoriesIdsAndUrls(); localRepository = getLocalRepository(); } finally { accessToken.finish(); } myProjectIndices = MavenIndicesManager.getInstance().ensureIndicesExist(myProject, localRepository, remoteRepositoriesIdsAndUrls); if(consumer != null) { consumer.consume(myProjectIndices); } } }); }
private void scheduleKeymapUpdate(List<MavenProject> mavenProjects, boolean forUpdate) { synchronized (mySheduledProjects) { for (MavenProject each : mavenProjects) { mySheduledProjects.put(each, forUpdate); } } myUpdateQueue.queue(new Update(MavenShortcutsManager.this) { @Override public void run() { List<MavenProject> projectToUpdate; List<MavenProject> projectToDelete; synchronized (mySheduledProjects) { projectToUpdate = selectScheduledProjects(true); projectToDelete = selectScheduledProjects(false); mySheduledProjects.clear(); } if (!myProject.isDisposed()) { MavenKeymapExtension.clearActions(myProject, projectToDelete); MavenKeymapExtension.updateActions(myProject, projectToUpdate); } } }); }
@Override public void queue(@NotNull Update update) { boolean passThrough = false; if (ApplicationManager.getApplication().isUnitTestMode()) { passThrough = isPassThrough(); } else if (MavenUtil.isNoBackgroundMode()) { passThrough = true; } if (passThrough) { update.run(); return; } super.queue(update); }
private void updateTreeFromPath(final String text) { if (!myShowPath) return; if (myPathTextField.isPathUpdating()) return; if (text == null) return; myUiUpdater.queue(new Update("treeFromPath.1") { public void run() { ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { final LocalFsFinder.VfsFile toFind = (LocalFsFinder.VfsFile)myPathTextField.getFile(); if (toFind == null || !toFind.exists()) return; myUiUpdater.queue(new Update("treeFromPath.2") { public void run() { selectInTree(toFind.getFile(), text); } }); } }); } }); }
/** * Updates tab title and tab tool tip for the specified <code>file</code> */ void updateFileName(@Nullable final VirtualFile file) { // Queue here is to prevent title flickering when tab is being closed and two events arriving: with component==null and component==next focused tab // only the last event makes sense to handle myQueue.queue(new Update("UpdateFileName " + (file == null ? "" : file.getPath())) { public boolean isExpired() { return myProject.isDisposed() || !myProject.isOpen() || (file == null ? super.isExpired() : !file.isValid()); } public void run() { Set<EditorsSplitters> all = getAllSplitters(); for (EditorsSplitters each : all) { each.updateFileName(file); } } }); }
public void queueUiUpdate(final boolean forceScrollToEnd) { myForceScrollToEnd.compareAndSet(false, forceScrollToEnd); myUpdateQueue.queue(new Update("UpdateUi") { @Override public void run() { if (Disposer.isDisposed(LanguageConsoleImpl.this)) return; if (isConsoleEditorEnabled()) { myPanel.revalidate(); myPanel.repaint(); } if (myUiUpdateRunnable != null) { ApplicationManager.getApplication().runReadAction(myUiUpdateRunnable); } } }); }
private void scheduleKeymapUpdate(List<MavenProject> mavenProjects, boolean forUpdate) { synchronized (mySheduledProjects) { for (MavenProject each : mavenProjects) { mySheduledProjects.put(each, forUpdate); } } myUpdateQueue.queue(new Update(MavenShortcutsManager.this) { @Override public void run() { List<MavenProject> projectToUpdate; List<MavenProject> projectToDelete; synchronized (mySheduledProjects) { projectToUpdate = selectScheduledProjects(true); projectToDelete = selectScheduledProjects(false); mySheduledProjects.clear(); } MavenKeymapExtension.clearActions(myProject, projectToDelete); MavenKeymapExtension.updateActions(myProject, projectToUpdate); } }); }
private void bindToDesigner(final DesignerEditorPanel designer) { myWindowQueue.cancelAllUpdates(); myWindowQueue.queue(new Update("update") { @Override public void run() { if (!myToolWindowReady || myToolWindowDisposed) { return; } if (myToolWindow == null) { if (designer == null) { return; } initToolWindow(); } updateToolWindow(designer); } }); }
private void bindToDesigner(final CordovaDesignerEditorPanel designer) { myWindowQueue.cancelAllUpdates(); myWindowQueue.queue(new Update("update") { @Override public void run() { if (!myToolWindowReady || myToolWindowDisposed) { return; } if (myToolWindow == null) { if (designer == null) { return; } initToolWindow(); } updateToolWindow(designer); } }); }
public PresentationModeProgressPanel(InlineProgressIndicator progress) { myProgress = progress; Font font = JBUI.Fonts.label(11); myText.setFont(font); myText2.setFont(font); myText.setIcon(JBUI.scale(EmptyIcon.create(1, 16))); myText2.setIcon(JBUI.scale(EmptyIcon.create(1, 16))); myUpdateQueue = new MergingUpdateQueue("Presentation Mode Progress", 100, true, null); myUpdate = new Update("Update UI") { @Override public void run() { updateImpl(); } }; myEastButtons = myProgress.createEastButtons(); myButtonPanel.add(InlineProgressIndicator.createButtonPanel(myEastButtons.map(b -> b.button))); }
/** * Updates tab title and tab tool tip for the specified {@code file} */ void updateFileName(@Nullable final VirtualFile file) { // Queue here is to prevent title flickering when tab is being closed and two events arriving: with component==null and component==next focused tab // only the last event makes sense to handle myQueue.queue(new Update("UpdateFileName " + (file == null ? "" : file.getPath())) { @Override public boolean isExpired() { return myProject.isDisposed() || !myProject.isOpen() || (file == null ? super.isExpired() : !file.isValid()); } @Override public void run() { Set<EditorSplitters> all = getAllSplitters(); for (EditorSplitters each : all) { each.updateFileName(file); } } }); }
public void setText(final String text) { myUpdateQueue.queue(new Update("Text") { @Override public void run() { DebuggerInvocationUtil.invokeLater(getProject(), new Runnable() { public void run() { if (!myProgressWindow.isCanceled() && myProgressWindow.isRunning()) { myProgressWindow.setText(text); } } }, myProgressWindow.getModalityState()); } }); }
public void reset() { LOG.debug("analyzer started"); myAnalyzerQueue.activate(); myResultsUpdateQueue.activate(); myAnalyzerQueue.queue(new Update("reset") { @Override public void run() { myStopped.set(false); } }); }
public void queueConnectionStatusChanged(final ServerConnectionImpl<?> connection) { myEventsQueue.activate(); myEventsQueue.queue(new Update(connection) { @Override public void run() { myMessageBus.syncPublisher(ServerConnectionListener.TOPIC).onConnectionStatusChanged(connection); } }); }
public void queueDeploymentsChanged(final ServerConnectionImpl<?> connection) { myEventsQueue.activate(); myEventsQueue.queue(new Update(connection) { @Override public void run() { myMessageBus.syncPublisher(ServerConnectionListener.TOPIC).onDeploymentsChanged(connection); } }); }
public ActionCallback refilter(@Nullable final Object preferredSelection, final boolean adjustSelection, final boolean now) { if (myRefilterQueue != null) { myRefilterQueue.cancelAllUpdates(); } final ActionCallback callback = new ActionCallback(); final Runnable afterCancelUpdate = new Runnable() { @Override public void run() { if (myRefilterQueue == null || now) { refilterNow(preferredSelection, adjustSelection).doWhenDone(callback.createSetDoneRunnable()); } else { myRefilterQueue.queue(new Update(this) { @Override public void run() { refilterNow(preferredSelection, adjustSelection).notifyWhenDone(callback); } @Override public void setRejected() { super.setRejected(); callback.setDone(); } }); } } }; if (!isDisposed()) { if (!ApplicationManager.getApplication().isUnitTestMode()) { getUi().cancelUpdate().doWhenProcessed(afterCancelUpdate); } else { afterCancelUpdate.run(); } } return callback; }
@Override protected void queueRunningUpdate(final Runnable update) { myUpdateQueue.queue(new Update(new Object(), false, 0) { @Override public void run() { ApplicationManager.getApplication().invokeLater(update); } }); }
public PresentationModeProgressPanel(InlineProgressIndicator progress) { myProgress = progress; Font font = JBUI.Fonts.label(11); myText.setFont(font); myText2.setFont(font); myText.setIcon(EmptyIcon.create(1, 16)); myText2.setIcon(EmptyIcon.create(1, 16)); myUpdateQueue = new MergingUpdateQueue("Presentation Mode Progress", 100, true, null); myUpdate = new Update("Update UI") { @Override public void run() { updateImpl(); } }; }
@Override public void progressMessageChanged(final boolean indeterminate, @NotNull final String message) { myProgressUpdatesQueue.queue(new Update("progress text") { @Override public void run() { myProgressLabel.setText(message); } }); }
@Override public void progressFractionChanged(final double fraction) { myProgressUpdatesQueue.queue(new Update("fraction") { @Override public void run() { myProgressBar.setValue((int)Math.round(100 * fraction)); } }); }
protected void queueUpdateFile(@NotNull final VirtualFile file) { myQueue.queue(new Update(file) { @Override public void run() { if (isFileOpen(file)) { updateFileIcon(file); updateFileColor(file); updateFileBackgroundColor(file); } } }); }
private void queueModificationCheck() { final Configurable configurable = getContext().getCurrentConfigurable(); myModificationChecker.queue(new Update(this) { @Override public void run() { checkModified(configurable); } @Override public boolean isExpired() { return getContext().getCurrentConfigurable() != configurable; } }); }