Search in sources :

Example 31 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class ReputationSynopsisTableController method buildCharacterColumn.

private TableColumnController<Faction, FactionStatus> buildCharacterColumn(CharacterFile character) {
    final CharacterFile toon = character;
    CellDataProvider<Faction, FactionStatus> cell = new CellDataProvider<Faction, FactionStatus>() {

        @Override
        public FactionStatus getData(Faction item) {
            ReputationStatus status = toon.getReputation();
            return status.getOrCreateFactionStat(item);
        }
    };
    String id = character.getIdentifier();
    TableColumnController<Faction, FactionStatus> column = new TableColumnController<Faction, FactionStatus>(id, "Faction", FactionStatus.class, cell);
    // Cell renderer
    TableCellRenderer renderer = buildFactionStatusCellRenderer();
    column.setCellRenderer(renderer);
    // Header renderer
    JPanel headerPanel = buildToonHeaderPanel(character);
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(headerPanel);
    column.setHeaderCellRenderer(headerRenderer);
    int minWidth = headerPanel.getPreferredSize().width;
    column.setMinWidth(minWidth);
    column.setPreferredWidth(minWidth);
    // Comparator
    final FactionLevelComparator factionLevelComparator = new FactionLevelComparator();
    Comparator<FactionStatus> statsComparator = new Comparator<FactionStatus>() {

        @Override
        public int compare(FactionStatus data1, FactionStatus data2) {
            return factionLevelComparator.compare(data1.getFactionLevel(), data2.getFactionLevel());
        }
    };
    column.setComparator(statsComparator);
    return column;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) JPanel(javax.swing.JPanel) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CharacterFile(delta.games.lotro.character.CharacterFile) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) Comparator(java.util.Comparator) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) ReputationStatus(delta.games.lotro.character.reputation.ReputationStatus) FactionStatus(delta.games.lotro.character.reputation.FactionStatus) Faction(delta.games.lotro.lore.reputation.Faction)

Example 32 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class ReputationSynopsisTableController method setToons.

/**
 * Set the displayed toons.
 * @param toons Toons to display.
 */
public void setToons(List<CharacterFile> toons) {
    for (CharacterFile toon : _toons) {
        removeToon(toon);
    }
    _toons.clear();
    _toons.addAll(toons);
    for (CharacterFile toon : _toons) {
        addToon(toon);
    }
    _table.updateColumns();
}
Also used : CharacterFile(delta.games.lotro.character.CharacterFile)

Example 33 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class WarbandsPanelController method doChooseToons.

private void doChooseToons() {
    CharactersManager manager = CharactersManager.getInstance();
    List<CharacterFile> toons = manager.getAllToons();
    List<CharacterFile> selectedToons = _tableController.getToons();
    List<CharacterFile> enabledToons = new ArrayList<CharacterFile>();
    for (CharacterFile toon : toons) {
        if (toon.hasLog()) {
            enabledToons.add(toon);
        }
    }
    List<CharacterFile> newSelectedToons = CharactersChooserController.selectToons(_parent, enabledToons, selectedToons);
    if (newSelectedToons != null) {
        _tableController.refresh(newSelectedToons);
    }
}
Also used : CharactersManager(delta.games.lotro.character.CharactersManager) ArrayList(java.util.ArrayList) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 34 with CharacterFile

use of delta.games.lotro.character.CharacterFile in project lotro-companion by dmorcellet.

the class ReputationSynopsisPanelController method doChooseToons.

private void doChooseToons() {
    CharactersManager manager = CharactersManager.getInstance();
    List<CharacterFile> toons = manager.getAllToons();
    List<CharacterFile> selectedToons = _tableController.getToons();
    List<CharacterFile> newSelectedToons = CharactersChooserController.selectToons(_parent, toons, selectedToons);
    if (newSelectedToons != null) {
        _tableController.setToons(newSelectedToons);
    }
}
Also used : CharactersManager(delta.games.lotro.character.CharactersManager) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 35 with CharacterFile

use of delta.games.lotro.character.CharacterFile 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)

Aggregations

CharacterFile (delta.games.lotro.character.CharacterFile)42 LotroTestUtils (delta.games.lotro.character.log.LotroTestUtils)13 ArrayList (java.util.ArrayList)11 CharactersManager (delta.games.lotro.character.CharactersManager)9 JPanel (javax.swing.JPanel)6 CharacterData (delta.games.lotro.character.CharacterData)5 CharacterLog (delta.games.lotro.character.log.CharacterLog)5 Preferences (delta.common.utils.misc.Preferences)4 TypedProperties (delta.common.utils.misc.TypedProperties)4 CraftingStatus (delta.games.lotro.character.crafting.CraftingStatus)3 CharacterEventType (delta.games.lotro.character.events.CharacterEventType)3 File (java.io.File)3 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)2 TableColumnController (delta.common.ui.swing.tables.TableColumnController)2 CharacterInfosManager (delta.games.lotro.character.CharacterInfosManager)2 CharacterSummary (delta.games.lotro.character.CharacterSummary)2 ProfessionStatus (delta.games.lotro.character.crafting.ProfessionStatus)2 CharacterStatsComputer (delta.games.lotro.character.stats.CharacterStatsComputer)2 Profession (delta.games.lotro.lore.crafting.Profession)2 GridBagConstraints (java.awt.GridBagConstraints)2