Search in sources :

Example 1 with DataElement

use of pcgen.core.doomsdaybook.DataElement in project pcgen by PCGen.

the class NameGenPanel method loadStructureDD.

private void loadStructureDD() {
    if (chkStructure.isSelected()) {
        cbStructure.setModel(new DefaultComboBoxModel());
        cbStructure.setEnabled(false);
    } else {
        Vector<DataElement> struct = new Vector<>();
        for (String key : ((RuleSet) cbCatalog.getSelectedItem())) {
            try {
                struct.add(allVars.getDataElement(key));
            } catch (Exception e) {
                Logging.errorPrint(e.getMessage(), e);
            }
        }
        DefaultComboBoxModel structModel = new DefaultComboBoxModel(struct);
        cbStructure.setModel(structModel);
        cbStructure.setEnabled(true);
    }
}
Also used : DataElement(pcgen.core.doomsdaybook.DataElement) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Vector(java.util.Vector) FileNotFoundException(java.io.FileNotFoundException) DataConversionException(org.jdom2.DataConversionException)

Example 2 with DataElement

use of pcgen.core.doomsdaybook.DataElement in project pcgen by PCGen.

the class NameGenPanel method NameButtonActionPerformed.

private void NameButtonActionPerformed(ActionEvent evt) {
    try {
        NameButton nb = (NameButton) evt.getSource();
        DataElement element = nb.getDataElement();
        element.getData();
        Rule rule = this.lastRule;
        if (rule == null) {
            if (chkStructure.isSelected()) {
                RuleSet rs = (RuleSet) cbCatalog.getSelectedItem();
                rule = rs.getLastRule();
            } else {
                rule = (Rule) cbStructure.getSelectedItem();
            }
            this.lastRule = rule;
        }
        ArrayList<DataValue> aName = rule.getLastData();
        setNameText(aName);
        setMeaningText(aName);
        setPronounciationText(aName);
    } catch (Exception e) {
        Logging.errorPrint(e.getMessage(), e);
    }
}
Also used : DataElement(pcgen.core.doomsdaybook.DataElement) RuleSet(pcgen.core.doomsdaybook.RuleSet) WeightedDataValue(pcgen.core.doomsdaybook.WeightedDataValue) DataValue(pcgen.core.doomsdaybook.DataValue) CRRule(pcgen.core.doomsdaybook.CRRule) HyphenRule(pcgen.core.doomsdaybook.HyphenRule) Rule(pcgen.core.doomsdaybook.Rule) SpaceRule(pcgen.core.doomsdaybook.SpaceRule) FileNotFoundException(java.io.FileNotFoundException) DataConversionException(org.jdom2.DataConversionException)

Example 3 with DataElement

use of pcgen.core.doomsdaybook.DataElement in project pcgen by PCGen.

the class NameGenPanel method displayButtons.

private void displayButtons(Rule rule) {
    clearButtons();
    for (String key : rule) {
        try {
            DataElement ele = allVars.getDataElement(key);
            if (ele.getTitle() != null) {
                NameButton nb = new NameButton(ele);
                nb.addActionListener(this::NameButtonActionPerformed);
                buttonPanel.add(nb);
            }
        } catch (Exception e) {
            Logging.errorPrint(e.getMessage(), e);
        }
    }
    buttonPanel.repaint();
}
Also used : DataElement(pcgen.core.doomsdaybook.DataElement) FileNotFoundException(java.io.FileNotFoundException) DataConversionException(org.jdom2.DataConversionException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)3 DataConversionException (org.jdom2.DataConversionException)3 DataElement (pcgen.core.doomsdaybook.DataElement)3 Vector (java.util.Vector)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 CRRule (pcgen.core.doomsdaybook.CRRule)1 DataValue (pcgen.core.doomsdaybook.DataValue)1 HyphenRule (pcgen.core.doomsdaybook.HyphenRule)1 Rule (pcgen.core.doomsdaybook.Rule)1 RuleSet (pcgen.core.doomsdaybook.RuleSet)1 SpaceRule (pcgen.core.doomsdaybook.SpaceRule)1 WeightedDataValue (pcgen.core.doomsdaybook.WeightedDataValue)1