Program: 123968
Project: 123968
Buggy source:
/** 
 * DOC smallet Comment method "openRoutineEditor".
 * @param routineItem
 * @throws SystemException
 * @throws PartInitException
 */
protected IEditorPart openRoutineEditor(RoutineItem routineItem,boolean readOnly) throws SystemException, PartInitException {
  if (routineItem == null) {
    return null;
  }
  ICodeGeneratorService service=(ICodeGeneratorService)GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
  ECodeLanguage lang=((RepositoryContext)CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
  ITalendSynchronizer routineSynchronizer;
switch (lang) {
case JAVA:
    routineSynchronizer=service.createJavaRoutineSynchronizer();
  break;
case PERL:
routineSynchronizer=service.createPerlRoutineSynchronizer();
break;
default :
throw new UnsupportedOperationException(Messages.getString("String_Node_Str") + lang);
}
IWorkbenchPage page=getActivePage();
IEditorReference[] editorParts=page.getEditorReferences();
String talendEditorID="String_Node_Str" + lang.getCaseName() + "String_Node_Str";
boolean found=false;
IEditorPart talendEditor=null;
for (IEditorReference reference : editorParts) {
IEditorPart editor=reference.getEditor(false);
if (talendEditorID.equals(editor.getSite().getId())) {
RepositoryEditorInput editorInput=(RepositoryEditorInput)editor.getEditorInput();
if (editorInput.getItem().equals(routineItem)) {
page.bringToTop(editor);
found=true;
talendEditor=editor;
break;
}
}
}
if (!found) {
routineSynchronizer.syncRoutine(routineItem,true);
IFile file=null;
ProjectManager projectManager=ProjectManager.getInstance();
boolean flag=projectManager.isInCurrentMainProject(routineItem);
if (!flag) {
file=routineSynchronizer.getRoutinesFile(routineItem);
}
 else {
ProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
String lastVersion=factory.getLastVersion(routineItem.getProperty().getId()).getVersion();
String curVersion=routineItem.getProperty().getVersion();
if (curVersion != null && curVersion.equals(lastVersion)) {
file=routineSynchronizer.getFile(routineItem);
}
 else {
file=routineSynchronizer.getRoutinesFile(routineItem);
}
}
RepositoryEditorInput input=new RoutineEditorInput(file,routineItem);
input.setReadOnly(readOnly);
talendEditor=page.openEditor(input,talendEditorID);
}
return talendEditor;
}

Fixed version (ground truth):
/** 
 * DOC smallet Comment method "openRoutineEditor".
 * @param routineItem
 * @throws SystemException
 * @throws PartInitException
 */
protected IEditorPart openRoutineEditor(RoutineItem routineItem,boolean readOnly) throws SystemException, PartInitException {
  if (routineItem == null) {
    return null;
  }
  ICodeGeneratorService service=(ICodeGeneratorService)GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);
  ECodeLanguage lang=((RepositoryContext)CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
  ITalendSynchronizer routineSynchronizer;
switch (lang) {
case JAVA:
    routineSynchronizer=service.createJavaRoutineSynchronizer();
  break;
case PERL:
routineSynchronizer=service.createPerlRoutineSynchronizer();
break;
default :
throw new UnsupportedOperationException(Messages.getString("String_Node_Str") + lang);
}
IWorkbenchPage page=getActivePage();
IEditorReference[] editorParts=page.getEditorReferences();
String talendEditorID="String_Node_Str" + lang.getCaseName() + "String_Node_Str";
boolean found=false;
IEditorPart talendEditor=null;
for (IEditorReference reference : editorParts) {
IEditorPart editor=reference.getEditor(false);
if (talendEditorID.equals(editor.getSite().getId())) {
RepositoryEditorInput editorInput=(RepositoryEditorInput)editor.getEditorInput();
if (editorInput.getItem().equals(routineItem)) {
page.bringToTop(editor);
found=true;
talendEditor=editor;
break;
}
}
}
if (!found) {
IFile file=null;
ProjectManager projectManager=ProjectManager.getInstance();
boolean flag=projectManager.isInCurrentMainProject(routineItem);
if (!flag) {
file=routineSynchronizer.getRoutinesFile(routineItem);
}
 else {
routineSynchronizer.syncRoutine(routineItem,true);
ProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
String lastVersion=factory.getLastVersion(routineItem.getProperty().getId()).getVersion();
String curVersion=routineItem.getProperty().getVersion();
if (curVersion != null && curVersion.equals(lastVersion)) {
file=routineSynchronizer.getFile(routineItem);
}
 else {
file=routineSynchronizer.getRoutinesFile(routineItem);
}
}
RepositoryEditorInput input=new RoutineEditorInput(file,routineItem);
input.setReadOnly(readOnly);
talendEditor=page.openEditor(input,talendEditorID);
}
return talendEditor;
}