if (experiment != null) { DefaultMutableTreeNode newNode = addExperimentToWorkspace(experiment); RecipeComponent[] recipes = experiment.getRecipeComponents(); for (int i = 0; i < recipes.length; i++) if (!recipeNames.contains(recipes[i].getRecipeName())) addRecipeToWorkspace(recipes[i]); workspace.setSelection(newNode); } } }
if (experiment != null) addDatabaseExperimentToWorkspace(experiment); } }
  public void selectExperimentFromDatabase() {    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;    }    if(log.isDebugEnabled()) {      log.debug("Experiment Id: " + experimentId);    }    // 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;    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) {		DefaultMutableTreeNode newNode =		  addExperimentToWorkspace(experiment);		RecipeComponent[] recipes = experiment.getRecipeComponents();		for (int i = 0; i < recipes.length; i++)		  if (!recipeNames.contains(recipes[i].getRecipeName()))		    addRecipeToWorkspace(recipes[i]);		workspace.setSelection(newNode);	      }	    }	  }          GUIUtils.timeConsumingTaskEnd(organizer);        }      }.start();    } catch (RuntimeException re) {      if(log.isErrorEnabled()) {        log.error("Runtime exception creating experiment", re);      }      GUIUtils.timeConsumingTaskEnd(organizer);    }  }