Example #1
0
  private String loadRule(Element rule, String id) throws DataConversionException {
    Rule dataRule = new Rule(allVars, id, id, rule.getAttribute("weight").getIntValue());
    java.util.List<?> elements = rule.getChildren();

    for (final Object element : elements) {
      Element child = (Element) element;
      String elementName = child.getName();

      if (elementName.equals("GETLIST")) {
        String listId = child.getAttributeValue("idref");
        dataRule.add(listId);
      } else if (elementName.equals("SPACE")) {
        SpaceRule sp = new SpaceRule();
        allVars.addDataElement(sp);
        dataRule.add(sp.getId());
      } else if (elementName.equals("HYPHEN")) {
        HyphenRule hy = new HyphenRule();
        allVars.addDataElement(hy);
        dataRule.add(hy.getId());
      } else if (elementName.equals("CR")) {
        CRRule cr = new CRRule();
        allVars.addDataElement(cr);
        dataRule.add(cr.getId());
      } else if (elementName.equals("GETRULE")) {
        String ruleId = child.getAttributeValue("idref");
        dataRule.add(ruleId);
      }
    }

    allVars.addDataElement(dataRule);

    return dataRule.getId();
  }
Example #2
0
  private String loadList(Element list) throws DataConversionException {
    pcgen.core.doomsdaybook.DDList dataList =
        new pcgen.core.doomsdaybook.DDList(
            allVars, list.getAttributeValue("title"), list.getAttributeValue("id"));
    java.util.List<?> elements = list.getChildren();

    for (final Object element : elements) {
      Element child = (Element) element;
      String elementName = child.getName();

      if (elementName.equals("VALUE")) {
        WeightedDataValue dv =
            new WeightedDataValue(child.getText(), child.getAttribute("weight").getIntValue());
        List<?> subElements = child.getChildren("SUBVALUE");

        for (final Object subElement1 : subElements) {
          Element subElement = (Element) subElement1;
          dv.addSubValue(subElement.getAttributeValue("type"), subElement.getText());
        }

        dataList.add(dv);
      }
    }

    allVars.addDataElement(dataList);

    return dataList.getId();
  }
Example #3
0
  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();
  }
Example #4
0
  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);
    }
  }
Example #5
0
  private void loadFromDocument(Document nameSet) throws DataConversionException {
    Element generator = nameSet.getRootElement();
    java.util.List<?> rulesets = generator.getChildren("RULESET");
    java.util.List<?> lists = generator.getChildren("LIST");
    ListIterator<?> listIterator = lists.listIterator();

    // TODO This is a "dead local store" - is this intended to do something? thpr 10/21/06
    RuleSet rs = new RuleSet(allVars);

    while (listIterator.hasNext()) {
      Element list = (Element) listIterator.next();
      loadList(list);
    }

    for (final Object ruleset : rulesets) {
      Element ruleSet = (Element) ruleset;
      rs = loadRuleSet(ruleSet);
      allVars.addDataElement(rs);
    }
  }