if (selectedNode.getUserObject() != null && selectedNode.getUserObject().equals(cc)) { DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)selectedNode.getParent(); if (parentNode.getUserObject() != null && parentNode.getUserObject() instanceof Experiment) { experiment = (Experiment)parentNode.getUserObject();  if (cc instanceof SocietyComponent) { SocietyComponent society = (SocietyComponent)cc; String newName = organizer.generateSocietyName(society.getSocietyName(), false); if (newName == null) return; SocietyComponent societyCopy = (SocietyComponent)society.copy(newName); originalComponent = cc; cc = societyCopy; } else if (cc instanceof RecipeComponent) { RecipeComponent recipe = (RecipeComponent)cc; String newName = organizer.generateRecipeName(recipe.getRecipeName(), false); if (newName == null) return; RecipeComponent recipeCopy = (RecipeComponent)recipe.copy(newName); originalComponent = cc; cc = recipeCopy; } }
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode)selectedNode.getParent(); if (parentNode.getUserObject() != null && parentNode.getUserObject() instanceof Experiment) { experiment = (Experiment)parentNode.getUserObject();   if (cc instanceof SocietyComponent) { SocietyComponent society = (SocietyComponent)cc; String newName = organizer.generateSocietyName(society.getSocietyName(), false); if (newName == null) return; SocietyComponent societyCopy = (SocietyComponent)society.copy(newName); originalComponent = cc; cc = societyCopy; } else if (cc instanceof RecipeComponent) { RecipeComponent recipe = (RecipeComponent)cc; String newName = organizer.generateRecipeName(recipe.getRecipeName(), false); if (newName == null) return; RecipeComponent recipeCopy = (RecipeComponent)recipe.copy(newName); originalComponent = cc; cc = recipeCopy; } else return;
  protected void runBuilder(ModifiableComponent cc,                             boolean alwaysNew) {    // note that cc is guaranteed non-null when this is called    if (cc instanceof Experiment) {      runBuilderOnExperiment((Experiment)cc);      return;    }    ModifiableComponent originalComponent = null;    Experiment experiment = null;    // if configuring a component in an experiment, get the experiment    DefaultMutableTreeNode selectedNode = organizer.getSelectedNode();    if (selectedNode.getUserObject() != null &&        selectedNode.getUserObject().equals(cc)) {      DefaultMutableTreeNode parentNode =         (DefaultMutableTreeNode)selectedNode.getParent();      if (parentNode.getUserObject() != null &&          parentNode.getUserObject() instanceof Experiment) {        experiment = (Experiment)parentNode.getUserObject();        // copy the component, so it's modified only in the experiment        if (cc instanceof SocietyComponent) {          SocietyComponent society = (SocietyComponent)cc;          String newName =            organizer.generateSocietyName(society.getSocietyName(), false);          if (newName == null)            return;          SocietyComponent societyCopy =             (SocietyComponent)society.copy(newName);          originalComponent = cc;          cc = societyCopy;        } else if (cc instanceof RecipeComponent) {          RecipeComponent recipe = (RecipeComponent)cc;          String newName =            organizer.generateRecipeName(recipe.getRecipeName(), false);          if (newName == null)            return;          RecipeComponent recipeCopy = (RecipeComponent)recipe.copy(newName);          originalComponent = cc;          cc = recipeCopy;        }      }    }    JFrame tool =       (JFrame)new PropertyBuilder(this, cc, originalComponent, experiment);    addTool(CONFIGURATION_BUILDER, cc.getShortName(), tool);  }