private void deleteRecipeInNode(DefaultMutableTreeNode node) { if (node == null) return; model.removeNodeFromParent(node); RecipeComponent rc = (RecipeComponent) node.getUserObject();
private void deleteRecipeInNode(DefaultMutableTreeNode recipeNode) { RecipeComponent recipe = (RecipeComponent) recipeNode.getUserObject(); model.removeNodeFromParent(recipeNode); int result = JOptionPane.showConfirmDialog(this, "Delete recipe " + recipe.getRecipeName() + " from all experiments?", "Delete Recipe", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if (result == JOptionPane.NO_OPTION) { return; }    displayExperimentsInWorkspace(recipe); ArrayList nodesToDelete = new ArrayList(); Enumeration nodes = root.depthFirstEnumeration(); while (nodes.hasMoreElements()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)nodes.nextElement(); Object o = node.getUserObject(); if (o instanceof Experiment) { Experiment exp = (Experiment)o; RecipeComponent[] recipes = exp.getRecipeComponents(); for (int j = 0; j < recipes.length; j++) { if (recipes[j].equals(recipe)) { exp.removeRecipeComponent(recipe); break; } } } else if (recipe.equals(o)) { nodesToDelete.add(node); } }  for (int i = 0; i < nodesToDelete.size(); i++) model.removeNodeFromParent((DefaultMutableTreeNode)nodesToDelete.get(i));
  private void deleteRecipeInNode(DefaultMutableTreeNode node) {    if (node == null) return;    model.removeNodeFromParent(node);    RecipeComponent rc = (RecipeComponent) node.getUserObject();    try {      PDbBase pdb = new PDbBase();      try {        int status = pdb.recipeExists(rc);        if (status == PDbBase.RECIPE_STATUS_EXISTS || status == PDbBase.RECIPE_STATUS_DIFFERS) {          int answer =            JOptionPane.showConfirmDialog(this,                                          "Delete recipe " +                                          rc.getRecipeName() +                                          " from database?",                                          "Delete Recipe",                                          JOptionPane.YES_NO_OPTION);          if (answer == JOptionPane.YES_OPTION) {            pdb.removeLibRecipe(rc);          }        }      } finally {        pdb.close();      }    } catch (Exception e) {      JOptionPane.showMessageDialog(this,                                    "An exception occurred deleting the recipe from the database",                                    "Error Writing Database",                                    JOptionPane.ERROR_MESSAGE);    }    recipeNames.remove(rc.getRecipeName());  }