Program: 75344
Project: 75344
Buggy source:
/** 
 * Query the user for a filename, save the model to that file, and open a new window to view the model. This overrides the base class to update the entry in the ModelDirectory and to rename the model to match the file name.
 * @return True if the save succeeds.
 */
protected boolean _saveAs(){
  if (_tableau == null) {
    throw new InternalErrorException("String_Node_Str");
  }
  JFileChooser fileDialog=new JFileChooser();
  if (_fileFilter != null) {
    fileDialog.addChoosableFileFilter(_fileFilter);
  }
  fileDialog.setDialogTitle("String_Node_Str");
  if (_directory != null) {
    fileDialog.setCurrentDirectory(_directory);
  }
 else {
    String currentWorkingDirectory=StringUtilities.getProperty("String_Node_Str");
    if (currentWorkingDirectory != null) {
      fileDialog.setCurrentDirectory(new File(currentWorkingDirectory));
    }
  }
  if (_initialSaveAsFileName != null) {
    fileDialog.setSelectedFile(new File(fileDialog.getCurrentDirectory(),_initialSaveAsFileName));
  }
  int returnVal=fileDialog.showSaveDialog(this);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file=fileDialog.getSelectedFile();
    try {
      URL newURL=file.toURL();
      String newKey=newURL.toExternalForm();
      Effigy previousOpen=getDirectory().getEffigy(newKey);
      if (previousOpen != null && previousOpen != getEffigy()) {
        if (previousOpen.isModified()) {
          previousOpen.showTableaux();
          String confirm="String_Node_Str" + file.getName() + "String_Node_Str";
          int selected=JOptionPane.showOptionDialog(this,confirm,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
          if (selected == 1) {
            return false;
          }
          previousOpen.setModified(false);
        }
        previousOpen.closeTableaux();
      }
      if (file.exists()) {
        String query="String_Node_Str" + file.getName() + "String_Node_Str";
        int selected=JOptionPane.showOptionDialog(this,query,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
        if (selected == 1) {
          return false;
        }
      }
      _directory=fileDialog.getCurrentDirectory();
      _writeFile(file);
      getConfiguration().openModel(newURL,newURL,newKey);
      Effigy effigy=getEffigy();
      if (effigy != null) {
        String id=effigy.identifier.getExpression();
        if (id.equals("String_Node_Str")) {
          effigy.setContainer(null);
        }
      }
    }
 catch (    Exception ex) {
      report("String_Node_Str",ex);
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Query the user for a filename, save the model to that file, and open a new window to view the model. This overrides the base class to update the entry in the ModelDirectory and to rename the model to match the file name.
 * @return True if the save succeeds.
 */
protected boolean _saveAs(){
  if (_tableau == null) {
    throw new InternalErrorException("String_Node_Str");
  }
  JFileChooser fileDialog=new JFileChooser();
  if (_fileFilter != null) {
    fileDialog.addChoosableFileFilter(_fileFilter);
  }
  fileDialog.setDialogTitle("String_Node_Str");
  if (_directory != null) {
    fileDialog.setCurrentDirectory(_directory);
  }
 else {
    String currentWorkingDirectory=StringUtilities.getProperty("String_Node_Str");
    if (currentWorkingDirectory != null) {
      fileDialog.setCurrentDirectory(new File(currentWorkingDirectory));
    }
  }
  if (_initialSaveAsFileName != null) {
    fileDialog.setSelectedFile(new File(fileDialog.getCurrentDirectory(),_initialSaveAsFileName));
  }
  int returnVal=fileDialog.showSaveDialog(this);
  if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file=fileDialog.getSelectedFile();
    try {
      URL newURL=file.toURL();
      String newKey=newURL.toExternalForm();
      Effigy previousOpen=getDirectory().getEffigy(newKey);
      if (previousOpen != null && previousOpen != getEffigy()) {
        if (previousOpen.isModified()) {
          previousOpen.showTableaux();
          String confirm="String_Node_Str" + file.getName() + "String_Node_Str";
          int selected=JOptionPane.showOptionDialog(this,confirm,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
          if (selected == 1) {
            return false;
          }
          if (!_checkForDerivedObjects()) {
            return false;
          }
          previousOpen.setModified(false);
        }
        previousOpen.closeTableaux();
      }
      if (file.exists()) {
        String query="String_Node_Str" + file.getName() + "String_Node_Str";
        int selected=JOptionPane.showOptionDialog(this,query,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
        if (selected == 1) {
          return false;
        }
      }
      _directory=fileDialog.getCurrentDirectory();
      _writeFile(file);
      getConfiguration().openModel(newURL,newURL,newKey);
      Effigy effigy=getEffigy();
      if (effigy != null) {
        String id=effigy.identifier.getExpression();
        if (id.equals("String_Node_Str")) {
          effigy.setContainer(null);
        }
      }
    }
 catch (    Exception ex) {
      report("String_Node_Str",ex);
      return false;
    }
  }
  return true;
}