20 package net.sf.gridarta.updater;
22 import java.awt.Component;
23 import java.util.prefs.Preferences;
24 import javax.swing.Action;
29 import net.
sf.japi.swing.action.ActionBuilder;
30 import net.
sf.japi.swing.action.ActionBuilderFactory;
31 import net.
sf.japi.swing.action.ActionMethod;
32 import org.jetbrains.annotations.NotNull;
44 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
125 final String propUrl = ACTION_BUILDER.getString(
"update.url");
126 hasUpdateURL = propUrl != null && !propUrl.isEmpty();
133 if (!hasUpdateURL || !PREFERENCES.getBoolean(AUTO_CHECK_KEY, AUTO_CHECK_DEFAULT)) {
136 final long timeDifference = UPDATE_TIMES[PREFERENCES.getInt(INTERVAL_KEY, INTERVAL_DEFAULT)];
138 if (System.currentTimeMillis() > lastUpdate + timeDifference) {
149 new Thread(
new Updater(parentComponent, exiter, updateFileName)).start();
151 ACTION_BUILDER.showMessageDialog(parentComponent,
"updateCloseMaps");
156 public void setAction(@NotNull
final Action action, @NotNull
final String name) {
157 action.setEnabled(hasUpdateURL);
static final ActionBuilder ACTION_BUILDER
Action Builder to create Actions.
final MapManager<?, ?, ?> mapManager
The map manager to use.
A MapManager manages all opened maps.
void update()
Perform an update.
final Component parentComponent
The component to show dialogs on.
final boolean hasUpdateURL
Whether an update URL is defined.
static final String LAST_UPDATE_KEY
Preferences key for last update.
This class handles updating the map editor.
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
final Exiter exiter
The Exiter for terminating the application.
static final long [] UPDATE_TIMES
The times for update calculation.
Base package of all Gridarta classes.
static final boolean AUTO_CHECK_DEFAULT
Preferences default value for AUTO_CHECK_KEY.
This class handles updating the map editor.
Interface used as preferences location.
static final String AUTO_CHECK_KEY
Preferences key whether to automatically check for updates.
final String updateFileName
The file to update.
static final String INTERVAL_KEY
Preferences key for selected update interval.
static final int INTERVAL_DEFAULT
Preferences default value for INTERVAL_KEY.
static final Preferences PREFERENCES
Preferences.
UpdaterManager(@NotNull final Exiter exiter, @NotNull final MapManager<?, ?, ?> mapManager, @NotNull final Component parentComponent, @NotNull final String updateFileName)
Creates a new instance.
void startup()
Eventually perform an update during startup.
List< MapControl< G, A, R > > getOpenedMaps()
Returns all opened maps.