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);
}
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();
}
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);
}
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;
}
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);
}
Aggregations