Changeset 3090 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2010-03-06T12:37:34+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
r3083 r3090 38 38 private static final Logger logger = Logger.getLogger(PluginDownloadTask.class.getName()); 39 39 40 private final Collection<PluginInformation> toUpdate ;40 private final Collection<PluginInformation> toUpdate = new LinkedList<PluginInformation>(); 41 41 private final Collection<PluginInformation> failed = new LinkedList<PluginInformation>(); 42 42 private final Collection<PluginInformation> downloaded = new LinkedList<PluginInformation>(); … … 56 56 super(parent, title == null ? "" : title, false /* don't ignore exceptions */); 57 57 CheckParameterUtil.ensureParameterNotNull(toUpdate, "toUpdate"); 58 this.toUpdate = toUpdate;58 this.toUpdate.addAll(toUpdate); 59 59 } 60 60 … … 70 70 super(title, monitor == null? NullProgressMonitor.INSTANCE: monitor, false /* don't ignore exceptions */); 71 71 CheckParameterUtil.ensureParameterNotNull(toUpdate, "toUpdate"); 72 this.toUpdate = toUpdate; 72 this.toUpdate.addAll(toUpdate); 73 } 74 75 /** 76 * Sets the collection of plugins to update. 77 * 78 * @param toUpdate the collection of plugins to update. Must not be null. 79 * @throws IllegalArgumentException thrown if toUpdate is null 80 */ 81 public void setPluginsToDownload(Collection<PluginInformation> toUpdate) throws IllegalArgumentException{ 82 CheckParameterUtil.ensureParameterNotNull(toUpdate, "toUpdate"); 83 this.toUpdate.clear(); 84 this.toUpdate.addAll(toUpdate); 73 85 } 74 86 -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r3086 r3090 382 382 pluginList.add(plugin.load(klass)); 383 383 } 384 } catch (Throwable e) { 384 } catch(PluginException e) { 385 if (e.getCause() instanceof ClassNotFoundException) { 386 e.printStackTrace(); 387 String msg = tr("<html>Could not load plugin {0} because the plugin<br>main class ''{1}'' was not found.<br>" 388 + "Delete from preferences?", plugin.name, plugin.className); 389 if (confirmDisablePlugin(parent, msg, plugin.name)) { 390 Main.pref.removeFromCollection("plugins", plugin.name); 391 } 392 } 393 } catch (Throwable e) { 385 394 e.printStackTrace(); 386 395 String msg = tr("Could not load plugin {0}. Delete from preferences?", plugin.name); … … 639 648 } 640 649 641 // try to update the locally installed plugins650 // filter plugins which actually have to be updated 642 651 // 643 PluginDownloadTask task2 = new PluginDownloadTask( 644 monitor.createSubTaskMonitor(1,false), 645 plugins, 646 tr("Update plugins") 647 ); 648 649 future = service.submit(task2); 650 try { 651 future.get(); 652 } catch(ExecutionException e) { 653 e.printStackTrace(); 654 alertFailedPluginUpdate(parent, plugins); 655 return; 656 } catch(InterruptedException e) { 657 e.printStackTrace(); 658 alertFailedPluginUpdate(parent, plugins); 659 return; 660 } 661 // notify user if downloading a locally installed plugin failed 662 // 663 if (! task2.getFailedPlugins().isEmpty()) { 664 alertFailedPluginUpdate(parent, task2.getFailedPlugins()); 665 return; 652 Iterator<PluginInformation> it = plugins.iterator(); 653 while(it.hasNext()) { 654 PluginInformation pi = it.next(); 655 if (!pi.isUpdateRequired()) { 656 it.remove(); 657 } 658 } 659 660 if (!plugins.isEmpty()) { 661 // try to update the locally installed plugins 662 // 663 PluginDownloadTask task2 = new PluginDownloadTask( 664 monitor.createSubTaskMonitor(1,false), 665 plugins, 666 tr("Update plugins") 667 ); 668 669 future = service.submit(task2); 670 try { 671 future.get(); 672 } catch(ExecutionException e) { 673 e.printStackTrace(); 674 alertFailedPluginUpdate(parent, plugins); 675 return; 676 } catch(InterruptedException e) { 677 e.printStackTrace(); 678 alertFailedPluginUpdate(parent, plugins); 679 return; 680 } 681 // notify user if downloading a locally installed plugin failed 682 // 683 if (! task2.getFailedPlugins().isEmpty()) { 684 alertFailedPluginUpdate(parent, task2.getFailedPlugins()); 685 return; 686 } 666 687 } 667 688 } finally { … … 744 765 * ".jar" files. 745 766 * 767 * If {@code dowarn} is true, this methods emits warning messages on the console if a downloaded 768 * but not yet installed plugin .jar can't be be installed. If {@code dowarn} is false, the 769 * installation of the respective plugin is sillently skipped. 770 * 771 * @param dowarn if true, warning messages are displayed; false otherwise 746 772 */ 747 773 public static void installDownloadedPlugins(boolean dowarn) { … … 760 786 String pluginName = updatedPlugin.getName().substring(0, updatedPlugin.getName().length() - 8); 761 787 if (plugin.exists()) { 762 if (!plugin.delete() && !dowarn) {788 if (!plugin.delete() && dowarn) { 763 789 System.err.println(tr("Warning: failed to delete outdated plugin ''{0}''.", plugin.toString())); 764 790 System.err.println(tr("Warning: failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.", pluginName)); … … 766 792 } 767 793 } 768 if (!updatedPlugin.renameTo(plugin) && !dowarn) {794 if (!updatedPlugin.renameTo(plugin) && dowarn) { 769 795 System.err.println(tr("Warning: failed to install plugin ''{0}'' from temporary download file ''{1}''. Renaming failed.", plugin.toString(), updatedPlugin.toString())); 770 796 System.err.println(tr("Warning: failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.", pluginName)); -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r3070 r3090 48 48 public String downloadlink = null; 49 49 public List<URL> libraries = new LinkedList<URL>(); 50 51 50 public final Map<String, String> attr = new TreeMap<String, String>(); 52 51 53 52 /** 54 * @param file the plugin jar file. 53 * Creates a plugin information object by reading the plugin information from 54 * the manifest in the plugin jar. 55 * 56 * The plugin name is derived from the file name. 57 * 58 * @param file the plugin jar file 59 * @throws PluginException if reading the manifest fails 55 60 */ 56 61 public PluginInformation(File file) throws PluginException{ … … 58 63 } 59 64 65 /** 66 * Creates a plugin information object for the plugin with name {@code name}. 67 * Information about the plugin is extracted from the maifest file in the the plugin jar 68 * {@code file}. 69 * @param file the plugin jar 70 * @param name the plugin name 71 * @throws PluginException thrown if reading the manifest file fails 72 */ 60 73 public PluginInformation(File file, String name) throws PluginException{ 61 74 this.name = name; … … 80 93 } 81 94 95 /** 96 * Creates a plugin information object by reading plugin information in Manifest format 97 * from the input stream {@code manifestStream}. 98 * 99 * @param manifestStream the stream to read the manifest from 100 * @param name the plugin name 101 * @param url the download URL for the plugin 102 * @throws PluginException thrown if the plugin information can't be read from the input stream 103 */ 82 104 public PluginInformation(InputStream manifestStream, String name, String url) throws PluginException { 83 105 this.name = name; … … 94 116 } 95 117 96 private void scanManifest(Manifest manifest, boolean oldcheck) 97 { 118 /** 119 * Updates the plugin information of this plugin information object with the 120 * plugin information in a plugin information object retrieved from a plugin 121 * update site. 122 * 123 * @param other the plugin information object retrieved from the update 124 * site 125 */ 126 public void updateFromPluginSite(PluginInformation other) { 127 this.mainversion = other.mainversion; 128 this.className = other.className; 129 this.requires = other.requires; 130 this.link = other.link; 131 this.description = other.description; 132 this.early = other.early; 133 this.author = other.author; 134 this.stage = other.stage; 135 this.version = other.version; 136 this.downloadlink = other.downloadlink; 137 this.libraries = other.libraries; 138 this.attr.clear(); 139 this.attr.putAll(other.attr); 140 } 141 142 private void scanManifest(Manifest manifest, boolean oldcheck){ 98 143 String lang = LanguageInfo.getLanguageCodeManifest(); 99 144 Attributes attr = manifest.getMainAttributes();
Note:
See TracChangeset
for help on using the changeset viewer.