Example #1
0
    public void actionPerformed(ActionEvent arg0) {
      DefaultMutableTreeNode curTreeNode =
          (DefaultMutableTreeNode) treWhere.getLastSelectedPathComponent();
      if (curTreeNode == null || !curTreeNode.isLeaf()) return;

      // 检查信息是否填写完整
      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 + "'";
      } else {
        // 检查一下是不是数字
        try {
          Double.parseDouble(objValue);
        } catch (Exception e) {
          new MessageBox(calcColumnDialog, "值不是合法的数字!", MessageBox.MESSAGE, MessageBox.BUTTON_OK)
              .show();
          return;
        }
      }

      DefaultMutableTreeNode defaultMutableTreeNode =
          (DefaultMutableTreeNode) treWhere.getLastSelectedPathComponent();
      if (defaultMutableTreeNode == null) return;
      IStatisticCaliber asCal = ((Caliber) defaultMutableTreeNode.getUserObject()).getACal();

      asCal.setSourceID(objDs.toString());
      asCal.setSourceColID(arrField[0]);
      asCal.setCompareType(objCompare.toString());
      asCal.setValue(objValue.toString());
      asCal.setJoinBefore(frdoType.getValue().toString());

      defaultMutableTreeNode.setUserObject(new Caliber(asCal));
      // 刷新节点中文名称
      refreshNodeChName(defaultMutableTreeNode);
      // 刷新节点
      ((DefaultTreeModel) treWhere.getModel()).nodeChanged(defaultMutableTreeNode);
    }
Example #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);
    }