- Timestamp:
- 2018-10-29T22:24:29+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginCheckBox.java
r11848 r14384 63 63 if (!p.equals(pi) && p.requires != null && ppModel.isSelectedPlugin(p.getName())) { 64 64 for (String s : p.getRequiredPlugins()) { 65 if (s.equals(pi.getName()) ) {65 if (s.equals(pi.getName()) || s.equals(pi.provides)) { 66 66 otherPlugins.add(p.getName()); 67 67 break; -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferencesModel.java
r13802 r14384 237 237 */ 238 238 public PluginInformation getPluginInformation(String name) { 239 for (PluginInformation pi: availablePlugins) { 240 if (pi.getName() != null && pi.getName().equals(name)) 241 return pi; 239 if (name != null) { 240 for (PluginInformation pi: availablePlugins) { 241 if (name.equals(pi.getName()) || name.equals(pi.provides)) 242 return pi; 243 } 242 244 } 243 245 return null; -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r14327 r14384 607 607 } 608 608 609 private static void logWrongPlatform(String plugin, String pluginPlatform) { 610 Logging.warn( 611 tr("Plugin {0} must be run on a {1} platform.", 612 plugin, pluginPlatform 613 )); 614 } 615 609 616 private static void logJavaUpdateRequired(String plugin, int requiredVersion) { 610 617 Logging.warn( … … 640 647 public static boolean checkLoadPreconditions(Component parent, Collection<PluginInformation> plugins, PluginInformation plugin) { 641 648 649 // make sure the plugin is not meant for another platform 650 if (!plugin.isForCurrentPlatform()) { 651 // Just log a warning, this is unlikely to happen as we display only relevant plugins in HMI 652 logWrongPlatform(plugin.name, plugin.platform); 653 return false; 654 } 655 642 656 // make sure the plugin is compatible with the current Java version 643 657 if (plugin.localminjavaversion > Utils.getJavaVersion()) { 644 // Just log a warning until we switch to Java 11 so that openjfx plugin does not trigger a popup658 // Just log a warning until we switch to Java 11 so that javafx plugin does not trigger a popup 645 659 logJavaUpdateRequired(plugin.name, plugin.localminjavaversion); 646 660 return false; … … 686 700 for (PluginInformation pi: plugins) { 687 701 pluginNames.add(pi.name); 702 if (pi.provides != null) { 703 pluginNames.add(pi.provides); 704 } 688 705 } 689 706 Set<String> missingPlugins = new HashSet<>(); -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r14378 r14384 31 31 import org.openstreetmap.josm.tools.LanguageInfo; 32 32 import org.openstreetmap.josm.tools.Logging; 33 import org.openstreetmap.josm.tools.Platform; 34 import org.openstreetmap.josm.tools.PlatformManager; 33 35 import org.openstreetmap.josm.tools.Utils; 34 36 … … 62 64 /** The list of required plugins, separated by ';' (from locally available jar). */ 63 65 public String localrequires; 66 /** The plugin platform on which it is meant to run (windows, osx, unixoid). */ 67 public String platform; 68 /** The virtual plugin provided by this plugin, if native for a given platform. */ 69 public String provides; 64 70 /** The plugin link (for documentation). */ 65 71 public String link; … … 169 175 this.className = other.className; 170 176 this.requires = other.requires; 177 this.provides = other.provides; 178 this.platform = other.platform; 171 179 this.link = other.link; 172 180 this.description = other.description; … … 216 224 } 217 225 link = s; 226 platform = attr.getValue("Plugin-Platform"); 227 provides = attr.getValue("Plugin-Provides"); 218 228 requires = attr.getValue("Plugin-Requires"); 219 229 s = attr.getValue(lang+"Plugin-Description"); … … 422 432 Collection<String> locations = getPluginLocations(); 423 433 434 String[] nameCandidates = new String[] { 435 pluginName, 436 pluginName + "-" + PlatformManager.getPlatform().getPlatform().name().toLowerCase(Locale.ENGLISH)}; 424 437 for (String s : locations) { 425 File pluginFile = new File(s, pluginName + ".jar"); 426 if (pluginFile.exists()) { 427 return new PluginInformation(pluginFile); 438 for (String nameCandidate: nameCandidates) { 439 File pluginFile = new File(s, nameCandidate + ".jar"); 440 if (pluginFile.exists()) { 441 return new PluginInformation(pluginFile); 442 } 428 443 } 429 444 } … … 579 594 } 580 595 } 596 597 /** 598 * Determines if this plugin can be run on the current platform. 599 * @return {@code true} if this plugin can be run on the current platform 600 * @since 14384 601 */ 602 public boolean isForCurrentPlatform() { 603 try { 604 return platform == null || PlatformManager.getPlatform().getPlatform() == Platform.valueOf(platform.toUpperCase(Locale.ENGLISH)); 605 } catch (IllegalArgumentException e) { 606 Logging.warn(e); 607 return true; 608 } 609 } 581 610 } -
trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java
r13647 r14384 190 190 } 191 191 192 protected void filterIrrelevantPlugins() { 193 availablePlugins.entrySet().removeIf(e -> !e.getValue().isForCurrentPlatform()); 194 } 195 192 196 @Override 193 197 protected void realRun() throws SAXException, IOException, OsmTransferException { … … 207 211 if (canceled) return; 208 212 filterOldPlugins(); 213 filterIrrelevantPlugins(); 209 214 getProgressMonitor().worked(1); 210 215 } -
trunk/src/org/openstreetmap/josm/plugins/ReadRemotePluginInformationTask.java
r14149 r14384 25 25 import java.util.Optional; 26 26 import java.util.Set; 27 import java.util.stream.Collectors; 27 28 28 29 import javax.swing.JLabel; … … 283 284 } 284 285 286 protected List<PluginInformation> filterIrrelevantPlugins(List<PluginInformation> plugins) { 287 return plugins.stream().filter(PluginInformation::isForCurrentPlatform).collect(Collectors.toList()); 288 } 289 285 290 /** 286 291 * Parses the plugin list … … 294 299 InputStream in = new ByteArrayInputStream(doc.getBytes(StandardCharsets.UTF_8)); 295 300 List<PluginInformation> pis = new PluginListParser().parse(in); 296 availablePlugins.addAll(filter DeprecatedPlugins(pis));301 availablePlugins.addAll(filterIrrelevantPlugins(filterDeprecatedPlugins(pis))); 297 302 } catch (PluginListParseException e) { 298 303 Logging.error(tr("Failed to parse plugin list document from site ''{0}''. Skipping site. Exception was: {1}", site, e.toString()));
Note:
See TracChangeset
for help on using the changeset viewer.