Program: 128829
Project: 128829
Buggy source:
@Override protected void doRun(){
  final ISelection selection=getSelection();
  final IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  final DeleteActionCache deleteActionCache=DeleteActionCache.getInstance();
  deleteActionCache.setGetAlways(false);
  deleteActionCache.setDocRefresh(false);
  deleteActionCache.createRecords();
  final Set<ERepositoryObjectType> types=new HashSet<ERepositoryObjectType>();
  final List<RepositoryNode> deletedFolder=new ArrayList<RepositoryNode>();
  final IWorkspaceRunnable op=new IWorkspaceRunnable(){
    @Override public void run(    IProgressMonitor monitor){
      monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
      Object[] selections=((IStructuredSelection)selection).toArray();
      List<RepositoryNode> selectNodes=new ArrayList<RepositoryNode>();
      for (      Object obj : selections) {
        if (obj instanceof RepositoryNode) {
          selectNodes.add((RepositoryNode)obj);
        }
      }
      final List<ItemReferenceBean> unDeleteItems=RepositoryNodeDeleteManager.getInstance().getUnDeleteItems(selectNodes,deleteActionCache);
      for (      RepositoryNode node : selectNodes) {
        try {
          if (sourceFileOpening(node)) {
            continue;
          }
          if (containParent(node,(IStructuredSelection)selection)) {
            continue;
          }
          if (isForbidNode(node)) {
            continue;
          }
          if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
              IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
              Item repoItem=node.getObject().getProperty().getItem();
              if (service != null && !repoItem.getState().isDeleted()) {
                final StringBuffer jobNames=service.getAllTheJObNames(node);
                if (jobNames != null) {
                  Display.getDefault().syncExec(new Runnable(){
                    @Override public void run(){
                      String message=jobNames.toString() + Messages.getString("String_Node_Str");
                      final Shell shell=getShell();
                      confirmAssignDialog=MessageDialog.openQuestion(shell,"String_Node_Str",message);
                    }
                  }
);
                  if (!confirmAssignDialog) {
                    continue;
                  }
                }
              }
            }
            if (isInDeletedFolder(deletedFolder,node.getParent())) {
              continue;
            }
            boolean needReturn=deleteElements(factory,deleteActionCache,node);
            if (node.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.JOBLET) {
              needToUpdataPalette=true;
            }
            if (needReturn) {
              return;
            }
            types.add(node.getObjectType());
            IDesignerCoreService coreService=(IDesignerCoreService)GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
            IRepositoryViewObject object=node.getObject();
            if (coreService != null && object != null && object.getProperty() != null) {
              Item item=object.getProperty().getItem();
              IProcess iProcess=coreService.getProcessFromItem(item);
              if (iProcess != null && iProcess instanceof IProcess2) {
                IProcess2 process=(IProcess2)iProcess;
                process.removeProblems4ProcessDeleted();
              }
            }
          }
 else           if (node.getType() == ENodeType.SIMPLE_FOLDER) {
            FolderItem folderItem=(FolderItem)node.getObject().getProperty().getItem();
            if (node.getChildren().size() > 0 && !folderItem.getState().isDeleted()) {
              if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
                IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
                if (service != null) {
                  final StringBuffer jobNames=service.getAllTheJObNames(node);
                  if (jobNames != null) {
                    Display.getDefault().syncExec(new Runnable(){
                      @Override public void run(){
                        String message=null;
                        if (jobNames.toString().contains("String_Node_Str")) {
                          message=jobNames.toString() + Messages.getString("String_Node_Str");
                        }
 else {
                          message=jobNames.toString() + Messages.getString("String_Node_Str");
                        }
                        final Shell shell=getShell();
                        confirmAssignDialog=MessageDialog.openQuestion(shell,"String_Node_Str",message);
                      }
                    }
);
                    if (!confirmAssignDialog) {
                      continue;
                    }
                  }
                }
              }
            }
            boolean isSqlTemplate=false;
            if (node.getObject() instanceof Folder) {
              Object label=node.getProperties(EProperties.LABEL);
              if (ENodeType.SIMPLE_FOLDER.equals(node.getType()) && ERepositoryObjectType.SQLPATTERNS.equals(node.getContentType()) && (label.equals("String_Node_Str") || label.equals("String_Node_Str") || label.equals("String_Node_Str")|| label.equals("String_Node_Str")|| label.equals("String_Node_Str")|| label.equals("String_Node_Str")|| label.equals("String_Node_Str")) || label.equals("String_Node_Str")) {
                isSqlTemplate=true;
              }
            }
            if (!isSqlTemplate) {
              types.add(node.getContentType());
              if (node.getContentType() == ERepositoryObjectType.PROCESS || node.getContentType() == ERepositoryObjectType.JOBLET) {
                types.add(ERepositoryObjectType.DOCUMENTATION);
              }
              deletedFolder.add(node);
              deleteFolder(node,factory,deleteActionCache);
            }
          }
        }
 catch (        PersistenceException e) {
          MessageBoxExceptionHandler.process(e);
        }
catch (        BusinessException e) {
          MessageBoxExceptionHandler.process(e);
        }
      }
      if (unDeleteItems.size() > 0) {
        Display.getDefault().syncExec(new Runnable(){
          @Override public void run(){
            ItemReferenceDialog dialog=new ItemReferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),unDeleteItems);
            dialog.open();
          }
        }
);
      }
      try {
        factory.saveProject(ProjectManager.getInstance().getCurrentProject());
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
    /** 
 * DOC xqliu Comment method "sourceFileOpening".
 * @param node
 * @return
 */
    private boolean sourceFileOpening(    RepositoryNode node){
      boolean result=false;
      if (node != null) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
          ITDQRepositoryService service=(ITDQRepositoryService)GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
          if (service != null) {
            result=service.sourceFileOpening(node);
          }
        }
      }
      return result;
    }
  }
;
  IRunnableWithProgress iRunnableWithProgress=new IRunnableWithProgress(){
    @Override public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      IWorkspace workspace=ResourcesPlugin.getWorkspace();
      try {
        ISchedulingRule schedulingRule=workspace.getRoot();
        workspace.run(op,schedulingRule,IWorkspace.AVOID_UPDATE,monitor);
      }
 catch (      CoreException e) {
        throw new InvocationTargetException(e);
      }
    }
  }
;
  try {
    PlatformUI.getWorkbench().getProgressService().run(false,false,iRunnableWithProgress);
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  final boolean updatePalette=needToUpdataPalette;
  Display.getCurrent().syncExec(new Runnable(){
    @Override public void run(){
      if (!org.talend.commons.utils.platform.PluginChecker.isOnlyTopLoaded()) {
        if (updatePalette && GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
          ICoreService service=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
          service.updatePalette();
        }
        IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        for (        IEditorReference editors : page.getEditorReferences()) {
          if (GlobalServiceRegister.getDefault().isServiceRegistered(IDiagramModelService.class)) {
            IDiagramModelService service=(IDiagramModelService)GlobalServiceRegister.getDefault().getService(IDiagramModelService.class);
            service.refreshBusinessModel(editors);
          }
        }
      }
      deleteActionCache.revertParameters();
    }
  }
);
}

Fixed version (ground truth):
@Override protected void doRun(){
  final ISelection selection=getSelection();
  final IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  final DeleteActionCache deleteActionCache=DeleteActionCache.getInstance();
  deleteActionCache.setGetAlways(false);
  deleteActionCache.setDocRefresh(false);
  deleteActionCache.createRecords();
  final Set<ERepositoryObjectType> types=new HashSet<ERepositoryObjectType>();
  final List<RepositoryNode> deletedFolder=new ArrayList<RepositoryNode>();
  final IWorkspaceRunnable op=new IWorkspaceRunnable(){
    @Override public void run(    IProgressMonitor monitor){
      monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
      Object[] selections=((IStructuredSelection)selection).toArray();
      List<RepositoryNode> selectNodes=new ArrayList<RepositoryNode>();
      for (      Object obj : selections) {
        if (obj instanceof RepositoryNode) {
          selectNodes.add((RepositoryNode)obj);
        }
      }
      final List<ItemReferenceBean> unDeleteItems=RepositoryNodeDeleteManager.getInstance().getUnDeleteItems(selectNodes,deleteActionCache);
      for (      RepositoryNode node : selectNodes) {
        try {
          if (sourceFileOpening(node)) {
            continue;
          }
          if (containParent(node,(IStructuredSelection)selection)) {
            continue;
          }
          if (isForbidNode(node)) {
            continue;
          }
          if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
              IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
              Item repoItem=node.getObject().getProperty().getItem();
              if (service != null && !repoItem.getState().isDeleted()) {
                final StringBuffer jobNames=service.getAllTheJObNames(node);
                if (jobNames != null) {
                  Display.getDefault().syncExec(new Runnable(){
                    @Override public void run(){
                      String message=jobNames.toString() + Messages.getString("String_Node_Str");
                      final Shell shell=getShell();
                      confirmAssignDialog=MessageDialog.openQuestion(shell,"String_Node_Str",message);
                    }
                  }
);
                  if (!confirmAssignDialog) {
                    continue;
                  }
                }
              }
            }
            if (isInDeletedFolder(deletedFolder,node.getParent())) {
              continue;
            }
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
              IDesignerCoreService coreService=(IDesignerCoreService)GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
              IRepositoryViewObject object=node.getObject();
              if (coreService != null && object != null && object.getProperty() != null) {
                Item item=object.getProperty().getItem();
                IProcess iProcess=coreService.getProcessFromItem(item);
                if (iProcess != null && iProcess instanceof IProcess2) {
                  IProcess2 process=(IProcess2)iProcess;
                  process.removeProblems4ProcessDeleted();
                }
              }
            }
            boolean needReturn=deleteElements(factory,deleteActionCache,node);
            if (node.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.JOBLET) {
              needToUpdataPalette=true;
            }
            if (needReturn) {
              return;
            }
            types.add(node.getObjectType());
          }
 else           if (node.getType() == ENodeType.SIMPLE_FOLDER) {
            FolderItem folderItem=(FolderItem)node.getObject().getProperty().getItem();
            if (node.getChildren().size() > 0 && !folderItem.getState().isDeleted()) {
              if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
                IESBService service=(IESBService)GlobalServiceRegister.getDefault().getService(IESBService.class);
                if (service != null) {
                  final StringBuffer jobNames=service.getAllTheJObNames(node);
                  if (jobNames != null) {
                    Display.getDefault().syncExec(new Runnable(){
                      @Override public void run(){
                        String message=null;
                        if (jobNames.toString().contains("String_Node_Str")) {
                          message=jobNames.toString() + Messages.getString("String_Node_Str");
                        }
 else {
                          message=jobNames.toString() + Messages.getString("String_Node_Str");
                        }
                        final Shell shell=getShell();
                        confirmAssignDialog=MessageDialog.openQuestion(shell,"String_Node_Str",message);
                      }
                    }
);
                    if (!confirmAssignDialog) {
                      continue;
                    }
                  }
                }
              }
            }
            boolean isSqlTemplate=false;
            if (node.getObject() instanceof Folder) {
              Object label=node.getProperties(EProperties.LABEL);
              if (ENodeType.SIMPLE_FOLDER.equals(node.getType()) && ERepositoryObjectType.SQLPATTERNS.equals(node.getContentType()) && (label.equals("String_Node_Str") || label.equals("String_Node_Str") || label.equals("String_Node_Str")|| label.equals("String_Node_Str")|| label.equals("String_Node_Str")|| label.equals("String_Node_Str")|| label.equals("String_Node_Str")) || label.equals("String_Node_Str")) {
                isSqlTemplate=true;
              }
            }
            if (!isSqlTemplate) {
              types.add(node.getContentType());
              if (node.getContentType() == ERepositoryObjectType.PROCESS || node.getContentType() == ERepositoryObjectType.JOBLET) {
                types.add(ERepositoryObjectType.DOCUMENTATION);
              }
              deletedFolder.add(node);
              deleteFolder(node,factory,deleteActionCache);
            }
          }
        }
 catch (        PersistenceException e) {
          MessageBoxExceptionHandler.process(e);
        }
catch (        BusinessException e) {
          MessageBoxExceptionHandler.process(e);
        }
      }
      if (unDeleteItems.size() > 0) {
        Display.getDefault().syncExec(new Runnable(){
          @Override public void run(){
            ItemReferenceDialog dialog=new ItemReferenceDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),unDeleteItems);
            dialog.open();
          }
        }
);
      }
      try {
        factory.saveProject(ProjectManager.getInstance().getCurrentProject());
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
    /** 
 * DOC xqliu Comment method "sourceFileOpening".
 * @param node
 * @return
 */
    private boolean sourceFileOpening(    RepositoryNode node){
      boolean result=false;
      if (node != null) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
          ITDQRepositoryService service=(ITDQRepositoryService)GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
          if (service != null) {
            result=service.sourceFileOpening(node);
          }
        }
      }
      return result;
    }
  }
;
  IRunnableWithProgress iRunnableWithProgress=new IRunnableWithProgress(){
    @Override public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      IWorkspace workspace=ResourcesPlugin.getWorkspace();
      try {
        ISchedulingRule schedulingRule=workspace.getRoot();
        workspace.run(op,schedulingRule,IWorkspace.AVOID_UPDATE,monitor);
      }
 catch (      CoreException e) {
        throw new InvocationTargetException(e);
      }
    }
  }
;
  try {
    PlatformUI.getWorkbench().getProgressService().run(false,false,iRunnableWithProgress);
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  final boolean updatePalette=needToUpdataPalette;
  Display.getCurrent().syncExec(new Runnable(){
    @Override public void run(){
      if (!org.talend.commons.utils.platform.PluginChecker.isOnlyTopLoaded()) {
        if (updatePalette && GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
          ICoreService service=(ICoreService)GlobalServiceRegister.getDefault().getService(ICoreService.class);
          service.updatePalette();
        }
        IWorkbenchPage page=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        for (        IEditorReference editors : page.getEditorReferences()) {
          if (GlobalServiceRegister.getDefault().isServiceRegistered(IDiagramModelService.class)) {
            IDiagramModelService service=(IDiagramModelService)GlobalServiceRegister.getDefault().getService(IDiagramModelService.class);
            service.refreshBusinessModel(editors);
          }
        }
      }
      deleteActionCache.revertParameters();
    }
  }
);
}