createCMTExperiment(treeNode, originalExperimentName,
createCMTExperiment(getSelectedNode(), originalExperimentName,
  private void selectExperimentFromDatabase(DefaultMutableTreeNode node) {    Map experimentNamesMap = ExperimentDB.getExperimentNames();    Set keys = experimentNamesMap.keySet();    JComboBox cb = new JComboBox(keys.toArray(new String[keys.size()]));    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();    final String originalExperimentName = experimentName;    String experimentId = (String)experimentNamesMap.get(experimentName);    // if the CSMART workspace contains an experiment with this name,    // then force the user to select a new unique name    if (experimentNames.contains(experimentName)) {      experimentName =         getUniqueExperimentName(experimentNames.generateName(experimentName),                                false);      if (experimentName == null)        return;    }    // get threads and groups information    cmtDialog = new CMTDialog(csmart, this, experimentName, experimentId);    while (!cmtDialog.isULThreadSelected() && !cmtDialog.wasCancelled()) {      JOptionPane.showMessageDialog(this,                                    "You must select at least one thread.",                                    "No Thread Selected",                                    JOptionPane.ERROR_MESSAGE);      // TODO: the following doesn't work, so we recreate the dialog each time      //      cmtDialog.show();      //      cmtDialog.toFront();      cmtDialog = new CMTDialog(csmart, this, experimentName, experimentId);    }    if (cmtDialog.wasCancelled())      return;    final DefaultMutableTreeNode treeNode = node;    GUIUtils.timeConsumingTaskStart(organizer);    try {      new Thread("SelectExperiment") {        public void run() {          cmtDialog.processResults(); // a potentially long process          final String trialId = cmtDialog.getTrialId();          if (trialId != null)            createCMTExperiment(treeNode, originalExperimentName,                                cmtDialog.getExperimentName(),                                cmtDialog.getExperimentId(),                                 trialId);//              createCMTExperiment(treeNode, originalExperimentName,//                                  cmtDialog.getExperimentName(),//                                  cmtDialog.getExperimentId(), //                                  trialId, cmtDialog.isCloned());          GUIUtils.timeConsumingTaskEnd(organizer);        }      }.start();    } catch (RuntimeException re) {      System.out.println("Runtime exception creating experiment: " + re);      re.printStackTrace();      GUIUtils.timeConsumingTaskEnd(organizer);    }  }