private RuleSet loadRuleSet(Element ruleSet) throws DataConversionException { RuleSet rs = new RuleSet( allVars, ruleSet.getAttributeValue("title"), ruleSet.getAttributeValue("id"), ruleSet.getAttributeValue("usage")); java.util.List<?> elements = ruleSet.getChildren(); ListIterator<?> elementsIterator = elements.listIterator(); int num = 0; while (elementsIterator.hasNext()) { Element child = (Element) elementsIterator.next(); String elementName = child.getName(); if (elementName.equals("CATEGORY")) { loadCategory(child, rs); } else if (elementName.equals("RULE")) { rs.add(loadRule(child, rs.getId() + num)); } num++; } return rs; }
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 void loadCatalogDD() { try { String catKey = (String) cbCategory.getSelectedItem(); String sexKey = (String) cbSex.getSelectedItem(); RuleSet oldRS = (RuleSet) cbCatalog.getSelectedItem(); String catalogKey = ""; if (oldRS != null) { catalogKey = oldRS.getTitle(); } List<RuleSet> cats = categories.get(catKey); List<RuleSet> sexes = categories.get("Sex: " + sexKey); List<RuleSet> join = new ArrayList<>(); join.addAll(cats); join.retainAll(sexes); Collections.sort(join, new DataElementComperator()); Vector<RuleSet> catalogs = new Vector<>(); int oldSelected = -1; int n = 0; for (int i = 0; i < join.size(); i++) { RuleSet rs = join.get(i); if (rs.getUsage().equals("final")) { catalogs.add(rs); if (rs.getTitle().equals(catalogKey)) { oldSelected = n; } n++; } } DefaultComboBoxModel catalogModel = new DefaultComboBoxModel(catalogs); cbCatalog.setModel(catalogModel); if (oldSelected >= 0) cbCatalog.setSelectedIndex(oldSelected); } catch (Exception e) { Logging.errorPrint(e.getMessage(), e); } }
/** * 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; } }