Program: 76226
Project: 76226
Buggy source:
public PtolemyPackage(VergilApplication application){
  _application=application;
  Action action;
  JMenu menuDevel=new JMenu("String_Node_Str");
  menuDevel.setMnemonic('D');
  _application.addMenu(menuDevel);
  action=new AbstractAction("String_Node_Str"){
    public void actionPerformed(    ActionEvent e){
      Document d=_application.getCurrentDocument();
      if (d == null) {
        System.out.println("String_Node_Str");
      }
 else {
        System.out.println(d.toString());
      }
    }
  }
;
  _application.addMenuItem(menuDevel,action,'P',"String_Node_Str");
  action=new AbstractAction("String_Node_Str"){
    public void actionPerformed(    ActionEvent e){
      PtolemyDocument d=(PtolemyDocument)_application.getCurrentDocument();
      if (d == null) {
        return;
      }
      try {
        CompositeActor toplevel=(CompositeActor)d.getModel();
        if (toplevel.getDirector() == null) {
          ptolemy.domains.sdf.kernel.SDFDirector director=new ptolemy.domains.sdf.kernel.SDFDirector(toplevel.workspace());
          toplevel.setDirector(director);
          director.iterations.setExpression("String_Node_Str");
        }
        Manager manager=toplevel.getManager();
        if (manager == null) {
          manager=new Manager(toplevel.workspace(),"String_Node_Str");
          toplevel.setManager(manager);
          manager.addExecutionListener(new VergilExecutionListener());
        }
        if (_executionFrame != null) {
          _executionFrame.getContentPane().removeAll();
        }
 else {
          _executionFrame=new JFrame();
        }
        ModelPane modelPane=new ModelPane(toplevel);
        _executionFrame.getContentPane().add(modelPane,BorderLayout.NORTH);
        JPanel displayPanel=new JPanel();
        displayPanel.setLayout(new BoxLayout(displayPanel,BoxLayout.Y_AXIS));
        modelPane.setDisplayPane(displayPanel);
        for (Iterator i=toplevel.deepEntityList().iterator(); i.hasNext(); ) {
          Object o=i.next();
          if (o instanceof Placeable) {
            ((Placeable)o).place(displayPanel);
          }
        }
        if (_executionFrame != null) {
          _executionFrame.setVisible(true);
        }
        final JFrame packframe=_executionFrame;
        Action packer=new AbstractAction(){
          public void actionPerformed(          ActionEvent event){
            packframe.getContentPane().doLayout();
            packframe.repaint();
            packframe.pack();
          }
        }
;
        javax.swing.Timer timer=new javax.swing.Timer(200,packer);
        timer.setRepeats(false);
        timer.start();
      }
 catch (      Exception ex) {
        ex.printStackTrace();
        throw new GraphException(ex.getMessage());
      }
    }
  }
;
  _application.addMenuItem(menuDevel,action,'E',"String_Node_Str");
  JToolBar tb=new JToolBar();
  Container pane=((DesktopFrame)_application.getApplicationFrame()).getToolBarPane();
  pane.add(tb);
  String dflt="String_Node_Str";
  _layoutComboBox=new JComboBox();
  dflt="String_Node_Str";
  _layoutComboBox.addItem(dflt);
  _layoutComboBox.addItem("String_Node_Str");
  _layoutComboBox.setSelectedItem(dflt);
  _layoutComboBox.setMaximumSize(_layoutComboBox.getMinimumSize());
  _layoutComboBox.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      if (e.getStateChange() == ItemEvent.SELECTED) {
        VergilDocument d=(VergilDocument)_application.getCurrentDocument();
        JGraph jg=(JGraph)_application.getView(d);
        redoLayout(jg,(String)e.getItem());
      }
    }
  }
);
  tb.add(_layoutComboBox);
  _directorModel=new DefaultComboBoxModel();
  _directorModel.addElement(new SDFDirector());
  _directorModel.addElement(new PNDirector());
  _directorComboBox=new JComboBox(_directorModel);
  _directorComboBox.setRenderer(new DirectorCellRenderer());
  _directorComboBox.setMaximumSize(_directorComboBox.getMinimumSize());
  _directorComboBox.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      if (e.getStateChange() == ItemEvent.SELECTED) {
        Director director=(Director)e.getItem();
        PtolemyDocument d=(PtolemyDocument)_application.getCurrentDocument();
        CompositeEntity entity=d.getModel();
        if (entity instanceof Actor) {
          CompositeActor actor=(CompositeActor)entity;
          try {
            Director clone=(Director)director.clone(actor.workspace());
            actor.setDirector(clone);
          }
 catch (          Exception ex) {
            System.out.println(ex.getMessage());
            ex.printStackTrace();
          }
        }
      }
    }
  }
);
  tb.add(_directorComboBox);
}

Fixed version (ground truth):
public PtolemyPackage(VergilApplication application){
  _application=application;
  Action action;
  JMenu menuDevel=new JMenu("String_Node_Str");
  menuDevel.setMnemonic('D');
  _application.addMenu(menuDevel);
  action=new AbstractAction("String_Node_Str"){
    public void actionPerformed(    ActionEvent e){
      Document d=_application.getCurrentDocument();
      if (d == null) {
        System.out.println("String_Node_Str");
      }
 else {
        System.out.println(d.toString());
      }
    }
  }
;
  _application.addMenuItem(menuDevel,action,'P',"String_Node_Str");
  action=new AbstractAction("String_Node_Str"){
    public void actionPerformed(    ActionEvent e){
      PtolemyDocument d=(PtolemyDocument)_application.getCurrentDocument();
      if (d == null) {
        return;
      }
      try {
        CompositeActor toplevel=(CompositeActor)d.getModel();
        if (toplevel.getDirector() == null) {
          ptolemy.domains.sdf.kernel.SDFDirector director=new ptolemy.domains.sdf.kernel.SDFDirector(toplevel.workspace());
          toplevel.setDirector(director);
          director.iterations.setExpression("String_Node_Str");
        }
        Manager manager=toplevel.getManager();
        if (manager == null) {
          manager=new Manager(toplevel.workspace(),"String_Node_Str");
          toplevel.setManager(manager);
          manager.addExecutionListener(new VergilExecutionListener());
        }
        if (_executionFrame != null) {
          _executionFrame.getContentPane().removeAll();
        }
 else {
          _executionFrame=new JFrame();
        }
        ModelPane modelPane=new ModelPane(toplevel);
        _executionFrame.getContentPane().add(modelPane,BorderLayout.NORTH);
        JPanel displayPanel=new JPanel();
        displayPanel.setLayout(new BoxLayout(displayPanel,BoxLayout.Y_AXIS));
        modelPane.setDisplayPane(displayPanel);
        for (Iterator i=toplevel.deepEntityList().iterator(); i.hasNext(); ) {
          Object o=i.next();
          if (o instanceof Placeable) {
            ((Placeable)o).place(displayPanel);
          }
        }
        if (_executionFrame != null) {
          _executionFrame.setVisible(true);
        }
        final JFrame packframe=_executionFrame;
        Action packer=new AbstractAction(){
          public void actionPerformed(          ActionEvent event){
            packframe.getContentPane().doLayout();
            packframe.repaint();
            packframe.pack();
          }
        }
;
        javax.swing.Timer timer=new javax.swing.Timer(200,packer);
        timer.setRepeats(false);
        timer.start();
      }
 catch (      Exception ex) {
        ex.printStackTrace();
        throw new GraphException(ex.getMessage());
      }
    }
  }
;
  _application.addMenuItem(menuDevel,action,'E',"String_Node_Str");
  JToolBar tb=new JToolBar();
  Container pane=((DesktopFrame)_application.getApplicationFrame()).getToolBarPane();
  pane.add(tb);
  String dflt="String_Node_Str";
  _layoutComboBox=new JComboBox();
  dflt="String_Node_Str";
  _layoutComboBox.addItem(dflt);
  _layoutComboBox.setSelectedItem(dflt);
  _layoutComboBox.addItem("String_Node_Str");
  _layoutComboBox.addItem("String_Node_Str");
  _layoutComboBox.setMaximumSize(_layoutComboBox.getMinimumSize());
  _layoutComboBox.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      if (e.getStateChange() == ItemEvent.SELECTED) {
        VergilDocument d=(VergilDocument)_application.getCurrentDocument();
        JGraph jg=(JGraph)_application.getView(d);
        redoLayout(jg,(String)e.getItem());
      }
    }
  }
);
  tb.add(_layoutComboBox);
  _directorModel=new DefaultComboBoxModel();
  _directorModel.addElement(new SDFDirector());
  _directorModel.addElement(new PNDirector());
  _directorComboBox=new JComboBox(_directorModel);
  _directorComboBox.setRenderer(new DirectorCellRenderer());
  _directorComboBox.setMaximumSize(_directorComboBox.getMinimumSize());
  _directorComboBox.addItemListener(new ItemListener(){
    public void itemStateChanged(    ItemEvent e){
      if (e.getStateChange() == ItemEvent.SELECTED) {
        Director director=(Director)e.getItem();
        PtolemyDocument d=(PtolemyDocument)_application.getCurrentDocument();
        CompositeEntity entity=d.getModel();
        if (entity instanceof Actor) {
          CompositeActor actor=(CompositeActor)entity;
          try {
            Director clone=(Director)director.clone(actor.workspace());
            actor.setDirector(clone);
          }
 catch (          Exception ex) {
            System.out.println(ex.getMessage());
            ex.printStackTrace();
          }
        }
      }
    }
  }
);
  tb.add(_directorComboBox);
  application.addDocumentFactory(new PtolemyDocument.Factory());
}