Search in sources :

Example 16 with CharacterEvent

use of delta.games.lotro.character.events.CharacterEvent 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 17 with CharacterEvent

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

the class CraftingWindowController method okImpl.

@Override
protected void okImpl() {
    _vocationController.updateDataFromUi();
    _toon.saveCrafting();
    // Broadcast crafting update event...
    CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_CRAFTING_UPDATED, _toon, null);
    EventsManager.invokeEvent(event);
}
Also used : CharacterEvent(delta.games.lotro.character.events.CharacterEvent)

Aggregations

CharacterEvent (delta.games.lotro.character.events.CharacterEvent)17 CharacterData (delta.games.lotro.character.CharacterData)4 CharacterInfosManager (delta.games.lotro.character.CharacterInfosManager)3 BuffsManager (delta.games.lotro.character.stats.buffs.BuffsManager)3 CharacterSummary (delta.games.lotro.character.CharacterSummary)2 BuffInstance (delta.games.lotro.character.stats.buffs.BuffInstance)2 FlowLayout (java.awt.FlowLayout)2 JPanel (javax.swing.JPanel)2 ItemSelectionListener (delta.common.ui.swing.combobox.ItemSelectionListener)1 DateEditionController (delta.common.ui.swing.text.dates.DateEditionController)1 DefaultWindowController (delta.common.ui.swing.windows.DefaultWindowController)1 WindowController (delta.common.ui.swing.windows.WindowController)1 CharacterEquipment (delta.games.lotro.character.CharacterEquipment)1 SlotContents (delta.games.lotro.character.CharacterEquipment.SlotContents)1 CharacterFile (delta.games.lotro.character.CharacterFile)1 CharactersManager (delta.games.lotro.character.CharactersManager)1 CharacterXMLParser (delta.games.lotro.character.io.xml.CharacterXMLParser)1 CharacterStatsComputer (delta.games.lotro.character.stats.CharacterStatsComputer)1 STAT (delta.games.lotro.character.stats.STAT)1 Buff (delta.games.lotro.character.stats.buffs.Buff)1