Program: 128965
Project: 128965
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>();
  IRunnableWithProgress op=new IRunnableWithProgress(){
    public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
      for (      Object obj : ((IStructuredSelection)selection).toArray()) {
        if (obj instanceof RepositoryNode) {
          RepositoryNode node=(RepositoryNode)obj;
          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(){
                      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());
            }
 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(){
                        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);
          }
        }
      }
    }
    /** 
 * 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;
    }
  }
;
  try {
    PlatformUI.getWorkbench().getProgressService().run(true,true,op);
    factory.saveProject(ProjectManager.getInstance().getCurrentProject());
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  final boolean updatePalette=needToUpdataPalette;
  Display.getCurrent().syncExec(new Runnable(){
    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();
        }
        if (!CoreRuntimePlugin.getInstance().isDataProfilePerspectiveSelected()) {
          RepositoryManager.refresh(ERepositoryObjectType.JOB_SCRIPT);
          IRepositoryView repositoryView=RepositoryManagerHelper.getRepositoryView();
          if (repositoryView != null) {
            RepositoryManager.refresh(types);
          }
        }
        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);
          }
        }
        if (!deleteActionCache.isDocRefresh() && !CoreRuntimePlugin.getInstance().isDataProfilePerspectiveSelected()) {
          RepositoryManager.refreshCreatedNode(ERepositoryObjectType.DOCUMENTATION);
        }
      }
      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>();
  IRunnableWithProgress op=new IRunnableWithProgress(){
    public void run(    IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
      monitor.beginTask("String_Node_Str",IProgressMonitor.UNKNOWN);
      for (      Object obj : ((IStructuredSelection)selection).toArray()) {
        if (obj instanceof RepositoryNode) {
          RepositoryNode node=(RepositoryNode)obj;
          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(){
                      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(){
                        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);
          }
        }
      }
    }
    /** 
 * 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;
    }
  }
;
  try {
    PlatformUI.getWorkbench().getProgressService().run(true,true,op);
    factory.saveProject(ProjectManager.getInstance().getCurrentProject());
  }
 catch (  Exception e) {
    ExceptionHandler.process(e);
  }
  final boolean updatePalette=needToUpdataPalette;
  Display.getCurrent().syncExec(new Runnable(){
    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();
        }
        if (!CoreRuntimePlugin.getInstance().isDataProfilePerspectiveSelected()) {
          RepositoryManager.refresh(ERepositoryObjectType.JOB_SCRIPT);
          IRepositoryView repositoryView=RepositoryManagerHelper.getRepositoryView();
          if (repositoryView != null) {
            RepositoryManager.refresh(types);
          }
        }
        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);
          }
        }
        if (!deleteActionCache.isDocRefresh() && !CoreRuntimePlugin.getInstance().isDataProfilePerspectiveSelected()) {
          RepositoryManager.refreshCreatedNode(ERepositoryObjectType.DOCUMENTATION);
        }
      }
      deleteActionCache.revertParameters();
    }
  }
);
}