Ejemplo n.º 1
0
  public ColWhereSetPnl(final CalcColumnDialog calcColumnDialog) {
    this.calcColumnDialog = calcColumnDialog;

    // 数据源组合框
    dataSourceCbx = new MyFComboBox("数据源:", calcColumnDialog.getQuerySource());
    ((JComboBox) dataSourceCbx.getComponent(1)).addItemListener(new SelectItemListener());

    // 字段名
    FLabel fieldNameLbl = new FLabel();
    fieldNameLbl.setTitle("字段名:");
    // 升降序选择
    FLabel operateLbl = new FLabel();
    operateLbl.setText("操作:");
    // 条件值
    FLabel whereValueLbl = new FLabel();
    whereValueLbl.setText("值:");

    // 字段名称组合框
    cbxFieldName = new FComboBox();
    cbxFieldName.setTitleVisible(false);
    ((JComboBox) cbxFieldName.getComponent(1))
        .addItemListener(
            new ItemListener() {

              public void itemStateChanged(ItemEvent arg0) {
                if (cbxFieldName.getValue() == null) {
                  return;
                }

                String sFieldTyp = getFieldType();
                // 判断字段类型,如果是数值型包含和不包含不显示
                if (DefinePub.checkCharVal(sFieldTyp)) {
                  cbxCompare.setRefModel(CompareType.COMPARE_TYPE);
                } else {
                  cbxCompare.setRefModel(CompareType.COMPARE_TYPE_NUM);
                }
                cbxCompare.setSelectedIndex(-1);
                // 得到基础信息选择列的值,根据报表id和ename值
                if (!Common.isNullStr(dataSourceCbx.getValue().toString())
                    && !Common.isNullStr(cbxFieldName.getValue().toString())) {
                  String sFeildEname = cbxFieldName.getValue().toString();
                  sFeildEname = sFeildEname.substring(0, sFeildEname.indexOf(":"));

                  List lstInputValue = null;
                  try {
                    lstInputValue =
                        DefineReportI.getMethod()
                            .getBasSelectInputValue(
                                dataSourceCbx.getValue().toString(), sFeildEname);
                  } catch (Exception e) {
                    e.printStackTrace();
                    new MessageBox(
                            calcColumnDialog,
                            "错误信息:" + e.getMessage(),
                            MessageBox.ERROR,
                            MessageBox.BUTTON_OK)
                        .show();
                  }
                  cbxWhereValue.setEditable(true);
                  addRefValue(cbxWhereValue, lstInputValue, IDefineReport.CODE, IDefineReport.NAME);
                  cbxWhereValue.setSelectedIndex(-1);
                } else {
                  cbxWhereValue.removeAllItems();
                }
              }
            });

    // 比较类型
    cbxCompare = new FComboBox();
    cbxCompare.setTitleVisible(false);
    cbxCompare.setRefModel(CompareType.COMPARE_TYPE);
    cbxCompare.setSelectedIndex(-1);

    // 条件值
    // txtWhereValue = new FTextField(false);
    cbxWhereValue = new FComboBox();
    ((JComboBox) cbxWhereValue.getEditor()).setEditable(true);
    cbxWhereValue.setTitleVisible(false);

    // 定义条件面板
    FPanel orderPnl = new FPanel();
    orderPnl.setLayout(new RowPreferedLayout(5));

    FLabel flblEmpty = new FLabel();
    // 数据来源
    orderPnl.addControl(dataSourceCbx, new TableConstraints(1, 2, false, true));
    orderPnl.addControl(flblEmpty, new TableConstraints(1, 3, false, true));
    // Label
    orderPnl.addControl(fieldNameLbl, new TableConstraints(1, 2, false, true));
    orderPnl.addControl(operateLbl, new TableConstraints(1, 1, false, true));
    orderPnl.addControl(whereValueLbl, new TableConstraints(1, 2, false, true));
    // 编码框
    orderPnl.addControl(cbxFieldName, new TableConstraints(1, 2, false, true));
    orderPnl.addControl(cbxCompare, new TableConstraints(1, 1, false, true));
    orderPnl.add(cbxWhereValue, new TableConstraints(1, 2, false, true));

    // 定义条件类型
    frdoType = new FRadioGroup("", FRadioGroup.HORIZON);
    frdoType.setRefModel(JoinBefore.JOIN_BEFORE);
    frdoType.setTitleVisible(false);
    frdoType.setValue("and");

    // 增加、修改按钮
    FButton addBtn = new FButton("addBtn", "增加");
    addBtn.addActionListener(new AddActionListener());

    FButton modifyBtn = new FButton("addBtn", "修改");
    modifyBtn.addActionListener(new ModifyActionListener());
    // FFlowLayoutPanel editBtnPnl = new FFlowLayoutPanel();
    FPanel editBtnPnl = new FPanel();
    RowPreferedLayout rEditBtnLay = new RowPreferedLayout(2);
    rEditBtnLay.setColumnGap(1);
    rEditBtnLay.setColumnWidth(70);
    editBtnPnl.setLayout(rEditBtnLay);
    // editBtnPnl.setAlignment(FlowLayout.RIGHT);
    editBtnPnl.addControl(addBtn, new TableConstraints(1, 1, false, false));
    editBtnPnl.addControl(modifyBtn, new TableConstraints(1, 1, false, false));

    FLabel flbEmpty = new FLabel();
    FPanel fpnlEdit = new FPanel();
    RowPreferedLayout rEditLay = new RowPreferedLayout(4);
    rEditLay.setColumnWidth(140);
    fpnlEdit.setLayout(rEditLay);

    fpnlEdit.addControl(flbEmpty, new TableConstraints(1, 1, true, true));
    fpnlEdit.addControl(frdoType, new TableConstraints(1, 2, true, true));
    fpnlEdit.addControl(editBtnPnl, new TableConstraints(1, 1, true, false));

    // 定义条件树
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("过滤条件");
    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    treWhere = new MyTree(treeModel);
    // 变换树节点,刷新显示框信息事件
    treWhere.addTreeSelectionListener(new WhereTreeSelectionListener());
    JScrollPane fpnltalRela = new JScrollPane(treWhere);

    // 过滤条件按钮面板
    FPanel btnPnl = new BtnPnl();

    JTabbedPane pnlWhere = new JTabbedPane();
    RowPreferedLayout rLay = new RowPreferedLayout(2);
    FPanel pnlCol = new FPanel();
    pnlCol.setLayout(rLay);
    rLay.setColumnWidth(70);
    rLay.setColumnGap(1);

    pnlCol.addControl(orderPnl, new TableConstraints(3, 2, false, true));
    pnlCol.addControl(fpnlEdit, new TableConstraints(1, 2, false, true));
    pnlCol.add(fpnltalRela, new TableConstraints(1, 1, true, true));
    pnlCol.addControl(btnPnl, new TableConstraints(1, 1, true, false));

    txtSql = new FTextArea();
    txtSql.setTitleVisible(false);
    txtSql.setEditable(false);

    FScrollPane spnlSql = new FScrollPane(txtSql);

    pnlWhere.add("列条件信息", pnlCol);
    pnlWhere.add("分栏设置条件", spnlSql);
    this.setLayout(new BorderLayout());
    this.add(pnlWhere, BorderLayout.CENTER);
  }
Ejemplo n.º 2
0
    public BtnPnl() {
      // 删除排序条件按钮
      FButton delBtn = new FButton("delBtn", "删除");
      delBtn.addActionListener(new DelActionListener());
      // 上移按钮
      FButton upBtn = new FButton("upBtn", "上移");
      upBtn.addActionListener(new UpActionListener());
      // 下移按钮
      FButton downBtn = new FButton("downBtn", "下移");
      downBtn.addActionListener(new DownActionListener());

      // 左括号按钮
      FButton lParenthesisBtn = new FButton("lParenthesisBtn", "左括号");
      lParenthesisBtn.addActionListener(new LParenthesisActionListener());
      // 右括号按钮
      FButton rParenthesisBtn = new FButton("rParenthesisBtn", "右括号");
      rParenthesisBtn.addActionListener(new RParenthesisActionListener());
      // 删括号按钮
      FButton delParenthesisBtn = new FButton("delParenthesisBtn", "删括号");
      delParenthesisBtn.addActionListener(new DelParenthesisActionListener());

      this.setLayout(new RowPreferedLayout(1));
      this.addControl(delBtn, new TableConstraints(1, 1, false, true));
      this.addControl(upBtn, new TableConstraints(1, 1, false, true));
      this.addControl(downBtn, new TableConstraints(1, 1, false, true));
      this.addControl(lParenthesisBtn, new TableConstraints(1, 1, false, true));
      this.addControl(rParenthesisBtn, new TableConstraints(1, 1, false, true));
      this.addControl(delParenthesisBtn, new TableConstraints(1, 1, false, true));
    }