P4ChangeListDecorator implements ChangeListDecorator, ProjectComponent { @Override public void decorateChangeList(LocalChangeList changeList, ColoredTreeCellRenderer cellRenderer, boolean selected, boolean expanded, boolean hasFocus) { if (isProjectInvalid()) { return; } CacheComponent cache = CacheComponent.getInstance(project); ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); Pair<IdeChangelistMap, IdeFileMap> openedCache = cache.getServerOpenedCache(); try { Collection<P4ChangelistId> p4Changes = openedCache.first.getP4ChangesFor(changeList); if (LOG.isDebugEnabled()) { LOG.debug("Change " + changeList + " has p4 changes " + p4Changes); } if (p4Changes.isEmpty()) { return; } ChangelistConnectionInfo info = new ChangelistConnectionInfo(p4Changes.size()); for (P4ChangelistId p4Change: p4Changes) { if (registry != null && registry.isOnline(p4Change.getClientServerRef())) { info.addOnline(p4Change); } else { info.addOffline(p4Change); } } decorateInfo(info, cellRenderer); } catch (InterruptedException e) { InternalErrorMessage.send(project).cacheLockTimeoutError(new ErrorEvent<>(new VcsInterruptedException(e))); } } @SuppressWarnings("WeakerAccess")  P4ChangeListDecorator(@NotNull Project project); @Override void decorateChangeList(LocalChangeList changeList, ColoredTreeCellRenderer cellRenderer, boolean selected, boolean expanded, boolean hasFocus); @Override void projectOpened(); @Override void projectClosed(); @Override void initComponent(); @Override void disposeComponent(); @NotNull @Override String getComponentName();  }
@ExtendWith(TemporaryFolderExtension.class) @Test void offlineNoP4ChangeDecorateChangeListWithDefault(TemporaryFolder tmp) { ClientConfigRoot root = vcs.addClientConfigRoot(tmp, "client"); assertNotNull(root.getClientRootDir()); vcs.goOffline(root); assertFalse(vcs.registry.isOnline(root.getClientConfig().getClientServerRef())); P4ChangelistId defaultP4Changelist = vcs.addDefaultChangelist(root); MockLocalChangeList changeList = vcs.addIdeChangelist("new change", "a test change", false); P4ChangeListDecorator decorator = new P4ChangeListDecorator(vcs.getMockProject()); MockColoredTreeCellRenderer renderer = new MockColoredTreeCellRenderer(); decorator.decorateChangeList(changeList, renderer, false, false, false); assertEmpty(renderer.appendedText); }
@ExtendWith(TemporaryFolderExtension.class) @Test void offlineNoP4ChangeDecorateChangeList(TemporaryFolder tmp) { MockLocalChangeList changeList = vcs.addIdeChangelist("new change", "a test change", false); P4ChangeListDecorator decorator = new P4ChangeListDecorator(vcs.getMockProject()); MockColoredTreeCellRenderer renderer = new MockColoredTreeCellRenderer(); decorator.decorateChangeList(changeList, renderer, false, false, false); assertEmpty(renderer.appendedText); }