Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r8506 r8510 121 121 } 122 122 byte[] buffer = new byte[8192]; 123 for (int len = in.read(buffer); len > 0; len = in.read(buffer)) {123 for (int len = in.read(buffer); len > 0; len = in.read(buffer)) { 124 124 out.write(buffer, 0, len); 125 125 } -
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
r8443 r8510 71 71 */ 72 72 public PluginDownloadTask(ProgressMonitor monitor, Collection<PluginInformation> toUpdate, String title) { 73 super(title, monitor == null ? NullProgressMonitor.INSTANCE: monitor, false /* don't ignore exceptions */);73 super(title, monitor == null ? NullProgressMonitor.INSTANCE : monitor, false /* don't ignore exceptions */); 74 74 CheckParameterUtil.ensureParameterNotNull(toUpdate, "toUpdate"); 75 75 this.toUpdate.addAll(toUpdate); … … 91 91 protected void cancel() { 92 92 this.canceled = true; 93 synchronized (this) {93 synchronized (this) { 94 94 if (downloadConnection != null) { 95 95 downloadConnection.disconnect(); … … 101 101 protected void finish() {} 102 102 103 protected void download(PluginInformation pi, File file) throws PluginDownloadException {103 protected void download(PluginInformation pi, File file) throws PluginDownloadException { 104 104 if (pi.mainversion > Version.getInstance().getVersion()) { 105 105 ExtendedDialog dialog = new ExtendedDialog( … … 124 124 } 125 125 URL url = new URL(pi.downloadlink); 126 synchronized (this) {126 synchronized (this) { 127 127 downloadConnection = CachedFile.connectFollowingRedirect(url, PLUGIN_MIME_TYPES, null); 128 128 } … … 146 146 throw new PluginDownloadException(e); 147 147 } finally { 148 synchronized (this) {148 synchronized (this) { 149 149 downloadConnection = null; 150 150 } … … 168 168 try { 169 169 download(d, pluginFile); 170 } catch (PluginDownloadException e) {170 } catch (PluginDownloadException e) { 171 171 Main.error(e); 172 172 failed.add(d); -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r8509 r8510 100 100 new DeprecatedPlugin("tways-0.2", IN_CORE), 101 101 new DeprecatedPlugin("geotagged", IN_CORE), 102 new DeprecatedPlugin("landsat", tr("replaced by new {0} plugin", "lakewalker")),102 new DeprecatedPlugin("landsat", tr("replaced by new {0} plugin", "lakewalker")), 103 103 new DeprecatedPlugin("namefinder", IN_CORE), 104 104 new DeprecatedPlugin("waypoints", IN_CORE), 105 105 new DeprecatedPlugin("slippy_map_chooser", IN_CORE), 106 new DeprecatedPlugin("tcx-support", tr("replaced by new {0} plugin", "dataimport")),106 new DeprecatedPlugin("tcx-support", tr("replaced by new {0} plugin", "dataimport")), 107 107 new DeprecatedPlugin("usertools", IN_CORE), 108 108 new DeprecatedPlugin("AgPifoJ", IN_CORE), … … 117 117 new DeprecatedPlugin("wmsplugin", IN_CORE), 118 118 new DeprecatedPlugin("ParallelWay", IN_CORE), 119 new DeprecatedPlugin("dumbutils", tr("replaced by new {0} plugin", "utilsplugin2")),119 new DeprecatedPlugin("dumbutils", tr("replaced by new {0} plugin", "utilsplugin2")), 120 120 new DeprecatedPlugin("ImproveWayAccuracy", IN_CORE), 121 new DeprecatedPlugin("Curves", tr("replaced by new {0} plugin", "utilsplugin2")),121 new DeprecatedPlugin("Curves", tr("replaced by new {0} plugin", "utilsplugin2")), 122 122 new DeprecatedPlugin("epsg31287", tr("replaced by new {0} plugin", "proj4j")), 123 123 new DeprecatedPlugin("licensechange", tr("no longer required")), … … 241 241 */ 242 242 private static final List<ClassLoader> sources = new LinkedList<>(); 243 244 243 static { 245 244 try { … … 321 320 + "<br>This plugin is no longer developed and very likely will produce errors." 322 321 +"<br>It should be disabled.<br>Delete from preferences?</html>", unmaintained); 323 if (confirmDisablePlugin(parent, msg, unmaintained)) {322 if (confirmDisablePlugin(parent, msg, unmaintained)) { 324 323 Main.pref.removeFromCollection("plugins", unmaintained); 325 324 plugins.remove(unmaintained); … … 818 817 try { 819 818 future.get(); 820 } catch (ExecutionException e) {819 } catch (ExecutionException e) { 821 820 Main.error(e); 822 821 return null; 823 } catch (InterruptedException e) {822 } catch (InterruptedException e) { 824 823 Main.warn("InterruptedException in "+PluginHandler.class.getSimpleName()+" while loading locally available plugin information"); 825 824 return null; … … 879 878 monitor.subTask(tr("Removing unmaintained plugins...")); 880 879 filterUnmaintainedPlugins(parent, plugins); 881 Map<String, PluginInformation> infos = loadLocallyAvailablePluginInformation(monitor.createSubTaskMonitor(1, false));880 Map<String, PluginInformation> infos = loadLocallyAvailablePluginInformation(monitor.createSubTaskMonitor(1, false)); 882 881 List<PluginInformation> ret = new LinkedList<>(); 883 882 for (Iterator<String> it = plugins.iterator(); it.hasNext();) { … … 1042 1041 // 1043 1042 pluginDownloadTask = new PluginDownloadTask( 1044 monitor.createSubTaskMonitor(1, false),1043 monitor.createSubTaskMonitor(1, false), 1045 1044 pluginsToDownload, 1046 1045 tr("Update plugins") … … 1050 1049 try { 1051 1050 future.get(); 1052 } catch (ExecutionException e) {1051 } catch (ExecutionException e) { 1053 1052 Main.error(e); 1054 1053 alertFailedPluginUpdate(parent, pluginsToUpdate); 1055 1054 return plugins; 1056 } catch (InterruptedException e) {1055 } catch (InterruptedException e) { 1057 1056 Main.warn("InterruptedException in "+PluginHandler.class.getSimpleName()+" while updating plugins"); 1058 1057 alertFailedPluginUpdate(parent, pluginsToUpdate); … … 1174 1173 if (plugin.exists() && !plugin.delete() && dowarn) { 1175 1174 Main.warn(tr("Failed to delete outdated plugin ''{0}''.", plugin.toString())); 1176 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.", 1175 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. " + 1176 "Skipping installation. JOSM is still going to load the old plugin version.", 1177 1177 pluginName)); 1178 1178 continue; … … 1192 1192 Main.warn(tr("Failed to install plugin ''{0}'' from temporary download file ''{1}''. Renaming failed.", 1193 1193 plugin.toString(), updatedPlugin.toString())); 1194 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. Skipping installation. JOSM is still going to load the old plugin version.", 1194 Main.warn(tr("Failed to install already downloaded plugin ''{0}''. " + 1195 "Skipping installation. JOSM is still going to load the old plugin version.", 1195 1196 pluginName)); 1196 1197 } … … 1250 1251 try { 1251 1252 pi.updateFromJar(new PluginInformation(downloadedPluginFile, pi.name)); 1252 } catch (PluginException e) {1253 } catch (PluginException e) { 1253 1254 Main.error(e); 1254 1255 } … … 1273 1274 tr("Keep plugin"), 1274 1275 ImageProvider.get("cancel"), 1275 tr("Click to keep the plugin ''{0}''", plugin.getPluginInformation().name),1276 tr("Click to keep the plugin ''{0}''", plugin.getPluginInformation().name), 1276 1277 null /* no specific help context */ 1277 1278 ) … … 1358 1359 1359 1360 Set<String> plugins = new HashSet<>( 1360 Main.pref.getCollection("plugins", Collections.<String>emptySet())1361 Main.pref.getCollection("plugins", Collections.<String>emptySet()) 1361 1362 ); 1362 1363 final PluginInformation pluginInfo = plugin.getPluginInformation(); … … 1473 1474 gc.weightx = 1.0; 1474 1475 gc.weighty = 1.0; 1475 gc.insets = new Insets(5, 5,5,5);1476 gc.insets = new Insets(5, 5, 5, 5); 1476 1477 add(lblMessage = new JMultilineLabel(""), gc); 1477 1478 lblMessage.setFont(lblMessage.getFont().deriveFont(Font.PLAIN)); -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r8470 r8510 97 97 * @throws PluginException if reading the manifest fails 98 98 */ 99 public PluginInformation(File file) throws PluginException {99 public PluginInformation(File file) throws PluginException { 100 100 this(file, file.getName().substring(0, file.getName().length()-4)); 101 101 } … … 143 143 Manifest manifest = new Manifest(); 144 144 manifest.read(manifestStream); 145 if (url != null) {145 if (url != null) { 146 146 downloadlink = url; 147 147 } … … 238 238 try { 239 239 mainversion = Integer.parseInt(s); 240 } catch (NumberFormatException e) {240 } catch (NumberFormatException e) { 241 241 Main.warn(tr("Invalid plugin main version ''{0}'' in plugin {1}", s, name)); 242 242 } … … 259 259 for (Map.Entry<Object, Object> entry : attr.entrySet()) { 260 260 try { 261 String key = ((Attributes.Name) entry.getKey()).toString();261 String key = ((Attributes.Name) entry.getKey()).toString(); 262 262 if (key.endsWith("_Plugin-Url")) { 263 int mv = Integer.parseInt(key.substring(0, key.length()-11));263 int mv = Integer.parseInt(key.substring(0, key.length()-11)); 264 264 if (mv <= myv && (mv > mainversion || mainversion > myv)) { 265 String v = (String) entry.getValue();265 String v = (String) entry.getValue(); 266 266 int i = v.indexOf(';'); 267 267 if (i > 0) { 268 268 downloadlink = v.substring(i+1); 269 269 mainversion = mv; 270 version = v.substring(0, i);270 version = v.substring(0, i); 271 271 oldmode = true; 272 272 } 273 273 } 274 274 } 275 } catch (Exception e) {275 } catch (Exception e) { 276 276 Main.error(e); 277 277 } … … 333 333 Object plugin = c.newInstance(this); 334 334 return new PluginProxy(plugin, this); 335 } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {335 } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { 336 336 throw new PluginException(name, e); 337 337 } … … 436 436 public boolean isUpdateRequired(String referenceVersion) { 437 437 if (this.downloadlink == null) return false; 438 if (this.version == null && referenceVersion != null)438 if (this.version == null && referenceVersion != null) 439 439 return true; 440 440 if (this.version != null && !this.version.equals(referenceVersion)) -
trunk/src/org/openstreetmap/josm/plugins/PluginListParser.java
r8470 r8510 34 34 * @throws PluginListParseException if plugin manifest cannot be parsed 35 35 */ 36 protected static PluginInformation createInfo(String name, String url, String manifest) throws PluginListParseException {36 protected static PluginInformation createInfo(String name, String url, String manifest) throws PluginListParseException { 37 37 try { 38 38 return new PluginInformation( … … 57 57 * @throws PluginListParseException if something goes wrong while parsing 58 58 */ 59 public List<PluginInformation> parse(InputStream in) throws PluginListParseException {59 public List<PluginInformation> parse(InputStream in) throws PluginListParseException { 60 60 List<PluginInformation> ret = new LinkedList<>(); 61 61 BufferedReader r = null; … … 77 77 addPluginInformation(ret, name, url, manifest.toString()); 78 78 String[] x = line.split(";"); 79 if (x.length != 2)79 if (x.length != 2) 80 80 throw new IOException(tr("Illegal entry in plugin list.")); 81 81 name = x[0]; -
trunk/src/org/openstreetmap/josm/plugins/PluginProxy.java
r6380 r8510 38 38 @Override public PreferenceSetting getPreferenceSetting() { 39 39 try { 40 return (PreferenceSetting) plugin.getClass().getMethod("getPreferenceSetting").invoke(plugin);40 return (PreferenceSetting) plugin.getClass().getMethod("getPreferenceSetting").invoke(plugin); 41 41 } catch (NoSuchMethodException e) { 42 42 Main.debug("Plugin "+plugin+" does not define getPreferenceSetting"); -
trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
r8030 r8510 47 47 48 48 public ReadLocalPluginInformationTask(ProgressMonitor monitor) { 49 super(tr("Reading local plugin information.."), monitor, false);49 super(tr("Reading local plugin information.."), monitor, false); 50 50 availablePlugins = new HashMap<>(); 51 51 } … … 59 59 protected void finish() {} 60 60 61 protected void processJarFile(File f, String pluginName) throws PluginException {61 protected void processJarFile(File f, String pluginName) throws PluginException { 62 62 PluginInformation info = new PluginInformation( 63 63 f, … … 95 95 try { 96 96 processLocalPluginInformationFile(f); 97 } catch (PluginListParseException e) {97 } catch (PluginListParseException e) { 98 98 Main.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname)); 99 99 Main.error(e); … … 127 127 processJarFile(f, pluginName); 128 128 } 129 } catch (PluginException e) {129 } catch (PluginException e) { 130 130 Main.warn("PluginException: "+e.getMessage()); 131 131 Main.warn(tr("Failed to scan file ''{0}'' for plugin information. Skipping.", fname)); … … 147 147 } 148 148 149 protected void processLocalPluginInformationFile(File file) throws PluginListParseException {149 protected void processLocalPluginInformationFile(File file) throws PluginListParseException { 150 150 try (FileInputStream fin = new FileInputStream(file)) { 151 151 List<PluginInformation> pis = new PluginListParser().parse(fin); … … 157 157 availablePlugins.put(pi.name, pi); 158 158 } 159 } catch (IOException e) {159 } catch (IOException e) { 160 160 throw new PluginListParseException(e); 161 161 } … … 165 165 for (PluginProxy proxy : PluginHandler.pluginList) { 166 166 PluginInformation info = proxy.getPluginInformation(); 167 if (canceled) return;167 if (canceled) return; 168 168 if (!availablePlugins.containsKey(info.name)) { 169 169 availablePlugins.put(info.name, info); … … 176 176 protected void filterOldPlugins() { 177 177 for (PluginHandler.DeprecatedPlugin p : PluginHandler.DEPRECATED_PLUGINS) { 178 if (canceled) return;178 if (canceled) return; 179 179 if (availablePlugins.containsKey(p.name)) { 180 180 availablePlugins.remove(p.name); … … 194 194 ); 195 195 getProgressMonitor().worked(1); 196 if (canceled) return;196 if (canceled) return; 197 197 } 198 198 analyseInProcessPlugins(); 199 199 getProgressMonitor().worked(1); 200 if (canceled) return;200 if (canceled) return; 201 201 filterOldPlugins(); 202 202 getProgressMonitor().worked(1); -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r8509 r8510 84 84 */ 85 85 public ReadRemotePluginInformationTask(ProgressMonitor monitor, Collection<String> sites, boolean displayErrMsg) { 86 super(tr("Download plugin list..."), monitor == null ? NullProgressMonitor.INSTANCE : monitor, false /* don't ignore exceptions */);86 super(tr("Download plugin list..."), monitor == null ? NullProgressMonitor.INSTANCE : monitor, false /* don't ignore exceptions */); 87 87 init(sites, displayErrMsg); 88 88 } … … 91 91 protected void cancel() { 92 92 canceled = true; 93 synchronized (this) {93 synchronized (this) { 94 94 if (connection != null) { 95 95 connection.disconnect(); … … 120 120 } 121 121 String path = url.getPath(); 122 for (int i = 0;i<path.length(); i++) {122 for (int i = 0; i < path.length(); i++) { 123 123 char c = path.charAt(i); 124 124 if (Character.isLetterOrDigit(c)) { … … 130 130 sb.append(".txt"); 131 131 name = sb.toString(); 132 } catch (MalformedURLException e) {132 } catch (MalformedURLException e) { 133 133 name = "site-unknown.txt"; 134 134 } … … 158 158 159 159 URL url = new URL(site); 160 synchronized (this) {160 synchronized (this) { 161 161 connection = Utils.openHttpConnection(url); 162 162 connection.setRequestProperty("Cache-Control", "no-cache"); … … 181 181 return null; 182 182 } finally { 183 synchronized (this) {183 synchronized (this) { 184 184 if (connection != null) { 185 185 connection.disconnect(); … … 264 264 writer.write(list); 265 265 writer.flush(); 266 } catch (IOException e) {266 } catch (IOException e) { 267 267 // just failed to write the cache file. No big deal, but log the exception anyway 268 268 Main.error(e); … … 328 328 } 329 329 ); 330 if (f != null && f.length > 0) {330 if (f != null && f.length > 0) { 331 331 siteCacheFiles.addAll(Arrays.asList(f)); 332 332 }
Note:
See TracChangeset
for help on using the changeset viewer.