Program: 122145
Project: 122145
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());
    connParameters.setFirstOpenSqlBuilder(true);
  }
  Display display=Display.getCurrent();
  if (display == null) {
    display=Display.getDefault();
  }
  Shell parentShell=new Shell(display);
  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):
@Override 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);
  }
  Display display=Display.getCurrent();
  if (display == null) {
    display=Display.getDefault();
  }
  Shell parentShell=new Shell(display);
  TextUtil.setDialogTitle(TalendTextUtils.SQL_BUILDER_TITLE_REP);
  Connection connection=dbConnectionItem.getConnection();
  String selectedContext=null;
  if (connection.isContextMode()) {
    ContextItem contextItem=ContextUtils.getContextItemById2(connection.getContextId());
    if (contextItem != null && connection.isContextMode()) {
      ContextSetsSelectionDialog setsDialog=new ContextSetsSelectionDialog(null,contextItem,false);
      setsDialog.open();
      selectedContext=setsDialog.getSelectedContext();
    }
  }
  SQLBuilderDialog dial=new SQLBuilderDialog(parentShell,repositoryNode,selectedContext);
  dial.setReadOnly(true);
  if (connection instanceof DatabaseConnection) {
    IMetadataConnection imetadataConnection=ConvertionHelper.convert(connection,true);
    connParameters.setSchema(imetadataConnection.getSchema());
  }
  connParameters.setNodeReadOnly(true);
  connParameters.setFromRepository(true);
  dial.setConnParameters(connParameters);
  dial.open();
  refresh(repositoryNode);
}