コード例 #1
0
 @Override
 public Object[] getChildren(Object parentElement) {
   if (parentElement instanceof MongoDBCollectionInfoDTO) {
     MongoDBCollectionInfoDTO dto = (MongoDBCollectionInfoDTO) parentElement;
     return dto.getChild().toArray();
   }
   return null;
 }
コード例 #2
0
  @Override
  public boolean hasChildren(Object element) {
    if (element instanceof MongoDBCollectionInfoDTO) {
      MongoDBCollectionInfoDTO info = (MongoDBCollectionInfoDTO) element;

      return info.getChild().size() > 0;
    }
    return false;
  }
コード例 #3
0
  @Override
  public boolean select(Viewer viewer, Object parentElement, Object element) {

    if (searchString == null || searchString.length() == 0) {
      return true;
    }

    if (element instanceof MongoDBCollectionInfoDTO) {
      MongoDBCollectionInfoDTO user = (MongoDBCollectionInfoDTO) element;
      if (user.getName().matches(searchString)) return true;
    }

    return false;
  }
コード例 #4
0
  @Override
  public String getColumnText(Object element, int columnIndex) {
    if (element instanceof MongoDBCollectionInfoDTO) {
      MongoDBCollectionInfoDTO info = (MongoDBCollectionInfoDTO) element;

      switch (columnIndex) {
        case 0:
          return info.getName();
        case 1:
          return NumberFormatUtils.commaFormat(info.getCount());
        case 2:
          return NumberFormatUtils.kbMbFormat(info.getSize());
        case 3:
          return NumberFormatUtils.kbMbFormat(info.getStorage());
        case 4:
          return NumberFormatUtils.kbMbFormat(info.getIndex());
        case 5:
          return NumberFormatUtils.commaFormat(info.getAvgObj());
        case 6:
          return NumberFormatUtils.commaFormat(info.getPadding());
      }
      return "*** not set column ***"; //$NON-NLS-1$
    } else {
      TableColumnDAO dao = (TableColumnDAO) element;

      switch (columnIndex) {
        case 0:
          return dao.getField();
        case 1:
          return dao.getType();
        case 2:
          return dao.getKey();
        case 3:
          return ""; //$NON-NLS-1$
        case 4:
          return ""; //$NON-NLS-1$
        case 5:
          return ""; //$NON-NLS-1$
        case 6:
          return ""; //$NON-NLS-1$
      }
      return "*** not set column ***"; //$NON-NLS-1$
    }
  }
コード例 #5
0
  /** 초기 데이터를 로드합니다. */
  private void initData() {
    collectionList.clear();

    try {
      DB mongoDB = MongoDBConnection.connection(userDB);

      for (String col : mongoDB.getCollectionNames()) {

        CommandResult commandResult = mongoDB.getCollection(col).getStats();
        // logger.debug(commandResult);

        MongoDBCollectionInfoDTO info = new MongoDBCollectionInfoDTO();
        info.setName(col);

        try {
          info.setCount(commandResult.getInt("count")); // $NON-NLS-1$
          info.setSize(commandResult.getInt("size")); // $NON-NLS-1$
          info.setStorage(commandResult.getInt("storageSize")); // $NON-NLS-1$
          info.setIndex(commandResult.getInt("totalIndexSize")); // $NON-NLS-1$
          info.setAvgObj(commandResult.getDouble("avgObjSize")); // $NON-NLS-1$
          info.setPadding(commandResult.getInt("paddingFactor")); // $NON-NLS-1$
        } catch (Exception e) {
          logger.error("collection info error [" + col + "]", e); // $NON-NLS-1$ //$NON-NLS-2$
        }
        collectionList.add(info);
      }
      treeViewerCollections.setInput(collectionList);

      // summary 정보를 표시합니다.
      double dblSize = 0, dblStorage = 0, dblIndex = 0;
      for (MongoDBCollectionInfoDTO info : collectionList) {
        dblSize += info.getSize();
        dblStorage += info.getStorage();
        dblIndex += info.getIndex();
      }
      lblCollection.setText(collectionList.size() + " Collections"); // $NON-NLS-1$
      lblSizes.setText("Size " + NumberFormatUtils.kbMbFormat(dblSize)); // $NON-NLS-1$
      lblStorages.setText("Storage " + NumberFormatUtils.kbMbFormat(dblStorage)); // $NON-NLS-1$
      lblIndex.setText("Index " + NumberFormatUtils.kbMbFormat(dblIndex)); // $NON-NLS-1$

    } catch (Exception e) {
      logger.error("mongodb collection infomtion init", e); // $NON-NLS-1$

      Status errStatus =
          new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); // $NON-NLS-1$
      ExceptionDetailsErrorDialog.openError(
          null, "Error", "MongoDB Information", errStatus); // $NON-NLS-1$ //$NON-NLS-2$
    }
  }
コード例 #6
0
  @Override
  public int compare(Viewer viewer, Object e1, Object e2) {
    int rc = 0;

    if (e1 instanceof MongoDBCollectionInfoDTO) {
      MongoDBCollectionInfoDTO m1 = (MongoDBCollectionInfoDTO) e1;
      MongoDBCollectionInfoDTO m2 = (MongoDBCollectionInfoDTO) e2;

      Double dbl1, dbl2;

      switch (propertyIndex) {
        case 0:
          rc = m1.getName().compareTo(m2.getName());
          break;
        case 1:
          dbl1 = Double.valueOf("" + m1.getCount());
          dbl2 = Double.valueOf("" + m2.getCount());

          rc = dbl1.compareTo(dbl2);
          break;

        case 2:
          dbl1 = Double.valueOf("" + m1.getSize());
          dbl2 = Double.valueOf("" + m2.getSize());

          rc = dbl1.compareTo(dbl2);
          break;
        case 3:
          dbl1 = Double.valueOf("" + m1.getStorage());
          dbl2 = Double.valueOf("" + m2.getStorage());

          rc = dbl1.compareTo(dbl2);
          break;
        case 4:
          dbl1 = Double.valueOf("" + m1.getIndex());
          dbl2 = Double.valueOf("" + m2.getIndex());

          rc = dbl1.compareTo(dbl2);
          break;
        case 5:
          dbl1 = Double.valueOf("" + m1.getAvgObj());
          dbl2 = Double.valueOf("" + m2.getAvgObj());

          rc = dbl1.compareTo(dbl2);
          break;
        case 6:
          dbl1 = Double.valueOf("" + m1.getPadding());
          dbl2 = Double.valueOf("" + m2.getPadding());

          rc = dbl1.compareTo(dbl2);
          break;
        default:
          break;
      }

      if (direction == DESCENDING) rc = -rc;
    }

    return rc;
  }