Example #1
0
  public static TableCellRenderer getColumnRender(ColumnMetaData colinfo) {
    TableCellRenderer dcr = (TableCellRenderer) colinfo.getRender();
    if (dcr != null) return dcr;
    if (colinfo.getColType().equals("B")) {
      dcr = new BlobCellRender();
    } else if (colinfo.getHelpFObj().trim().length() > 0) {
      dcr = new FkeyCellRenderer(colinfo.getFOBJ());
      ((FkeyCellRenderer) dcr).setColumnMetaData(colinfo);
    } else if (colinfo.getHelpClass().trim().length() > 0) {
      dcr = new FkeyCellRenderer(getFObj(colinfo));
      ((FkeyCellRenderer) dcr).setColumnMetaData(colinfo);
    } else if (colinfo.isFKEY()) {
      dcr = new FkeyCellRenderer(colinfo.getFOBJ());
      ((FkeyCellRenderer) dcr).setColumnMetaData(colinfo);
    } else {
      switch (colinfo.getColEditType()) {
        case ColumnMetaData.EL_BOOL:
          dcr = new BoolCellRender("1", "0");
          break;
        case ColumnMetaData.EL_DATE:
          String pattern = colinfo.getEditPattern();
          if (pattern == null || pattern.trim().length() == 0) {
            pattern = "yyyy-MM-dd HH:mm:ss";
            if ("C".equals(colinfo.getColType())) {
              if (colinfo.getColDataLen() == 4) {
                pattern = "yyyy";
              } else if (colinfo.getColDataLen() == 6) {
                pattern = "yyyy-MM";
              } else if (colinfo.getColDataLen() == 8) {
                pattern = "yyyy-MM-dd";
              }
              if (colinfo.getColView() != null && colinfo.getColView().trim().length() > 0) {
                pattern = colinfo.getColView();
              }
              String displayformat =
                  colinfo.getExtAttriValue(
                      "COL_OPT",
                      ESPKeyValueUtil._DEFAULT_CONNECTOR_,
                      ESPKeyValueUtil._DEFAULT_DELIMETER_,
                      "DisplayFormat");
              if (displayformat != null && displayformat.trim().length() > 0) {
                pattern = displayformat;
              }
            } else if ("D".equals(colinfo.getColType())) {
              String colView = colinfo.getColView();
              if (colView.length() > 0) pattern = colView;
            }
          }
          dcr = new DateCellRenderer(pattern);
          break;
        case ColumnMetaData.EL_TIME:
          String pattern1 = colinfo.getEditPattern();
          if (pattern1 == null || pattern1.trim().length() == 0) pattern1 = "HH:mm:ss";
          dcr = new TimeCellRenderer(pattern1);
          break;
        case ColumnMetaData.EL_FLOAT:
          dcr = new NumberCellRenderer();
          ((NumberCellRenderer) dcr).setColumnMetaData(colinfo);
          break;
        case ColumnMetaData.EL_POPUP:
          {
            Hashtable hash = new Hashtable();
            String view = colinfo.getColView();
            // 如果是变量(脚本对象),则获取真正的掩码
            if (view != null && view.equals("@POUP@")) {
              //                        try {
              //                            BIZPoupScript poupScript = new BIZPoupScript(
              //                                    colinfo.getString("OBJ_ID", null),
              //                                    colinfo.getString("COL_ID", null),
              //                                    colinfo.getString("ServerName", ""));
              //                            Object obj =
              // poupScript.getScriptManager().runFunction(poupScript,colinfo.getString("COL_ID",
              // null));
              //                            if (obj != null && obj instanceof String) {
              //                                view = (String) obj;
              //                            } else {
              //                                view = "";
              //                            }
              //                        } catch (Exception ex) {
              //                            ex.printStackTrace();
              //                        }
            }
            String[] item = view.split(";");
            for (int i = 0; i < item.length; i++) {
              String[] v = item[i].split(":");
              if (v.length == 1) return null;
              hash.put(v[0], v[1]);
            }
            dcr = new EnumCellRenderer(hash);
            break;
          }
        case ColumnMetaData.EL_WINDOW:
          dcr = new PassWordCellRender();
          break;
        case ColumnMetaData.EL_PRO_BAR:
          dcr = new ProgressCellRender();
          break;
        case ColumnMetaData.EL_SELFENUM:
          {
            Hashtable hash = new Hashtable();
            String view = colinfo.getString("COL_EDITVIEW", null);
            if (view == null) view = colinfo.getColView();
            String[] item = view.split(";");
            for (int i = 0; i < item.length; i++) {
              if (item[i] == null || item[i].indexOf(":") < 0) continue;
              String s1 = item[i].substring(0, item[i].indexOf(":"));
              String s2 = item[i].substring(item[i].indexOf(":") + 1);
              hash.put(s1, s2);
            }
            dcr = new SelfEnumCellRenderer(hash);

            break;
          }
        case ColumnMetaData.EL_STRING:
          dcr = new StringCellRenderer();
          break;
        case ColumnMetaData.EL_TEXT:
          dcr = new TextCellRenderer();
          break;
        default:
          break;
      }
    }
    colinfo.setRender(dcr);
    return dcr;
  }
Example #2
0
  public static DefaultCellEditor getColumnEditor(ColumnMetaData colinfo) {
    DefaultCellEditor dce = (DefaultCellEditor) colinfo.getEditor();
    if (dce != null) return dce;
    if (colinfo.getHelpFObj().trim().length() > 0) {
      dce = new FKeyCellEditor(colinfo);
    } else if (colinfo.getHelpClass().trim().length() > 0) {
      IHelpCallBack callback = null;
      try {
        callback = (IHelpCallBack) Class.forName(colinfo.getHelpClass().trim()).newInstance();
        callback.setColumnMetaData(colinfo);
        colinfo.setLostValue("IHelpCallback", callback);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      dce = new SelfHelpCellEditor(callback, colinfo);
    } else if (colinfo.isFKEY()) {
      dce = new FKeyCellEditor(colinfo);
    } else {
      switch (colinfo.getColEditType()) {
        case ColumnMetaData.EL_STRING:
          dce = new StringCellEditor(colinfo);
          break;
        case ColumnMetaData.EL_TEXT:
          dce = new TextCellEditor(colinfo);
          break;
        case ColumnMetaData.EL_BOOL:
          dce = new BoolCellEditor();
          break;
        case ColumnMetaData.EL_DATE:
          dce = new DateCellEditor();
          ((DateCellEditor) dce).setColumnMetaData(colinfo);
          break;
        case ColumnMetaData.EL_TIME:
          dce = new TimeCellEditor(colinfo, 0);
          ((TimeCellEditor) dce).setColumnMetaData(colinfo);
          break;
        case ColumnMetaData.EL_FLOAT:
          dce = new NumberCellEditor();
          break;
        case ColumnMetaData.EL_POPUP:
          {
            Map hash = new Hashtable();
            String view = colinfo.getString("COL_EDITVIEW", null);
            if (view == null) view = colinfo.getColView();
            // 如果是变量(脚本对象),则获取真正的掩码
            if (view != null && view.equals("@POUP@")) {
              try {
                //                            BIZPoupScript poupScript = new BIZPoupScript(
                //                                    colinfo.getString("OBJ_ID", null),
                //                                    colinfo.getString("COL_ID", null),
                //                                    colinfo.getString("ServerName", ""));
                //                            Object obj = poupScript.getReturnObject();
                //                            if (obj != null && obj instanceof String) {
                //                                view = (String) obj;
                //                            } else {
                //                                view = "";
                //                            }
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
            String[] item = view.split(";");
            List keyList = new ArrayList();
            for (int i = 0; i < item.length; i++) {
              if (item[i] == null || item[i].indexOf(":") < 0) continue;
              String s1 = item[i].substring(0, item[i].indexOf(":"));
              String s2 = item[i].substring(item[i].indexOf(":") + 1);
              hash.put(s1, s2);
              keyList.add(s1);
            }
            String editorEditable = colinfo.getString("EnumCellEditor_EDITABLE", "0");
            if (editorEditable.equals("1")) {
              dce = new EnumCellEditor(hash, keyList, colinfo);
            } else {
              dce = new EnumCellEditor(hash, keyList);
            }

            break;
          }
          // 增加密码列
        case ColumnMetaData.EL_WINDOW:
          {
            dce = new PassWordCellEditor();
            break;
          }
          // 增加弹出窗口
        case ColumnMetaData.EL_DIALOG:
          {
            dce = new WindowCellEditor(colinfo);
            break;
          }
          // 自列表
        case ColumnMetaData.EL_SELFENUM:
          {
            Map hash = new Hashtable();
            List keyList = new ArrayList();
            String view = colinfo.getString("COL_EDITVIEW", null);
            if (view == null) view = colinfo.getColView();
            String[] item = view.split(";");
            for (int i = 0; i < item.length; i++) {
              if (item[i] == null || item[i].indexOf(":") < 0) continue;
              String s1 = item[i].substring(0, item[i].indexOf(":"));
              String s2 = item[i].substring(item[i].indexOf(":") + 1);
              hash.put(s1, s2);
              keyList.add(s1);
            }
            dce = new SelfEnumCellEditor(hash, keyList, colinfo);

            break;
          }
        default:
          break;
      }
    }
    colinfo.setEditor(dce);
    return dce;
  }