Search in sources :

Example 11 with SourceSelectionFacade

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);
    }
}
Also used : SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade)

Example 12 with SourceSelectionFacade

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);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) DataInstaller(pcgen.gui2.dialog.DataInstaller) SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) GameModeFacade(pcgen.facade.core.GameModeFacade) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) CampaignFacade(pcgen.facade.core.CampaignFacade) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) BorderLayout(java.awt.BorderLayout) JTableEx(pcgen.gui2.util.JTableEx) JTable(javax.swing.JTable) SortedListFacade(pcgen.facade.util.SortedListFacade) JList(javax.swing.JList) FacadeListModel(pcgen.gui2.util.FacadeListModel)

Example 13 with SourceSelectionFacade

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);
    }
}
Also used : SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) BoxLayout(javax.swing.BoxLayout)

Example 14 with SourceSelectionFacade

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);
    }
}
Also used : SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) PartyFacade(pcgen.facade.core.PartyFacade) SourceFileLoader(pcgen.persistence.SourceFileLoader) PCGFile(pcgen.io.PCGFile) File(java.io.File)

Aggregations

SourceSelectionFacade (pcgen.facade.core.SourceSelectionFacade)14 File (java.io.File)4 ArrayList (java.util.ArrayList)4 CampaignFacade (pcgen.facade.core.CampaignFacade)4 PCGFile (pcgen.io.PCGFile)4 SourceFileLoader (pcgen.persistence.SourceFileLoader)3 CharacterFacade (pcgen.facade.core.CharacterFacade)2 GameModeFacade (pcgen.facade.core.GameModeFacade)2 PCGIOHandler (pcgen.io.PCGIOHandler)2 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 Point (java.awt.Point)1 HashSet (java.util.HashSet)1 BoxLayout (javax.swing.BoxLayout)1 JList (javax.swing.JList)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JTable (javax.swing.JTable)1 JTextField (javax.swing.JTextField)1 ListSelectionEvent (javax.swing.event.ListSelectionEvent)1