Search in sources :

Example 1 with CharacterStubFacade

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);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) CharacterStubFacade(pcgen.facade.core.CharacterStubFacade) CharacterFacade(pcgen.facade.core.CharacterFacade) CompanionFacade(pcgen.facade.core.CompanionFacade)

Aggregations

ArrayList (java.util.ArrayList)1 CharacterFacade (pcgen.facade.core.CharacterFacade)1 CharacterStubFacade (pcgen.facade.core.CharacterStubFacade)1 CompanionFacade (pcgen.facade.core.CompanionFacade)1