Search in sources :

Example 11 with InfoFacade

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

Example 12 with InfoFacade

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

Example 13 with InfoFacade

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

Example 14 with InfoFacade

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;
}
Also used : InfoFacade(pcgen.facade.core.InfoFacade) ArrayList(java.util.ArrayList) PCClass(pcgen.core.PCClass) Domain(pcgen.core.Domain)

Example 15 with InfoFacade

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);
    }
}
Also used : Ability(pcgen.core.Ability) ArrayList(java.util.ArrayList) PCClass(pcgen.core.PCClass) AvailableSpell(pcgen.cdom.helper.AvailableSpell) Spell(pcgen.core.spell.Spell) InfoFacade(pcgen.facade.core.InfoFacade) PObject(pcgen.core.PObject) Domain(pcgen.core.Domain)

Aggregations

InfoFacade (pcgen.facade.core.InfoFacade)16 ArrayList (java.util.ArrayList)7 Spell (pcgen.core.spell.Spell)4 Ability (pcgen.core.Ability)3 Domain (pcgen.core.Domain)3 Equipment (pcgen.core.Equipment)3 PCClass (pcgen.core.PCClass)3 CNAbility (pcgen.cdom.content.CNAbility)2 AvailableSpell (pcgen.cdom.helper.AvailableSpell)2 PObject (pcgen.core.PObject)2 AbilityFacade (pcgen.facade.core.AbilityFacade)2 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 ButtonGroup (javax.swing.ButtonGroup)1 JPanel (javax.swing.JPanel)1 JRadioButton (javax.swing.JRadioButton)1 TitledBorder (javax.swing.border.TitledBorder)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 EquipmentModifier (pcgen.core.EquipmentModifier)1 PlayerCharacter (pcgen.core.PlayerCharacter)1