Program: 123896
Project: 123896
Buggy source:
/** 
 * DOC YeXiaowei Comment method "createSalesforceSchemaWizard".
 * @param selection
 * @param forceReadOnly
 */
public void createSalesforceSchemaWizard(RepositoryNode node,final boolean forceReadOnly){
  SalesforceSchemaConnection connection=null;
  MetadataTable metadataTable=null;
  boolean creation=false;
  if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
    ERepositoryObjectType nodeType=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
    String tableLabel=(String)node.getProperties(EProperties.LABEL);
    SalesforceSchemaConnectionItem item=null;
    if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
      item=(SalesforceSchemaConnectionItem)node.getParent().getObject().getProperty().getItem();
      connection=(SalesforceSchemaConnection)item.getConnection();
      metadataTable=TableHelper.findByLabel(connection,tableLabel);
      creation=false;
    }
 else     if (nodeType == ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA) {
      item=(SalesforceSchemaConnectionItem)node.getObject().getProperty().getItem();
      connection=(SalesforceSchemaConnection)item.getConnection();
      metadataTable=ConnectionFactory.eINSTANCE.createMetadataTable();
      String nextId=ProxyRepositoryFactory.getInstance().getNextId();
      metadataTable.setId(nextId);
      metadataTable.setLabel(getStringIndexed(metadataTable.getLabel()));
      GenericPackage g=(GenericPackage)ConnectionHelper.getPackage(connection.getName(),(Connection)connection,GenericPackage.class);
      if (g != null) {
        g.getOwnedElement().add(metadataTable);
      }
 else {
        GenericPackage gpkg=ConnectionFactory.eINSTANCE.createGenericPackage();
        PackageHelper.addMetadataTable(metadataTable,gpkg);
        ConnectionHelper.addPackage(gpkg,connection);
      }
      creation=true;
    }
 else {
      return;
    }
    initContextMode(item);
    SalesforceSchemaTableWizard salesforceSchemaWizard=new SalesforceSchemaTableWizard(PlatformUI.getWorkbench(),creation,item,metadataTable,forceReadOnly);
    salesforceSchemaWizard.setRepositoryObject(node.getObject());
    WizardDialog wizardDialog=new WizardDialog(Display.getCurrent().getActiveShell(),salesforceSchemaWizard);
    handleWizard(node,wizardDialog);
  }
}

Fixed version (ground truth):
/** 
 * DOC YeXiaowei Comment method "createSalesforceSchemaWizard".
 * @param selection
 * @param forceReadOnly
 */
public void createSalesforceSchemaWizard(RepositoryNode node,final boolean forceReadOnly){
  SalesforceSchemaConnection connection=null;
  MetadataTable metadataTable=null;
  boolean creation=false;
  if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
    ERepositoryObjectType nodeType=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
    String tableLabel=(String)node.getProperties(EProperties.LABEL);
    SalesforceSchemaConnectionItem item=null;
    if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
      item=(SalesforceSchemaConnectionItem)node.getParent().getObject().getProperty().getItem();
      connection=(SalesforceSchemaConnection)item.getConnection();
      metadataTable=TableHelper.findByLabel(connection,tableLabel);
      creation=false;
    }
 else     if (nodeType == ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA) {
      item=(SalesforceSchemaConnectionItem)node.getObject().getProperty().getItem();
      connection=(SalesforceSchemaConnection)item.getConnection();
      metadataTable=ConnectionFactory.eINSTANCE.createMetadataTable();
      String nextId=ProxyRepositoryFactory.getInstance().getNextId();
      metadataTable.setId(nextId);
      metadataTable.setLabel(getStringIndexed(metadataTable.getLabel()));
      GenericPackage g=(GenericPackage)ConnectionHelper.getPackage(connection.getName(),(Connection)connection,GenericPackage.class);
      if (g != null) {
        g.getOwnedElement().add(metadataTable);
      }
 else {
        GenericPackage gpkg=ConnectionFactory.eINSTANCE.createGenericPackage();
        PackageHelper.addMetadataTable(metadataTable,gpkg);
        ConnectionHelper.addPackage(gpkg,connection);
      }
      creation=true;
    }
 else {
      return;
    }
    initContextMode(item);
    if (metadataTable.eContainer() instanceof SalesforceModuleUnit) {
      SalesforceModuleUnit unit=(SalesforceModuleUnit)metadataTable.eContainer();
      connection.setModuleName(unit.getModuleName());
    }
    SalesforceSchemaTableWizard salesforceSchemaWizard=new SalesforceSchemaTableWizard(PlatformUI.getWorkbench(),creation,item,metadataTable,forceReadOnly);
    salesforceSchemaWizard.setRepositoryObject(node.getObject());
    WizardDialog wizardDialog=new WizardDialog(Display.getCurrent().getActiveShell(),salesforceSchemaWizard);
    handleWizard(node,wizardDialog);
  }
}