Пример #1
0
  /**
   * 参数条件树上增加节点
   *
   * @param conditionNodeObj
   */
  private TreeNode addParaTreNode(IStatisticCaliber aCal) {
    // 得到父节点
    DefaultTreeModel treeModel = (DefaultTreeModel) treWhere.getModel();
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
    // 判断增加的父节点是否已存在,默认父节点不存在
    boolean sFlag = false;
    IStatisticCaliber curCal = null;
    DefaultMutableTreeNode curNode = null;
    int iChildCount = root.getChildCount();
    // 得到根节点下的子节点
    for (int i = 0; i < iChildCount; i++) {
      curNode = (DefaultMutableTreeNode) root.getChildAt(i);
      curCal = ((Caliber) curNode.getUserObject()).getACal();
      if (aCal.getSourceID().equals(curCal.getSourceID())) {
        sFlag = true;
        break;
      }
    }

    DefaultMutableTreeNode ANode = null;
    if (!sFlag) { // 父节点不存在
      // 增加父节点
      ICustomStatisticCaliber parCal = new MySummaryStatisticCaliberImpl();
      parCal.setSourceID(aCal.getSourceID());
      // 数据源名称
      String sDataSourceName = dataSourceCbx.getRefModel().getNameByValue(aCal.getSourceID());
      parCal.setValue(sDataSourceName);
      ANode = new DefaultMutableTreeNode(new Caliber(parCal));
      treeModel.insertNodeInto(ANode, root, root.getChildCount());
      curNode = (DefaultMutableTreeNode) root.getLastChild();
    }
    ANode = new DefaultMutableTreeNode(new Caliber(aCal));
    treeModel.insertNodeInto(ANode, curNode, curNode.getChildCount());
    return ANode;
  }
Пример #2
0
    public void actionPerformed(ActionEvent arg0) {
      DefaultMutableTreeNode curTreeNode =
          (DefaultMutableTreeNode) treWhere.getLastSelectedPathComponent();
      if (curTreeNode == null || !curTreeNode.isLeaf()) return;

      Caliber cal = (Caliber) curTreeNode.getUserObject();
      IStatisticCaliber myCaliber = cal.getACal();
      if (!(myCaliber instanceof ICustomStatisticCaliber)) {
        ICustomStatisticCaliber caliberTmp = new MySummaryStatisticCaliberImpl();
        caliberTmp.setAddSQL(myCaliber.getAddSQL());
        caliberTmp.setCompareType(myCaliber.getCompareType());
        caliberTmp.setJoinBefore(myCaliber.getJoinBefore());
        caliberTmp.setSourceColID(myCaliber.getSourceColID());
        caliberTmp.setSourceID(myCaliber.getSourceID());
        caliberTmp.setValue(myCaliber.getValue());
        caliberTmp.setCaliberID(DefinePub.getRandomUUID());
        cal.setACal(caliberTmp);
      }

      myCaliber = cal.getACal();
      if (((ICustomStatisticCaliber) myCaliber).getRParenthesis() != null) {
        ((ICustomStatisticCaliber) myCaliber)
            .setRParenthesis(((ICustomStatisticCaliber) cal.getACal()).getRParenthesis() + ")");
      } else {
        ((ICustomStatisticCaliber) myCaliber).setRParenthesis(")");
      }
      curTreeNode.setUserObject(cal);
      // 刷新节点中文名称
      refreshNodeChName(curTreeNode);
      // 刷新节点
      ((DefaultTreeModel) treWhere.getModel()).nodeChanged(curTreeNode);
    }
Пример #3
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);
    }
Пример #4
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();

    }
Пример #5
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);
    }