Beispiel #1
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());
    }
Beispiel #2
0
    public void actionPerformed(ActionEvent arg0) {
      // 检查信息是否填写完整
      if (!checkInputInfo()) return;

      String objDs = (String) dataSourceCbx.getValue();
      String objField = (String) cbxFieldName.getValue();
      String objValue = (String) cbxWhereValue.getValue();
      String objCompare = (String) cbxCompare.getValue();

      String[] arrField = objField.split(":");
      String fieldType = arrField[1];
      fieldType = DefinePub.getFieldTypeWithCh(fieldType);
      if (DefinePub.checkCharVal(fieldType)) {
        objValue = "'" + objValue + "'";
        // 判断是不是in或not in比较符
        if (CompareType.IN_TYPE.equalsIgnoreCase(objCompare)
            || CompareType.NOTIN_TYPE.equalsIgnoreCase(objCompare)) {
          objValue = objValue.replaceAll(",", "','");
          objValue = "(" + objValue + ")";
        }
      } else {
        // 检查一下是不是数字
        try {
          Double.parseDouble(objValue);
        } catch (Exception e) {
          new MessageBox(calcColumnDialog, "值不是合法的数字!", MessageBox.MESSAGE, MessageBox.BUTTON_OK)
              .show();
          return;
        }
      }

      IStatisticCaliber asCal = new SummaryStatisticCaliberImpl();
      asCal.setSourceID(objDs.toString());
      asCal.setSourceColID(arrField[0]);
      asCal.setCompareType(objCompare.toString());
      asCal.setValue(objValue.toString());
      asCal.setJoinBefore(frdoType.getValue().toString());
      asCal.setCaliberID(DefinePub.getRandomUUID());
      TreeNode node = addParaTreNode(asCal);

      // 刷新节点中文名称
      refreshNodeChName(node);
      // 定位到新增加的节点
      treWhere.expendTo(node);
    }