Program: 73282
Project: 73282
Buggy source:
/** 
 * Create a java.awt.FileDialog and get the user input.  If  {@link ptolemy.gui.PtGUIUtilities#useFileDialog()} returnstrue, then  {@link #actionPerformed(ActionEvent)} uses this method.Otherwise,  {@link #_actionPerformedJFileChooser(ActionEvent)} is used.<p>Under Mac OS X, this method is preferred over _actionPerformedJFileChooser().</p> <p>Under Bash, to test this method, use:</p> <pre> export JAVAFLAGS=-Dptolemy.ptII.useFileDialog=true $PTII/bin/vergil ~/ptII/ptolemy/actor/lib/io/test/auto/FileReader.xml </pre>
 */
private void _actionPerformedFileDialog(ActionEvent e){
  FileDialog fileDialog=new FileDialog(JOptionPane.getFrameForComponent(Query.this),"String_Node_Str",FileDialog.LOAD);
  if (_startingDirectory != null) {
    fileDialog.setDirectory(_startingDirectory.toString());
  }
  String fileName=getSelectedFileName().trim();
  if (!fileName.equals("String_Node_Str")) {
    fileDialog.setFile(fileName);
  }
  if (_allowDirectories) {
    System.setProperty("String_Node_Str","String_Node_Str");
  }
  fileDialog.show();
  if (fileDialog.getFile() == null) {
    return;
  }
  File file=null;
  if (_startingDirectory != null) {
    file=new File(_startingDirectory,fileDialog.getFile());
  }
 else {
    String currentWorkingDirectory=null;
    try {
      currentWorkingDirectory=System.getProperty("String_Node_Str");
    }
 catch (    Throwable throwable) {
    }
    if (currentWorkingDirectory != null) {
      file=new File(currentWorkingDirectory,fileDialog.getFile());
    }
 else {
      file=new File(fileDialog.getFile());
    }
  }
  if (file.exists() && fileDialog.getMode() == FileDialog.SAVE) {
    String queryString=file.getName() + "String_Node_Str";
    int selected=JOptionPane.showOptionDialog(null,queryString,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
    if (selected == 1) {
      return;
    }
  }
  if (_base == null) {
    try {
      _entryBox.setText(new File(fileDialog.getFile()).getCanonicalPath());
    }
 catch (    IOException ex) {
      _entryBox.setText(fileDialog.getFile());
    }
  }
 else {
    File selectedFile=new File(fileDialog.getDirectory(),fileDialog.getFile());
    try {
      selectedFile=selectedFile.getCanonicalFile();
    }
 catch (    IOException ex) {
    }
    URI relativeURI=_base.relativize(selectedFile.toURI());
    if (relativeURI != null && relativeURI.getScheme() != null && relativeURI.getScheme().equals("String_Node_Str")) {
      String pathName=relativeURI.getPath();
      file=new File(pathName.replace("String_Node_Str","String_Node_Str"));
      try {
        _entryBox.setText(file.getCanonicalPath().replace('\\','/'));
      }
 catch (      IOException ex) {
        _entryBox.setText(file.toString());
      }
    }
 else {
      _entryBox.setText(relativeURI.toString());
    }
  }
  _owner._notifyListeners(_name);
}

Fixed version (ground truth):
/** 
 * Create a java.awt.FileDialog and get the user input.  If  {@link ptolemy.gui.PtGUIUtilities#useFileDialog()} returnstrue, then  {@link #actionPerformed(ActionEvent)} uses this method.Otherwise,  {@link #_actionPerformedJFileChooser(ActionEvent)} is used.<p>Under Mac OS X, this method is preferred over _actionPerformedJFileChooser().</p> <p>Under Bash, to test this method, use:</p> <pre> export JAVAFLAGS=-Dptolemy.ptII.useFileDialog=true $PTII/bin/vergil ~/ptII/ptolemy/actor/lib/io/test/auto/FileReader.xml </pre>
 */
private void _actionPerformedFileDialog(ActionEvent e){
  FileDialog fileDialog=new FileDialog(JOptionPane.getFrameForComponent(Query.this),"String_Node_Str",FileDialog.LOAD);
  if (_startingDirectory != null) {
    fileDialog.setDirectory(_startingDirectory.toString());
  }
  String fileName=getSelectedFileName().trim();
  if (!fileName.equals("String_Node_Str")) {
    fileDialog.setFile(fileName);
  }
  if (_allowDirectories) {
    System.setProperty("String_Node_Str","String_Node_Str");
  }
  fileDialog.show();
  if (fileDialog.getFile() == null) {
    return;
  }
  File file=null;
  _startingDirectory=new File(fileDialog.getDirectory());
  if (_startingDirectory != null) {
    file=new File(_startingDirectory,fileDialog.getFile());
  }
 else {
    String currentWorkingDirectory=null;
    try {
      currentWorkingDirectory=System.getProperty("String_Node_Str");
    }
 catch (    Throwable throwable) {
    }
    if (currentWorkingDirectory != null) {
      file=new File(currentWorkingDirectory,fileDialog.getFile());
    }
 else {
      file=new File(fileDialog.getFile());
    }
  }
  if (file.exists() && fileDialog.getMode() == FileDialog.SAVE) {
    String queryString=file.getName() + "String_Node_Str";
    int selected=JOptionPane.showOptionDialog(null,queryString,"String_Node_Str",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,null);
    if (selected == 1) {
      return;
    }
  }
  if (_base == null) {
    try {
      _entryBox.setText(new File(fileDialog.getDirectory(),fileDialog.getFile()).getCanonicalPath());
    }
 catch (    IOException ex) {
      _entryBox.setText(fileDialog.getFile());
    }
  }
 else {
    File selectedFile=new File(fileDialog.getDirectory(),fileDialog.getFile());
    try {
      selectedFile=selectedFile.getCanonicalFile();
    }
 catch (    IOException ex) {
    }
    URI relativeURI=_base.relativize(selectedFile.toURI());
    if (relativeURI != null && relativeURI.getScheme() != null && relativeURI.getScheme().equals("String_Node_Str")) {
      String pathName=relativeURI.getPath();
      file=new File(pathName.replace("String_Node_Str","String_Node_Str"));
      try {
        _entryBox.setText(file.getCanonicalPath().replace('\\','/'));
      }
 catch (      IOException ex) {
        _entryBox.setText(file.toString());
      }
    }
 else {
      _entryBox.setText(relativeURI.toString());
    }
  }
  _owner._notifyListeners(_name);
}