Example #1
0
  /**
   * 检查填写的信息
   *
   * @return
   */
  private boolean checkInputInfo() {
    String objDs = (String) dataSourceCbx.getValue();
    if (Common.isNullStr(objDs)) {
      new MessageBox(calcColumnDialog, "请选择数据源!", MessageBox.MESSAGE, MessageBox.BUTTON_OK).show();
      return false;
    }
    String objField = (String) cbxFieldName.getValue();
    if (Common.isNullStr(objField)) {
      new MessageBox(calcColumnDialog, "请选择一字段!", MessageBox.MESSAGE, MessageBox.BUTTON_OK).show();
      return false;
    }

    String objCompare = (String) cbxCompare.getValue();
    if (Common.isNullStr(objCompare)) {
      new MessageBox(calcColumnDialog, "请指定比较类型!", MessageBox.MESSAGE, MessageBox.BUTTON_OK).show();
      return false;
    }
    String objValue = (String) cbxWhereValue.getValue();
    if (Common.isNullStr(objValue)) {
      new MessageBox(calcColumnDialog, "请指定比较值!", MessageBox.MESSAGE, MessageBox.BUTTON_OK).show();
      return false;
    }

    return true;
  }
Example #2
0
    public String toString() {

      XMLData aData = (XMLData) calcColumnDialog.getXmlDsFieldToName().get(aCal.getSourceID());
      if (aData == null) return "";
      String fieldName = (String) aData.get(aCal.getSourceColID());
      String oper = CompareType.getComparTypeName(aCal.getCompareType());
      String join = "";
      if (!isFirstNode) {
        if (aCal.getJoinBefore() == null) {
          join = "";
        } else {
          join = frdoType.getRefModel().getNameByValue(aCal.getJoinBefore()).substring(0, 2);
        }
      }

      // String sSourceName = definePub.getDataSourceNameWithID(
      // calcColumnDialog.getQuerySource(), aCal.getSourceID());
      String result = "";
      if (!Common.isNullStr(join)) {
        result = result + join + " ";
      }

      if (aCal instanceof ICustomStatisticCaliber) {
        if (((ICustomStatisticCaliber) aCal).getLParenthesis() != null) {
          result = result + ((ICustomStatisticCaliber) aCal).getLParenthesis();
        }
      }

      if (!Common.isNullStr(fieldName)) {
        result = result + fieldName + "   ";
      }
      if (!Common.isNullStr(oper)) {
        result = result + oper + "   ";
      }
      result = result + aCal.getValue();

      if (aCal instanceof ICustomStatisticCaliber) {
        if (((ICustomStatisticCaliber) aCal).getRParenthesis() != null) {
          result = result + ((ICustomStatisticCaliber) aCal).getRParenthesis();
        }
      }

      return result;
      // join + " "
      // + sSourceName + "."
      // + fieldName + " " + oper + " " + aCal.getValue();

    }
Example #3
0
    public void valueChanged(TreeSelectionEvent arg0) {

      DefaultMutableTreeNode curTreeNode =
          (DefaultMutableTreeNode) ((MyTree) arg0.getSource()).getLastSelectedPathComponent();
      if (curTreeNode == null) return;

      if (!(curTreeNode.getUserObject() instanceof Caliber)) {
        return;
      }
      Caliber cal = (Caliber) curTreeNode.getUserObject();

      // 数据源组合框
      dataSourceCbx.setValue(cal.getACal().getSourceID());

      // 根据字段列名得到字段类型
      // cbxFieldName.setSelectedIndex(-1);
      JComboBox cbxFieldNameTmp = (JComboBox) cbxFieldName.getEditor();
      int count = cbxFieldNameTmp.getItemCount();
      String value;
      for (int i = 0; i < count; i++) {
        value = ((FComboBoxItem) cbxFieldNameTmp.getItemAt(i)).getValue().toString();
        if (value.substring(0, value.indexOf(":")).equals(cal.getACal().getSourceColID())) {
          cbxFieldName.setSelectedIndex(i);
          break;
        }
      }

      // 字段名称组合框
      // cbxFieldName.setValue(cal.getACal().getSourceColID());
      // 比较类型
      cbxCompare.setValue(cal.getACal().getCompareType());

      // 根据sFieldEname返回字段类型
      String sFieldTyp = getFieldType();
      // 根据字段类型判断参数加不加引号(')
      // 条件值
      if (DefinePub.checkCharVal(sFieldTyp)) {
        String paraValue = cal.getACal().getValue();
        // 判断是不是in或not in比较符
        if (CompareType.IN_TYPE.equalsIgnoreCase(cal.getACal().getCompareType())
            || CompareType.NOTIN_TYPE.equalsIgnoreCase(cal.getACal().getCompareType())) {
          // 去掉左右括号
          paraValue = paraValue.substring(1, paraValue.length() - 1);
          // 去掉逗号旁的引号
          paraValue = paraValue.replaceAll("','", ",");
        }
        // 去掉最外层引号
        cbxWhereValue.setValue(paraValue.substring(1, paraValue.length() - 1));

      } else {
        cbxWhereValue.setValue(cal.getACal().getValue());
      }

      // 定义条件类型
      if (!Common.isNullStr(cal.getACal().getJoinBefore()))
        frdoType.setValue(cal.getACal().getJoinBefore());
    }
Example #4
0
 public Object populate(Object target, Field field, Object value, int arrayIndex, String format)
     throws Exception {
   String s = value.toString();
   if (Common.isNullStr(s)) {
     return null;
   }
   if (Formatters.isHexNumber(s)) {
     return Short.decode(s);
   }
   return new Short(
       ((Number) super.populate(target, field, value, arrayIndex, format)).shortValue());
 }
Example #5
0
  /**
   * 根据列表和字段名,组织语句
   *
   * @param lstValue
   * @param sFieldName
   * @return
   */
  public static void addRefValue(
      FComboBox combox, List lstValue, String codeField, String nameField) {
    combox.removeAllItems();

    if (lstValue != null) {
      String value = "";
      for (Iterator it = lstValue.iterator(); it.hasNext(); ) {
        XMLData data = (XMLData) it.next();
        if (!Common.isNullStr(value)) {
          value += "+";
        }
        value = value + data.get(codeField).toString() + "#" + data.get(nameField).toString();
      }
      combox.setRefModel(value);
    }
  }