final DefaultMutableTreeNode parentNode = node; final String newExperimentName = dialog.getExperimentName(); final String newExperimentId = dialog.getExperimentId(); final boolean isCloned = dialog.isCloned();
  private void selectExperimentFromDatabase(DefaultMutableTreeNode node) {    // TODO: put up wait cursor while accessing database    // the following does NOT work as the display is not updated    // when the wait cursor is put up//      final java.awt.Component c = this;//      // put up wait cursor and block input//      System.out.println("PUTTING UP WAIT CURSOR");//      GUIUtils.timeConsumingTaskStart(this);//      try {//        new Thread("") {//          public void run() {//            // select experiment from database//            synchronized (sharedObject) {//            experimentNamesHT = ExperimentDB.getExperimentNames();//            System.out.println("Experiment names: " + experimentNamesHT.keySet().size());//            System.out.println("TAKING DOWN WAIT CURSOR");//            GUIUtils.timeConsumingTaskEnd(c);//            sharedObject.notifyAll();//            }//          }//        }.start();//      } catch (RuntimeException e) {//        System.out.println("Runtime exception creating experiment: " + e);//        e.printStackTrace();//      }//      try {//        synchronized (sharedObject) {//          sharedObject.wait();//        }//      } catch (InterruptedException ie) {//        System.out.println(ie);//      }    experimentNamesHT = ExperimentDB.getExperimentNames();    if (experimentNamesHT == null) {      System.out.println("no experiment names");      return;    }    System.out.println("Experiment names ht: " + experimentNamesHT);    Set dbExperimentNames = experimentNamesHT.keySet();    if (dbExperimentNames == null)      return;    // for debugging, print experiment names and ids    Object[] tmp = dbExperimentNames.toArray();    for (int i = 0; i < tmp.length; i++)       System.out.println("Experiment name: " + tmp[i] +                         " Experiment id: " + experimentNamesHT.get(tmp[i]));    // end for debugging    JComboBox cb = new JComboBox(dbExperimentNames.toArray());    cb.setEditable(false);    JPanel panel = new JPanel();    panel.add(new JLabel("Select Experiment:"));    panel.add(cb);    int result =       JOptionPane.showConfirmDialog(null, panel, "Experiment",                                    JOptionPane.OK_CANCEL_OPTION,                                    JOptionPane.PLAIN_MESSAGE);    if (result != JOptionPane.OK_OPTION)      return;    String experimentName = (String)cb.getSelectedItem();    String experimentId = (String)experimentNamesHT.get(experimentName);    // produce an unique name for CSMART if necessary    if (experimentNames.contains(experimentName)) {      experimentName =         getUniqueExperimentName(experimentNames.generateName(experimentName));      if (experimentName == null)        return;    }    // if defining new experiment, select society template next//      if (!((ArrayList)experimentNames).contains(experimentName)) {//        societyTemplates = ExperimentDB.getSocietyTemplates();//        Set societyNames = societyTemplates.keySet();//        JComboBox societyCB = new JComboBox(societyNames.toArray());//        societyCB.setEditable(false);//        JPanel societyPanel = new JPanel();//        societyPanel.add(new JLabel("Select Society Template:"));//        societyPanel.add(societyCB);//        result = //          JOptionPane.showConfirmDialog(null, societyPanel, "Society Template",//                                        JOptionPane.OK_CANCEL_OPTION,//                                        JOptionPane.PLAIN_MESSAGE);//        if (result != JOptionPane.OK_OPTION)//          return null;//        societyTemplateName = societyCB.getSelectedItem();//      }    // get threads and groups information    CMTDialog dialog =       new CMTDialog(csmart, this, experimentName, experimentId);    final String trialId = dialog.getTrialId();    if (trialId == null)      return;    // final arguments needed to run in separate thread    final DefaultMutableTreeNode parentNode = node;    final String newExperimentName = dialog.getExperimentName();    final String newExperimentId = dialog.getExperimentId();    final boolean isCloned = dialog.isCloned();    // put up wait cursor and block input    GUIUtils.timeConsumingTaskStart(this);    try {      new Thread("") {        public void run() {          createCMTExperiment(parentNode, newExperimentName, newExperimentId,                               trialId, isCloned);        }      }.start();    } catch (RuntimeException e) {      System.err.println("Runtime exception creating experiment: " + e);      e.printStackTrace();    }  }