IDEA-196053 Plugins: counter on Updates page appears only on opening the tab

This commit is contained in:
Alexander Lobas
2018-11-30 19:41:02 +03:00
parent a1f02c6ca9
commit 73e687e50a
4 changed files with 16 additions and 14 deletions
@@ -465,7 +465,7 @@ public class PluginManagerConfigurableNew
myTabHeaderComponent.addTab(myUpdatesTabName = new CountTabName(myTabHeaderComponent, "Updates"));
myPluginUpdatesServiceCallback =
PluginUpdatesService.connectConfigurableTab(countValue -> myUpdatesTabName.setCount(countValue == null ? 0 : countValue));
PluginUpdatesService.connectConfigurable(countValue -> myUpdatesTabName.setCount(countValue == null ? 0 : countValue));
createSearchPanels();
@@ -37,7 +37,7 @@ public class PluginManagerConfigurableTreeRenderer implements ConfigurableTreeRe
if (myTree == null) {
PluginUpdatesService.connectTreeRenderer(tree, countValue -> {
String oldCountValue = myCountValue;
myCountValue = countValue == null || countValue == 0 ? null : countValue.toString();
myCountValue = countValue == null || countValue <= 0 ? null : countValue.toString();
if (myTree != null && !StringUtil.equals(oldCountValue, myCountValue)) {
myTree.repaint();
}
@@ -70,7 +70,9 @@ public class DetailsPagePluginComponent extends OpaquePanel {
myCenterPanel = createCenterPanel(update);
header.add(myCenterPanel);
createTagPanel();
if (!update) {
createTagPanel();
}
createMetricsPanel();
createErrorPanel();
createProgressPanel(!update);
@@ -47,7 +47,7 @@ public class PluginUpdatesService {
}
@Nullable
public static Runnable connectConfigurableTab(@NotNull Consumer<Integer> callback) {
public static Runnable connectConfigurable(@NotNull Consumer<Integer> callback) {
assert SwingUtilities.isEventDispatchThread();
Runnable disposer = myCreate ? () -> dispose() : null;
@@ -82,7 +82,7 @@ public class PluginUpdatesService {
PluginDownloader downloader = I.next();
if (downloader.getDescriptor() == descriptor) {
I.remove();
doCountCallback();
runCallbacks(getCount());
return;
}
}
@@ -90,8 +90,9 @@ public class PluginUpdatesService {
public static void recalculateUpdates() {
assert SwingUtilities.isEventDispatchThread();
assert !myPreparing;
runCallbacks(-1);
calculateUpdates();
}
@@ -118,11 +119,6 @@ public class PluginUpdatesService {
}
}
@Nullable
private static Integer getCount() {
return myCache == null ? null : new Integer(myCache.size());
}
private static void calculateUpdates() {
assert SwingUtilities.isEventDispatchThread();
@@ -142,7 +138,7 @@ public class PluginUpdatesService {
myPrepared = true;
myCache = updates;
doCountCallback();
runCallbacks(getCount());
if (myPanelCallbacks != null) {
for (Consumer<Collection<PluginDownloader>> callback : myPanelCallbacks) {
@@ -154,8 +150,12 @@ public class PluginUpdatesService {
});
}
private static void doCountCallback() {
Integer countValue = getCount();
@Nullable
private static Integer getCount() {
return myCache == null ? null : new Integer(myCache.size());
}
private static void runCallbacks(@Nullable Integer countValue) {
if (myTreeCallback != null) {
myTreeCallback.accept(countValue);
}