Search in sources :

Example 6 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class TempBonusInfoTab method initComponents.

private void initComponents() {
    FlippingSplitPane topPane = new FlippingSplitPane("TempBonusTop");
    setTopComponent(topPane);
    setOrientation(VERTICAL_SPLIT);
    JPanel availPanel = new JPanel(new BorderLayout());
    FilterBar<CharacterFacade, TempBonusFacade> bar = new FilterBar<>();
    bar.addDisplayableFilter(new SearchFilterPanel());
    availPanel.add(bar, BorderLayout.NORTH);
    availableTable.setDisplayableFilter(bar);
    availableTable.setTreeCellRenderer(tempBonusRenderer);
    availPanel.add(new JScrollPane(availableTable), BorderLayout.CENTER);
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    addButton.setHorizontalTextPosition(SwingConstants.LEADING);
    box.add(addButton);
    box.add(Box.createHorizontalStrut(5));
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    availPanel.add(box, BorderLayout.SOUTH);
    topPane.setLeftComponent(availPanel);
    JPanel selPanel = new JPanel(new BorderLayout());
    FilterBar<CharacterFacade, TempBonusFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    selectedTable.setDisplayableFilter(filterBar);
    selectedTable.setTreeCellRenderer(tempBonusRenderer);
    selPanel.add(new JScrollPane(selectedTable), BorderLayout.CENTER);
    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalStrut(5));
    box.add(removeButton);
    box.add(Box.createHorizontalGlue());
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    selPanel.add(box, BorderLayout.SOUTH);
    topPane.setRightComponent(selPanel);
    setBottomComponent(infoPane);
    setResizeWeight(0.75);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FilterBar(pcgen.gui2.filter.FilterBar) TempBonusFacade(pcgen.facade.core.TempBonusFacade) BorderLayout(java.awt.BorderLayout) Box(javax.swing.Box) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel) EmptyBorder(javax.swing.border.EmptyBorder) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) CharacterFacade(pcgen.facade.core.CharacterFacade)

Example 7 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class PCGenFrame method closeAllCharacters.

public boolean closeAllCharacters() {
    final int CLOSE_OPT_CHOOSE = 2;
    ListFacade<CharacterFacade> characters = CharacterManager.getCharacters();
    if (characters.isEmpty()) {
        return true;
    }
    int saveAllChoice = CLOSE_OPT_CHOOSE;
    List<CharacterFacade> characterList = new ArrayList<>();
    List<CharacterFacade> unsavedPCs = new ArrayList<>();
    for (CharacterFacade characterFacade : characters) {
        if (characterFacade.isDirty()) {
            unsavedPCs.add(characterFacade);
        } else {
            characterList.add(characterFacade);
        }
    }
    if (unsavedPCs.size() > 1) {
        Object[] options = new Object[] { //$NON-NLS-1$
        LanguageBundle.getString("in_closeOptSaveAll"), //$NON-NLS-1$
        LanguageBundle.getString("in_closeOptSaveNone"), //$NON-NLS-1$
        LanguageBundle.getString("in_closeOptChoose"), //$NON-NLS-1$
        LanguageBundle.getString("in_cancel") };
        saveAllChoice = //$NON-NLS-1$
        JOptionPane.showOptionDialog(//$NON-NLS-1$
        this, //$NON-NLS-1$
        LanguageBundle.getString("in_closeOptSaveTitle"), Constants.APPLICATION_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
    }
    if (saveAllChoice == 3) {
        // Cancel
        return false;
    }
    if (saveAllChoice == 1) {
        // Save none
        CharacterManager.removeAllCharacters();
        return true;
    }
    for (CharacterFacade character : unsavedPCs) {
        int saveSingleChoice = JOptionPane.YES_OPTION;
        if (saveAllChoice == CLOSE_OPT_CHOOSE) {
            saveSingleChoice = JOptionPane.showConfirmDialog(this, LanguageBundle.getFormattedString("in_savePcChoice", //$NON-NLS-1$
            character.getNameRef().get()), Constants.APPLICATION_NAME, JOptionPane.YES_NO_CANCEL_OPTION);
        }
        if (saveSingleChoice == JOptionPane.YES_OPTION) {
            //If you get here then the user either selected "Yes to All" or "Yes"
            if (saveCharacter(character)) {
                characterList.add(character);
            }
        } else if (saveSingleChoice == JOptionPane.NO_OPTION) {
            characterList.add(character);
        } else if (saveSingleChoice == JOptionPane.CANCEL_OPTION) {
            return false;
        }
    }
    for (CharacterFacade character : characterList) {
        CharacterManager.removeCharacter(character);
    }
    return characters.isEmpty();
}
Also used : ArrayList(java.util.ArrayList) CharacterFacade(pcgen.facade.core.CharacterFacade)

Example 8 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class PCGenFrame method createNewCharacter.

/**
	 * creates a new character and sets its file if possible
	 * then sets the character as the currently selected character
	 * @param file the File for this character
	 */
private void createNewCharacter(File file) {
    DataSetFacade data = getLoadedDataSetRef().get();
    CharacterFacade character = CharacterManager.createNewCharacter(this, data);
    //it is first displayed
    if (file != null) {
        character.setFile(file);
    }
    //Because CharacterManager adds the new character to the character
    //list before it returns, it is not necessary to update the character
    //tabs since they will catch that event before the call to
    //setSelectedCharacter is called
    setSelectedCharacter(character);
}
Also used : DataSetFacade(pcgen.facade.core.DataSetFacade) CharacterFacade(pcgen.facade.core.CharacterFacade)

Example 9 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class CharacterFacadeImpl method getMaster.

@Override
public CharacterStubFacade getMaster() {
    Follower master = charDisplay.getMaster();
    if (master == null) {
        return null;
    }
    CompanionNotLoaded stub = new CompanionNotLoaded(master.getName(), new File(master.getFileName()), master.getRace(), master.getType().getKeyName());
    CharacterFacade masterFacade = CharacterManager.getCharacterMatching(stub);
    if (masterFacade != null) {
        return masterFacade;
    }
    return stub;
}
Also used : Follower(pcgen.core.character.Follower) File(java.io.File) CharacterFacade(pcgen.facade.core.CharacterFacade)

Example 10 with CharacterFacade

use of pcgen.facade.core.CharacterFacade in project pcgen by PCGen.

the class SpellBooksTab method initComponents.

private void initComponents() {
    availableTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setTreeCellRenderer(spellRenderer);
    selectedTable.setRowSorter(new SortableTableRowSorter() {

        @Override
        public SortableTableModel getModel() {
            return (SortableTableModel) selectedTable.getModel();
        }
    });
    selectedTable.getRowSorter().toggleSortOrder(0);
    FilterBar<CharacterFacade, SuperNode> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    //$NON-NLS-1$
    qFilterButton.setText(LanguageBundle.getString("in_igQualFilter"));
    filterBar.addDisplayableFilter(qFilterButton);
    FlippingSplitPane upperPane = new FlippingSplitPane("SpellBooksTop");
    JPanel availPanel = FilterUtilities.configureFilteredTreeViewPane(availableTable, filterBar);
    Box box = Box.createVerticalBox();
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(new JLabel(LanguageBundle.getString("InfoSpells.set.auto.book")));
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(defaultBookCombo);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(addButton);
        hbox.add(Box.createHorizontalStrut(5));
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    availPanel.add(box, BorderLayout.SOUTH);
    upperPane.setLeftComponent(availPanel);
    box = Box.createVerticalBox();
    box.add(new JScrollPane(selectedTable));
    box.add(Box.createVerticalStrut(5));
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(removeButton);
        hbox.add(Box.createHorizontalGlue());
        box.add(hbox);
    }
    box.add(Box.createVerticalStrut(5));
    upperPane.setRightComponent(box);
    upperPane.setResizeWeight(0);
    setTopComponent(upperPane);
    FlippingSplitPane bottomPane = new FlippingSplitPane("SpellBooksBottom");
    bottomPane.setLeftComponent(spellsPane);
    bottomPane.setRightComponent(classPane);
    setBottomComponent(bottomPane);
    setOrientation(VERTICAL_SPLIT);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) SuperNode(pcgen.facade.core.SpellSupportFacade.SuperNode) JLabel(javax.swing.JLabel) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) CharacterFacade(pcgen.facade.core.CharacterFacade) FlippingSplitPane(pcgen.gui2.tools.FlippingSplitPane) FilterBar(pcgen.gui2.filter.FilterBar) SearchFilterPanel(pcgen.gui2.filter.SearchFilterPanel)

Aggregations

CharacterFacade (pcgen.facade.core.CharacterFacade)31 File (java.io.File)11 JPanel (javax.swing.JPanel)9 JScrollPane (javax.swing.JScrollPane)9 FilterBar (pcgen.gui2.filter.FilterBar)9 SearchFilterPanel (pcgen.gui2.filter.SearchFilterPanel)9 FlippingSplitPane (pcgen.gui2.tools.FlippingSplitPane)9 Box (javax.swing.Box)8 BorderLayout (java.awt.BorderLayout)6 ArrayList (java.util.ArrayList)5 PCGFile (pcgen.io.PCGFile)5 EmptyBorder (javax.swing.border.EmptyBorder)4 JCheckBox (javax.swing.JCheckBox)3 JLabel (javax.swing.JLabel)3 PlayerCharacter (pcgen.core.PlayerCharacter)3 SuperNode (pcgen.facade.core.SpellSupportFacade.SuperNode)3 SortableTableModel (pcgen.gui2.util.table.SortableTableModel)3 SortableTableRowSorter (pcgen.gui2.util.table.SortableTableRowSorter)3 IOException (java.io.IOException)2 URI (java.net.URI)2