MCPcopy Create free account
hub / github.com/PCGen/pcgen / closeAllCharacters

Method closeAllCharacters

code/src/java/pcgen/gui2/PCGenFrame.java:658–742  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

656 }
657
658 public boolean closeAllCharacters()
659 {
660 final int CLOSE_OPT_CHOOSE = 2;
661 ListFacade<CharacterFacade> characters = CharacterManager.getCharacters();
662 if (characters.isEmpty())
663 {
664 return true;
665 }
666 int saveAllChoice = CLOSE_OPT_CHOOSE;
667
668 List<CharacterFacade> characterList = new ArrayList<>();
669 List<CharacterFacade> unsavedPCs = new ArrayList<>();
670 for (CharacterFacade characterFacade : characters)
671 {
672 if (characterFacade.isDirty())
673 {
674 unsavedPCs.add(characterFacade);
675 }
676 else
677 {
678 characterList.add(characterFacade);
679 }
680 }
681 if (unsavedPCs.size() > 1)
682 {
683 Object[] options = {LanguageBundle.getString("in_closeOptSaveAll"), //$NON-NLS-1$
684 LanguageBundle.getString("in_closeOptSaveNone"), //$NON-NLS-1$
685 LanguageBundle.getString("in_closeOptChoose"), //$NON-NLS-1$
686 LanguageBundle.getString("in_cancel") //$NON-NLS-1$
687 };
688 saveAllChoice = JOptionPane.showOptionDialog(this,
689 LanguageBundle.getString("in_closeOptSaveTitle"), //$NON-NLS-1$
690 Constants.APPLICATION_NAME,
691 JOptionPane.YES_NO_CANCEL_OPTION,
692 JOptionPane.QUESTION_MESSAGE,
693 null,
694 options,
695 options[0]);
696 }
697 if (saveAllChoice == 3 || saveAllChoice == CLOSED_OPTION)
698 {
699 // Cancel
700 return false;
701 }
702 if (saveAllChoice == 1)
703 {
704 // Save none
705 CharacterManager.removeAllCharacters();
706 return true;
707 }
708
709 for (CharacterFacade character : unsavedPCs)
710 {
711 int saveSingleChoice = JOptionPane.YES_OPTION;
712
713 if (saveAllChoice == CLOSE_OPT_CHOOSE)
714 {
715 saveSingleChoice = JOptionPane.showConfirmDialog(this,

Callers 5

unloadSourcesMethod · 0.95
loadSourceSelectionMethod · 0.95
actionPerformedMethod · 0.80
actionPerformedMethod · 0.80
closePCGenMethod · 0.80

Calls 12

getCharactersMethod · 0.95
getStringMethod · 0.95
removeAllCharactersMethod · 0.95
getFormattedStringMethod · 0.95
saveCharacterMethod · 0.95
removeCharacterMethod · 0.95
isEmptyMethod · 0.65
isDirtyMethod · 0.65
addMethod · 0.65
sizeMethod · 0.65
getMethod · 0.65
getNameRefMethod · 0.65

Tested by

no test coverage detected