Search in sources :

Example 1 with Preferences

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

Example 2 with Preferences

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;
    }
}
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 3 with Preferences

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

Example 4 with Preferences

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;
    }
}
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 5 with Preferences

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

Aggregations

Preferences (delta.common.utils.misc.Preferences)10 TypedProperties (delta.common.utils.misc.TypedProperties)9 CharacterFile (delta.games.lotro.character.CharacterFile)4 ArrayList (java.util.ArrayList)4 EQUIMENT_SLOT (delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT)1 CharacterClass (delta.games.lotro.common.CharacterClass)1 ItemChoiceTableColumnsManager (delta.games.lotro.gui.items.ItemChoiceTableColumnsManager)1 Point (java.awt.Point)1 File (java.io.File)1 List (java.util.List)1