Subject: [PATCH] #22381: Plugins with new dependencies don't have those dependencies automatically downloaded
---
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
diff --git a/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java b/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
a
|
b
|
|
17 | 17 | import java.util.ArrayList; |
18 | 18 | import java.util.Collection; |
19 | 19 | import java.util.Collections; |
| 20 | import java.util.HashSet; |
20 | 21 | import java.util.LinkedList; |
21 | 22 | import java.util.List; |
22 | 23 | import java.util.Set; |
… |
… |
|
431 | 432 | alertNothingToUpdate(); |
432 | 433 | return; |
433 | 434 | } |
| 435 | int toUpdateSize; |
| 436 | boolean refreshRequired = false; |
| 437 | do { |
| 438 | toUpdateSize = toUpdate.size(); |
| 439 | Set<PluginInformation> enabledPlugins = new HashSet<>(PluginHandler.getPlugins()); |
| 440 | enabledPlugins.addAll(toUpdate); |
| 441 | Set<PluginInformation> toAdd = new HashSet<>(); |
| 442 | for (PluginInformation pi : toUpdate) { |
| 443 | if (!PluginHandler.checkRequiredPluginsPreconditions(null, enabledPlugins, pi, false)) { |
| 444 | // Time to find the missing plugins... |
| 445 | toAdd.addAll(pi.getRequiredPlugins().stream().filter(plugin -> PluginHandler.getPlugin(plugin) == null) |
| 446 | .map(plugin -> model.getPluginInformation(plugin)) |
| 447 | .collect(Collectors.toSet())); |
| 448 | } |
| 449 | } |
| 450 | toAdd.forEach(plugin -> model.setPluginSelected(plugin.name, true)); |
| 451 | refreshRequired |= !toAdd.isEmpty(); // We need to force refresh the checkboxes if we are adding new plugins |
| 452 | toAdd.removeIf(plugin -> !plugin.isUpdateRequired()); // Avoid downloading plugins that already exist |
| 453 | toUpdate.addAll(toAdd); |
| 454 | } while (toUpdateSize != toUpdate.size()); |
| 455 | |
434 | 456 | pluginDownloadTask.setPluginsToDownload(toUpdate); |
435 | 457 | MainApplication.worker.submit(pluginDownloadTask); |
436 | 458 | MainApplication.worker.submit(pluginDownloadContinuation); |
| 459 | if (refreshRequired) { |
| 460 | // Needed since we need to recreate the checkboxes to show the enabled dependent plugins that were not previously enabled |
| 461 | pnlPluginPreferences.resetDisplayedComponents(); |
| 462 | } |
| 463 | GuiHelper.runInEDT(pnlPluginPreferences::refreshView); |
437 | 464 | }; |
438 | 465 | |
439 | 466 | MainApplication.worker.submit(pluginInfoDownloadTask); |