/**
   * 모든 테이블을 조회합니다.
   *
   * @param userDB
   * @param mapDBTables
   * @param db
   * @throws Exception
   */
  public static void calRelation(UserDBDAO userDB, Map<String, Table> mapDBTables, DB db)
      throws Exception {

    // 현재 sqlite는 관계 정의를 못하겠는바 막습니다.
    if (DBDefine.SQLite_DEFAULT == DBDefine.getDBDefine(userDB)) {
      calRelation(userDB, mapDBTables, db, makeSQLiteRelation(userDB));

    } else if (DBDefine.CUBRID_DEFAULT == DBDefine.getDBDefine(userDB)) {
      calRelation(userDB, mapDBTables, db, CubridTableRelation.makeCubridRelation(userDB));

    } else if (DBDefine.HIVE_DEFAULT == DBDefine.getDBDefine(userDB)) {
      calRelation(userDB, mapDBTables, db, new ArrayList<ReferencedTableDAO>());

    } else {
      calRelation(userDB, mapDBTables, db, getReferenceTable(userDB));
    }
  }
  @Override
  protected void handleDrop() {
    String[] arrayDragSourceData = null;
    try {
      arrayDragSourceData =
          StringUtils.splitByWholeSeparator(
              ((String) getCurrentEvent().data), PublicTadpoleDefine.DELIMITER);

      int sourceDBSeq = Integer.parseInt(arrayDragSourceData[0]);
      if (userDB.getSeq() != sourceDBSeq) {
        MessageDialog.openError(
            null, "Error", Messages.TableTransferDropTargetListener_1); // $NON-NLS-1$
        return;
      }
    } catch (Exception e) {
      logger.error("dragger error", e); // $NON-NLS-1$
      MessageDialog.openError(
          null, "Error", "Draging exception : " + e.getMessage()); // $NON-NLS-1$
      return;
    }

    String tableName = arrayDragSourceData[1];
    String refTableNames = "'" + tableName + "',"; // $NON-NLS-1$ //$NON-NLS-2$

    // 이미 editor 상에 테이블 정보를 가져온다.
    Map<String, Table> mapDBTables = new HashMap<String, Table>();
    for (Table table : db.getTables()) {
      mapDBTables.put(table.getName(), table);
      refTableNames += "'" + table.getName() + "',"; // $NON-NLS-1$ //$NON-NLS-2$
    }
    refTableNames = StringUtils.chompLast(refTableNames, ","); // $NON-NLS-1$

    // 이미 등록되어 있는 것이 아니라면
    if (mapDBTables.get(tableName) == null) {
      // 테이블 모델 생성
      Table tableModel = tadpoleFactory.createTable();
      tableModel.setName(tableName);
      tableModel.setDb(db);

      if (userDB.getDBDefine() == DBDefine.SQLite_DEFAULT) {
        tableModel.setComment("");
      } else {
        String tableComment = arrayDragSourceData[2];
        tableComment = StringUtils.substring("" + tableComment, 0, 10);
        tableModel.setComment(tableComment);
      }

      tableModel.setConstraints(new Rectangle(getDropLocation().x, getDropLocation().y, -1, -1));

      try {
        // 컬럼 모델 생성
        for (TableColumnDAO columnDAO : getColumns(tableName)) {
          Column column = tadpoleFactory.createColumn();

          column.setDefault(columnDAO.getDefault());
          column.setExtra(columnDAO.getExtra());
          column.setField(columnDAO.getField());
          column.setNull(columnDAO.getNull());
          column.setKey(columnDAO.getKey());
          column.setType(columnDAO.getType());

          String strComment = columnDAO.getComment();
          if (strComment == null) strComment = "";
          else strComment = StringUtils.substring("" + strComment, 0, 10);
          column.setComment(strComment);

          column.setTable(tableModel);
          tableModel.getColumns().add(column);
        }
        mapDBTables.put(tableName, tableModel);
        RelationUtil.calRelation(
            userDB,
            mapDBTables,
            db,
            refTableNames); // RelationUtil.getReferenceTable(userDB, refTableNames));

      } catch (Exception e) {
        logger.error("GEF Table Drag and Drop Exception", e); // $NON-NLS-1$

        Status errStatus =
            new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); // $NON-NLS-1$
        ExceptionDetailsErrorDialog.openError(
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
            "Error",
            Messages.TadpoleModelUtils_2,
            errStatus); //$NON-NLS-1$
      }

      transferFactory.setTable(tableModel);
    } else {
      transferFactory.setTable(mapDBTables.get(tableName));
    }

    super.handleDrop();
  }