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

The following examples show how to use com.intellij.util.ui.update.MergingUpdateQueue. 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: HistoryDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void init() {
  LocalHistoryFacade facade = LocalHistoryImpl.getInstanceImpl().getFacade();

  myModel = createModel(facade);
  setTitle(myModel.getTitle());
  JComponent root = createComponent();
  setComponent(root);

  setPreferredFocusedComponent(showRevisionsList() ? myRevisionsList.getComponent() : myDiffView);

  myUpdateQueue = new MergingUpdateQueue(getClass() + ".revisionsUpdate", 500, true, root, this, null, false);
  myUpdateQueue.setRestartTimerOnAdd(true);

  facade.addListener(new LocalHistoryFacade.Listener() {
    public void changeSetFinished() {
      scheduleRevisionsUpdate(null);
    }
  }, this);

  scheduleRevisionsUpdate(null);
}
 
Example #2
Source File: InfoAndProgressPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
InfoAndProgressPanel() {
  setOpaque(false);
  setBorder(JBUI.Borders.empty());

  myRefreshIcon.setVisible(false);

  myRefreshAndInfoPanel.setLayout(new BorderLayout());
  myRefreshAndInfoPanel.setOpaque(false);
  myRefreshAndInfoPanel.add(myRefreshIcon, BorderLayout.WEST);
  myRefreshAndInfoPanel.add(myInfoPanel, BorderLayout.CENTER);

  myUpdateQueue = new MergingUpdateQueue("Progress indicator", 50, true, MergingUpdateQueue.ANY_COMPONENT);
  myPopup = new ProcessPopup(this);

  setRefreshVisible(false);

  restoreEmptyStatus();

  runOnProgressRelatedChange(this::updateProgressIcon, this);
}
 
Example #3
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 #4
Source File: Updater.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected Updater(@Nonnull Painter painter, JScrollBar bar) {
  myPainter = painter;
  myScrollBar = bar;
  myScrollBar.addMouseListener(myMouseAdapter);
  myScrollBar.addMouseMotionListener(myMouseAdapter);
  myQueue = new MergingUpdateQueue("ErrorStripeUpdater", 100, true, myScrollBar, this);
  UIUtil.putClientProperty(myScrollBar, ScrollBarUIConstants.TRACK, (g, x, y, width, height, object) -> {
    DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
    myPainter.setMinimalThickness(settings == null ? 2 : Math.min(settings.ERROR_STRIPE_MARK_MIN_HEIGHT, JBUI.scale(4)));
    myPainter.setErrorStripeGap(1);
    if (myPainter instanceof ExtraErrorStripePainter) {
      ExtraErrorStripePainter extra = (ExtraErrorStripePainter)myPainter;
      extra.setGroupSwap(!myScrollBar.getComponentOrientation().isLeftToRight());
    }
    myPainter.paint(g, x, y, width, height, object);
  });
}
 
Example #5
Source File: AbstractTreeUpdater.java    From consulo with Apache License 2.0 5 votes vote down vote up
public AbstractTreeUpdater(@Nonnull AbstractTreeBuilder treeBuilder) {
  myTreeBuilder = treeBuilder;
  final JTree tree = myTreeBuilder.getTree();
  final JComponent component = tree instanceof TreeTableTree ? ((TreeTableTree)tree).getTreeTable() : tree;
  myUpdateQueue = new MergingUpdateQueue("UpdateQueue", 100, component.isShowing(), component);
  myUpdateQueue.setRestartTimerOnAdd(false);

  final UiNotifyConnector uiNotifyConnector = new UiNotifyConnector(component, myUpdateQueue);
  Disposer.register(this, myUpdateQueue);
  Disposer.register(this, uiNotifyConnector);
}
 
Example #6
Source File: AbstractTreeBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
protected AbstractTreeUpdater createUpdater() {
  if (isDisposed()) return null;

  AbstractTreeUpdater updater = new AbstractTreeUpdater(this);
  updater.setModalityStateComponent(MergingUpdateQueue.ANY_COMPONENT);
  return updater;
}
 
Example #7
Source File: EditorNotificationsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public EditorNotificationsImpl(Project project) {
  myProject = project;
  myUpdateMerger = new MergingUpdateQueue("EditorNotifications update merger", 100, true, null, project);
  MessageBusConnection connection = project.getMessageBus().connect(project);
  connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
    @Override
    public void fileOpened(@Nonnull FileEditorManager source, @Nonnull VirtualFile file) {
      updateNotifications(file);
    }
  });
  connection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
    @Override
    public void enteredDumbMode() {
      updateAllNotifications();
    }

    @Override
    public void exitDumbMode() {
      updateAllNotifications();
    }
  });
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      updateAllNotifications();
    }
  });
}
 
Example #8
Source File: AnnotationsPreloader.java    From consulo with Apache License 2.0 5 votes vote down vote up
public AnnotationsPreloader(final Project project) {
  myProject = project;
  myUpdateQueue = new MergingUpdateQueue("Annotations preloader queue", 1000, true, null, project, null, false);

  project.getMessageBus().connect(project).subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
    @Override
    public void selectionChanged(@Nonnull FileEditorManagerEvent event) {
      if (!isEnabled()) return;
      VirtualFile file = event.getNewFile();
      if (file != null) {
        schedulePreloading(file);
      }
    }
  });
}
 
Example #9
Source File: CompletionProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
CompletionProgressIndicator(Editor editor, @Nonnull Caret caret, int invocationCount,
                            CodeCompletionHandlerBase handler, @Nonnull OffsetMap offsetMap, @Nonnull OffsetsInFile hostOffsets,
                            boolean hasModifiers, @Nonnull LookupImpl lookup) {
  myEditor = editor;
  myCaret = caret;
  myHandler = handler;
  myCompletionType = handler.completionType;
  myInvocationCount = invocationCount;
  myOffsetMap = offsetMap;
  myHostOffsets = hostOffsets;
  myLookup = lookup;
  myStartCaret = myEditor.getCaretModel().getOffset();
  myThreading = ApplicationManager.getApplication().isWriteAccessAllowed() || myHandler.isTestingCompletionQualityMode() ? new SyncCompletion() : new AsyncCompletion();

  myAdvertiserChanges.offer(() -> myLookup.getAdvertiser().clearAdvertisements());

  myArranger = new CompletionLookupArrangerImpl(this);
  myLookup.setArranger(myArranger);

  myLookup.addLookupListener(myLookupListener);
  myLookup.setCalculating(true);

  myLookupManagerListener = evt -> {
    if (evt.getNewValue() != null) {
      LOG.error("An attempt to change the lookup during completion, phase = " + CompletionServiceImpl.getCompletionPhase());
    }
  };
  LookupManager.getInstance(getProject()).addPropertyChangeListener(myLookupManagerListener);

  myQueue = new MergingUpdateQueue("completion lookup progress", ourShowPopupAfterFirstItemGroupingTime, true, myEditor.getContentComponent());
  myQueue.setPassThrough(false);

  ApplicationManager.getApplication().assertIsDispatchThread();

  if (hasModifiers && !ApplicationManager.getApplication().isUnitTestMode()) {
    trackModifiers();
  }
}
 
Example #10
Source File: ServerConnectionEventDispatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ServerConnectionEventDispatcher() {
  myMessageBus = ApplicationManager.getApplication().getMessageBus();
  myEventsQueue = new MergingUpdateQueue("remote server connection events", 500, false, null);
}
 
Example #11
Source File: BaseTreeTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
static AbstractTreeUpdater _createUpdater(AbstractTreeBuilder builder) {
  final AbstractTreeUpdater updater = new AbstractTreeUpdater(builder);
  updater.setModalityStateComponent(MergingUpdateQueue.ANY_COMPONENT);
  return updater;
}
 
Example #12
Source File: ExternalToolPassFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Inject
public ExternalToolPassFactory(Project project) {
  myExternalActivitiesQueue = new MergingUpdateQueue("ExternalActivitiesQueue", 300, true, MergingUpdateQueue.ANY_COMPONENT, project, null, false);
  myExternalActivitiesQueue.setPassThrough(ApplicationManager.getApplication().isUnitTestMode());
}
 
Example #13
Source File: ProjectStructureDaemonAnalyzer.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ProjectStructureDaemonAnalyzer(StructureConfigurableContext context) {
  Disposer.register(context, this);
  myProjectConfigurationProblems = new ProjectConfigurationProblems(this, context);
  myAnalyzerQueue = new MergingUpdateQueue("Project Structure Daemon Analyzer", 300, false, null, this, null, false);
}
 
Example #14
Source File: StructureViewWrapperImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public StructureViewWrapperImpl(Project project, ToolWindowEx toolWindow) {
  myProject = project;
  myToolWindow = toolWindow;

  myUpdateQueue = new MergingUpdateQueue("StructureView", Registry.intValue("structureView.coalesceTime"), false, myToolWindow.getComponent(), this, myToolWindow.getComponent(), true);
  myUpdateQueue.setRestartTimerOnAdd(true);

  final TimerListener timerListener = new TimerListener() {
    @Override
    public ModalityState getModalityState() {
      return ModalityState.stateForComponent(myToolWindow.getComponent());
    }

    @Override
    public void run() {
      checkUpdate();
    }
  };
  ActionManager.getInstance().addTimerListener(500, timerListener);
  Disposer.register(this, new Disposable() {
    @Override
    public void dispose() {
      ActionManager.getInstance().removeTimerListener(timerListener);
    }
  });

  myToolWindow.getComponent().addHierarchyListener(new HierarchyListener() {
    @Override
    public void hierarchyChanged(HierarchyEvent e) {
      if (BitUtil.isSet(e.getChangeFlags(), HierarchyEvent.DISPLAYABILITY_CHANGED)) {
        scheduleRebuild();
      }
    }
  });
  myToolWindow.getContentManager().addContentManagerListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(ContentManagerEvent event) {
      if (myStructureView instanceof StructureViewComposite) {
        StructureViewComposite.StructureViewDescriptor[] views = ((StructureViewComposite)myStructureView).getStructureViews();
        for (StructureViewComposite.StructureViewDescriptor view : views) {
          if (view.title.equals(event.getContent().getTabName())) {
            updateHeaderActions(view.structureView);
            break;
          }
        }
      }
    }
  });
  Disposer.register(myToolWindow.getContentManager(), this);
}
 
Example #15
Source File: FileChooserDialogImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected JComponent createCenterPanel() {
  JPanel panel = new MyPanel();

  myUiUpdater = new MergingUpdateQueue("FileChooserUpdater", 200, false, panel);
  Disposer.register(myDisposable, myUiUpdater);
  new UiNotifyConnector(panel, myUiUpdater);

  panel.setBorder(JBUI.Borders.empty());

  createTree();

  final DefaultActionGroup group = createActionGroup();
  ActionToolbar toolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
  toolBar.setTargetComponent(panel);

  final JPanel toolbarPanel = new JPanel(new BorderLayout());
  toolbarPanel.add(toolBar.getComponent(), BorderLayout.CENTER);

  myTextFieldAction = new TextFieldAction() {
    public void linkSelected(final LinkLabel aSource, final Object aLinkData) {
      toggleShowTextField();
    }
  };
  toolbarPanel.add(myTextFieldAction, BorderLayout.EAST);
  JPanel extraToolbarPanel = createExtraToolbarPanel();
  if (extraToolbarPanel != null) {
    toolbarPanel.add(extraToolbarPanel, BorderLayout.SOUTH);
  }

  myPathTextFieldWrapper = new JPanel(new BorderLayout());
  myPathTextFieldWrapper.setBorder(JBUI.Borders.emptyBottom(2));
  myPathTextField = new FileTextFieldImpl.Vfs(FileChooserFactoryImpl.getMacroMap(), getDisposable(), new LocalFsFinder.FileChooserFilter(myChooserDescriptor, myFileSystemTree)) {
    @Override
    protected void onTextChanged(final String newValue) {
      myUiUpdater.cancelAllUpdates();
      updateTreeFromPath(newValue);
    }
  };
  consulo.disposer.Disposer.register(myDisposable, myPathTextField);
  myPathTextFieldWrapper.add(myPathTextField.getField(), BorderLayout.CENTER);
  if (getRecentFiles().length > 0) {
    myPathTextFieldWrapper.add(createHistoryButton(), BorderLayout.EAST);
  }

  myNorthPanel = new JPanel(new BorderLayout());
  myNorthPanel.add(toolbarPanel, BorderLayout.NORTH);


  updateTextFieldShowing();

  panel.add(myNorthPanel, BorderLayout.NORTH);

  registerMouseListener(group);

  JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myFileSystemTree.getTree());
  //scrollPane.setBorder(BorderFactory.createLineBorder(new Color(148, 154, 156)));
  panel.add(scrollPane, BorderLayout.CENTER);
  panel.setPreferredSize(JBUI.size(400));


  JLabel hintLabel = new JLabel(DRAG_N_DROP_HINT, SwingConstants.CENTER);
  hintLabel.setForeground(JBColor.gray);
  hintLabel.setFont(JBUI.Fonts.smallFont());
  panel.add(hintLabel, BorderLayout.SOUTH);

  ApplicationManager.getApplication().getMessageBus().connect(getDisposable()).subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener() {
    @Override
    public void applicationActivated(IdeFrame ideFrame) {
      ((DesktopSaveAndSyncHandlerImpl)SaveAndSyncHandler.getInstance()).maybeRefresh(ModalityState.current());
    }
  });

  return panel;
}