Program: 118279
Project: 118279
Buggy source:
@Override public void init(TreeViewer viewer,IStructuredSelection selection){
  boolean canWork=!selection.isEmpty() && selection.size() == 1;
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  if (factory.isUserReadOnlyOnCurrentProject()) {
    canWork=false;
  }
  if (canWork) {
    Object o=selection.getFirstElement();
    repositoryNode=(RepositoryNode)o;
switch (repositoryNode.getType()) {
case REPOSITORY_ELEMENT:
      if (repositoryNode.getObject().getRepositoryStatus() == ERepositoryStatus.DELETED || repositoryNode.getObject().getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
        canWork=false;
      }
    if (!isUnderDBConnection(repositoryNode)) {
      canWork=false;
    }
  Item item=repositoryNode.getObject().getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
  DatabaseConnectionItem dbItem=(DatabaseConnectionItem)item;
  DatabaseConnection dbConn=(DatabaseConnection)dbItem.getConnection();
  String dbType=dbConn.getDatabaseType();
  if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType) || EDatabaseTypeName.HBASE.getXmlName().equalsIgnoreCase(dbType)) {
    canWork=false;
    break;
  }
}
if (repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CONNECTIONS && repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CON_QUERY && repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CON_TABLE) {
canWork=false;
}
 else {
if (PluginChecker.isCDCPluginLoaded()) {
  ICDCProviderService cdcService=(ICDCProviderService)GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
  if (cdcService != null && cdcService.isSubscriberTableNode(repositoryNode)) {
    canWork=false;
    break;
  }
}
IRepositoryService service=(IRepositoryService)GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory repFactory=service.getProxyRepositoryFactory();
if (!repFactory.isPotentiallyEditable(repositoryNode.getObject())) {
  canWork=false;
  break;
}
}
break;
default :
canWork=false;
}
if (canWork && (!ProjectManager.getInstance().isInCurrentMainProject(repositoryNode) || !isLastVersion(repositoryNode))) {
canWork=false;
}
}
setEnabled(canWork);
}

Fixed version (ground truth):
@Override public void init(TreeViewer viewer,IStructuredSelection selection){
  boolean canWork=!selection.isEmpty() && selection.size() == 1;
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  if (factory.isUserReadOnlyOnCurrentProject()) {
    canWork=false;
  }
  if (canWork) {
    Object o=selection.getFirstElement();
    repositoryNode=(RepositoryNode)o;
switch (repositoryNode.getType()) {
case REPOSITORY_ELEMENT:
      if (repositoryNode.getObject().getRepositoryStatus() == ERepositoryStatus.DELETED || repositoryNode.getObject().getRepositoryStatus() == ERepositoryStatus.LOCK_BY_OTHER) {
        canWork=false;
      }
    if (!isUnderDBConnection(repositoryNode)) {
      canWork=false;
    }
  Item item=repositoryNode.getObject().getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
  DatabaseConnectionItem dbItem=(DatabaseConnectionItem)item;
  DatabaseConnection dbConn=(DatabaseConnection)dbItem.getConnection();
  String dbType=dbConn.getDatabaseType();
  if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType) || EDatabaseTypeName.HBASE.getXmlName().equalsIgnoreCase(dbType) || EDatabaseTypeName.IMPALA.getXmlName().equalsIgnoreCase(dbType)) {
    canWork=false;
    break;
  }
}
if (repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CONNECTIONS && repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CON_QUERY && repositoryNode.getObjectType() != ERepositoryObjectType.METADATA_CON_TABLE) {
canWork=false;
}
 else {
if (PluginChecker.isCDCPluginLoaded()) {
  ICDCProviderService cdcService=(ICDCProviderService)GlobalServiceRegister.getDefault().getService(ICDCProviderService.class);
  if (cdcService != null && cdcService.isSubscriberTableNode(repositoryNode)) {
    canWork=false;
    break;
  }
}
IRepositoryService service=(IRepositoryService)GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
IProxyRepositoryFactory repFactory=service.getProxyRepositoryFactory();
if (!repFactory.isPotentiallyEditable(repositoryNode.getObject())) {
  canWork=false;
  break;
}
}
break;
default :
canWork=false;
}
if (canWork && (!ProjectManager.getInstance().isInCurrentMainProject(repositoryNode) || !isLastVersion(repositoryNode))) {
canWork=false;
}
}
setEnabled(canWork);
}