Program: 72466
Project: 72466
Buggy source:
/** 
 * If the specified effigy is a TextEffigy and it already contains a tableau named "textTableau", then return that tableau; otherwise, create a new instance of TextEditorTableau in the specified effigy, and name it "textTableau" and return that tableau. If the specified effigy is not an instance of TextEffigy, but contains an instance of TextEffigy, then open a tableau for that effigy.  If it is a PtolemyEffigy, then create a text effigy with the MoML representation of the model. Finally, if is not a TextEffigy or a PtolemyEffigy, and it does not contain a TextEffigy, then attempt to open its URL and display its date by creating a text effigy, which will then be contained by the specified effigy. If all of this fails, then do not create a tableau and return null. It is the responsibility of callers of this method to check the return value and call show().
 * @param effigy The effigy.
 * @return A text editor tableau, or null if one cannot befound or created.
 * @exception Exception If the factory should be able to create atableau for the effigy, but something goes wrong.
 */
@Override public Tableau createTableau(Effigy effigy) throws Exception {
  if (effigy instanceof TextEffigy) {
    TextEditorTableau tableau=(TextEditorTableau)effigy.getEntity("String_Node_Str");
    if (tableau == null) {
      TextEditor editor=null;
      String style=syntaxStyle.getExpression();
      if (style == null || style.trim().equals("String_Node_Str")) {
        style=((TextEffigy)effigy).getSyntaxStyle();
      }
      if (style != null && !style.trim().equals("String_Node_Str")) {
        try {
          Class editorClass=Class.forName("String_Node_Str");
          Constructor constructor=editorClass.getConstructor(new Class[]{String.class,Document.class});
          editor=(TextEditor)constructor.newInstance(new Object[]{"String_Node_Str",((TextEffigy)effigy).getDocument()});
        }
 catch (        Throwable ex) {
          System.out.println("String_Node_Str" + ex.getMessage());
        }
      }
      tableau=(TextEditorTableau)_tableauConstructor.newInstance(new Object[]{effigy,"String_Node_Str",editor});
    }
    URL url=effigy.uri.getURL();
    if (url != null) {
      effigy.identifier.setExpression(url.toExternalForm());
    }
    tableau.setEditable(effigy.isModifiable());
    return tableau;
  }
 else {
    Iterator effigies=effigy.entityList(TextEffigy.class).iterator();
    while (effigies.hasNext()) {
      TextEffigy textEffigy=(TextEffigy)effigies.next();
      if (textEffigy.getName().equals("String_Node_Str")) {
        return createTableau(textEffigy);
      }
    }
    URL url=effigy.uri.getURL();
    TextEffigy textEffigy;
    if (effigy instanceof PtolemyEffigy) {
      String moml=((PtolemyEffigy)effigy).getModel().exportMoML();
      textEffigy=(TextEffigy)_newTextEffigyText.invoke(null,new Object[]{effigy,moml,"String_Node_Str"});
      textEffigy.setModifiable(false);
      textEffigy.setName("String_Node_Str");
    }
 else {
      textEffigy=(TextEffigy)_newTextEffigyURL.invoke(null,new Object[]{effigy,url,url});
      textEffigy.setName("String_Node_Str");
    }
    TextEditorTableau textTableau=(TextEditorTableau)createTableau(textEffigy);
    if (url != null) {
      textEffigy.identifier.setExpression(url.toExternalForm());
    }
    return textTableau;
  }
}

Fixed version (ground truth):
/** 
 * If the specified effigy is a TextEffigy and it already contains a tableau named "textTableau", then return that tableau; otherwise, create a new instance of TextEditorTableau in the specified effigy, and name it "textTableau" and return that tableau. If the specified effigy is not an instance of TextEffigy, but contains an instance of TextEffigy, then open a tableau for that effigy.  If it is a PtolemyEffigy, then create a text effigy with the MoML representation of the model. Finally, if is not a TextEffigy or a PtolemyEffigy, and it does not contain a TextEffigy, then attempt to open its URL and display its date by creating a text effigy, which will then be contained by the specified effigy. If all of this fails, then do not create a tableau and return null. It is the responsibility of callers of this method to check the return value and call show().
 * @param effigy The effigy.
 * @return A text editor tableau, or null if one cannot befound or created.
 * @exception Exception If the factory should be able to create atableau for the effigy, but something goes wrong.
 */
@Override public Tableau createTableau(Effigy effigy) throws Exception {
  if (effigy instanceof TextEffigy) {
    TextEditorTableau tableau=(TextEditorTableau)effigy.getEntity("String_Node_Str");
    if (tableau == null) {
      TextEditor editor=null;
      String style=syntaxStyle.getExpression();
      if (style == null || style.trim().equals("String_Node_Str")) {
        style=((TextEffigy)effigy).getSyntaxStyle();
      }
      if (style != null && !style.trim().equals("String_Node_Str")) {
        try {
          Class editorClass=Class.forName("String_Node_Str");
          Constructor constructor=editorClass.getConstructor(new Class[]{String.class,Document.class});
          editor=(TextEditor)constructor.newInstance(new Object[]{"String_Node_Str",((TextEffigy)effigy).getDocument()});
        }
 catch (        Throwable ex) {
          System.out.println("String_Node_Str" + ex.getMessage());
        }
      }
      tableau=(TextEditorTableau)_tableauConstructor.newInstance(new Object[]{effigy,"String_Node_Str",editor});
    }
    URL url=effigy.uri.getURL();
    if (url != null) {
      effigy.identifier.setExpression(url.toExternalForm());
    }
    tableau.setEditable(effigy.isModifiable());
    return tableau;
  }
 else {
    Iterator effigies=effigy.entityList(TextEffigy.class).iterator();
    while (effigies.hasNext()) {
      TextEffigy textEffigy=(TextEffigy)effigies.next();
      if (textEffigy.getName().equals("String_Node_Str")) {
        return createTableau(textEffigy);
      }
    }
    URL url=effigy.uri.getURL();
    TextEffigy textEffigy;
    if (effigy instanceof PtolemyEffigy) {
      String moml=((PtolemyEffigy)effigy).getModel().exportMoML();
      textEffigy=(TextEffigy)_newTextEffigyText.invoke(null,new Object[]{effigy,moml,"String_Node_Str"});
      textEffigy.setName("String_Node_Str");
    }
 else {
      textEffigy=(TextEffigy)_newTextEffigyURL.invoke(null,new Object[]{effigy,url,url});
      textEffigy.setName("String_Node_Str");
    }
    TextEditorTableau textTableau=(TextEditorTableau)createTableau(textEffigy);
    if (url != null) {
      textEffigy.identifier.setExpression(url.toExternalForm());
    }
    return textTableau;
  }
}