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); } }
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(); }
/** * Generate a Rule * * @return new Rule */ public Rule generate() { try { Rule rule = null; if (chkStructure.isSelected()) { RuleSet rs = (RuleSet) cbCatalog.getSelectedItem(); rule = rs.getRule(); } else { rule = (Rule) cbStructure.getSelectedItem(); } ArrayList<DataValue> aName = rule.getData(); setNameText(aName); setMeaningText(aName); setPronounciationText(aName); return rule; } catch (Exception e) { Logging.errorPrint(e.getMessage(), e); return null; } }