Program: 128887
Project: 128887
Buggy source:
public void init(TreeViewer viewer,IStructuredSelection selection){
  visible=!selection.isEmpty();
  if (selection.isEmpty()) {
    setEnabled(false);
    return;
  }
  boolean enabled=true;
  this.setText(null);
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  if (factory.isUserReadOnlyOnCurrentProject()) {
    visible=false;
  }
  for (  Object o : (selection).toArray()) {
    if (visible) {
      RepositoryNode node=(RepositoryNode)o;
      if (!ProjectManager.getInstance().isInCurrentMainProject(node)) {
        visible=false;
        break;
      }
switch (node.getType()) {
case STABLE_SYSTEM_FOLDER:
        visible=false;
case SYSTEM_FOLDER:
      visible=false;
    break;
case SIMPLE_FOLDER:
  Object obj=node.getProperties(EProperties.LABEL);
String label=null;
IRepositoryViewObject folderObj=node.getObject();
ERepositoryStatus statusFolder=folderObj.getRepositoryStatus();
boolean isDeletedFolder=statusFolder == ERepositoryStatus.DELETED;
if (obj instanceof String) {
label=(String)obj;
}
if (node.getContentType() == ERepositoryObjectType.JOB_DOC || node.getContentType() == ERepositoryObjectType.JOBLET_DOC || RepositoryConstants.USER_DEFINED.equals(label)) {
visible=false;
}
 else {
if (isDeletedFolder) {
this.setText(DELETE_FOREVER_TITLE);
this.setToolTipText(DELETE_FOREVER_TOOLTIP);
}
 else {
this.setText(DELETE_LOGICAL_TITLE);
this.setToolTipText(DELETE_LOGICAL_TOOLTIP);
}
if (node.hasChildren()) {
visible=true;
enabled=true;
}
}
String selectName=selection.getFirstElement().toString();
if (node.getContentType() == ERepositoryObjectType.SQLPATTERNS && selectName.equals(label) && !selectName.contains("String_Node_Str")) {
visible=false;
}
break;
case REPOSITORY_ELEMENT:
Object contentType=node.getProperties(EProperties.CONTENT_TYPE);
if (contentType == ERepositoryObjectType.JOB_DOC || contentType == ERepositoryObjectType.JOBLET_DOC) {
visible=false;
break;
}
if (contentType == ERepositoryObjectType.METADATA_CON_CDC) {
enabled=false;
visible=false;
break;
}
if (contentType == ERepositoryObjectType.SERVICESOPERATION) {
enabled=false;
visible=false;
break;
}
if (contentType == ERepositoryObjectType.SERVICESPORT) {
enabled=false;
visible=false;
break;
}
IRepositoryViewObject repObj=node.getObject();
ERepositoryStatus status=repObj.getRepositoryStatus();
boolean isEditable=status.isPotentiallyEditable() || status.isEditable();
boolean isDeleted=status == ERepositoryStatus.DELETED;
ERepositoryObjectType nodeType=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
if (nodeType.isSubItem() && repObj instanceof ISubRepositoryObject) {
ISubRepositoryObject subRepositoryObject=(ISubRepositoryObject)repObj;
isDeleted=SubItemHelper.isDeleted(subRepositoryObject.getAbstractMetadataObject());
}
if (isDeleted) {
if (ERepositoryObjectType.METADATA_CON_TABLE.equals(nodeType)) {
visible=false;
break;
}
if (ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
visible=false;
break;
}
if (ERepositoryObjectType.METADATA_CON_QUERY.equals(nodeType)) {
visible=false;
break;
}
if (getText() == null || DELETE_FOREVER_TITLE.equals(getText())) {
this.setText(DELETE_FOREVER_TITLE);
this.setToolTipText(DELETE_FOREVER_TOOLTIP);
}
 else {
visible=false;
}
}
 else {
ERepositoryObjectType repositoryObjectType=repObj.getRepositoryObjectType();
if (repositoryObjectType == ERepositoryObjectType.METADATA_CON_TABLE || repositoryObjectType == ERepositoryObjectType.METADATA_CON_QUERY || repositoryObjectType == ERepositoryObjectType.METADATA_CON_COLUMN) {
visible=false;
}
 else {
if (getText() == null || DELETE_LOGICAL_TITLE.equals(getText())) {
this.setText(DELETE_LOGICAL_TITLE);
this.setToolTipText(DELETE_LOGICAL_TOOLTIP);
if (!isEditable) {
visible=true;
enabled=false;
}
}
 else {
visible=false;
}
}
}
break;
default :
break;
}
}
}
setEnabled(enabled);
}

Fixed version (ground truth):
public void init(TreeViewer viewer,IStructuredSelection selection){
  visible=!selection.isEmpty();
  if (selection.isEmpty()) {
    setEnabled(false);
    return;
  }
  boolean enabled=true;
  this.setText(null);
  IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  if (factory.isUserReadOnlyOnCurrentProject()) {
    visible=false;
  }
  for (  Object o : (selection).toArray()) {
    if (visible) {
      RepositoryNode node=(RepositoryNode)o;
      if (!ProjectManager.getInstance().isInCurrentMainProject(node)) {
        visible=false;
        break;
      }
switch (node.getType()) {
case STABLE_SYSTEM_FOLDER:
        visible=false;
case SYSTEM_FOLDER:
      visible=false;
    break;
case SIMPLE_FOLDER:
  Object obj=node.getProperties(EProperties.LABEL);
String label=null;
IRepositoryViewObject folderObj=node.getObject();
ERepositoryStatus statusFolder=folderObj.getRepositoryStatus();
boolean isDeletedFolder=statusFolder == ERepositoryStatus.DELETED;
if (obj instanceof String) {
label=(String)obj;
}
if (node.getContentType() == ERepositoryObjectType.JOB_DOC || node.getContentType() == ERepositoryObjectType.JOBLET_DOC || RepositoryConstants.USER_DEFINED.equals(label)) {
visible=false;
}
 else {
if (isDeletedFolder) {
this.setText(DELETE_FOREVER_TITLE);
this.setToolTipText(DELETE_FOREVER_TOOLTIP);
}
 else {
this.setText(DELETE_LOGICAL_TITLE);
this.setToolTipText(DELETE_LOGICAL_TOOLTIP);
}
if (node.hasChildren()) {
visible=true;
enabled=true;
}
}
String selectName=selection.getFirstElement().toString();
if (node.getContentType() == ERepositoryObjectType.SQLPATTERNS && selectName.equals(label) && !selectName.contains("String_Node_Str")) {
visible=false;
}
break;
case REPOSITORY_ELEMENT:
Object contentType=node.getProperties(EProperties.CONTENT_TYPE);
if (contentType == ERepositoryObjectType.JOB_DOC || contentType == ERepositoryObjectType.JOBLET_DOC) {
visible=false;
break;
}
if (contentType == ERepositoryObjectType.METADATA_CON_CDC) {
enabled=false;
visible=false;
break;
}
if (contentType == ERepositoryObjectType.SERVICESOPERATION) {
enabled=false;
visible=false;
break;
}
if (contentType == ERepositoryObjectType.SERVICESPORT) {
enabled=false;
visible=false;
break;
}
IRepositoryViewObject repObj=node.getObject();
ERepositoryStatus status=repObj.getRepositoryStatus();
boolean isEditable=status.isPotentiallyEditable() || status.isEditable();
boolean isDeleted=status == ERepositoryStatus.DELETED;
ERepositoryObjectType nodeType=(ERepositoryObjectType)node.getProperties(EProperties.CONTENT_TYPE);
if (nodeType.isSubItem() && repObj instanceof ISubRepositoryObject) {
ISubRepositoryObject subRepositoryObject=(ISubRepositoryObject)repObj;
isDeleted=SubItemHelper.isDeleted(subRepositoryObject.getAbstractMetadataObject());
}
if (isDeleted) {
if (ERepositoryObjectType.METADATA_CON_COLUMN.equals(nodeType)) {
visible=false;
break;
}
if (ERepositoryObjectType.METADATA_CON_QUERY.equals(nodeType)) {
visible=false;
break;
}
if (getText() == null || DELETE_FOREVER_TITLE.equals(getText())) {
this.setText(DELETE_FOREVER_TITLE);
this.setToolTipText(DELETE_FOREVER_TOOLTIP);
}
 else {
visible=false;
}
}
 else {
ERepositoryObjectType repositoryObjectType=repObj.getRepositoryObjectType();
if (repositoryObjectType == ERepositoryObjectType.METADATA_CON_TABLE || repositoryObjectType == ERepositoryObjectType.METADATA_CON_QUERY || repositoryObjectType == ERepositoryObjectType.METADATA_CON_COLUMN) {
visible=false;
}
 else {
if (getText() == null || DELETE_LOGICAL_TITLE.equals(getText())) {
this.setText(DELETE_LOGICAL_TITLE);
this.setToolTipText(DELETE_LOGICAL_TOOLTIP);
if (!isEditable) {
visible=true;
enabled=false;
}
}
 else {
visible=false;
}
}
}
break;
default :
break;
}
}
}
setEnabled(enabled);
}