Program: 167575
Project: 167575
Buggy source:
/** 
 * @param lastConnectionProps - the last connection properties used. if this is the first connection since starting the applications this will be the default settings
 * @param connectionPropertiesTemplateAndLabels - the connection properties and labels to show in this dialog
 * @param zooInspectorPanel - the  {@link ZooInspectorPanel} linked to this dialog
 */
public ZooInspectorConnectionPropertiesDialog(Properties lastConnectionProps,Pair<Map<String,List<String>>,Map<String,String>> connectionPropertiesTemplateAndLabels,final ZooInspectorPanel zooInspectorPanel){
  final Map<String,List<String>> connectionPropertiesTemplate=connectionPropertiesTemplateAndLabels.getKey();
  final Map<String,String> connectionPropertiesLabels=connectionPropertiesTemplateAndLabels.getValue();
  this.setLayout(new BorderLayout());
  this.setTitle("String_Node_Str");
  this.setModal(true);
  this.setAlwaysOnTop(true);
  this.setResizable(false);
  final JPanel options=new JPanel();
  final JFileChooser fileChooser=new JFileChooser();
  options.setLayout(new GridBagLayout());
  int i=0;
  components=new HashMap<String,JComponent>();
  for (  Entry<String,List<String>> entry : connectionPropertiesTemplate.entrySet()) {
    int rowPos=2 * i + 1;
    JLabel label=new JLabel(connectionPropertiesLabels.get(entry.getKey()));
    GridBagConstraints c1=new GridBagConstraints();
    c1.gridx=0;
    c1.gridy=rowPos;
    c1.gridwidth=1;
    c1.gridheight=1;
    c1.weightx=0;
    c1.weighty=0;
    c1.anchor=GridBagConstraints.WEST;
    c1.fill=GridBagConstraints.HORIZONTAL;
    c1.insets=new Insets(5,5,5,5);
    c1.ipadx=0;
    c1.ipady=0;
    options.add(label,c1);
    if (entry.getValue().size() == 0) {
      JTextField text=new JTextField();
      GridBagConstraints c2=new GridBagConstraints();
      c2.gridx=2;
      c2.gridy=rowPos;
      c2.gridwidth=1;
      c2.gridheight=1;
      c2.weightx=0;
      c2.weighty=0;
      c2.anchor=GridBagConstraints.WEST;
      c2.fill=GridBagConstraints.HORIZONTAL;
      c2.insets=new Insets(5,5,5,5);
      c2.ipadx=0;
      c2.ipady=0;
      options.add(text,c2);
      components.put(entry.getKey(),text);
    }
 else     if (entry.getValue().size() == 1) {
      JTextField text=new JTextField(entry.getValue().get(0));
      text.addKeyListener(new KeyListener(){
        @Override public void keyTyped(        KeyEvent e){
        }
        @Override public void keyReleased(        KeyEvent e){
        }
        @Override public void keyPressed(        KeyEvent e){
switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER:
            ZooInspectorConnectionPropertiesDialog.this.dispose();
          Properties connectionProps=getConnectionProps();
        zooInspectorPanel.connect(connectionProps);
      break;
case KeyEvent.VK_ESCAPE:
    ZooInspectorConnectionPropertiesDialog.this.dispose();
  break;
default :
break;
}
}
}
);
GridBagConstraints c2=new GridBagConstraints();
c2.gridx=2;
c2.gridy=rowPos;
c2.gridwidth=1;
c2.gridheight=1;
c2.weightx=0;
c2.weighty=0;
c2.anchor=GridBagConstraints.WEST;
c2.fill=GridBagConstraints.HORIZONTAL;
c2.insets=new Insets(5,5,5,5);
c2.ipadx=0;
c2.ipady=0;
options.add(text,c2);
components.put(entry.getKey(),text);
}
 else {
List<String> list=entry.getValue();
JComboBox combo=new JComboBox(list.toArray(new String[list.size()]));
combo.setEditable(true);
combo.setSelectedItem(list.get(0));
GridBagConstraints c2=new GridBagConstraints();
c2.gridx=2;
c2.gridy=rowPos;
c2.gridwidth=1;
c2.gridheight=1;
c2.weightx=0;
c2.weighty=0;
c2.anchor=GridBagConstraints.WEST;
c2.fill=GridBagConstraints.HORIZONTAL;
c2.insets=new Insets(5,5,5,5);
c2.ipadx=0;
c2.ipady=0;
options.add(combo,c2);
components.put(entry.getKey(),combo);
}
i++;
}
loadConnectionProps(lastConnectionProps);
JPanel buttonsPanel=new JPanel();
buttonsPanel.setLayout(new GridBagLayout());
JButton loadPropsFileButton=new JButton("String_Node_Str");
loadPropsFileButton.addActionListener(new ActionListener(){
@Override public void actionPerformed(ActionEvent e){
int result=fileChooser.showOpenDialog(ZooInspectorConnectionPropertiesDialog.this);
if (result == JFileChooser.APPROVE_OPTION) {
File propsFilePath=fileChooser.getSelectedFile();
Properties props=new Properties();
try {
FileReader reader=new FileReader(propsFilePath);
try {
props.load(reader);
loadConnectionProps(props);
}
  finally {
reader.close();
}
}
 catch (IOException ex) {
LoggerFactory.getLogger().error("String_Node_Str",ex);
JOptionPane.showMessageDialog(ZooInspectorConnectionPropertiesDialog.this,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
}
options.revalidate();
options.repaint();
}
}
}
);
GridBagConstraints c3=new GridBagConstraints();
c3.gridx=0;
c3.gridy=0;
c3.gridwidth=1;
c3.gridheight=1;
c3.weightx=0;
c3.weighty=1;
c3.anchor=GridBagConstraints.SOUTHWEST;
c3.fill=GridBagConstraints.NONE;
c3.insets=new Insets(5,5,5,5);
c3.ipadx=0;
c3.ipady=0;
buttonsPanel.add(loadPropsFileButton,c3);
JButton saveDefaultPropsFileButton=new JButton("String_Node_Str");
saveDefaultPropsFileButton.addActionListener(new ActionListener(){
@Override public void actionPerformed(ActionEvent e){
Properties connectionProps=getConnectionProps();
try {
zooInspectorPanel.setdefaultConnectionProps(connectionProps);
}
 catch (IOException ex) {
LoggerFactory.getLogger().error("String_Node_Str",ex);
JOptionPane.showMessageDialog(ZooInspectorConnectionPropertiesDialog.this,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
}
}
}
);
GridBagConstraints c6=new GridBagConstraints();
c6.gridx=1;
c6.gridy=0;
c6.gridwidth=1;
c6.gridheight=1;
c6.weightx=1;
c6.weighty=1;
c6.anchor=GridBagConstraints.SOUTHWEST;
c6.fill=GridBagConstraints.NONE;
c6.insets=new Insets(5,5,5,5);
c6.ipadx=0;
c6.ipady=0;
buttonsPanel.add(saveDefaultPropsFileButton,c6);
JButton okButton=new JButton("String_Node_Str");
okButton.addActionListener(new ActionListener(){
@Override public void actionPerformed(ActionEvent e){
ZooInspectorConnectionPropertiesDialog.this.dispose();
Properties connectionProps=getConnectionProps();
zooInspectorPanel.connect(connectionProps);
}
}
);
GridBagConstraints c4=new GridBagConstraints();
c4.gridx=2;
c4.gridy=0;
c4.gridwidth=1;
c4.gridheight=1;
c4.weightx=0;
c4.weighty=1;
c4.anchor=GridBagConstraints.SOUTH;
c4.fill=GridBagConstraints.HORIZONTAL;
c4.insets=new Insets(5,5,5,5);
c4.ipadx=0;
c4.ipady=0;
buttonsPanel.add(okButton,c4);
JButton cancelButton=new JButton("String_Node_Str");
cancelButton.addActionListener(new ActionListener(){
@Override public void actionPerformed(ActionEvent e){
ZooInspectorConnectionPropertiesDialog.this.dispose();
}
}
);
GridBagConstraints c5=new GridBagConstraints();
c5.gridx=3;
c5.gridy=0;
c5.gridwidth=1;
c5.gridheight=1;
c5.weightx=0;
c5.weighty=1;
c5.anchor=GridBagConstraints.SOUTH;
c5.fill=GridBagConstraints.HORIZONTAL;
c5.insets=new Insets(5,5,5,5);
c5.ipadx=0;
c5.ipady=0;
buttonsPanel.add(cancelButton,c5);
this.add(options,BorderLayout.CENTER);
this.add(buttonsPanel,BorderLayout.SOUTH);
this.pack();
}

Fixed version (ground truth):
/** 
 * @param lastConnectionProps - the last connection properties used. if this is the first connection since starting the applications this will be the default settings
 * @param connectionPropertiesTemplateAndLabels - the connection properties and labels to show in this dialog
 * @param zooInspectorPanel - the  {@link ZooInspectorPanel} linked to this dialog
 */
public ZooInspectorConnectionPropertiesDialog(Properties lastConnectionProps,Pair<Map<String,List<String>>,Map<String,String>> connectionPropertiesTemplateAndLabels,final ZooInspectorPanel zooInspectorPanel){
  final Map<String,List<String>> connectionPropertiesTemplate=connectionPropertiesTemplateAndLabels.getKey();
  final Map<String,String> connectionPropertiesLabels=connectionPropertiesTemplateAndLabels.getValue();
  this.setLayout(new BorderLayout());
  this.setTitle("String_Node_Str");
  this.setModal(true);
  this.setAlwaysOnTop(true);
  this.setResizable(false);
  final JPanel options=new JPanel();
  final JFileChooser fileChooser=new JFileChooser();
  options.setLayout(new GridBagLayout());
  int i=0;
  components=new HashMap<String,JComponent>();
  for (  Entry<String,List<String>> entry : connectionPropertiesTemplate.entrySet()) {
    int rowPos=2 * i + 1;
    JLabel label=new JLabel(connectionPropertiesLabels.get(entry.getKey()));
    GridBagConstraints c1=new GridBagConstraints();
    c1.gridx=0;
    c1.gridy=rowPos;
    c1.gridwidth=1;
    c1.gridheight=1;
    c1.weightx=0;
    c1.weighty=0;
    c1.anchor=GridBagConstraints.WEST;
    c1.fill=GridBagConstraints.HORIZONTAL;
    c1.insets=new Insets(5,5,5,5);
    c1.ipadx=0;
    c1.ipady=0;
    options.add(label,c1);
    if (entry.getValue().size() == 0) {
      JTextField text=new JTextField();
      GridBagConstraints c2=new GridBagConstraints();
      c2.gridx=2;
      c2.gridy=rowPos;
      c2.gridwidth=1;
      c2.gridheight=1;
      c2.weightx=0;
      c2.weighty=0;
      c2.anchor=GridBagConstraints.WEST;
      c2.fill=GridBagConstraints.HORIZONTAL;
      c2.insets=new Insets(5,5,5,5);
      c2.ipadx=0;
      c2.ipady=0;
      options.add(text,c2);
      components.put(entry.getKey(),text);
    }
 else     if (entry.getValue().size() == 1) {
      JTextField text=new JTextField(entry.getValue().get(0));
      text.addKeyListener(new KeyListener(){
        @Override public void keyTyped(        KeyEvent e){
        }
        @Override public void keyReleased(        KeyEvent e){
        }
        @Override public void keyPressed(        KeyEvent e){
switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER:
            ZooInspectorConnectionPropertiesDialog.this.dispose();
          Properties connectionProps=getConnectionProps();
        zooInspectorPanel.connect(connectionProps);
      break;
case KeyEvent.VK_ESCAPE:
    ZooInspectorConnectionPropertiesDialog.this.dispose();
  break;
default :
break;
}
}
}
);
GridBagConstraints c2=new GridBagConstraints();
c2.gridx=2;
c2.gridy=rowPos;
c2.gridwidth=1;
c2.gridheight=1;
c2.weightx=0;
c2.weighty=0;
c2.anchor=GridBagConstraints.WEST;
c2.fill=GridBagConstraints.HORIZONTAL;
c2.insets=new Insets(5,5,5,5);
c2.ipadx=0;
c2.ipady=0;
options.add(text,c2);
components.put(entry.getKey(),text);
}
 else {
List<String> list=entry.getValue();
JComboBox combo=new JComboBox(list.toArray(new String[list.size()]));
combo.setEditable(true);
combo.setSelectedItem(list.get(0));
combo.getEditor().getEditorComponent().addKeyListener(new KeyListener(){
@Override public void keyTyped(KeyEvent e){
}
@Override public void keyReleased(KeyEvent e){
}
@Override public void keyPressed(KeyEvent e){
switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER:
ZooInspectorConnectionPropertiesDialog.this.dispose();
Properties connectionProps=getConnectionProps();
zooInspectorPanel.connect(connectionProps);
break;
case KeyEvent.VK_ESCAPE:
ZooInspectorConnectionPropertiesDialog.this.dispose();
break;
default :
System.out.println("String_Node_Str");
break;
}
}
}
);
GridBagConstraints c2=new GridBagConstraints();
c2.gridx=2;
c2.gridy=rowPos;
c2.gridwidth=1;
c2.gridheight=1;
c2.weightx=0;
c2.weighty=0;
c2.anchor=GridBagConstraints.WEST;
c2.fill=GridBagConstraints.HORIZONTAL;
c2.insets=new Insets(5,5,5,5);
c2.ipadx=0;
c2.ipady=0;
options.add(combo,c2);
components.put(entry.getKey(),combo);
}
i++;
}
loadConnectionProps(lastConnectionProps);
JPanel buttonsPanel=new JPanel();
buttonsPanel.setLayout(new GridBagLayout());
JButton loadPropsFileButton=new JButton("String_Node_Str");
loadPropsFileButton.addActionListener(new ActionListener(){
@Override public void actionPerformed(ActionEvent e){
int result=fileChooser.showOpenDialog(ZooInspectorConnectionPropertiesDialog.this);
if (result == JFileChooser.APPROVE_OPTION) {
File propsFilePath=fileChooser.getSelectedFile();
Properties props=new Properties();
try {
FileReader reader=new FileReader(propsFilePath);
try {
props.load(reader);
loadConnectionProps(props);
}
  finally {
reader.close();
}
}
 catch (IOException ex) {
LoggerFactory.getLogger().error("String_Node_Str",ex);
JOptionPane.showMessageDialog(ZooInspectorConnectionPropertiesDialog.this,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
}
options.revalidate();
options.repaint();
}
}
}
);
GridBagConstraints c3=new GridBagConstraints();
c3.gridx=0;
c3.gridy=0;
c3.gridwidth=1;
c3.gridheight=1;
c3.weightx=0;
c3.weighty=1;
c3.anchor=GridBagConstraints.SOUTHWEST;
c3.fill=GridBagConstraints.NONE;
c3.insets=new Insets(5,5,5,5);
c3.ipadx=0;
c3.ipady=0;
buttonsPanel.add(loadPropsFileButton,c3);
JButton saveDefaultPropsFileButton=new JButton("String_Node_Str");
saveDefaultPropsFileButton.addActionListener(new ActionListener(){
@Override public void actionPerformed(ActionEvent e){
Properties connectionProps=getConnectionProps();
try {
zooInspectorPanel.setdefaultConnectionProps(connectionProps);
}
 catch (IOException ex) {
LoggerFactory.getLogger().error("String_Node_Str",ex);
JOptionPane.showMessageDialog(ZooInspectorConnectionPropertiesDialog.this,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
}
}
}
);
GridBagConstraints c6=new GridBagConstraints();
c6.gridx=1;
c6.gridy=0;
c6.gridwidth=1;
c6.gridheight=1;
c6.weightx=1;
c6.weighty=1;
c6.anchor=GridBagConstraints.SOUTHWEST;
c6.fill=GridBagConstraints.NONE;
c6.insets=new Insets(5,5,5,5);
c6.ipadx=0;
c6.ipady=0;
buttonsPanel.add(saveDefaultPropsFileButton,c6);
JButton okButton=new JButton("String_Node_Str");
okButton.addActionListener(new ActionListener(){
@Override public void actionPerformed(ActionEvent e){
ZooInspectorConnectionPropertiesDialog.this.dispose();
Properties connectionProps=getConnectionProps();
zooInspectorPanel.connect(connectionProps);
}
}
);
GridBagConstraints c4=new GridBagConstraints();
c4.gridx=2;
c4.gridy=0;
c4.gridwidth=1;
c4.gridheight=1;
c4.weightx=0;
c4.weighty=1;
c4.anchor=GridBagConstraints.SOUTH;
c4.fill=GridBagConstraints.HORIZONTAL;
c4.insets=new Insets(5,5,5,5);
c4.ipadx=0;
c4.ipady=0;
buttonsPanel.add(okButton,c4);
JButton cancelButton=new JButton("String_Node_Str");
cancelButton.addActionListener(new ActionListener(){
@Override public void actionPerformed(ActionEvent e){
ZooInspectorConnectionPropertiesDialog.this.dispose();
}
}
);
GridBagConstraints c5=new GridBagConstraints();
c5.gridx=3;
c5.gridy=0;
c5.gridwidth=1;
c5.gridheight=1;
c5.weightx=0;
c5.weighty=1;
c5.anchor=GridBagConstraints.SOUTH;
c5.fill=GridBagConstraints.HORIZONTAL;
c5.insets=new Insets(5,5,5,5);
c5.ipadx=0;
c5.ipady=0;
buttonsPanel.add(cancelButton,c5);
this.add(options,BorderLayout.CENTER);
this.add(buttonsPanel,BorderLayout.SOUTH);
this.pack();
}