Changeset 10611 in josm for trunk/src/org/openstreetmap/josm/gui/preferences/plugin
- Timestamp:
- 2016-07-23T18:46:45+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/preferences/plugin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java
r10228 r10611 15 15 import javax.swing.SwingConstants; 16 16 import javax.swing.SwingUtilities; 17 import javax.swing.event.HyperlinkEvent;18 17 import javax.swing.event.HyperlinkEvent.EventType; 19 import javax.swing.event.HyperlinkListener;20 18 21 19 import org.openstreetmap.josm.gui.widgets.HtmlPanel; … … 151 149 HtmlPanel description = new HtmlPanel(); 152 150 description.setText(pi.getDescriptionAsHtml()); 153 description.getEditorPane().addHyperlinkListener(new HyperlinkListener() { 154 @Override 155 public void hyperlinkUpdate(HyperlinkEvent e) { 156 if (e.getEventType() == EventType.ACTIVATED) { 157 OpenBrowser.displayUrl(e.getURL().toString()); 158 } 151 description.getEditorPane().addHyperlinkListener(e -> { 152 if (e.getEventType() == EventType.ACTIVATED) { 153 OpenBrowser.displayUrl(e.getURL().toString()); 159 154 } 160 155 }); … … 170 165 repaint(); 171 166 if (visibleRect != null && visibleRect.width > 0 && visibleRect.height > 0) { 172 SwingUtilities.invokeLater(new Runnable() { 173 @Override 174 public void run() { 175 scrollRectToVisible(visibleRect); 176 } 177 }); 167 SwingUtilities.invokeLater(() -> scrollRectToVisible(visibleRect)); 178 168 } 179 169 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r10482 r10611 150 150 sb.append("</html>"); 151 151 if (!GraphicsEnvironment.isHeadless()) { 152 GuiHelper.runInEDTAndWait(new Runnable() { 153 @Override 154 public void run() { 155 HelpAwareOptionPane.showOptionDialog( 156 parent, 157 sb.toString(), 158 tr("Update plugins"), 159 !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, 160 HelpUtil.ht("/Preferences/Plugins") 161 ); 162 } 163 }); 152 GuiHelper.runInEDTAndWait(() -> HelpAwareOptionPane.showOptionDialog( 153 parent, 154 sb.toString(), 155 tr("Update plugins"), 156 !failed.isEmpty() ? JOptionPane.WARNING_MESSAGE : JOptionPane.INFORMATION_MESSAGE, 157 HelpUtil.ht("/Preferences/Plugins") 158 )); 164 159 } 165 160 } … … 318 313 public void readLocalPluginInformation() { 319 314 final ReadLocalPluginInformationTask task = new ReadLocalPluginInformationTask(); 320 Runnable r = new Runnable() { 321 @Override 322 public void run() { 323 if (!task.isCanceled()) { 324 SwingUtilities.invokeLater(new Runnable() { 325 @Override 326 public void run() { 327 model.setAvailablePlugins(task.getAvailablePlugins()); 328 pnlPluginPreferences.refreshView(); 329 } 330 }); 331 } 315 Runnable r = () -> { 316 if (!task.isCanceled()) { 317 SwingUtilities.invokeLater(() -> { 318 model.setAvailablePlugins(task.getAvailablePlugins()); 319 pnlPluginPreferences.refreshView(); 320 }); 332 321 } 333 322 }; … … 357 346 } 358 347 final ReadRemotePluginInformationTask task = new ReadRemotePluginInformationTask(pluginSites); 359 Runnable continuation = new Runnable() { 360 @Override 361 public void run() { 362 if (!task.isCanceled()) { 363 SwingUtilities.invokeLater(new Runnable() { 364 @Override 365 public void run() { 366 model.updateAvailablePlugins(task.getAvailablePlugins()); 367 pnlPluginPreferences.refreshView(); 368 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); // fix #7030 369 } 370 }); 371 } 348 Runnable continuation = () -> { 349 if (!task.isCanceled()) { 350 SwingUtilities.invokeLater(() -> { 351 model.updateAvailablePlugins(task.getAvailablePlugins()); 352 pnlPluginPreferences.refreshView(); 353 Main.pref.putInteger("pluginmanager.version", Version.getInstance().getVersion()); // fix #7030 354 }); 372 355 } 373 356 }; … … 389 372 protected void alertNothingToUpdate() { 390 373 try { 391 SwingUtilities.invokeAndWait(new Runnable() { 392 @Override 393 public void run() { 394 HelpAwareOptionPane.showOptionDialog( 395 pnlPluginPreferences, 396 tr("All installed plugins are up to date. JOSM does not have to download newer versions."), 397 tr("Plugins up to date"), 398 JOptionPane.INFORMATION_MESSAGE, 399 null // FIXME: provide help context 400 ); 401 } 402 }); 374 SwingUtilities.invokeAndWait(() -> HelpAwareOptionPane.showOptionDialog( 375 pnlPluginPreferences, 376 tr("All installed plugins are up to date. JOSM does not have to download newer versions."), 377 tr("Plugins up to date"), 378 JOptionPane.INFORMATION_MESSAGE, 379 null // FIXME: provide help context 380 )); 403 381 } catch (InterruptedException | InvocationTargetException e) { 404 382 Main.error(e); … … 421 399 // to be run asynchronously after the plugin download 422 400 // 423 final Runnable pluginDownloadContinuation = new Runnable() { 424 @Override 425 public void run() { 426 if (pluginDownloadTask.isCanceled()) 427 return; 428 boolean restartRequired = false; 429 for (PluginInformation pi : pluginDownloadTask.getDownloadedPlugins()) { 430 if (!model.getNewlyActivatedPlugins().contains(pi) || !pi.canloadatruntime) { 431 restartRequired = true; 432 break; 433 } 434 } 435 notifyDownloadResults(pnlPluginPreferences, pluginDownloadTask, restartRequired); 436 model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins()); 437 model.clearPendingPlugins(pluginDownloadTask.getDownloadedPlugins()); 438 GuiHelper.runInEDT(new Runnable() { 439 @Override 440 public void run() { 441 pnlPluginPreferences.refreshView(); 442 } 443 }); 444 } 401 final Runnable pluginDownloadContinuation = () -> { 402 if (pluginDownloadTask.isCanceled()) 403 return; 404 boolean restartRequired = false; 405 for (PluginInformation pi : pluginDownloadTask.getDownloadedPlugins()) { 406 if (!model.getNewlyActivatedPlugins().contains(pi) || !pi.canloadatruntime) { 407 restartRequired = true; 408 break; 409 } 410 } 411 notifyDownloadResults(pnlPluginPreferences, pluginDownloadTask, restartRequired); 412 model.refreshLocalPluginVersion(pluginDownloadTask.getDownloadedPlugins()); 413 model.clearPendingPlugins(pluginDownloadTask.getDownloadedPlugins()); 414 GuiHelper.runInEDT(pnlPluginPreferences::refreshView); 445 415 }; 446 416 447 417 // to be run asynchronously after the plugin list download 448 418 // 449 final Runnable pluginInfoDownloadContinuation = new Runnable() { 450 @Override 451 public void run() { 452 if (pluginInfoDownloadTask.isCanceled()) 453 return; 454 model.updateAvailablePlugins(pluginInfoDownloadTask.getAvailablePlugins()); 455 // select plugins which actually have to be updated 456 // 457 Iterator<PluginInformation> it = toUpdate.iterator(); 458 while (it.hasNext()) { 459 PluginInformation pi = it.next(); 460 if (!pi.isUpdateRequired()) { 461 it.remove(); 462 } 463 } 464 if (toUpdate.isEmpty()) { 465 alertNothingToUpdate(); 466 return; 467 } 468 pluginDownloadTask.setPluginsToDownload(toUpdate); 469 Main.worker.submit(pluginDownloadTask); 470 Main.worker.submit(pluginDownloadContinuation); 471 } 419 final Runnable pluginInfoDownloadContinuation = () -> { 420 if (pluginInfoDownloadTask.isCanceled()) 421 return; 422 model.updateAvailablePlugins(pluginInfoDownloadTask.getAvailablePlugins()); 423 // select plugins which actually have to be updated 424 // 425 Iterator<PluginInformation> it = toUpdate.iterator(); 426 while (it.hasNext()) { 427 PluginInformation pi = it.next(); 428 if (!pi.isUpdateRequired()) { 429 it.remove(); 430 } 431 } 432 if (toUpdate.isEmpty()) { 433 alertNothingToUpdate(); 434 return; 435 } 436 pluginDownloadTask.setPluginsToDownload(toUpdate); 437 Main.worker.submit(pluginDownloadTask); 438 Main.worker.submit(pluginDownloadContinuation); 472 439 }; 473 440 … … 476 443 } 477 444 } 478 479 445 480 446 /** … … 509 475 510 476 @Override 511 public void changedUpdate(DocumentEvent arg0) {477 public void changedUpdate(DocumentEvent evt) { 512 478 filter(); 513 479 } 514 480 515 481 @Override 516 public void insertUpdate(DocumentEvent arg0) {482 public void insertUpdate(DocumentEvent evt) { 517 483 filter(); 518 484 } 519 485 520 486 @Override 521 public void removeUpdate(DocumentEvent arg0) {487 public void removeUpdate(DocumentEvent evt) { 522 488 filter(); 523 489 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
r10210 r10611 6 6 import java.util.Collection; 7 7 import java.util.Collections; 8 import java.util.Comparator;9 8 import java.util.HashMap; 10 9 import java.util.HashSet; … … 150 149 Collections.sort( 151 150 availablePlugins, 152 new Comparator<PluginInformation>() { 153 @Override 154 public int compare(PluginInformation o1, PluginInformation o2) { 155 String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase(Locale.ENGLISH); 156 String n2 = o2.getName() == null ? "" : o2.getName().toLowerCase(Locale.ENGLISH); 157 return n1.compareTo(n2); 158 } 151 (o1, o2) -> { 152 String n1 = o1.getName() == null ? "" : o1.getName().toLowerCase(Locale.ENGLISH); 153 String n2 = o2.getName() == null ? "" : o2.getName().toLowerCase(Locale.ENGLISH); 154 return n1.compareTo(n2); 159 155 } 160 156 );
Note:
See TracChangeset
for help on using the changeset viewer.