/** 초기 데이터를 로드합니다. */
  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$
    }
  }
 /**
  * delete message
  *
  * @param msgHead
  * @param e
  */
 private void exeMessage(String msgHead, Exception e) {
   Status errStatus =
       new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); // $NON-NLS-1$
   ExceptionDetailsErrorDialog.openError(
       null, "Error", msgHead + Messages.ObjectDeleteAction_25, errStatus); // $NON-NLS-1$
 }
  @Override
  public void run() {
    try {
      CompoundCommand commands = new CompoundCommand();
      List models = getViewer().getContents().getChildren();
      NodeList graphNodes = new NodeList();
      EdgeList graphEdges = new EdgeList();

      // nodes
      for (int i = 0; i < models.size(); i++) {
        Object obj = models.get(i);
        if (obj instanceof TableEditPart) {
          TableEditPart editPart = (TableEditPart) obj;
          Table model = (Table) editPart.getModel();
          EntityNode node = new EntityNode();
          node.model = model;
          node.width = editPart.getFigure().getSize().width;
          node.height = editPart.getFigure().getSize().height;
          graphNodes.add(node);
        }
      }

      // edge
      for (int i = 0; i < models.size(); i++) {
        Object obj = models.get(i);
        if (obj instanceof TableEditPart) {
          TableEditPart tableEditpart = (TableEditPart) obj;

          List outgoing = tableEditpart.getSourceConnections();
          for (int j = 0; j < outgoing.size(); j++) {
            RelationEditPart conn = (RelationEditPart) outgoing.get(j);
            EntityNode source =
                (EntityNode) getNode(graphNodes, (Table) conn.getSource().getModel());
            EntityNode target =
                (EntityNode) getNode(graphNodes, (Table) conn.getTarget().getModel());

            if (source != null && target != null) {
              ConnectionEdge edge = new ConnectionEdge(source, target);
              Relation relation = (Relation) conn.getModel();
              edge.model = relation.getSource();
              graphEdges.add(edge);
            }
          }
        }
      }

      DirectedGraph graph = new DirectedGraph();
      graph.nodes = graphNodes;
      graph.edges = graphEdges;
      new DirectedGraphLayout().visit(graph);
      for (int i = 0; i < graph.nodes.size(); i++) {
        EntityNode node = (EntityNode) graph.nodes.getNode(i);
        commands.add(new LayoutCommand(node.model, node.x, node.y));
      }

      getViewer().getEditDomain().getCommandStack().execute(commands);
    } catch (Exception e) {
      logger.error(Messages.AutoLayoutAction_2, e);

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