Program: 123836
Project: 123836
Buggy source:
protected void doRun(){
  IStructuredSelection selection=(IStructuredSelection)getSelection();
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  if (repositoryNode == null && selection != null) {
    repositoryNode=(RepositoryNode)selection.getFirstElement();
  }
  DatabaseConnectionItem dbConnectionItem=null;
  ConnectionParameters connParameters=new ConnectionParameters();
  if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
    dbConnectionItem=(DatabaseConnectionItem)repositoryNode.getObject().getProperty().getItem();
    connParameters.setRepositoryName(repositoryNode.getObject().getLabel());
    connParameters.setRepositoryId(repositoryNode.getObject().getId());
    connParameters.setQuery("String_Node_Str");
  }
 else   if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_QUERY) {
    QueryRepositoryObject queryRepositoryObject=(QueryRepositoryObject)repositoryNode.getObject();
    dbConnectionItem=(DatabaseConnectionItem)queryRepositoryObject.getProperty().getItem();
    connParameters.setRepositoryName(dbConnectionItem.getProperty().getLabel());
    connParameters.setRepositoryId(dbConnectionItem.getProperty().getId());
    connParameters.setQueryObject(queryRepositoryObject.getQuery());
    connParameters.setQuery(queryRepositoryObject.getQuery().getValue());
  }
  Shell parentShell=new Shell(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IRepositoryView.VIEW_ID).getSite().getShell().getDisplay());
  TextUtil.setDialogTitle(TalendTextUtils.SQL_BUILDER_TITLE_REP);
  SQLBuilderDialog dial=new SQLBuilderDialog(parentShell);
  dial.setReadOnly(true);
  Connection connection=dbConnectionItem.getConnection();
  if (connection instanceof DatabaseConnection) {
    IMetadataConnection imetadataConnection=ConvertionHelper.convert((DatabaseConnection)connection,true);
    connParameters.setSchema(imetadataConnection.getSchema());
  }
  connParameters.setNodeReadOnly(true);
  connParameters.setFromRepository(true);
  dial.setConnParameters(connParameters);
  dial.open();
  refresh(repositoryNode);
}

Fixed version (ground truth):
protected void doRun(){
  IStructuredSelection selection=(IStructuredSelection)getSelection();
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  if (repositoryNode == null && selection != null) {
    repositoryNode=(RepositoryNode)selection.getFirstElement();
  }
  DatabaseConnectionItem dbConnectionItem=null;
  ConnectionParameters connParameters=new ConnectionParameters();
  if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
    dbConnectionItem=(DatabaseConnectionItem)repositoryNode.getObject().getProperty().getItem();
    connParameters.setRepositoryName(repositoryNode.getObject().getLabel());
    connParameters.setRepositoryId(repositoryNode.getObject().getId());
    connParameters.setQuery("String_Node_Str");
  }
 else   if (repositoryNode.getObjectType() == ERepositoryObjectType.METADATA_CON_QUERY) {
    QueryRepositoryObject queryRepositoryObject=(QueryRepositoryObject)repositoryNode.getObject();
    dbConnectionItem=(DatabaseConnectionItem)queryRepositoryObject.getProperty().getItem();
    connParameters.setRepositoryName(dbConnectionItem.getProperty().getLabel());
    connParameters.setRepositoryId(dbConnectionItem.getProperty().getId());
    connParameters.setQueryObject(queryRepositoryObject.getQuery());
    connParameters.setQuery(queryRepositoryObject.getQuery().getValue());
    connParameters.setFirstOpenSqlBuilder(true);
  }
  Shell parentShell=new Shell(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(IRepositoryView.VIEW_ID).getSite().getShell().getDisplay());
  TextUtil.setDialogTitle(TalendTextUtils.SQL_BUILDER_TITLE_REP);
  SQLBuilderDialog dial=new SQLBuilderDialog(parentShell);
  dial.setReadOnly(true);
  Connection connection=dbConnectionItem.getConnection();
  if (connection instanceof DatabaseConnection) {
    IMetadataConnection imetadataConnection=ConvertionHelper.convert((DatabaseConnection)connection,true);
    connParameters.setSchema(imetadataConnection.getSchema());
  }
  connParameters.setNodeReadOnly(true);
  connParameters.setFromRepository(true);
  dial.setConnParameters(connParameters);
  dial.open();
  refresh(repositoryNode);
}