src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleHandler.java
public static boolean checkAndConfirmModuleUpdate(Component parent) {
        String message = null;
        String togglePreferenceKey = null;
        long tim = System.currentTimeMillis();
        long last = Config.getPref().getLong("opendata.modulemanager.lastupdate", 0);
        Integer maxTime = Config.getPref().getInt("opendata.modulemanager.time-based-update.interval", 60);
        long d = (tim - last) / (24 * 60 * 60 * 1000L);
        if ((last <= 0) || (maxTime <= 0)) {
            Config.getPref().put("opendata.modulemanager.lastupdate", Long.toString(tim));
        } else if (d > maxTime) {
            message =
                    "<html>"
                            + tr("Last module update more than {0} days ago.", d)
                            + "</html>";
            togglePreferenceKey = "opendata.modulemanager.time-based-update.policy";
        }
        if (message == null) return false;

        ButtonSpec[] options = new ButtonSpec[] {
                new ButtonSpec(
                        tr("Update modules"),
                        new ImageProvider("dialogs", "refresh"),
                        tr("Click to update the activated modules"),
                        null /* no specific help context */
                        ),
                new ButtonSpec(
                        tr("Skip update"),
                        new ImageProvider("cancel"),
                        tr("Click to skip updating the activated modules"),
                        null /* no specific help context */
                        )
        };

        UpdateModulesMessagePanel pnlMessage = new UpdateModulesMessagePanel();
        pnlMessage.setMessage(message);
        pnlMessage.initDontShowAgain(togglePreferenceKey);

        // check whether automatic update at startup was disabled
        //
        String policy = Config.getPref().get(togglePreferenceKey, "ask");
        policy = policy.trim().toLowerCase();
        if (policy.equals("never")) {
            if ("opendata.modulemanager.time-based-update.policy".equals(togglePreferenceKey)) {
                Logging.info(tr("Skipping module update after elapsed update interval. Automatic update at startup is disabled."));
            }
            return false;
        }

        if (policy.equals("always")) {
            if ("opendata.modulemanager.time-based-update.policy".equals(togglePreferenceKey)) {
                Logging.info(tr("Running module update after elapsed update interval. Automatic update at startup is disabled."));
            }
            return true;
        }

        if (!policy.equals("ask")) {
            Logging.warn(tr("Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''.", policy, togglePreferenceKey));
        }
        int ret = HelpAwareOptionPane.showOptionDialog(
                parent,
                pnlMessage,
                tr("Update modules"),
                JOptionPane.WARNING_MESSAGE,
                null,
                options,
                options[0],
                null
                );

        if (pnlMessage.isRememberDecision()) {
            switch(ret) {
            case 0:
                Config.getPref().put(togglePreferenceKey, "always");
                break;
            case JOptionPane.CLOSED_OPTION:
            case 1:
                Config.getPref().put(togglePreferenceKey, "never");
                break;
            default:
                Logging.trace(Integer.toString(ret));
            }
        } else {
            Config.getPref().put(togglePreferenceKey, "ask");
        }
        return ret == 0;
    }
/**
     * Checks whether the locally available modules should be updated and
     * asks the user if running an update is OK. An update is advised if
     * JOSM was updated to a new version since the last module updates or
     * if the modules were last updated a long time ago.
     *
     * @param parent the parent window relative to which the confirmation dialog
     * is to be displayed
     * @return true if a module update should be run; false, otherwise
     */
Checks whether the locally available modules should be updated and
asks the user if running an update is OK. An update is advised if
JOSM was updated to a new version since the last module updates or
if the modules were last updated a long time ago.

@param parent the parent window relative to which the confirmation dialog
is to be displayed
@return true if a module update should be run; false, otherwise
Checks whether the locally available modules should be updated and asks the user if running an update is OK . An update is advised if JOSM was updated to a new version since the last module updates or if the modules were last updated a long time ago . @param parent the parent window relative to which the confirmation dialog is to be displayed @return true if a module update should be run ; false otherwise
public static boolean checkAndConfirmModuleUpdate(Component parent) {
        String message = null;
        String togglePreferenceKey = null;
        long tim = System.currentTimeMillis();
        long last = Config.getPref().getLong("opendata.modulemanager.lastupdate", 0);
        Integer maxTime = Config.getPref().getInt("opendata.modulemanager.time-based-update.interval", 60);
        long d = (tim - last) / (24 * 60 * 60 * 1000L);
        if ((last <= 0) || (maxTime <= 0)) {
            Config.getPref().put("opendata.modulemanager.lastupdate", Long.toString(tim));
        } else if (d > maxTime) {
            message =
                    "<html>"
                            + tr("Last module update more than {0} days ago.", d)
                            + "</html>";
            togglePreferenceKey = "opendata.modulemanager.time-based-update.policy";
        }
        if (message == null) return false;
        ButtonSpec[] options = new ButtonSpec[] {
                new ButtonSpec(
                        tr("Update modules"),
                        new ImageProvider("dialogs", "refresh"),
                        tr("Click to update the activated modules"),
                        null /* no specific help context */
                        ),
                new ButtonSpec(
                        tr("Skip update"),
                        new ImageProvider("cancel"),
                        tr("Click to skip updating the activated modules"),
                        null /* no specific help context */
                        )
        };
        UpdateModulesMessagePanel pnlMessage = new UpdateModulesMessagePanel();
        pnlMessage.setMessage(message);
        pnlMessage.initDontShowAgain(togglePreferenceKey);
        String policy = Config.getPref().get(togglePreferenceKey, "ask");
        policy = policy.trim().toLowerCase();
        if (policy.equals("never")) {
            if ("opendata.modulemanager.time-based-update.policy".equals(togglePreferenceKey)) {
                Logging.info(tr("Skipping module update after elapsed update interval. Automatic update at startup is disabled."));
            }
            return false;
        }
        if (policy.equals("always")) {
            if ("opendata.modulemanager.time-based-update.policy".equals(togglePreferenceKey)) {
                Logging.info(tr("Running module update after elapsed update interval. Automatic update at startup is disabled."));
            }
            return true;
        }
        if (!policy.equals("ask")) {
            Logging.warn(tr("Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''.", policy, togglePreferenceKey));
        }
        int ret = HelpAwareOptionPane.showOptionDialog(
                parent,
                pnlMessage,
                tr("Update modules"),
                JOptionPane.WARNING_MESSAGE,
                null,
                options,
                options[0],
                null
                );
        if (pnlMessage.isRememberDecision()) {
            switch(ret) {
            case 0:
                Config.getPref().put(togglePreferenceKey, "always");
                break;
            case JOptionPane.CLOSED_OPTION:
            case 1:
                Config.getPref().put(togglePreferenceKey, "never");
                break;
            default:
                Logging.trace(Integer.toString(ret));
            }
        } else {
            Config.getPref().put(togglePreferenceKey, "ask");
        }
        return ret == 0;
    }
public static boolean checkAndConfirmModuleUpdate ( Component parent ) { String message = null ; String togglePreferenceKey = null ; long tim = System . currentTimeMillis ( ) ; long last = Config . getPref ( ) . getLong ( "opendata.modulemanager.lastupdate" , 0 ) ; Integer maxTime = Config . getPref ( ) . getInt ( "opendata.modulemanager.time-based-update.interval" , 60 ) ; long d = ( tim - last ) / ( 24 * 60 * 60 * 1000L ) ; if ( ( last <= 0 ) || ( maxTime <= 0 ) ) { Config . getPref ( ) . put ( "opendata.modulemanager.lastupdate" , Long . toString ( tim ) ) ; } else if ( d > maxTime ) { message = "<html>" + tr ( "Last module update more than {0} days ago." , d ) + "</html>" ; togglePreferenceKey = "opendata.modulemanager.time-based-update.policy" ; } if ( message == null ) return false ; ButtonSpec [ ] options = new ButtonSpec [ ] { new ButtonSpec ( tr ( "Update modules" ) , new ImageProvider ( "dialogs" , "refresh" ) , tr ( "Click to update the activated modules" ) , null /* no specific help context */ ) , new ButtonSpec ( tr ( "Skip update" ) , new ImageProvider ( "cancel" ) , tr ( "Click to skip updating the activated modules" ) , null /* no specific help context */ ) } ; UpdateModulesMessagePanel pnlMessage = new UpdateModulesMessagePanel ( ) ; pnlMessage . setMessage ( message ) ; pnlMessage . initDontShowAgain ( togglePreferenceKey ) ; String policy = Config . getPref ( ) . get ( togglePreferenceKey , "ask" ) ; policy = policy . trim ( ) . toLowerCase ( ) ; if ( policy . equals ( "never" ) ) { if ( "opendata.modulemanager.time-based-update.policy" . equals ( togglePreferenceKey ) ) { Logging . info ( tr ( "Skipping module update after elapsed update interval. Automatic update at startup is disabled." ) ) ; } return false ; } if ( policy . equals ( "always" ) ) { if ( "opendata.modulemanager.time-based-update.policy" . equals ( togglePreferenceKey ) ) { Logging . info ( tr ( "Running module update after elapsed update interval. Automatic update at startup is disabled." ) ) ; } return true ; } if ( ! policy . equals ( "ask" ) ) { Logging . warn ( tr ( "Unexpected value ''{0}'' for preference ''{1}''. Assuming value ''ask''." , policy , togglePreferenceKey ) ) ; } int ret = HelpAwareOptionPane . showOptionDialog ( parent , pnlMessage , tr ( "Update modules" ) , JOptionPane . WARNING_MESSAGE , null , options , options [ 0 ] , null ) ; if ( pnlMessage . isRememberDecision ( ) ) { switch ( ret ) { case 0 : Config . getPref ( ) . put ( togglePreferenceKey , "always" ) ; break ; case JOptionPane . CLOSED_OPTION : case 1 : Config . getPref ( ) . put ( togglePreferenceKey , "never" ) ; break ; default : Logging . trace ( Integer . toString ( ret ) ) ; } } else { Config . getPref ( ) . put ( togglePreferenceKey , "ask" ) ; } return ret == 0 ; }
Checks whether the locally available modules should be updated and
 asks the user if running an update is OK. An update is advised if
 JOSM was updated to a new version since the last module updates or
 if the modules were last updated a long time ago.
Checks whether the locally available modules should be updated and asks the user if running an update is OK . An update is advised if JOSM was updated to a new version since the last module updates or if the modules were last updated a long time ago .
// check whether automatic update at startup was disabled
 //
