use of pcgen.facade.core.CharacterStubFacade in project pcgen by PCGen.
the class PCGenFrame method prepareForSave.
/**
* Prepare the character for a save. This is primarily concerned with
* ensuring all companions (or masters) have file names before the save is
* done.
* @param character The character being saved.
*/
private void prepareForSave(CharacterFacade character, boolean savingAll) {
List<CompanionFacade> tobeSaved = new ArrayList<>();
for (CompanionFacade comp : character.getCompanionSupport().getCompanions()) {
if (StringUtils.isEmpty(comp.getFileRef().get().getName()) && CharacterManager.getCharacterMatching(comp) != null) {
tobeSaved.add(comp);
}
}
if (!tobeSaved.isEmpty()) {
if (savingAll || showMessageConfirm(Constants.APPLICATION_NAME, //$NON-NLS-1$
LanguageBundle.getString("in_unsavedCompanions"))) {
for (CompanionFacade companionFacade : tobeSaved) {
CharacterFacade compChar = CharacterManager.getCharacterMatching(companionFacade);
showSaveCharacterChooser(compChar);
}
}
}
CharacterStubFacade master = character.getMaster();
if (master != null && (master.getFileRef().get() == null || StringUtils.isEmpty(master.getFileRef().get().getName()))) {
if (savingAll || showMessageConfirm(Constants.APPLICATION_NAME, //$NON-NLS-1$
LanguageBundle.getString("in_unsavedMaster"))) {
CharacterFacade masterChar = CharacterManager.getCharacterMatching(master);
showSaveCharacterChooser(masterChar);
}
}
}
Aggregations