use of delta.common.utils.misc.TypedProperties in project lotro-companion by dmorcellet.
the class WarbandsWindowController method dispose.
/**
* Release all managed resources.
*/
@Override
public void dispose() {
saveBoundsPreferences();
super.dispose();
if (_warbandsStatisticsPanelController != null) {
Preferences preferences = Config.getInstance().getPreferences();
TypedProperties props = preferences.getPreferences(WARBANDS_PREFERENCES_NAME);
List<String> toonIds = new ArrayList<String>();
for (CharacterFile toon : _warbandsStatisticsPanelController.getTableController().getToons()) {
toonIds.add(toon.getIdentifier());
}
props.setStringList(TOON_NAME_PREFERENCE, toonIds);
_warbandsStatisticsPanelController.dispose();
_warbandsStatisticsPanelController = null;
}
}
use of delta.common.utils.misc.TypedProperties in project lotro-companion by dmorcellet.
the class UpdatesChecker method loadRemoteVersion.
private Version loadRemoteVersion() {
Version ret = null;
TypedProperties props = loadRemoteProperties();
if (props != null) {
ret = loadVersionFromProps(props);
}
return ret;
}
use of delta.common.utils.misc.TypedProperties in project lotro-companion by dmorcellet.
the class UpdatesChecker method check.
/**
* Check for updates process.
*/
public void check() {
// Load the timestamp of the last update
Preferences preferences = Config.getInstance().getPreferences();
TypedProperties props = preferences.getPreferences(UPDATES_PREFERENCES_NAME);
long last = props.getLongProperty(LAST_UPDATE_CHECK_PROPERTY_NAME, 0);
// Load the check period
TypedProperties conf = Config.getInstance().getParameters();
int period = conf.getIntProperty("update.check.period", 24);
// Compute if a new check is necessary
long nextCheckTimeStamp = last + period * 3600 * 1000;
long now = System.currentTimeMillis();
if (now > nextCheckTimeStamp) {
Runnable r = new Runnable() {
@Override
public void run() {
doCheck();
}
};
Thread t = new Thread(r, "Update check");
t.setDaemon(true);
t.start();
}
}
use of delta.common.utils.misc.TypedProperties in project lotro-companion by dmorcellet.
the class UpdatesChecker method loadRemoteProperties.
private TypedProperties loadRemoteProperties() {
TypedProperties ret = null;
TypedProperties conf = Config.getInstance().getParameters();
String urlStr = conf.getStringProperty("update.check.url", null);
if (urlStr != null) {
try {
URL url = new URL(urlStr);
InputStream is = url.openStream();
TypedProperties props = new TypedProperties();
boolean ok = props.loadFromInputStream(is);
if (ok) {
ret = props;
}
} catch (Exception e) {
_logger.error("Updates checker error", e);
}
}
return ret;
}
use of delta.common.utils.misc.TypedProperties in project lotro-companion by dmorcellet.
the class UpdatesChecker method doCheck.
private void doCheck() {
Version current = loadCurrentVersion();
Version remote = loadRemoteVersion();
if ((current != null) && (remote != null)) {
int remoteId = remote.getId();
int currentId = current.getId();
if (remoteId > currentId) {
_logger.info("New version available: " + remote);
_logger.info("Old version: " + current);
showInfoWindow(current, remote);
}
}
// Update the timestamp of the check for updates
long now = System.currentTimeMillis();
Preferences preferences = Config.getInstance().getPreferences();
TypedProperties props = preferences.getPreferences(UPDATES_PREFERENCES_NAME);
props.setLongProperty(LAST_UPDATE_CHECK_PROPERTY_NAME, now);
preferences.savePreferences(props);
}
Aggregations