/**
   * resource load
   *
   * @param input
   */
  private void loadDBRsource(IEditorInput input) {
    TadpoleRDBEditorInput erdInput = (TadpoleRDBEditorInput) input;
    userDB = erdInput.getUserDBDAO();
    isAllTable = erdInput.isAllTable();

    // 신규로드 인지 기존 파일 로드 인지 검사합니다.
    if (null != erdInput.getUserDBERD()) {
      userDBErd = erdInput.getUserDBERD();

      // load resouce
      try {
        String xmlString = TadpoleSystem_UserDBResource.getResourceData(userDBErd);

        // 처음 로드 할때 ResourceSet에 instance가 등록 되어 있어야 합니다.
        /** <code>TadpolePackage.eNS_URI</code> */
        ResourceSet resourceSet = new ResourceSetImpl();
        if (resourceSet.getPackageRegistry().get("http://com.hangum.tadpole.rdb.model.ERDInfo")
            == null) {
          resourceSet
              .getPackageRegistry()
              .put("http://com.hangum.tadpole.rdb.model.ERDInfo", RdbPackage.eINSTANCE.getClass());
        }

        //
        XMLResourceImpl resource = new XMLResourceImpl();
        resource.setEncoding("UTF-8");
        resource.load(new InputSource(new StringReader(xmlString)), null);
        db = (DB) resource.getContents().get(0);

      } catch (Exception e) {
        logger.error("Load ERD Resource", e); // $NON-NLS-1$

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

      setPartName(isAllTable ? "All " + userDBErd.getName() : userDBErd.getName());
      setTitleToolTip(userDB.getDisplay_name());
    } else {
      setPartName(isAllTable ? "All " + userDB.getDisplay_name() : userDB.getDisplay_name());
      setTitleToolTip(userDB.getDisplay_name());
    }

    // google analytic
    AnalyticCaller.track(TadpoleRDBEditor.ID, userDB.getDbms_type());
  }
  //	/**
  //	 * export images
  //	 *
  //	 * RAP currently, GC drawing is only supported on Canvas, but not on image.
  //	 */
  //	public void exportImage() {
  //		try {
  //           IFigure figure =
  // ((AbstractGraphicalEditPart)getGraphicalViewer().getRootEditPart()).getFigure();
  //           File file = new File ("/Users/hangum/Downloads/gefout.png");
  //           if (file.exists ()) {
  //               if (!MessageDialog.openQuestion(null, "prompted", "The file already exists. Want
  // to re-cover it?")) {
  //                   return;
  //               }
  //           } else {
  //        	   file.createNewFile ();
  //           }
  //
  //           if (figure instanceof Viewport) {
  //	           ((Viewport)figure).setViewLocation(0, 0);
  //           }
  //
  //           Dimension size = figure.getPreferredSize ();
  //           Image image = new Image (Display.getDefault (), size.width, size.height);
  ////           Drawable drawable = (Drawable)image;
  //
  //           GC gc = new GC(getSite().getShell().getDisplay());
  //           gc.drawImage(image, size.width, size.height);
  //           SWTGraphics graphics = new SWTGraphics(gc);
  //           figure.paint (graphics);
  //
  //           ImageLoader loader = new ImageLoader ();
  //           loader.data = new ImageData []{image.getImageData ()};
  //           loader.save("/Users/hangum/Downloads/gefout.png",
  // SWT.IMAGE_PNG);//FileFormat.FORMATS);
  //
  //           graphics.dispose();
  //           gc.dispose();
  //           image.dispose();
  //
  //        } catch (Exception e) {
  //        	e.printStackTrace();
  //	     } finally {
  //        }
  //	}
  @Override
  public void doSave(IProgressMonitor monitor) {
    //		exportImage();

    // 신규 저장이면
    if (userDBErd == null) {

      // file 이름 dialog
      ResourceSaveDialog rsDialog =
          new ResourceSaveDialog(null, null, userDB, PublicTadpoleDefine.RESOURCE_TYPE.ERD, "");
      if (rsDialog.open() == Window.OK) {

        try {
          // erd 정보 디비저장
          userDBErd =
              TadpoleSystem_UserDBResource.saveResource(
                  userDB, rsDialog.getRetResourceDao(), createResourceToString());
          userDBErd.setParent(userDB);

          // command stack 초기화
          getCommandStack().markSaveLocation();

          // title 수정
          setPartName(userDBErd.getName());

          // managerView tree refresh
          // 뒤에 시간을붙인것은 한번 저장한 db_seq는 업데이지 않는 오류를 방지하기위해...
          //
          PlatformUI.getPreferenceStore()
              .setValue(
                  PublicTadpoleDefine.SAVE_FILE,
                  ""
                      + userDBErd.getDb_seq()
                      + ":"
                      + System.currentTimeMillis()); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

        } catch (Exception e) {
          logger.error(Messages.get().TadpoleEditor_9, e);

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

      // 기존 리소스를 가지고 있었으면
    } else {

      try {
        TadpoleSystem_UserDBResource.updateResource(userDBErd, createResourceToString());
        getCommandStack().markSaveLocation();
      } catch (Exception e) {
        logger.error(Messages.get().TadpoleEditor_12, e);

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