예제 #1
0
  public boolean validateInput() {

    String left = textField.getText();
    if (StringUtils.isBlank(left)) {
      MessageDialogs.alert("WSCA0006");
      return false;
    }
    int leftColumnNumber = Integer.parseInt(left);

    if (leftColumnNumber <= 0) {
      MessageDialogs.alert("WSCA0007", SCBundle.get("key.columnNumber"));
      return false;
    }

    CellValue l = new CellValue(leftColumnNumber);

    String[] right = getRight();

    boolean columnVal =
        lowerPanel.isVisible() && colValCheckBox.isEnabled() && colValCheckBox.isSelected();
    boolean caseSensitive =
        lowerPanel.isVisible() && casecheckBox.isEnabled() && casecheckBox.isSelected();

    Criteria criteria = (Criteria) criteriaCombo.getSelectedItem();

    FilterConditionItem filterConditionItem;
    switch (criteria) {
      case IS_EMPTY:
      case IS_NOT_EMPTY:
      case IS_A_NUMERIC:
      case IS_NOT_A_NUMERIC:
      case EXISTS:
      case DOES_NOT_EXISTS:
        filterConditionItem = new FilterConditionItem(l, criteria);
        break;
      case MATCHES_THE_REGEX_OF:
        Regex regex = new Regex(right[0], caseSensitive);
        if (!regex.isValid()) {
          MessageDialogs.alert("WSCA0009", regex.getError());
          return false;
        }
        filterConditionItem =
            new FilterConditionItem(l, criteria, new FixedValue(right[0]), caseSensitive);
        break;
      default:
        IValue[] r = new IValue[right.length];
        for (int i = 0; i < r.length; i++) {
          if (columnVal) {
            if (!com.smoothcsv.commons.utils.StringUtils.isNumber(right[i])) {
              MessageDialogs.alert("WSCA0008", SCBundle.get("key.columnNumber"));
              return false;
            }
            int ri = Integer.parseInt(right[i]);
            if (ri <= 0) {
              MessageDialogs.alert("WSCA0007", SCBundle.get("key.columnNumber"));
              return false;
            }
            r[i] = new CellValue(ri);
          } else {
            switch (criteria) {
              case IS_A_NUMBER_GREATER_THAN:
              case IS_A_NUMBER_LESS_THAN:
              case IS_A_NUMBER_EQUAL_TO_OR_GREATER_THAN:
              case IS_A_NUMBER_EQUAL_TO_OR_LESS_THAN:
                if (!StringUtils.isNumeric(right[i])) {
                  MessageDialogs.alert("WSCA0010");
                  return false;
                }
                break;
              default:
                break;
            }
            r[i] = new FixedValue(right[i]);
          }
        }
        filterConditionItem = new FilterConditionItem(l, criteria, r, caseSensitive);
        break;
    }

    this.filterConditionItem = filterConditionItem;

    return true;
  }
 @Override
 protected String convert(String s) {
   return StringUtils.decamelize(s);
 }