if (o instanceof RecipeComponent || o instanceof SocietyComponent) { if (o instanceof SocietyComponent) { SocietyComponent sc = (SocietyComponent) o; String name = "Experiment for " + sc.getSocietyName(); experiment = new Experiment(experimentNames.generateName(name), sc, new RecipeComponent[0]); } else if (o instanceof RecipeComponent) { RecipeComponent recipe = (RecipeComponent) o; String name = "Experiment for " + recipe.getRecipeName(); experiment = new Experiment(experimentNames.generateName(name), null, new RecipeComponent[] {recipe}); } DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent(); addExperimentAndComponentsToWorkspace(experiment, parentNode);
if (o instanceof SocietyComponent) { experiment = createExperiment((SocietyComponent)o); addExperimentAndComponentsToWorkspace(experiment, (DefaultMutableTreeNode) node.getParent()); } else if (o instanceof RecipeComponent) { experiment = createExperiment((RecipeComponent)o); addExperimentAndComponentsToWorkspace(experiment, (DefaultMutableTreeNode) node.getParent());
  protected void startExperimentBuilder() {    Experiment experiment = null;    DefaultMutableTreeNode node = getSelectedNode();    Object o = node.getUserObject();    if (o instanceof RecipeComponent || o instanceof SocietyComponent) {      if (o instanceof SocietyComponent) {        SocietyComponent sc = (SocietyComponent) o;        String name = "Experiment for " + sc.getSocietyName();        experiment = new Experiment(experimentNames.generateName(name),                                    sc,                                    new RecipeComponent[0]);      } else if (o instanceof RecipeComponent) {        RecipeComponent recipe = (RecipeComponent) o;        String name = "Experiment for " + recipe.getRecipeName();        experiment = new Experiment(experimentNames.generateName(name),                                    null,                                    new RecipeComponent[] {recipe});      }      DefaultMutableTreeNode parentNode =        (DefaultMutableTreeNode) node.getParent();      addExperimentAndComponentsToWorkspace(experiment, parentNode);    } else if (o instanceof Experiment)       experiment = (Experiment) o;    if (experiment != null)      csmart.runExperimentBuilder(experiment, false);  }