Search in sources :

Example 6 with Preferences

use of delta.common.utils.misc.Preferences 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)

Example 7 with Preferences

use of delta.common.utils.misc.Preferences in project lotro-companion by dmorcellet.

the class CharacterPreferencesManager method getUserProperties.

/**
 * Get the preferences for a character.
 * @param toonFile Character file.
 * @param id Identifier of the preferences set.
 * @return Some properties or <code>null</code> if not managed.
 */
public static TypedProperties getUserProperties(CharacterFile toonFile, String id) {
    TypedProperties props = null;
    if (id.startsWith(ItemChoiceWindowController.ITEM_CHOOSER_PROPERTIES_ID)) {
        if (toonFile != null) {
            Preferences prefs = toonFile.getPreferences();
            props = prefs.getPreferences(id);
            List<String> columnIds = props.getStringList(ItemChoiceWindowController.COLUMNS_PROPERTY);
            if (columnIds == null) {
                String slotKey = id.substring(id.indexOf("#") + 1);
                EQUIMENT_SLOT slot = EQUIMENT_SLOT.valueOf(slotKey);
                CharacterClass characterClass = toonFile.getSummary().getCharacterClass();
                ItemChoiceTableColumnsManager mgr = new ItemChoiceTableColumnsManager();
                columnIds = mgr.getItemChoiceColumns(characterClass, slot);
                props.setStringList(ItemChoiceWindowController.COLUMNS_PROPERTY, columnIds);
                prefs.savePreferences(props);
            }
        }
    } else if (ItemChoiceWindowController.ESSENCE_CHOOSER_PROPERTIES_ID.equals(id)) {
        Preferences prefs = toonFile.getPreferences();
        props = prefs.getPreferences(id);
        List<String> columnIds = props.getStringList(ItemChoiceWindowController.COLUMNS_PROPERTY);
        if (columnIds == null) {
            CharacterClass characterClass = toonFile.getSummary().getCharacterClass();
            ItemChoiceTableColumnsManager mgr = new ItemChoiceTableColumnsManager();
            columnIds = mgr.getEssenceChoiceColumns(characterClass);
            props.setStringList(ItemChoiceWindowController.COLUMNS_PROPERTY, columnIds);
            prefs.savePreferences(props);
        }
    }
    return props;
}
Also used : EQUIMENT_SLOT(delta.games.lotro.character.CharacterEquipment.EQUIMENT_SLOT) ItemChoiceTableColumnsManager(delta.games.lotro.gui.items.ItemChoiceTableColumnsManager) List(java.util.List) TypedProperties(delta.common.utils.misc.TypedProperties) Preferences(delta.common.utils.misc.Preferences) CharacterClass(delta.games.lotro.common.CharacterClass)

Example 8 with Preferences

use of delta.common.utils.misc.Preferences in project lotro-companion by dmorcellet.

the class CraftingSynopsisWindowController method dispose.

/**
 * Release all managed resources.
 */
@Override
public void dispose() {
    saveBoundsPreferences();
    super.dispose();
    if (_panelController != null) {
        Preferences preferences = Config.getInstance().getPreferences();
        TypedProperties props = preferences.getPreferences(CRAFTING_PREFERENCES_NAME);
        List<String> toonIds = new ArrayList<String>();
        for (CharacterFile toon : _panelController.getTableController().getToons()) {
            toonIds.add(toon.getIdentifier());
        }
        props.setStringList(TOON_NAME_PREFERENCE, toonIds);
        _panelController.dispose();
        _panelController = 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 9 with Preferences

use of delta.common.utils.misc.Preferences in project lotro-companion by dmorcellet.

the class ReputationSynopsisWindowController method dispose.

/**
 * Release all managed resources.
 */
@Override
public void dispose() {
    saveBoundsPreferences();
    super.dispose();
    if (_panelController != null) {
        Preferences preferences = Config.getInstance().getPreferences();
        TypedProperties props = preferences.getPreferences(REPUTATION_PREFERENCES_NAME);
        List<String> toonIds = new ArrayList<String>();
        for (CharacterFile toon : _panelController.getTableController().getToons()) {
            toonIds.add(toon.getIdentifier());
        }
        props.setStringList(TOON_NAME_PREFERENCE, toonIds);
        _panelController.dispose();
        _panelController = 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 10 with Preferences

use of delta.common.utils.misc.Preferences in project lotro-companion by dmorcellet.

the class MainFrameController method doQuit.

private void doQuit() {
    int result = GuiFactory.showQuestionDialog(getFrame(), "Do you really want to quit?", "Quit?", JOptionPane.YES_NO_OPTION);
    if (result == JOptionPane.OK_OPTION) {
        dispose();
    }
    Preferences preferences = Config.getInstance().getPreferences();
    preferences.saveAllPreferences();
}
Also used : Preferences(delta.common.utils.misc.Preferences) Point(java.awt.Point)

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