@Override
 public void run() {
   IStructuredSelection selection = (IStructuredSelection) selectionProvider.getSelection();
   RepositoryNode firstNode = (RepositoryNode) selection.getFirstElement();
   if (firstNode.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.FOLDER) {
     firstNode = repositoryNodeManager.getRepositoryNodebyName(connParam.getRepositoryName());
   }
   List<String> repositoryNames = repositoryNodeManager.getALLReposotoryNodeNames();
   IRepositoryViewObject object = SQLBuilderRepositoryNodeManager.getRoot(firstNode).getObject();
   connParam.setRepositoryName(object.getLabel());
   connParam.setRepositoryId(object.getId());
   connParam.setFirstOpenSqlBuilder(false);
   if (isQuery) {
     DBTreeProvider provider = (DBTreeProvider) selectionProvider.getContentProvider();
     selectReveal(provider.getSelectedExtReposiotryNode());
     isQuery = false;
   } else {
     connParam.setEditorTitle(TextUtil.getNewQueryLabel());
     connParam.setQueryObject(null);
   }
   dialog.openEditor(firstNode, repositoryNames, connParam, false);
 }
  /*
   * (non-Java)
   *
   * @see org.talend.sqlbuilder.actions.AbstractEditorAction#run()
   */
  @Override
  public void run() {
    currentSql = getEditor().getSQLToBeExecuted();
    // QueryTokenizer qt = new QueryTokenizer(currentSql, queryDelimiter, alternateDelimiter,
    // commentDelimiter);
    // List<String> queryStrings = new ArrayList<String>();
    // while (qt.hasQuery()) {
    // String querySql = qt.nextQuery();
    // // ignore commented lines.
    // if (!querySql.startsWith("--")) { //$NON-NLS-1$
    // queryStrings.add(querySql);
    // }
    // }
    // if (queryStrings.size() < 1) {
    // MessageDialog.openError(new Shell(), "Notice", "You must input one Sql Statement!");
    // return;
    // }
    // if (queryStrings.size() > 1) {
    // isForce = MessageDialog.openQuestion(new Shell(), "Notice",
    // "You only modify first Sql Statement by GUI, Would you like to continue?");
    // }
    // String string = queryStrings.get(0).toLowerCase().replaceAll("\n", " ");
    // string.replaceAll("\t", " ");
    // if (!string.startsWith("select ")) {
    // MessageDialog.openError(new Shell(), "Notice", "GUI Sql Editor only use for 'select'
    // Statement !");
    // return;
    // }
    // if (isForce != null && !isForce.booleanValue()) {
    // return;
    // }
    if (dialog instanceof SQLBuilderDialog) {
      SQLBuilderDialog d = (SQLBuilderDialog) dialog;
      final CTabItem selection = d.getEditorComposite().getTabFolder().getSelection();
      if (selection.getData("KEY") instanceof MultiPageSqlBuilderEditor) { // $NON-NLS-1$
        MultiPageSqlBuilderEditor editor =
            (MultiPageSqlBuilderEditor) selection.getData("KEY"); // $NON-NLS-1$
        switch (editor.getActivePage()) {
          case 1:
            isDesigner = true;
            break;
          default:
            isDesigner = false;
            break;
        }
      }
    }

    String query = null;
    if (isDesigner) {
      SqlEditDialog textDialog =
          new SqlEditDialog(
              dialog.getShell(),
              Messages.getString("GUIModificationQueryAction.TextDialog.TitleText"),
              currentSql,
              currentNode); //$NON-NLS-1$
      if (Window.OK == textDialog.open()) {
        query = textDialog.getSql();
      }
    } else {
      List<IRepositoryNode> selectedNodes = null;
      try {
        selectedNodes =
            EMFRepositoryNodeManager.getInstance().parseSqlStatement(currentSql, currentNode);
      } catch (Exception e) {
        MessageDialog.openError(
            new Shell(),
            Messages.getString("GUIModificationQueryAction.Error.Notice"),
            Messages.getString(
                "GUIModificationQueryAction.SqlStatement.ErrorMsg")); //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (selectedNodes == null) {
        return;
      }

      // String info = Messages.getString("MultiPageSqlBuilderEditor.Notice.InformationNotFull");
      // MessageDialog.openInformation(new Shell(),
      // Messages.getString("GUIModificationQueryAction.Information.Msg"), info); //$NON-NLS-1$

      ErDiagramDialog erDiagramDialog =
          new ErDiagramDialog(
              dialog.getShell(),
              Messages.getString("GUIModificationQueryAction.Dialog.TitleText"),
              currentNode); //$NON-NLS-1$
      erDiagramDialog.setDialog(dialog);
      erDiagramDialog.setNodes(selectedNodes);
      erDiagramDialog.setSqlText(currentSql);
      EMFRepositoryNodeManager.getInstance().setRoot(currentNode);
      if (Window.OK == erDiagramDialog.open()) {
        query = erDiagramDialog.getSql();
      }
    }
    if (query == null) {
      return;
    }
    if (!query.endsWith(";\n") && !query.endsWith(";")) { // $NON-NLS-1$ //$NON-NLS-2$
      query += ";\n"; // $NON-NLS-1$
    }
    String targetSql = ""; // $NON-NLS-1$
    boolean isfirst = true;
    QueryTokenizer qt =
        new QueryTokenizer(currentSql, queryDelimiter, alternateDelimiter, commentDelimiter);
    while (qt.hasQuery()) {
      String querySql = qt.nextQuery();
      if (querySql.startsWith("--") || !isfirst) { // $NON-NLS-1$
        targetSql += querySql + ";\n"; // $NON-NLS-1$
      } else {
        targetSql += query;
        isfirst = false;
      }
    }
    if (!qt.hasQuery()) {
      targetSql = query;
    }
    // currentSql = currentSql.replaceFirst(queryStrings.get(0), query);
    getEditor().setEditorContent(targetSql);
  }