コード例 #1
0
ファイル: InjectorDialog.java プロジェクト: panbasten/imeta
  @Override
  public JSONObject open() throws ImetaException {
    try {
      JSONObject rtn = new JSONObject();
      JSONArray cArr = new JSONArray();
      String id = this.getId();

      InjectorMeta step = (InjectorMeta) super.getStep();
      // 得到form
      this.columnFormDataMeta = new ColumnFormDataMeta(id, null);
      this.columnFormMeta = new ColumnFormMeta(columnFormDataMeta);

      // 得到步骤名称
      this.name =
          new LabelInputMeta(
              id + ".name",
              "步骤名称",
              null,
              null,
              "步骤名称必须填写",
              super.getStepMeta().getName(),
              null,
              ValidateForm.getInstance().setRequired(false));
      this.name.setSingle(true);

      // 字段

      this.fields = new LabelGridMeta(id + "_fields", "字段", 200);

      GridHeaderDataMeta fieldTypeDataMeta =
          new GridHeaderDataMeta(id + "_fields.type", "类型", null, false, 100);
      fieldTypeDataMeta.setOptions(
          super.getOptionsByStringArrayWithNumberValue(ValueMetaInterface.typeCodes, false));

      this.fields.addHeaders(
          new GridHeaderDataMeta[] {
            new GridHeaderDataMeta(
                id + "_fields.fieldId", "#", GridHeaderDataMeta.HEADER_TYPE_NUMBER, false, 50),
            new GridHeaderDataMeta(id + "_fields.name", "字段名称", null, false, 80),
            fieldTypeDataMeta,
            new GridHeaderDataMeta(id + "_fields.length", "长度", null, false, 50),
            new GridHeaderDataMeta(id + "_fields.precision", "精度", null, false, 50),
          });
      this.fields.setSingle(true);
      this.fields.setHasBottomBar(true);
      this.fields.setHasAdd(true, true, "jQuery.imeta.steps.injector.btn.injectorAdd");
      this.fields.setHasDelete(true, true, "jQuery.imeta.parameter.fieldsDelete");

      String[] values = step.getName();
      if (values != null && values.length > 0)
        for (int i = 0; i < values.length; i++) {

          this.fields.addRow(
              new Object[] {
                String.valueOf(i + 1),
                new GridCellDataMeta(null, step.getName()[i], GridCellDataMeta.CELL_TYPE_INPUT),
                new GridCellDataMeta(
                    null, String.valueOf(step.getType()[i]), GridCellDataMeta.CELL_TYPE_SELECT),
                new GridCellDataMeta(
                    null, String.valueOf(step.getLength()[i]), GridCellDataMeta.CELL_TYPE_INPUT),
                new GridCellDataMeta(
                    null, String.valueOf(step.getPrecision()[i]), GridCellDataMeta.CELL_TYPE_INPUT)
              });
        }

      // 装载到form
      columnFormMeta.putFieldsetsContent(new BaseFormMeta[] {this.name, this.fields});

      // 确定,取消
      columnFormMeta.putFieldsetsFootButtons(
          new ButtonMeta[] {super.getOkBtn(), super.getCancelBtn()});

      cArr.add(columnFormMeta.getFormJo());

      rtn.put("items", cArr);
      rtn.put("title", super.getStepMeta().getName());

      return rtn;
    } catch (Exception ex) {
      throw new ImetaException(ex.getMessage(), ex);
    }
  }
コード例 #2
0
  @Override
  public JSONObject open() throws ImetaException {
    try {
      JSONObject rtn = new JSONObject();
      JSONArray cArr = new JSONArray();
      String id = this.getId();

      ColumnExistsMeta step = (ColumnExistsMeta) super.getStep();
      // 得到form
      this.columnFormDataMeta = new ColumnFormDataMeta(id, null);
      this.columnFormMeta = new ColumnFormMeta(columnFormDataMeta);

      // 得到步骤名称
      this.name =
          new LabelInputMeta(
              id + ".name",
              "步骤名称",
              null,
              null,
              "步骤名称必须填写",
              super.getStepName(),
              null,
              ValidateForm.getInstance().setRequired(true));
      this.name.setSingle(true);

      // 得到数据库连接
      this.connectionId =
          new LabelSelectMeta(
              id + ".connectionId",
              "数据库连接",
              null,
              null,
              null,
              String.valueOf((step.getDatabase() != null) ? step.getDatabase().getID() : ""),
              null,
              super.getConnectionLine());
      this.connectionId.setSingle(true);

      // 得到结构名称

      this.schemaname =
          new LabelInputMeta(
              id + ".schemaname",
              "结构名称",
              null,
              null,
              "结构名称必须填写",
              step.getSchemaname(),
              null,
              ValidateForm.getInstance().setRequired(true));
      this.schemaname.setSingle(true);

      // 得到表名
      this.tablename =
          new LabelInputMeta(
              id + ".tablename",
              "表名",
              null,
              null,
              "表名必须填写",
              step.getTablename(),
              null,
              ValidateForm.getInstance().setRequired(true));
      this.tablename.setSingle(true);
      this.tablename.setDisabled(!step.isTablenameInField());

      // 表名在域中istablenameInfield
      this.istablenameInfield =
          new LabelInputMeta(
              id + ".istablenameInfield",
              "表名在域中",
              null,
              null,
              String.valueOf(step.isTablenameInField()),
              null,
              InputDataMeta.INPUT_TYPE_CHECKBOX,
              ValidateForm.getInstance().setRequired(false));
      this.istablenameInfield.setSingle(false);
      this.istablenameInfield.addClick(
          "jQuery.imeta.steps.columnexists.listeners.istablenameInfield");
      // 表名域
      this.tablenamefield =
          new LabelSelectMeta(
              id + ".tablenamefield",
              "表名域",
              null,
              null,
              null,
              step.getDynamicTablenameField(),
              null,
              super.getPrevStepResultFields());
      this.tablenamefield.setSingle(true);
      this.tablenamefield.setDisabled(!step.isTablenameInField());
      this.tablenamefield.setHasEmpty(true);

      // 得到列名
      this.columnnamefield =
          new LabelSelectMeta(
              id + ".columnnamefield",
              "列名域",
              null,
              null,
              null,
              step.getDynamicColumnnameField(),
              null,
              super.getPrevStepResultFields());
      this.columnnamefield.setSingle(true);
      this.columnnamefield.setHasEmpty(true);

      // 得到结果域名
      this.resultfieldname =
          new LabelInputMeta(
              id + ".resultfieldname",
              "结果域名",
              null,
              null,
              "结果域名必须填写",
              step.getResultFieldName(),
              null,
              ValidateForm.getInstance().setRequired(true));
      this.resultfieldname.setSingle(true);

      // 装载到form
      columnFormMeta.putFieldsetsContent(
          new BaseFormMeta[] {
            this.name,
            this.connectionId,
            this.schemaname,
            this.tablename,
            this.istablenameInfield,
            this.tablenamefield,
            this.columnnamefield,
            this.resultfieldname
          });

      columnFormMeta.putFieldsetsFootButtons(
          new ButtonMeta[] {super.getOkBtn(), super.getCancelBtn()});

      cArr.add(columnFormMeta.getFormJo());

      rtn.put("items", cArr);
      rtn.put("title", super.getStepMeta().getName());

      return rtn;
    } catch (Exception ex) {
      throw new ImetaException(ex.getMessage(), ex);
    }
  }