use of pcgen.facade.core.InfoFacade in project pcgen by PCGen.
the class ChooserDialog method valueChanged.
@Override
public void valueChanged(ListSelectionEvent e) {
if (availTable != null && !e.getValueIsAdjusting()) {
if (e.getSource() == availTable.getSelectionModel() && availTable.getSelectedObject() instanceof InfoFacade) {
InfoFacade target = (InfoFacade) availTable.getSelectedObject();
InfoFactory factory = chooser.getInfoFactory();
if (factory != null && target != null) {
infoPane.setText(factory.getHTMLInfo(target));
}
}
}
}
use of pcgen.facade.core.InfoFacade in project pcgen by PCGen.
the class ChooserDialog method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (availTable != null && (e.getActionCommand().equals("ADD") || e.getSource() == availTable)) {
List<Object> data = availTable.getSelectedData();
if (!data.isEmpty()) {
for (Object object : data) {
if (object instanceof InfoFacade) {
chooser.addSelected((InfoFacade) object);
}
}
}
return;
}
if (availInput != null && (e.getActionCommand().equals("ADD") || e.getSource() == availInput)) {
String data = availInput.getText();
if (StringUtils.isNotBlank(data)) {
chooser.addSelected(new InfoWrapper(data));
}
availInput.setText("");
return;
}
if (e.getActionCommand().equals("REMOVE") || e.getSource() == list) {
Object value = list.getSelectedValue();
if (value != null && value instanceof InfoFacade) {
chooser.removeSelected((InfoFacade) value);
if (availInput != null) {
availInput.setText(value.toString());
}
}
return;
}
if (e.getActionCommand().equals("OK")) {
if (chooser.isRequireCompleteSelection() && chooser.getRemainingSelections().get() > 0) {
JOptionPane.showMessageDialog(this, //$NON-NLS-1$
LanguageBundle.getFormattedString(//$NON-NLS-1$
"in_chooserRequireComplete", chooser.getRemainingSelections().get()), chooser.getName(), JOptionPane.INFORMATION_MESSAGE);
return;
} else {
chooser.commit();
}
} else {
chooser.rollback();
}
committed = e.getActionCommand().equals("OK");
dispose();
}
use of pcgen.facade.core.InfoFacade in project pcgen by PCGen.
the class CDOMChooserFacadeImpl method commit.
@Override
public void commit() {
finalSelected.clear();
for (InfoFacade object : selectedList) {
T selected;
if (object instanceof CDOMChooserFacadeImpl.CDOMInfoWrapper) {
selected = (T) ((CDOMChooserFacadeImpl.CDOMInfoWrapper) object).getCdomObj();
} else if (object instanceof InfoWrapper) {
selected = (T) ((InfoWrapper) object).getObj();
} else {
selected = (T) object;
}
finalSelected.add(selected);
}
}
use of pcgen.facade.core.InfoFacade in project pcgen by PCGen.
the class SpellBuilderFacadeImpl method getSpellTypeList.
private List<String> getSpellTypeList() {
List<String> spellTypes = new ArrayList<>();
InfoFacade castingClass = pcClass.get();
if (castingClass instanceof PCClass) {
spellTypes.add(((PCClass) castingClass).getSpellType());
} else if (castingClass instanceof Domain) {
spellTypes.add("Divine");
} else {
Logging.errorPrint("Found Casting Class that was not a Class or Domain: " + castingClass.getClass());
}
return spellTypes;
}
use of pcgen.facade.core.InfoFacade in project pcgen by PCGen.
the class SpellBuilderFacadeImpl method buildLists.
/**
* Use the parsed rules to build up the lists that will not change,
* such as class/domain list and metamagic feats.
*/
private void buildLists() {
List<PCClass> classes = new ArrayList<>();
List<Domain> domains = new ArrayList<>();
if (classList != null) {
for (String classKey : classList) {
PObject obj = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(PCClass.class, classKey);
if (obj == null) {
obj = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, classKey);
if (obj != null) {
domains.add((Domain) obj);
}
} else {
classes.add((PCClass) obj);
}
}
} else {
for (Spell spell : Globals.getContext().getReferenceContext().getConstructedCDOMObjects(Spell.class)) {
if (isSpellOfSubType(spell)) {
addSpellInfoToList(spell, classes, domains, reqSpellType);
}
}
for (PCClass aClass : Globals.getContext().getReferenceContext().getConstructedCDOMObjects(PCClass.class)) {
if (!aClass.getSpellType().equals(Constants.NONE)) {
// Only adds if the class can cast
if (character.getSpellSupport(aClass).canCastSpells(character)) {
continue;
}
if (!("".equals(reqSpellType)) && (!reqSpellType.contains(aClass.getSpellType()))) {
continue;
}
if (!classes.contains(aClass)) {
classes.add(aClass);
}
}
}
}
if (spellBooks != null) {
for (int i = classes.size() - 1; i >= 0; --i) {
PCClass obj = classes.get(i);
if (// can't have books
!spellBooks) {
if (obj.getSafe(ObjectKey.SPELLBOOK)) {
classes.remove(i);
}
} else // must have books
{
if (!(obj instanceof PCClass) || !obj.getSafe(ObjectKey.SPELLBOOK)) {
classes.remove(i);
}
}
}
if (spellBooks) {
domains.clear();
}
}
List<InfoFacade> allObjects = new ArrayList<>();
Globals.sortPObjectListByName(classes);
allObjects.addAll(classes);
Globals.sortPObjectListByName(domains);
allObjects.addAll(domains);
availClasses.setContents(allObjects);
// Spell levels
List<Integer> spellLevelValues = new ArrayList<>();
if ((levelList != null) && (!levelList.isEmpty())) {
for (int i = minSpellLevel; i < levelList.size(); ++i) {
spellLevelValues.add(Integer.valueOf(levelList.get(i)));
}
} else {
for (int i = minSpellLevel; i <= maxSpellLevel; i++) {
spellLevelValues.add(i);
}
}
availSpellLevels.setContents(spellLevelValues);
// Caster levels
updateAvailCasterLevels(1, 20);
//Metamagic
if (metaAllowed) {
List<Ability> metamagicFeats = new ArrayList<>();
for (Ability anAbility : Globals.getContext().getReferenceContext().getManufacturer(Ability.class, AbilityCategory.FEAT).getAllObjects()) {
if (anAbility.isType("Metamagic")) {
metamagicFeats.add(anAbility);
}
}
Globals.sortPObjectListByName(metamagicFeats);
availMetamagicFeats.setContents(metamagicFeats);
}
}
Aggregations