use of delta.common.utils.misc.Preferences in project lotro-companion by dmorcellet.
the class FileChooserController method chooseFile.
/**
* Choose a file.
* @param parent Parent component.
* @param approveButtonText Title of the approve button.
* @return A file or <code>null</code> if none chosen.
*/
public File chooseFile(Component parent, String approveButtonText) {
_chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
Preferences preferences = Config.getInstance().getPreferences();
TypedProperties props = preferences.getPreferences(_id);
String dirStr = props.getStringProperty(CURRENT_FILE_PREFERENCE, null);
File currentDir = null;
if (dirStr != null) {
currentDir = new File(dirStr);
}
_chooser.setDialogTitle(_title);
_chooser.setMultiSelectionEnabled(false);
_chooser.setCurrentDirectory(currentDir);
int ok = _chooser.showDialog(parent, approveButtonText);
File chosenFile = null;
if (ok == JFileChooser.APPROVE_OPTION) {
chosenFile = _chooser.getSelectedFile();
currentDir = _chooser.getCurrentDirectory();
if (currentDir != null) {
props.setStringProperty(CURRENT_FILE_PREFERENCE, currentDir.getAbsolutePath());
preferences.savePreferences(props);
}
}
return chosenFile;
}
use of delta.common.utils.misc.Preferences in project lotro-companion by dmorcellet.
the class CharacterLevelWindowController method dispose.
/**
* Release all managed resources.
*/
@Override
public void dispose() {
super.dispose();
List<CharacterFile> toons = _stats.getToonsList();
Preferences preferences = Config.getInstance().getPreferences();
TypedProperties props = preferences.getPreferences(LEVELLING_PREFERENCES_NAME);
List<String> toonIds = new ArrayList<String>();
for (CharacterFile toon : toons) {
toonIds.add(toon.getIdentifier());
}
props.setStringList(TOON_NAME_PREFERENCE, toonIds);
_stats = null;
if (_levellingPanelController != null) {
_levellingPanelController.dispose();
_levellingPanelController = null;
}
}
use of delta.common.utils.misc.Preferences in project lotro-companion by dmorcellet.
the class GlobalPreferences method getGlobalProperties.
/**
* Get properties from the global preferences.
* @param id Identifier of the preferences set.
* @return Some properties or <code>null</code> if not managed.
*/
public static TypedProperties getGlobalProperties(String id) {
Preferences prefs = Config.getInstance().getPreferences();
TypedProperties props = prefs.getPreferences(id);
return props;
}
use of delta.common.utils.misc.Preferences 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.Preferences 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();
}
}
Aggregations