experiment.addSocietyComponent(society);
SocietyComponent society = experiment.getSocietyComponent(); if (society == null) experiment.addSocietyComponent(newSociety); else if (!society.equals(newSociety)) if (log.isErrorEnabled()) log.error("Attempted to add society to experiment that has a society."); } else if (nSocieties == 0) { experiment.removeSocietyComponent();
  private void reconcileExperimentNodes() {    int nSocieties = societies.getChildCount();    if (nSocieties > 1) {      // Only 1 society should be allowed!      System.err.println("Only 1 society in an experiment!");    } else if (nSocieties == 1) {      SocietyComponent society = (SocietyComponent) ((DefaultMutableTreeNode) societies.getChildAt(0)).getUserObject();      //      society.setEditable(false); // so society editability tracks experiment editability      experiment.addSocietyComponent(society);    }    int nRecipes = recipes.getChildCount();    RecipeComponent[] recipeAry = new RecipeComponent[nRecipes];    for (int i = 0; i < nRecipes; i++) {      recipeAry[i] =        (RecipeComponent) ((DefaultMutableTreeNode) recipes.getChildAt(i)).getUserObject();      //      recipeAry[i].setEditable(false);    }    experiment.setRecipeComponents(recipeAry);    experiment.invalidateTrials(); // and force experiment to recreate trials  }