experimentName = getUniqueExperimentName(experimentNames.generateName(experimentName), false);
experimentName = generateExperimentName(experimentName, false);
  protected void selectExperimentFromDatabase() {    boolean haveCMTAssembly = false;    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;    }    // Does this experiment use a CMT assembly for configuration?    // If so, use the CMTDialog    // Otherwise, just do the load (which is now done through the CMTDialog)    // Note: CMTDialog creates a CMTSociety -- should it be creating    // a SocietyDBComponent?    if(log.isDebugEnabled()) {      log.debug("Experiment Id: " + experimentId);    }    // Does the experiment have a CMT configuration assembly    if(DBUtils.containsCMTAssembly(experimentId)) {      haveCMTAssembly = true;      // 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);        cmtDialog = new CMTDialog(csmart, this, experimentName, experimentId);      }      if (cmtDialog.wasCancelled())        return;    }    if(haveCMTAssembly) {      GUIUtils.timeConsumingTaskStart(organizer);      try {        new Thread("SelectExperiment") {          public void run() {            // a potentially long process            if (cmtDialog.processResults()) {              final String trialId = cmtDialog.getTrialId();              if (trialId != null) {                Experiment experiment =                  helper.createExperiment(originalExperimentName,                                          cmtDialog.getExperimentName(),                                          cmtDialog.getExperimentId(),                                           trialId);                if (experiment != null)                  addExperimentAndComponentsToWorkspace(experiment,                                                        getSelectedNode());              }            }                        GUIUtils.timeConsumingTaskEnd(organizer);          }        }.start();      } catch (RuntimeException re) {        if(log.isErrorEnabled()) {          log.error("Runtime exception creating experiment", re);        }        GUIUtils.timeConsumingTaskEnd(organizer);      }    } else {      final String trialId = ExperimentDB.getTrialId(experimentId);      final String expName = experimentName;      final String expId = experimentId;      if (trialId != null) {	GUIUtils.timeConsumingTaskStart(organizer);	try {	  new Thread("SelectExperiment") {	    public void run() {	      // a potentially long process	      Experiment experiment =		helper.createExperiment(originalExperimentName,					expName,					expId, 					trialId);	      if (experiment != null)		addExperimentAndComponentsToWorkspace(experiment,						      getSelectedNode());	      GUIUtils.timeConsumingTaskEnd(organizer);	    }	  }.start();	} catch (RuntimeException re) {	  if(log.isErrorEnabled()) {	    log.error("Runtime exception creating experiment", re);	  }	  GUIUtils.timeConsumingTaskEnd(organizer);	}      } // end of if block    } // end of else block  } // end of selectExpFromDB