Program: 118408
Project: 118408
Buggy source:
@Override public void init(TreeViewer viewer,IStructuredSelection selection){
  boolean canWork=UpdateManagerProviderDetector.INSTANCE.validateAction(viewer,selection);
  if (canWork) {
    setEnabled(true);
    return;
  }
  canWork=!selection.isEmpty() && selection.size() == 1;
  if (canWork) {
    IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
      canWork=false;
    }
 else {
      Object o=selection.getFirstElement();
      RepositoryNode node=(RepositoryNode)o;
      ENodeType nodeType=node.getType();
switch (nodeType) {
case REPOSITORY_ELEMENT:
        ERepositoryObjectType objectType=node.getObjectType();
      if (objectType != null) {
        String[] products=objectType.getProducts();
        if (products != null && products.length == 1 && "String_Node_Str".equals(products[0])) {
          setEnabled(false);
          return;
        }
      }
    if (objectType == ERepositoryObjectType.METADATA_CON_TABLE) {
      IRepositoryViewObject repositoryObject=node.getObject();
      if (repositoryObject != null) {
        Item item2=repositoryObject.getProperty().getItem();
        if (item2 instanceof DatabaseConnectionItem) {
          DatabaseConnectionItem item=(DatabaseConnectionItem)repositoryObject.getProperty().getItem();
          DatabaseConnection connection=(DatabaseConnection)item.getConnection();
          CDCConnection cdcConns=connection.getCdcConns();
          if (cdcConns != null) {
            if (repositoryObject instanceof MetadataTableRepositoryObject) {
              MetadataTable table=((MetadataTableRepositoryObject)repositoryObject).getTable();
              String tableType=table.getTableType();
              canWork=RepositoryConstants.TABLE.equals(tableType);
              break;
            }
          }
        }
      }
      canWork=true;
    }
 else     if (objectType == ERepositoryObjectType.METADATA_CON_QUERY || objectType == ERepositoryObjectType.METADATA_CONNECTIONS || objectType == ERepositoryObjectType.METADATA_FILE_DELIMITED || objectType == ERepositoryObjectType.METADATA_FILE_POSITIONAL || objectType == ERepositoryObjectType.METADATA_FILE_REGEXP || objectType == ERepositoryObjectType.METADATA_FILE_XML || objectType == ERepositoryObjectType.METADATA_FILE_LDIF || objectType == ERepositoryObjectType.METADATA_FILE_EXCEL || objectType == ERepositoryObjectType.METADATA_SAPCONNECTIONS || objectType == ERepositoryObjectType.METADATA_FILE_EBCDIC || objectType == ERepositoryObjectType.METADATA_FILE_HL7 || objectType == ERepositoryObjectType.METADATA_VALIDATION_RULES || objectType == ERepositoryObjectType.METADATA_FILE_FTP || objectType == ERepositoryObjectType.METADATA_FILE_BRMS || objectType == ERepositoryObjectType.METADATA_MDMCONNECTION || objectType == ERepositoryObjectType.CONTEXT || objectType == ERepositoryObjectType.JOBLET) {
      canWork=true;
    }
 else     if (objectType == ERepositoryObjectType.BUSINESS_PROCESS || objectType == ERepositoryObjectType.PROCESS || objectType == ERepositoryObjectType.ROUTINES || objectType == ERepositoryObjectType.PIG_UDF || objectType == ERepositoryObjectType.JOB_SCRIPT || objectType == ERepositoryObjectType.SQLPATTERNS || objectType == ERepositoryObjectType.JOB_DOC || objectType == ERepositoryObjectType.JOBLET_DOC || objectType == ERepositoryObjectType.DOCUMENTATION || objectType == ERepositoryObjectType.PROCESS_MR) {
      canWork=false;
    }
 else {
      Object obj=selection.getFirstElement();
      RepositoryNode nodeObj=(RepositoryNode)obj;
      Item item=nodeObj.getObject().getProperty().getItem();
      if (item instanceof ConnectionItem) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
          IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
          if (service != null) {
            boolean flag=service.isServiceItem(item.eClass().getClassifierID());
            if (flag) {
              canWork=false;
              break;
            }
          }
        }
      }
      for (      IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
        ERepositoryObjectType stype=handler.getRepositoryObjectType(item);
        if (stype == objectType) {
          canWork=true;
          break;
        }
      }
      if (RepositoryContentManager.getHandlers().size() < 0) {
        canWork=false;
      }
    }
  break;
default :
canWork=false;
}
RepositoryNode parent=node.getParent();
if (canWork && parent != null && parent.isBin()) {
canWork=false;
}
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
canWork=false;
}
}
}
setEnabled(canWork);
}

Fixed version (ground truth):
@Override public void init(TreeViewer viewer,IStructuredSelection selection){
  boolean canWork=UpdateManagerProviderDetector.INSTANCE.validateAction(viewer,selection);
  if (canWork) {
    setEnabled(true);
    return;
  }
  canWork=!selection.isEmpty() && selection.size() == 1;
  if (canWork) {
    IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
      canWork=false;
    }
 else {
      Object o=selection.getFirstElement();
      RepositoryNode node=(RepositoryNode)o;
      ENodeType nodeType=node.getType();
switch (nodeType) {
case REPOSITORY_ELEMENT:
        ERepositoryObjectType objectType=node.getObjectType();
      if (objectType != null) {
        String[] products=objectType.getProducts();
        if (products != null && products.length == 1 && "String_Node_Str".equals(products[0])) {
          setEnabled(false);
          return;
        }
      }
    if (objectType == ERepositoryObjectType.METADATA_CON_TABLE) {
      IRepositoryViewObject repositoryObject=node.getObject();
      if (repositoryObject != null) {
        Item item2=repositoryObject.getProperty().getItem();
        if (item2 instanceof DatabaseConnectionItem) {
          DatabaseConnectionItem item=(DatabaseConnectionItem)repositoryObject.getProperty().getItem();
          DatabaseConnection connection=(DatabaseConnection)item.getConnection();
          CDCConnection cdcConns=connection.getCdcConns();
          if (cdcConns != null) {
            if (repositoryObject instanceof MetadataTableRepositoryObject) {
              MetadataTable table=((MetadataTableRepositoryObject)repositoryObject).getTable();
              String tableType=table.getTableType();
              canWork=RepositoryConstants.TABLE.equals(tableType);
              break;
            }
          }
        }
      }
      canWork=true;
    }
 else     if (objectType == ERepositoryObjectType.METADATA_CON_QUERY || objectType == ERepositoryObjectType.METADATA_CONNECTIONS || objectType == ERepositoryObjectType.METADATA_FILE_DELIMITED || objectType == ERepositoryObjectType.METADATA_FILE_POSITIONAL || objectType == ERepositoryObjectType.METADATA_FILE_REGEXP || objectType == ERepositoryObjectType.METADATA_FILE_XML || objectType == ERepositoryObjectType.METADATA_FILE_LDIF || objectType == ERepositoryObjectType.METADATA_FILE_EXCEL || objectType == ERepositoryObjectType.METADATA_SAPCONNECTIONS || objectType == ERepositoryObjectType.METADATA_FILE_EBCDIC || objectType == ERepositoryObjectType.METADATA_FILE_HL7 || objectType == ERepositoryObjectType.METADATA_VALIDATION_RULES || objectType == ERepositoryObjectType.METADATA_FILE_FTP || objectType == ERepositoryObjectType.METADATA_FILE_BRMS || objectType == ERepositoryObjectType.METADATA_MDMCONNECTION || objectType == ERepositoryObjectType.CONTEXT || objectType == ERepositoryObjectType.JOBLET) {
      canWork=true;
    }
 else     if (objectType == ERepositoryObjectType.BUSINESS_PROCESS || objectType == ERepositoryObjectType.PROCESS || objectType == ERepositoryObjectType.ROUTINES || objectType == ERepositoryObjectType.PIG_UDF || objectType == ERepositoryObjectType.JOB_SCRIPT || objectType == ERepositoryObjectType.SQLPATTERNS || objectType == ERepositoryObjectType.JOB_DOC || objectType == ERepositoryObjectType.JOBLET_DOC || objectType == ERepositoryObjectType.DOCUMENTATION || objectType == ERepositoryObjectType.PROCESS_MR || (ERepositoryObjectType.TEST_CONTAINER != null && objectType == ERepositoryObjectType.TEST_CONTAINER)) {
      canWork=false;
    }
 else {
      Object obj=selection.getFirstElement();
      RepositoryNode nodeObj=(RepositoryNode)obj;
      Item item=nodeObj.getObject().getProperty().getItem();
      if (item instanceof ConnectionItem) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
          IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
          if (service != null) {
            boolean flag=service.isServiceItem(item.eClass().getClassifierID());
            if (flag) {
              canWork=false;
              break;
            }
          }
        }
      }
      for (      IRepositoryContentHandler handler : RepositoryContentManager.getHandlers()) {
        ERepositoryObjectType stype=handler.getRepositoryObjectType(item);
        if (stype == objectType) {
          canWork=true;
          break;
        }
      }
      if (RepositoryContentManager.getHandlers().size() < 0) {
        canWork=false;
      }
    }
  break;
default :
canWork=false;
}
RepositoryNode parent=node.getParent();
if (canWork && parent != null && parent.isBin()) {
canWork=false;
}
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
canWork=false;
}
}
}
setEnabled(canWork);
}