com.intellij.util.ui.update.Update Java Examples

The following examples show how to use com.intellij.util.ui.update.Update. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LightToolWindowManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
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);
    }
  });
}
 
Example #2
Source File: FileTextFieldImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public final void setText(final String text, boolean now, @Nullable final Runnable onDone) {
  final Update update = new Update("pathFromTree") {
    @Override
    public void run() {
      myPathIsUpdating = true;
      getField().setText(text);
      myPathIsUpdating = false;
      if (onDone != null) {
        onDone.run();
      }
    }
  };
  if (now) {
    update.run();
  }
  else {
    myUiUpdater.queue(update);
  }
}
 
Example #3
Source File: FileChooserDialogImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
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);
            }
          });
        }
      });
    }
  });
}
 
Example #4
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
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();
    }
  });
}
 
Example #5
Source File: FileEditorManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * 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<EditorsSplitters> all = getAllSplitters();
      for (EditorsSplitters each : all) {
        each.updateFileName(file);
      }
    }
  });
}
 
Example #6
Source File: PresentationModeProgressPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
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)));
}
 
Example #7
Source File: DesktopEditorAnalyzeStatusPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void repaintTrafficLightIcon() {
  ErrorStripeRenderer errorStripeRenderer = myModel.getErrorStripeRenderer();

  if (errorStripeRenderer == null) return;

  myStatusUpdates.queue(Update.create("icon", () -> {
    if (errorStripeRenderer != null) {
      AnalyzerStatus newStatus = errorStripeRenderer.getStatus(myEditor);
      if (!AnalyzerStatus.equals(newStatus, analyzerStatus)) {
        changeStatus(newStatus);
      }

      if(myErrorPanel != null) {
        myErrorPanel.repaint();
      }
    }
  }));
}
 
Example #8
Source File: AbstractTreeUpdater.java    From consulo with Apache License 2.0 6 votes vote down vote up
final void queueSelection(final SelectionRequest request) {
  queue(new Update("UserSelection", Update.LOW_PRIORITY) {
    @Override
    public void run() {
      AbstractTreeUi ui = myTreeBuilder.getUi();
      if (ui != null) {
        request.execute(ui);
      }
    }

    @Override
    public boolean isExpired() {
      return myTreeBuilder.isDisposed();
    }

    @Override
    public void setRejected() {
      request.reject();
    }
  });
}
 
Example #9
Source File: XLineBreakpointManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void documentChanged(final DocumentEvent e) {
  final Document document = e.getDocument();
  Collection<XLineBreakpointImpl> breakpoints = myBreakpoints.getKeysByValue(document);
  if (breakpoints != null && !breakpoints.isEmpty()) {
    myBreakpointsUpdateQueue.queue(new Update(document) {
      @Override
      public void run() {
        updateBreakpoints(document);
      }
    });
  }
}
 
Example #10
Source File: ServerConnectionEventDispatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void queueConnectionStatusChanged(final ServerConnectionImpl<?> connection) {
  myEventsQueue.activate();
  myEventsQueue.queue(new Update(connection) {
    @Override
    public void run() {
      myMessageBus.syncPublisher(ServerConnectionListener.TOPIC).onConnectionStatusChanged(connection);
    }
  });
}
 
Example #11
Source File: ServerConnectionEventDispatcher.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void queueDeploymentsChanged(final ServerConnectionImpl<?> connection) {
  myEventsQueue.activate();
  myEventsQueue.queue(new Update(connection) {
    @Override
    public void run() {
      myMessageBus.syncPublisher(ServerConnectionListener.TOPIC).onDeploymentsChanged(connection);
    }
  });
}
 
Example #12
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void rootsChanged(ModuleRootEvent event) {
  myUpdateQueue.cancelAllUpdates();
  myUpdateQueue.queue(new Update("RootsChanged") {
    @Override
    public void run() {
      refreshScope(getCurrentScope());
    }

    @Override
    public boolean isExpired() {
      return !isTreeShowing();
    }
  });
}
 
Example #13
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void queueUpdate(final Runnable request, boolean updateImmediately) {
  final Runnable wrapped = new Runnable() {
    @Override
    public void run() {
      if (myProject.isDisposed()) return;
      request.run();
    }
  };
  if (updateImmediately && isTreeShowing()) {
    myUpdateQueue.run(new Update(request) {
      @Override
      public void run() {
        wrapped.run();
      }
    });
  }
  else {
    myUpdateQueue.queue(new Update(request) {
      @Override
      public void run() {
        wrapped.run();
      }

      @Override
      public boolean isExpired() {
        return !isTreeShowing();
      }
    });
  }
}
 
Example #14
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void selectNode(final PsiElement element, final PsiFileSystemItem file, final boolean requestFocus) {
  final Runnable runnable = new Runnable() {
    @Override
    public void run() {
      myUpdateQueue.queue(new Update("Select") {
        @Override
        public void run() {
          if (myProject.isDisposed()) return;
          PackageDependenciesNode node = myBuilder.findNode(file, element);
          if (node != null && node.getPsiElement() != element) {
            final TreePath path = new TreePath(node.getPath());
            if (myTree.isCollapsed(path)) {
              myTree.expandPath(path);
              myTree.makeVisible(path);
            }
          }
          node = myBuilder.findNode(file, element);
          if (node != null) {
            TreeUtil.selectPath(myTree, new TreePath(node.getPath()));
            if (requestFocus) {
              IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(myTree);
            }
          }
        }
      });
    }
  };
  doWhenDone(runnable);
}
 
Example #15
Source File: StructureViewWrapperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void scheduleRebuild() {
  myUpdateQueue.queue(new Update("rebuild") {
    @Override
    public void run() {
      if (myProject.isDisposed()) return;
      rebuild();
    }
  });
}
 
Example #16
Source File: ChooseByNamePopup.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void repaintList() {
  myRepaintQueue.cancelAllUpdates();
  myRepaintQueue.queue(new Update(this) {
    @Override
    public void run() {
      repaintListImmediate();
    }
  });
}
 
Example #17
Source File: ProjectStructureDaemonAnalyzer.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void reset() {
  LOG.debug("analyzer started");
  myAnalyzerQueue.activate();
  myAnalyzerQueue.queue(new Update("reset") {
    @Override
    public void run() {
      myStopped.set(false);
    }
  });
}
 
Example #18
Source File: AnnotationsPreloader.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void schedulePreloading(@Nonnull final VirtualFile file) {
  if (myProject.isDisposed() || file.getFileType().isBinary()) return;

  myUpdateQueue.queue(new Update(file) {
    @Override
    public void run() {
      try {
        long start = 0;
        if (LOG.isDebugEnabled()) {
          start = System.currentTimeMillis();
        }
        if (!FileEditorManager.getInstance(myProject).isFileOpen(file)) return;

        FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(file);
        if (fileStatus == FileStatus.UNKNOWN || fileStatus == FileStatus.ADDED || fileStatus == FileStatus.IGNORED) {
          return;
        }

        AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(file);
        if (vcs == null) return;

        AnnotationProvider annotationProvider = vcs.getAnnotationProvider();
        if (annotationProvider == null || !annotationProvider.isCaching()) return;

        annotationProvider.annotate(file);
        if (LOG.isDebugEnabled()) {
          LOG.debug("Preloaded VCS annotations for ", file.getName(), " in ", String.valueOf(System.currentTimeMillis() - start), "ms");
        }
      }
      catch (VcsException e) {
        LOG.info(e);
      }
    }
  });
}
 
Example #19
Source File: XLineBreakpointManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void queueAllBreakpointsUpdate() {
  myBreakpointsUpdateQueue.queue(new Update("all breakpoints") {
    @Override
    public void run() {
      for (XLineBreakpointImpl breakpoint : myBreakpoints.keySet()) {
        breakpoint.updateUI();
      }
    }
  });
}
 
Example #20
Source File: TFVCNotifications.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
public static void showInvalidDollarFilePathNotification(@NotNull Project project, @NotNull String serverFilePath) {
    ourQueue.queue(new Update(Pair.create(project, serverFilePath)) {
        @Override
        public void run() {
            ApplicationManager.getApplication().assertIsDispatchThread();

            Notification notification = TFS_NOTIFICATIONS.createNotification(
                    TfPluginBundle.message(TfPluginBundle.KEY_TFVC_NOTIFICATION_FILE_NAME_STARTS_WITH_DOLLAR, serverFilePath),
                    NotificationType.WARNING);
            notification.addAction(new AddFileToTfIgnoreAction(project, serverFilePath));
            Notifications.Bus.notify(notification, project);
        }
    });
    UIUtil.invokeLaterIfNeeded(ourQueue::activate);
}
 
Example #21
Source File: InfoAndProgressPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void queueRunningUpdate(@Nonnull final Runnable update) {
  myUpdateQueue.queue(new Update(new Object(), false, 0) {
    @Override
    public void run() {
      ApplicationManager.getApplication().invokeLater(update);
    }
  });
}
 
Example #22
Source File: RemoteFilePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void progressMessageChanged(final boolean indeterminate, @Nonnull final String message) {
  myProgressUpdatesQueue.queue(new Update("progress text") {
    public void run() {
      myProgressLabel.setText(message);
    }
  });
}
 
Example #23
Source File: RemoteFilePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void progressFractionChanged(final double fraction) {
  myProgressUpdatesQueue.queue(new Update("fraction") {
    public void run() {
      myProgressBar.setValue((int)Math.round(100*fraction));
    }
  });
}
 
Example #24
Source File: FileEditorManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
void queueUpdateFile(@Nonnull final VirtualFile file) {
  myQueue.queue(new Update(file) {
    @Override
    public void run() {
      if (isFileOpen(file)) {
        updateFileIcon(file);
        updateFileColor(file);
        updateFileBackgroundColor(file);
      }

    }
  });
}
 
Example #25
Source File: OptionsEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
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;
    }
  });
}
 
Example #26
Source File: Updater.java    From consulo with Apache License 2.0 5 votes vote down vote up
public final void update() {
  myQueue.cancelAllUpdates();
  myQueue.queue(new Update("update") {
    @Override
    public void run() {
      update(myPainter);
      if (myPainter.isModified()) {
        myScrollBar.invalidate();
        myScrollBar.repaint();
      }
    }
  });
}
 
Example #27
Source File: EditorNotificationsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void updateAllNotifications() {
  myUpdateMerger.queue(new Update("update") {
    @Override
    public void run() {
      for (VirtualFile file : FileEditorManager.getInstance(myProject).getOpenFiles()) {
        updateNotifications(file);
      }
    }
  });
}
 
Example #28
Source File: XLineBreakpointManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void queueBreakpointUpdate(@Nonnull final XLineBreakpointImpl<?> breakpoint) {
  myBreakpointsUpdateQueue.queue(new Update(breakpoint) {
    @Override
    public void run() {
      breakpoint.updateUI();
    }
  });
}
 
Example #29
Source File: ProjectStructureDaemonAnalyzer.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canEat(Update update) {
  if (!(update instanceof AnalyzeElementUpdate)) return false;
  final AnalyzeElementUpdate other = (AnalyzeElementUpdate)update;
  return myElement.equals(other.myElement) && (!other.myCheck || myCheck) && (!other.myCollectUsages || myCollectUsages);
}
 
Example #30
Source File: BreadcrumbsWrapper.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canEat(final Update update) {
  return true;
}