Search in sources :

Example 36 with CharacterFile

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

the class WarbandsTableController method refresh.

/**
 * Refresh toons table.
 * @param toons New toon.
 */
public void refresh(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 37 with CharacterFile

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

the class ToonsManagementController method deleteToon.

private void deleteToon() {
    GenericTableController<CharacterFile> controller = _toonsTable.getTableController();
    CharacterFile file = controller.getSelectedItem();
    if (file != null) {
        String serverName = file.getServerName();
        String toonName = file.getName();
        // Check deletion
        int result = GuiFactory.showQuestionDialog(_parentController.getWindow(), "Do you really want to delete " + toonName + "@" + serverName + "?", "Delete?", JOptionPane.YES_NO_OPTION);
        if (result == JOptionPane.OK_OPTION) {
            String id = CharacterFileWindowController.getIdentifier(serverName, toonName);
            WindowController windowController = _mainWindowsManager.getWindow(id);
            if (windowController != null) {
                windowController.dispose();
            }
            CharactersManager manager = CharactersManager.getInstance();
            manager.removeToon(file);
        }
    }
}
Also used : CharactersManager(delta.games.lotro.character.CharactersManager) CharacterFile(delta.games.lotro.character.CharacterFile) WindowController(delta.common.ui.swing.windows.WindowController) CharacterFileWindowController(delta.games.lotro.gui.character.CharacterFileWindowController)

Example 38 with CharacterFile

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

the class ToonsManagementController method importToon.

private void importToon() {
    FileChooserController ctrl = new FileChooserController("import", "Import character...");
    Window window = _parentController.getWindow();
    File fromFile = ctrl.chooseFile(window, "Import");
    if (fromFile != null) {
        CharacterXMLParser parser = new CharacterXMLParser();
        CharacterData data = new CharacterData();
        boolean ok = parser.parseXML(fromFile, data);
        if (ok) {
            CharactersManager manager = CharactersManager.getInstance();
            CharacterFile toon = manager.getToonById(data.getServer(), data.getName());
            if (toon != null) {
                CharacterInfosManager infos = toon.getInfosManager();
                ok = infos.writeNewCharacterData(data);
                if (ok) {
                    CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_DATA_ADDED, toon, data);
                    EventsManager.invokeEvent(event);
                }
            } else {
                CharacterFile newFile = manager.addToon(data);
                ok = (newFile != null);
            }
            if (ok) {
                GuiFactory.showInformationDialog(window, "Import OK!", "OK!");
            } else {
                GuiFactory.showErrorDialog(window, "Import failed!", "Error!");
            }
        } else {
            GuiFactory.showErrorDialog(window, "Import failed (bad XML file)!", "Error!");
        }
    }
}
Also used : Window(java.awt.Window) CharactersManager(delta.games.lotro.character.CharactersManager) CharacterEvent(delta.games.lotro.character.events.CharacterEvent) CharacterData(delta.games.lotro.character.CharacterData) FileChooserController(delta.games.lotro.utils.gui.filechooser.FileChooserController) CharacterXMLParser(delta.games.lotro.character.io.xml.CharacterXMLParser) CharacterInfosManager(delta.games.lotro.character.CharacterInfosManager) CharacterFile(delta.games.lotro.character.CharacterFile) File(java.io.File) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 39 with CharacterFile

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

the class ToonsTableController method init.

private void init() {
    reset();
    CharactersManager manager = CharactersManager.getInstance();
    List<CharacterFile> toons = manager.getAllToons();
    for (CharacterFile toon : toons) {
        loadToon(toon);
    }
}
Also used : CharactersManager(delta.games.lotro.character.CharactersManager) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 40 with CharacterFile

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

the class TraitPoints method load.

/**
 * Load the trait points for a character.
 * @param character Targeted character.
 * @return A trait point status.
 */
public TraitPointsStatus load(CharacterFile character) {
    File fromFile = getStatusFile(character);
    TraitPointsStatus status = null;
    if (fromFile.exists()) {
        TraitPointsStatusXMLParser parser = new TraitPointsStatusXMLParser();
        status = parser.parseXML(fromFile);
    }
    if (status == null) {
        status = new TraitPointsStatus();
    }
    return status;
}
Also used : TraitPointsStatusXMLParser(delta.games.lotro.stats.traitPoints.io.xml.TraitPointsStatusXMLParser) CharacterFile(delta.games.lotro.character.CharacterFile) File(java.io.File)

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