Пример #1
0
  protected void fillCell(BandData band, XCell xCell)
      throws NoSuchElementException, WrappedTargetException {
    XText xText = as(XText.class, xCell);
    String cellText = xText.getString();
    cellText = cellText.replace("\r\n", "\n"); // just a workaround for Windows \r\n break symbol
    List<String> parametersToInsert = new ArrayList<String>();
    Matcher matcher = UNIVERSAL_ALIAS_PATTERN.matcher(cellText);
    while (matcher.find()) {
      parametersToInsert.add(unwrapParameterName(matcher.group()));
    }
    for (String parameterName : parametersToInsert) {
      XTextCursor xTextCursor = xText.createTextCursor();

      String paramStr = "${" + parameterName + "}";
      int index = cellText.indexOf(paramStr);
      while (index >= 0) {
        xTextCursor.gotoStart(false);
        xTextCursor.goRight((short) (index + paramStr.length()), false);
        xTextCursor.goLeft((short) paramStr.length(), true);

        insertValue(xText, xTextCursor, band, parameterName);
        cellText = formatCellText(xText.getString());

        index = cellText.indexOf(paramStr);
      }
    }
  }
Пример #2
0
    public BandFinder find() {
      bandName = tableName;
      band = rootBand.findBandRecursively(bandName);
      if (band == null) {
        XText xText = tableManager.findFirstEntryInRow(BAND_NAME_DECLARATION_PATTERN, 0);
        if (xText != null) {
          Matcher matcher = BAND_NAME_DECLARATION_PATTERN.matcher(xText.getString());
          if (matcher.find()) {
            bandName = matcher.group(1);
            band = rootBand.findBandRecursively(bandName);
            XTextCursor xTextCursor = xText.createTextCursor();

            xTextCursor.gotoStart(false);
            xTextCursor.goRight((short) matcher.end(), false);
            xTextCursor.goLeft((short) matcher.group().length(), true);

            xText.insertString(xTextCursor, "", true);
          }
        }
      }
      return this;
    }