// create a task for downloading plugins if the user has activated, yet not downloaded,
// new plugins
//
final PluginPreference preference = getPluginPreference();
final List<PluginInformation> toDownload = preference.getPluginsScheduledForUpdateOrDownload();
final PluginDownloadTask task;
if (toDownload != null && ! toDownload.isEmpty()) {
task = new PluginDownloadTask(this, toDownload, tr("Download plugins"));
} else {
task = null;
}
// this is the task which will run *after* the plugins are downloaded
//
final Runnable continuation = new Runnable() {
@Override
public void run() {
boolean requiresRestart = false;
if (task != null && !task.isCanceled()) {
if (!task.getDownloadedPlugins().isEmpty()) {
requiresRestart = true;
}
}
for (PreferenceSetting setting : settingsInitialized) {
if (setting.ok()) {
requiresRestart = true;
}
}
// build the messages. We only display one message, including the status
// information from the plugin download task and - if necessary - a hint
// to restart JOSM
//
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (task != null && !task.isCanceled()) {
sb.append(PluginPreference.buildDownloadSummary(task));
}
if (requiresRestart) {
sb.append(tr("You have to restart JOSM for some settings to take effect."));
sb.append("<br/><br/>");
sb.append(tr("Would you like to restart now?"));
}
sb.append("</html>");
// display the message, if necessary
//
if (requiresRestart) {
final ButtonSpec [] options = RestartAction.getButtonSpecs();
if (0 == HelpAwareOptionPane.showOptionDialog(
Main.parent,
sb.toString(),
tr("Restart"),
JOptionPane.INFORMATION_MESSAGE,
null, /* no special icon */
options,
options[0],
null /* no special help */
)) {
Main.main.menu.restart.actionPerformed(null);
}
} else if (task != null && !task.isCanceled()) {
JOptionPane.showMessageDialog(
Main.parent,
sb.toString(),
tr("Warning"),
JOptionPane.WARNING_MESSAGE