Program: 143738
Project: 143738
Buggy source:
public FormController showFormInMainPanel(final String formName,final IMainContainer container,final String title,final boolean closeAll,final String dialogName){
  if (loginForm != null && loginForm.getName() != formName) {
    return null;
  }
  if (formName == null)   throw new IllegalArgumentException(application.getI18NMessage("String_Node_Str"));
  FormController currentMainShowingForm=null;
  if (currentContainer != null) {
    currentMainShowingForm=container.getController();
  }
  boolean containerSwitch=container != currentContainer;
  if (currentMainShowingForm != null && formName.equals(currentMainShowingForm.getName()) && !containerSwitch && !design)   return leaseFormPanel(currentMainShowingForm.getName());
  final Form f=possibleForms.get(formName);
  if (f == null) {
    return null;
  }
  try {
    int access=application.getFlattenedSolution().getSecurityAccess(f.getUUID());
    if (access != -1) {
      boolean b_visible=((access & IRepository.VIEWABLE) != 0);
      if (!b_visible) {
        application.invokeLater(new Runnable(){
          public void run(){
            application.reportWarningInStatus(application.getI18NMessage("String_Node_Str"));
          }
        }
);
        return null;
      }
    }
    if (currentMainShowingForm != null) {
      if (!containerSwitch && application.getModeManager().getMode() != IModeManager.EDIT_MODE) {
        application.getModeManager().setMode(IModeManager.EDIT_MODE);
      }
      FormController fp=leaseFormPanel(currentMainShowingForm.getName());
      if (fp != null && !containerSwitch) {
        List<Runnable> invokeLaterRunnables=new ArrayList<Runnable>();
        boolean ok=fp.notifyVisible(false,invokeLaterRunnables);
        Utils.invokeLater(application,invokeLaterRunnables);
        if (application.getSolution() == null)         return null;
        if (!ok) {
          selectFormMenuItem(currentMainShowingForm.getForm());
          return fp;
        }
      }
    }
    FormController tmpForm=currentMainShowingForm;
    final FormController fp=leaseFormPanel(formName);
    currentMainShowingForm=fp;
    currentContainer=container;
    if (fp != null) {
      if (application.getCmdManager() instanceof ICmdManagerInternal) {
        ((ICmdManagerInternal)application.getCmdManager()).setCurrentUndoManager(fp.getUndoManager());
      }
      boolean isNewUser=checkAndUpdateFormUser(fp,container);
      if (isNewUser) {
        container.add(fp.getFormUI(),formName);
      }
      currentContainer.setFormController(fp);
      SolutionScope ss=application.getScriptEngine().getSolutionScope();
      ss.put("String_Node_Str",ss,fp.initForJSUsage());
      fp.setView(fp.getView());
      fp.executeOnLoadMethod();
      if (application.getSolution() == null)       return null;
      fillScriptMenu();
      if (!container.isVisible() && !closeAll) {
        ((FormManager)application.getFormManager()).getHistory(currentContainer).clear(100);
      }
      getHistory(currentContainer).add(fp.getName());
      selectFormMenuItem(f);
      List<Runnable> invokeLaterRunnables=new ArrayList<Runnable>();
      fp.notifyVisible(true,invokeLaterRunnables);
      enableCmds(true);
      final IMainContainer cachedContainer=currentContainer;
      Runnable title_focus=new Runnable(){
        public void run(){
          FormController fc=cachedContainer.getController();
          if (fc != null && fc == fp) {
            String titleText=title;
            if (titleText == null)             titleText=f.getTitleText();
            if (titleText == null || titleText.equals("String_Node_Str"))             titleText=fc.getName();
            if (NO_TITLE_TEXT.equals(titleText))             titleText="String_Node_Str";
            cachedContainer.setTitle(titleText);
            cachedContainer.requestFocus();
          }
        }
      }
;
      if (isNewUser) {
        final IMainContainer showContainer=currentContainer;
        currentContainer.showBlankPanel();
        invokeLaterRunnables.add(new Runnable(){
          public void run(){
            FormController currentController=showContainer.getController();
            if (currentController != null && fp.getName().equals(currentController.getName())) {
              showContainer.show(fp.getName());
              application.getJSWindowManager().setCurrentWindowName(dialogName);
            }
          }
        }
);
      }
 else {
        currentContainer.show(fp.getName());
        application.getJSWindowManager().setCurrentWindowName(dialogName);
      }
      invokeLaterRunnables.add(title_focus);
      Utils.invokeLater(application,invokeLaterRunnables);
    }
 else {
      currentContainer.setFormController(null);
    }
    J2DBGlobals.firePropertyChange(this,"String_Node_Str",tmpForm,currentMainShowingForm);
    return fp;
  }
 catch (  Exception e) {
    Debug.error(e);
  }
  return null;
}

Fixed version (ground truth):
public FormController showFormInMainPanel(final String formName,final IMainContainer container,final String title,final boolean closeAll,final String dialogName){
  if (loginForm != null && loginForm.getName() != formName) {
    return null;
  }
  if (formName == null)   throw new IllegalArgumentException(application.getI18NMessage("String_Node_Str"));
  FormController currentMainShowingForm=null;
  if (currentContainer != null) {
    currentMainShowingForm=container.getController();
  }
  boolean containerSwitch=container != currentContainer;
  if (currentMainShowingForm != null && formName.equals(currentMainShowingForm.getName()) && !containerSwitch && !design)   return leaseFormPanel(currentMainShowingForm.getName());
  final Form f=possibleForms.get(formName);
  if (f == null) {
    return null;
  }
  try {
    int access=application.getFlattenedSolution().getSecurityAccess(f.getUUID());
    if (access != -1) {
      boolean b_visible=((access & IRepository.VIEWABLE) != 0);
      if (!b_visible) {
        application.invokeLater(new Runnable(){
          public void run(){
            application.reportWarningInStatus(application.getI18NMessage("String_Node_Str"));
          }
        }
);
        return null;
      }
    }
    if (currentMainShowingForm != null) {
      if (!containerSwitch && application.getModeManager().getMode() != IModeManager.EDIT_MODE) {
        application.getModeManager().setMode(IModeManager.EDIT_MODE);
      }
      FormController fp=leaseFormPanel(currentMainShowingForm.getName());
      if (fp != null && !containerSwitch) {
        List<Runnable> invokeLaterRunnables=new ArrayList<Runnable>();
        boolean ok=fp.notifyVisible(false,invokeLaterRunnables);
        Utils.invokeLater(application,invokeLaterRunnables);
        if (application.getSolution() == null)         return null;
        if (!ok) {
          selectFormMenuItem(currentMainShowingForm.getForm());
          return fp;
        }
      }
    }
    FormController tmpForm=currentMainShowingForm;
    final FormController fp=leaseFormPanel(formName);
    currentMainShowingForm=fp;
    currentContainer=container;
    if (fp != null) {
      if (application.getCmdManager() instanceof ICmdManagerInternal) {
        ((ICmdManagerInternal)application.getCmdManager()).setCurrentUndoManager(fp.getUndoManager());
      }
      boolean isNewUser=checkAndUpdateFormUser(fp,container);
      if (isNewUser) {
        container.add(fp.getFormUI(),formName);
      }
      currentContainer.setFormController(fp);
      SolutionScope ss=application.getScriptEngine().getSolutionScope();
      Context.enter();
      try {
        ss.put("String_Node_Str",ss,new NativeJavaObject(ss,fp.initForJSUsage(),new InstanceJavaMembers(ss,JSForm.class)));
      }
  finally {
        Context.exit();
      }
      fp.setView(fp.getView());
      fp.executeOnLoadMethod();
      if (application.getSolution() == null)       return null;
      fillScriptMenu();
      if (!container.isVisible() && !closeAll) {
        ((FormManager)application.getFormManager()).getHistory(currentContainer).clear(100);
      }
      getHistory(currentContainer).add(fp.getName());
      selectFormMenuItem(f);
      List<Runnable> invokeLaterRunnables=new ArrayList<Runnable>();
      fp.notifyVisible(true,invokeLaterRunnables);
      enableCmds(true);
      final IMainContainer cachedContainer=currentContainer;
      Runnable title_focus=new Runnable(){
        public void run(){
          FormController fc=cachedContainer.getController();
          if (fc != null && fc == fp) {
            String titleText=title;
            if (titleText == null)             titleText=f.getTitleText();
            if (titleText == null || titleText.equals("String_Node_Str"))             titleText=fc.getName();
            if (NO_TITLE_TEXT.equals(titleText))             titleText="String_Node_Str";
            cachedContainer.setTitle(titleText);
            cachedContainer.requestFocus();
          }
        }
      }
;
      if (isNewUser) {
        final IMainContainer showContainer=currentContainer;
        currentContainer.showBlankPanel();
        invokeLaterRunnables.add(new Runnable(){
          public void run(){
            FormController currentController=showContainer.getController();
            if (currentController != null && fp.getName().equals(currentController.getName())) {
              showContainer.show(fp.getName());
              application.getJSWindowManager().setCurrentWindowName(dialogName);
            }
          }
        }
);
      }
 else {
        currentContainer.show(fp.getName());
        application.getJSWindowManager().setCurrentWindowName(dialogName);
      }
      invokeLaterRunnables.add(title_focus);
      Utils.invokeLater(application,invokeLaterRunnables);
    }
 else {
      currentContainer.setFormController(null);
    }
    J2DBGlobals.firePropertyChange(this,"String_Node_Str",tmpForm,currentMainShowingForm);
    return fp;
  }
 catch (  Exception e) {
    Debug.error(e);
  }
  return null;
}