use of delta.games.lotro.character.CharacterData in project lotro-companion by dmorcellet.
the class CharacterFileWindowController method exportCharacterData.
private void exportCharacterData() {
GenericTableController<CharacterData> controller = _toonsTable.getTableController();
CharacterData data = controller.getSelectedItem();
if (data != null) {
FileChooserController ctrl = new FileChooserController("export", "Export character...");
File toFile = ctrl.chooseFile(getWindow(), "Export");
if (toFile != null) {
boolean doIt = true;
if (!toFile.getName().toLowerCase().endsWith(".xml")) {
toFile = new File(toFile.getParentFile(), toFile.getName() + ".xml");
}
if (toFile.exists()) {
doIt = false;
int result = GuiFactory.showQuestionDialog(getFrame(), "Do you really want to overwrite the selected file?", "Overwrite?", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.OK_OPTION) {
doIt = true;
}
}
if (doIt) {
File sourceFile = data.getFile();
boolean ok = FileCopy.copy(sourceFile, toFile);
Window window = getWindow();
if (ok) {
GuiFactory.showInformationDialog(window, "Export OK!", "OK!");
} else {
GuiFactory.showErrorDialog(window, "Export failed!", "Error!");
}
}
}
}
}
use of delta.games.lotro.character.CharacterData in project lotro-companion by dmorcellet.
the class CharacterFileWindowController method actionPerformed.
/**
* Handle button actions.
* @param e Source event.
*/
@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (LOG_COMMAND.equals(command)) {
// Show log
String serverName = _toon.getServerName();
String toonName = _toon.getName();
String id = CharacterLogWindowController.getIdentifier(serverName, toonName);
WindowController controller = _windowsManager.getWindow(id);
if (controller == null) {
controller = new CharacterLogWindowController(_toon);
_windowsManager.registerWindow(controller);
controller.getWindow().setLocationRelativeTo(getFrame());
}
controller.bringToFront();
} else if (REPUTATION_COMMAND.equals(command)) {
// Reputation
CharacterReputationDialogController controller = new CharacterReputationDialogController(this, _toon);
controller.editModal();
} else if (LEVEL_COMMAND.equals(command)) {
// Level history
LevelHistoryEditionDialogController controller = new LevelHistoryEditionDialogController(this, _toon);
controller.editModal();
} else if (CRAFTING_COMMAND.equals(command)) {
// Crafting
CraftingWindowController controller = new CraftingWindowController(this, _toon);
controller.editModal();
} else if (STASH_COMMAND.equals(command)) {
showStash();
} else if (TRAIT_POINTS_COMMAND.equals(command)) {
editTraitPoints();
} else if (NEW_TOON_DATA_ID.equals(command)) {
startNewCharacterData();
} else if (CLONE_TOON_DATA_ID.equals(command)) {
cloneCharacterData();
} else if (EXPORT_TOON_DATA_ID.equals(command)) {
exportCharacterData();
} else if (REMOVE_TOON_DATA_ID.equals(command)) {
removeCharacterData();
} else if (GenericTableController.DOUBLE_CLICK.equals(command)) {
CharacterData data = (CharacterData) e.getSource();
showCharacterData(data);
}
}
use of delta.games.lotro.character.CharacterData in project lotro-companion by dmorcellet.
the class CharacterFileWindowController method removeCharacterData.
private void removeCharacterData() {
GenericTableController<CharacterData> controller = _toonsTable.getTableController();
CharacterData data = controller.getSelectedItem();
if (data != null) {
// Check deletion
String serverName = data.getServer();
String toonName = data.getName();
int result = GuiFactory.showQuestionDialog(getFrame(), "Do you really want to delete this configuration of " + toonName + "@" + serverName + "?", "Delete?", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.OK_OPTION) {
String id = CharacterDataWindowController.getIdentifier(data);
WindowController windowController = _windowsManager.getWindow(id);
if (windowController != null) {
windowController.dispose();
}
boolean ok = _toon.getInfosManager().remove(data);
if (ok) {
CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_DATA_REMOVED, _toon, data);
EventsManager.invokeEvent(event);
}
}
}
}
use of delta.games.lotro.character.CharacterData in project lotro-companion by dmorcellet.
the class CharacterFileWindowController method startNewCharacterData.
private void startNewCharacterData() {
CharacterInfosManager infos = _toon.getInfosManager();
CharacterData lastInfos = infos.getLastCharacterDescription();
CharacterData newInfos = new CharacterData();
CharacterSummary newSummary;
if (lastInfos != null) {
newSummary = new CharacterSummary(lastInfos.getSummary());
} else {
newSummary = new CharacterSummary(_toon.getSummary());
}
newInfos.setSummary(newSummary);
newInfos.setDate(Long.valueOf(System.currentTimeMillis()));
// Compute stats
CharacterStatsComputer computer = new CharacterStatsComputer();
newInfos.getStats().setStats(computer.getStats(newInfos));
boolean ok = _toon.getInfosManager().writeNewCharacterData(newInfos);
if (ok) {
CharacterEvent event = new CharacterEvent(CharacterEventType.CHARACTER_DATA_ADDED, _toon, newInfos);
EventsManager.invokeEvent(event);
showCharacterData(newInfos);
}
}
use of delta.games.lotro.character.CharacterData in project lotro-companion by dmorcellet.
the class AllEssencesEditionWindowController method eventOccurred.
/**
* Handle character events.
* @param event Source event.
*/
@Override
public void eventOccurred(CharacterEvent event) {
CharacterEventType type = event.getType();
if (type == CharacterEventType.CHARACTER_DATA_UPDATED) {
CharacterData data = event.getToonData();
if (data == _toon) {
_editionController.update();
getWindow().pack();
}
}
}
Aggregations