use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project pcgen by PCGen.
the class NameGenPanel method loadRule.
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();
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project pcgen by PCGen.
the class DiceBagModel method loadFromDocument.
/**
* <p>Loads the dicebag data from the specified jdom document.</p>
*
* @param doc A JDOM document.
*/
private void loadFromDocument(Document doc) {
m_dice.clear();
Element root = doc.getRootElement();
if (root.getName().equals("dice-bag")) {
m_name = root.getAttributeValue("name");
List children = root.getChildren("dice-roll");
for (Iterator i = children.iterator(); i.hasNext(); ) {
Element die = (Element) i.next();
m_dice.add(die.getTextNormalize());
}
}
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project pcgen by PCGen.
the class DiceBagModel method saveToDocument.
/**
* <p>Loads the current dicebag's information into the
* given JDOM document.</p>
*
* @param doc
*/
private void saveToDocument(Document doc) {
Element party = new Element("dice-bag");
party.setAttribute("name", m_name);
for (String dieString : m_dice) {
Element die = new Element("dice-roll");
die.addContent(dieString);
party.addContent(die);
}
doc.setRootElement(party);
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project pcgen by PCGen.
the class Localized method update.
/**
*
* @param e
* @param attribute if {@code null}, use the trimmed text.
*/
private void update(Element e, String attribute) {
List<?> children = e.getChildren(ELEMENT_LOC);
for (Object object : children) {
if (object instanceof Element) {
Element child = (Element) object;
String lang = child.getAttributeValue(ATTRIBUTE_LANGUAGE);
String name;
if (attribute == null)
name = child.getTextTrim();
else
name = child.getAttributeValue(attribute);
if (lang != null && !lang.isEmpty())
addName(lang, name);
}
}
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project pcgen by PCGen.
the class Initiative method loadFromDocument.
/**
* Loads a character or party from an XML document
*
*@param character XML document containing a character or a party
* @param comp
*/
private void loadFromDocument(Document character, PCGenMessageHandler comp) {
if (character.getRootElement().getName().equals("Party")) {
Element party = character.getRootElement();
List xmlList = party.getChildren("Character");
for (Object aXmlList : xmlList) {
Element eCharacter = (Element) aXmlList;
InitHolder combatant = new XMLCombatant(eCharacter);
initList.add(combatant);
}
List pcgList = party.getChildren("PcgCombatant");
for (Object aPcgList : pcgList) {
Element eCharacter = (Element) aPcgList;
final PcgCombatant combatant = new PcgCombatant(eCharacter, comp, messageHandler);
initList.add(combatant);
addTab(combatant);
}
List eventList = party.getChildren("Event");
for (Object anEventList : eventList) {
Element eCharacter = (Element) anEventList;
InitHolder combatant = new Event(eCharacter);
initList.add(combatant);
}
List spellList = party.getChildren("Spell");
for (Object aSpellList : spellList) {
Element eCharacter = (Element) aSpellList;
InitHolder combatant = new Spell(eCharacter);
initList.add(combatant);
}
initList.calculateNumberField();
} else if (character.getRootElement().getName().equals("Character")) {
Element eCharacter = character.getRootElement();
InitHolder combatant = new XMLCombatant(eCharacter);
initList.add(combatant);
}
}
Aggregations