use of pcgen.facade.core.PartyFacade in project pcgen by PCGen.
the class ExportDialog method printToFile.
private boolean printToFile(File outFile) throws IOException {
File template = getSelectedTemplate();
if (partyBox.isSelected()) {
SettingsHandler.setSelectedPartyHTMLOutputSheet(template.getAbsolutePath());
PartyFacade party = CharacterManager.getCharacters();
return BatchExporter.exportPartyToNonPDF(party, outFile, template);
} else {
CharacterFacade character = (CharacterFacade) characterBox.getSelectedItem();
return BatchExporter.exportCharacterToNonPDF(character, outFile, template);
}
}
use of pcgen.facade.core.PartyFacade in project pcgen by PCGen.
the class PCGenFrame method showSavePartyChooser.
boolean showSavePartyChooser() {
PartyFacade party = CharacterManager.getCharacters();
PCGenSettings context = PCGenSettings.getInstance();
String parentPath = context.getProperty(PCGenSettings.PCP_SAVE_PATH);
chooser.setCurrentDirectory(new File(parentPath));
File file = party.getFileRef().get();
chooser.setSelectedFile(file);
chooser.resetChoosableFileFilters();
FileFilter filter = new FileNameExtensionFilter("Pcp files only", "pcp");
chooser.addChoosableFileFilter(filter);
chooser.setFileFilter(filter);
int ret = chooser.showSaveDialog(this);
if (ret != JFileChooser.APPROVE_OPTION) {
return false;
}
file = chooser.getSelectedFile();
if (!file.getName().endsWith(Constants.EXTENSION_PARTY_FILE)) {
file = new File(file.getParent(), file.getName() + Constants.EXTENSION_PARTY_FILE);
}
if (file.isDirectory()) {
showErrorMessage(Constants.APPLICATION_NAME, //$NON-NLS-1$
LanguageBundle.getString("in_savePcDirOverwrite"));
return showSavePartyChooser();
}
if (file.exists()) {
boolean overwrite = showWarningConfirm(LanguageBundle.getFormattedString("in_savePcConfirmOverTitle", //$NON-NLS-1$
file.getName()), LanguageBundle.getFormattedString("in_savePcConfirmOverMsg", //$NON-NLS-1$
file.getName()));
if (!overwrite) {
return showSavePartyChooser();
}
}
party.setFile(file);
context.setProperty(PCGenSettings.PCP_SAVE_PATH, file.getParent());
if (!saveAllCharacters()) {
showErrorMessage(//$NON-NLS-1$
LanguageBundle.getString("in_savePartyFailTitle"), //$NON-NLS-1$
LanguageBundle.getString("in_savePartyFailMsg"));
return false;
}
if (!CharacterManager.saveCurrentParty()) {
return showSavePartyChooser();
}
return true;
}
use of pcgen.facade.core.PartyFacade in project pcgen by PCGen.
the class BatchExporter method exportParty.
/**
* Export a party sheet for the party to the output file using the
* pre-registered template. If the output file is null then a default file
* will be used based on the party file name and the type of export
* template in use. If the output file exists it will be overwritten.
* <p>
* This method will load the required data for the party, load the characters
* in the party and then export the party sheet.
*
* @param partyFilename The path to the party PCP file.
* @param outputFile The path to the output file to be created. May be null.
* @return true if the export was successful, false if it failed in some way.
*/
boolean exportParty(String partyFilename, String outputFile) {
File file = new File(partyFilename);
if (!PCGFile.isPCGenPartyFile(file)) {
Logging.errorPrint("Invalid party file specified: " + file.getAbsolutePath());
return false;
}
String outFilename = outputFile;
if (outFilename == null) {
outFilename = generateOutputFilename(partyFilename);
}
Logging.log(Logging.INFO, "Started export of party " + file.getAbsolutePath() + " using " + exportTemplateFilename + " to " + outFilename);
// Load data
SourceSelectionFacade sourcesForCharacter = CharacterManager.getRequiredSourcesForParty(file, uiDelegate);
SourceFileLoader loader = new SourceFileLoader(sourcesForCharacter, uiDelegate);
loader.execute();
// Load party
PartyFacade party = CharacterManager.openParty(file, uiDelegate, loader.getDataSetFacade());
// Export party
File templateFile = new File(exportTemplateFilename);
File outFile = new File(outFilename);
if (isPdf) {
return exportPartyToPDF(party, outFile, templateFile);
} else {
return exportPartyToNonPDF(party, outFile, templateFile);
}
}
Aggregations