Search in sources :

Example 6 with TypedProperties

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;
    }
}
Also used : ArrayList(java.util.ArrayList) Preferences(delta.common.utils.misc.Preferences) TypedProperties(delta.common.utils.misc.TypedProperties) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 7 with TypedProperties

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;
}
Also used : TypedProperties(delta.common.utils.misc.TypedProperties)

Example 8 with TypedProperties

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();
    }
}
Also used : Preferences(delta.common.utils.misc.Preferences) TypedProperties(delta.common.utils.misc.TypedProperties)

Example 9 with TypedProperties

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;
}
Also used : InputStream(java.io.InputStream) TypedProperties(delta.common.utils.misc.TypedProperties) URL(java.net.URL)

Example 10 with TypedProperties

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);
}
Also used : Preferences(delta.common.utils.misc.Preferences) TypedProperties(delta.common.utils.misc.TypedProperties)

Aggregations

TypedProperties (delta.common.utils.misc.TypedProperties)19 Preferences (delta.common.utils.misc.Preferences)9 CharacterFile (delta.games.lotro.character.CharacterFile)4 ArrayList (java.util.ArrayList)4 ItemChoiceWindowController (delta.games.lotro.gui.items.ItemChoiceWindowController)2 Item (delta.games.lotro.lore.items.Item)2 ComboBoxController (delta.common.ui.swing.combobox.ComboBoxController)1 ItemSelectionListener (delta.common.ui.swing.combobox.ItemSelectionListener)1 EQUIMENT_SLOT (delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT)1 CharacterClass (delta.games.lotro.common.CharacterClass)1 Race (delta.games.lotro.common.Race)1 DeedDisplayWindowController (delta.games.lotro.gui.deed.form.DeedDisplayWindowController)1 ItemChoiceTableColumnsManager (delta.games.lotro.gui.items.ItemChoiceTableColumnsManager)1 ItemFilterConfiguration (delta.games.lotro.gui.items.ItemFilterConfiguration)1 ItemFilterController (delta.games.lotro.gui.items.ItemFilterController)1 DeedDescription (delta.games.lotro.lore.deeds.DeedDescription)1 ItemsManager (delta.games.lotro.lore.items.ItemsManager)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1