コード例 #1
0
 public boolean editGroup(LanguageGroup group, Language language) {
   Element languageElement = this.getLanguageElement(language);
   Element element = factory.getGroupElement(languageElement, group);
   if (element != null) {
     factory.groupToElement(group, element);
     writeDocument();
     return true;
   }
   return false;
 }
コード例 #2
0
  public List<Language> readLangauges() {
    List<Language> list = new ArrayList<Language>();
    Element element;
    Language lang;

    NodeList languages = factory.getListLanguages(this.getLanguagesElement());
    for (int i = 0; i < languages.getLength(); i++) {
      element = (Element) languages.item(i);
      lang = factory.elementToLanguage(element);
      list.add(lang);
    }
    return list;
  }
コード例 #3
0
 private Element getLanguageElement(Language lang) {
   Element languageElement = factory.getLanguageElement(this.getLanguagesElement(), lang);
   if (languageElement == null) {
     languageElement = this.createLanguage(lang);
   }
   return languageElement;
 }
コード例 #4
0
 /**
  * Edits/alters a template in a xml file.
  *
  * @param template template that should be edited
  * @return true if the template was succesfuly edited
  */
 public boolean editTemplate(ConstraintTemplate template, LanguageGroup parent) {
   /* Element languageElement = this.getLanguageElement(template.getLanguage());
   Element element = factory.getTemplateElement(template, languageElement);
   if (element != null) {
     factory.templateToElement(template, element);
     writeDocument();
     return true;
   }
   return false;*/
   Element parentElement = getParentElement(parent, template.getLanguage());
   Element element = factory.getTemplateElement(template, parentElement);
   if (element != null) {
     factory.templateToElement(template, element);
     writeDocument();
     return true;
   }
   return false;
 }
コード例 #5
0
 public void deleteGroup(LanguageGroup group, LanguageGroup parent, Language language) {
   Element languageElement = this.getLanguageElement(language);
   Element parentElement = getParentElement(parent, language);
   Element groupElement = factory.getGroupElement(languageElement, group);
   if (parentElement != null && groupElement != null) {
     parentElement.removeChild(groupElement);
     writeDocument();
   }
 }
コード例 #6
0
  private Element getParentElement(LanguageGroup parent, Language language) {
    Element languageElement = this.getLanguageElement(language);
    Element parentElement = null;
    if (parent == language) {
      parentElement = languageElement;
    } else {
      parentElement = factory.getGroupElement(languageElement, parent);
    }

    return parentElement;
  }
コード例 #7
0
  /**
   * Deletes a template from a xml file.
   *
   * @param template template that should be deleted
   * @return true if the template was succesfuly deleted
   */
  public boolean deleteTemplate(ConstraintTemplate template, LanguageGroup parent) {
    Element parentElement = getParentElement(parent, template.getLanguage());

    Element element = factory.getTemplateElement(template, parentElement);
    if (element != null) {
      this.deleteElement(element, parentElement);
      // factory.deleteElement(element, parentElement);
      writeDocument();
      return true;
    }
    return false;
  }