use of pcgen.facade.core.SourceSelectionFacade in project pcgen by PCGen.
the class SourceSelectionDialog method valueChanged.
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
SourceSelectionFacade selection = basicPanel.getSourceSelection();
deleteButton.setEnabled(selection.isModifiable());
advancedPanel.setSourceSelection(selection);
}
}
use of pcgen.facade.core.SourceSelectionFacade in project pcgen by PCGen.
the class SourceSelectionDialog method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals(SAVE_COMMAND)) {
final JList sourcesList = new JList();
final JTextField nameField = new JTextField();
ListFacade<SourceSelectionFacade> sources = new SortedListFacade<>(Comparators.toStringIgnoreCaseCollator(), FacadeFactory.getCustomSourceSelections());
sourcesList.setModel(new FacadeListModel(sources));
sourcesList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent lse) {
nameField.setText(sourcesList.getSelectedValue().toString());
}
});
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JScrollPane(sourcesList), BorderLayout.CENTER);
panel.add(nameField, BorderLayout.SOUTH);
int ret = JOptionPane.showOptionDialog(this, panel, "Save the source selection as...", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
if (ret == JOptionPane.OK_OPTION) {
String name = nameField.getText();
List<CampaignFacade> selectedCampaigns = advancedPanel.getSelectedCampaigns();
GameModeFacade selectedGameMode = advancedPanel.getSelectedGameMode();
SourceSelectionFacade selection = null;
for (SourceSelectionFacade sourceSelectionFacade : sources) {
if (sourceSelectionFacade.toString().equals(name)) {
selection = sourceSelectionFacade;
break;
}
}
if (selection == null) {
selection = FacadeFactory.createCustomSourceSelection(name);
}
selection.setCampaigns(selectedCampaigns);
selection.setGameMode(selectedGameMode);
basicPanel.setSourceSelection(selection);
}
} else if (command.equals(DELETE_COMMAND)) {
FacadeFactory.deleteCustomSourceSelection(basicPanel.getSourceSelection());
} else if (command.equals(LOAD_COMMAND)) {
fireSourceLoad();
} else if (command.equals(INSTALLDATA_COMMAND)) {
// Swap to the install data dialog.
setVisible(false);
DataInstaller di = new DataInstaller();
di.setVisible(true);
} else if (command.equals(HIDEUNHIDE_COMMAND)) {
SourcesTableModel model = new SourcesTableModel();
JTableEx table = new JTableEx(model);
JTable rowTable = TableUtils.createDefaultTable();
JScrollPane pane = TableUtils.createCheckBoxSelectionPane(table, rowTable);
table.setShowGrid(false);
table.setFocusable(false);
table.setRowSelectionAllowed(false);
rowTable.setRowSelectionAllowed(false);
pane.setPreferredSize(new Dimension(300, 200));
int ret = JOptionPane.showOptionDialog(this, pane, "Select Sources to be visible", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null);
if (ret == JOptionPane.OK_OPTION) {
FacadeFactory.setDisplayedSources(model.getDisplayedSources());
}
model.dispose();
} else {
//must be the cancel command
setVisible(false);
}
}
use of pcgen.facade.core.SourceSelectionFacade in project pcgen by PCGen.
the class SourceSelectionDialog method initDefaults.
private void initDefaults() {
//$NON-NLS-1$
boolean useBasic = context.initBoolean("useBasic", true);
SourceSelectionFacade selection = basicPanel.getSourceSelection();
if (selection != null && useBasic) {
basicPanel.makeSourceSelected(selection);
} else {
deleteButton.setEnabled(false);
}
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
if (useBasic) {
setBasicButtons();
advancedPanel.setSourceSelection(basicPanel.getSourceSelection());
} else {
setAdvancedButtons();
tabs.setSelectedIndex(1);
}
}
use of pcgen.facade.core.SourceSelectionFacade 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