Example #1
0
  private void addTagForClosingHBox(
      Hashtable<String, PosLineCol> hashPosLineColByLanguage,
      Hashtable<String, CMapElement> hashMapsByLanguage) {
    // Enum all Maps in every language and add the item into the map
    Set<Entry<String, CMapElement>> set = hashMapsByLanguage.entrySet();
    Iterator<Entry<String, CMapElement>> iter = set.iterator();
    while (iter.hasNext()) {
      Entry<String, CMapElement> entry = iter.next();
      String csLg = entry.getKey();
      CMapElement eMap = entry.getValue();
      PosLineCol posLineCol = hashPosLineColByLanguage.get(csLg);

      CFieldElement eField = new CFieldElement("", 0);
      boolean bAdd = eField.setAsClosingHBox(posLineCol);
      if (bAdd) eMap.AddElement(eField);
    }
  }
Example #2
0
  private CBMSParser parseRESResource(Tag tagForm) {
    Hashtable<String, CMapElement> hashMapsByLanguage = new Hashtable<String, CMapElement>();
    Hashtable<String, PosLineCol> hashPosLineColByLanguage = new Hashtable<String, PosLineCol>();

    CBMSParser BMSParser = new CBMSParser();
    CMapSetElement eMapSet = new CMapSetElement("", 0);
    BMSParser.setRoot(eMapSet);

    String csName = tagForm.getVal("name");
    csName = csName.toUpperCase();

    eMapSet.loadFromRES(csName);

    csName = csName.substring(0, 4) + csName.substring(5);

    String csLanguages = tagForm.getVal("allLanguages");
    StringRef rcsLanguages = new StringRef(csLanguages);
    String csLanguage = StringUtil.extractCurrentWord(rcsLanguages, false, ";");
    while (csLanguage != null) {
      CMapElement eMap = new CMapElement("", 0);
      eMap.loadFromRES(0, csName, csLanguage);
      eMapSet.AddElement(eMap);
      hashMapsByLanguage.put(csLanguage, eMap);

      PosLineCol posLineCol = new PosLineCol();
      hashPosLineColByLanguage.put(csLanguage, posLineCol);

      if (rcsLanguages == null) {
        csLanguage = null;
        continue;
      }
      csLanguage = StringUtil.extractCurrentWord(rcsLanguages, false, ";");
      if (csLanguage == null) {
        csLanguage = rcsLanguages.get();
        rcsLanguages = null;
      }
      csLanguage = StringUtil.trimLeft(csLanguage, ';');
    }
    // Skip <pfkeydefine>
    // Skip <pfkeyaction>
    Tag tagFormBody = tagForm.getChild("formbody");
    if (tagFormBody != null) {
      Tag tagVBox = tagFormBody.getChild("vbox");
      if (tagVBox != null) {
        // Enum all tag hbox
        TagCursor curHBox = new TagCursor();
        Tag tagHBox = tagVBox.getFirstChild(curHBox, "hbox");
        while (tagHBox != null) {
          // Enum all edits
          TagCursor curEdit = new TagCursor();
          Tag tagEditTitle = tagHBox.getFirstChild(curEdit);
          while (tagEditTitle != null) {
            // Enum all Maps in every language and add the item into the map
            Set<Entry<String, CMapElement>> set = hashMapsByLanguage.entrySet();
            Iterator<Entry<String, CMapElement>> iter = set.iterator();
            while (iter.hasNext()) {
              Entry<String, CMapElement> entry = iter.next();
              String csLg = entry.getKey();
              CMapElement eMap = entry.getValue();
              PosLineCol posLineCol = hashPosLineColByLanguage.get(csLg);

              CFieldElement eField = new CFieldElement("", 0);
              boolean bToAdd = eField.loadTagParameters(posLineCol, tagEditTitle, csLg);
              if (bToAdd) eMap.AddElement(eField);
            }

            tagEditTitle = tagHBox.getNextChild(curEdit);
          }
          // Found </hbox>
          addTagForClosingHBox(hashPosLineColByLanguage, hashMapsByLanguage);
          tagHBox = tagVBox.getNextChild(curHBox);
        }
      }
    }

    return BMSParser;
  }