Changeset 14186 in josm


Ignore:
Timestamp:
2018-08-27T20:12:16+02:00 (4 weeks ago)
Author:
Don-vip
Message:

see #16682 - add new plugin property Minimum-Java-Version

Location:
trunk/src/org/openstreetmap/josm/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r14153 r14186  
    636636    }
    637637
     638    private static void logJavaUpdateRequired(String plugin, int requiredVersion) {
     639        Logging.warn(
     640                tr("Plugin {0} requires Java version {1}. The current Java version is {2}. "
     641                        +"You have to update Java in order to use this plugin.",
     642                        plugin, Integer.toString(requiredVersion), Utils.getJavaVersion()
     643                ));
     644    }
     645
    638646    private static void alertJOSMUpdateRequired(Component parent, String plugin, int requiredVersion) {
    639647        HelpAwareOptionPane.showOptionDialog(
     
    651659    /**
    652660     * Checks whether all preconditions for loading the plugin <code>plugin</code> are met. The
    653      * current JOSM version must be compatible with the plugin and no other plugins this plugin
     661     * current Java and JOSM versions must be compatible with the plugin and no other plugins this plugin
    654662     * depends on should be missing.
    655663     *
     
    661669    public static boolean checkLoadPreconditions(Component parent, Collection<PluginInformation> plugins, PluginInformation plugin) {
    662670
     671        // make sure the plugin is compatible with the current Java version
     672        if (plugin.localminjavaversion > Utils.getJavaVersion()) {
     673            // Just log a warning until we switch to Java 11 so that openjfx plugin does not trigger a popup
     674            logJavaUpdateRequired(plugin.name, plugin.localminjavaversion);
     675            return false;
     676        }
     677
    663678        // make sure the plugin is compatible with the current JOSM version
    664         //
    665679        int josmVersion = Version.getInstance().getVersion();
    666680        if (plugin.localmainversion > josmVersion && josmVersion != Version.JOSM_UNKNOWN_VERSION) {
  • trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java

    r14160 r14186  
    5050    /** The lowest JOSM version required by this plugin (from locally available jar). **/
    5151    public int localmainversion;
     52    /** The lowest Java version required by this plugin (from plugin list). **/
     53    public int minjavaversion;
     54    /** The lowest Java version required by this plugin (from locally available jar). **/
     55    public int localminjavaversion;
    5256    /** The plugin class name. */
    5357    public String className;
     
    162166    public void updateFromPluginSite(PluginInformation other) {
    163167        this.mainversion = other.mainversion;
     168        this.minjavaversion = other.minjavaversion;
    164169        this.className = other.className;
    165170        this.requires = other.requires;
     
    237242            } catch (NumberFormatException e) {
    238243                Logging.warn(tr("Invalid plugin main version ''{0}'' in plugin {1}", s, name));
     244                Logging.trace(e);
    239245            }
    240246        } else {
    241247            Logging.warn(tr("Missing plugin main version in plugin {0}", name));
     248        }
     249        s = attr.getValue("Minimum-Java-Version");
     250        if (s != null) {
     251            try {
     252                minjavaversion = Integer.parseInt(s);
     253            } catch (NumberFormatException e) {
     254                Logging.warn(tr("Invalid Java version ''{0}'' in plugin {1}", s, name));
     255                Logging.trace(e);
     256            }
    242257        }
    243258        author = attr.getValue("Author");
     
    543558
    544559    /**
    545      * Updates the local fields ({@link #localversion}, {@link #localmainversion}, {@link #localrequires})
    546      * to values contained in the up-to-date fields ({@link #version}, {@link #mainversion}, {@link #requires})
     560     * Updates the local fields
     561     * ({@link #localversion}, {@link #localmainversion}, {@link #localminjavaversion}, {@link #localrequires})
     562     * to values contained in the up-to-date fields
     563     * ({@link #version}, {@link #mainversion}, {@link #minjavaversion}, {@link #requires})
    547564     * of the given PluginInformation.
    548565     * @param info The plugin information to get the data from.
     
    553570            this.localversion = info.version;
    554571            this.localmainversion = info.mainversion;
     572            this.localminjavaversion = info.minjavaversion;
    555573            this.localrequires = info.requires;
    556574        }
Note: See TracChangeset for help on using the changeset viewer.