if (doPopup) return false; DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode)organizer.getSelectedNode(); return isActionAllowedOnFolder(action, organizer, rootNode);
return false;
  public static boolean isActionAllowed(String action,                                        Organizer organizer,                                        boolean doPopup) {    // If nothing is selected, some things are still legitimate    if (organizer.getSelectedNode() == null) {      if (action.equals(DELETE_EXPERIMENT_FROM_DATABASE_ACTION) ||          action.equals(DELETE_RECIPE_FROM_DATABASE_ACTION)) {        return true;      } else {	return false;      }    }    // can't do anything with nodes in an experiment being edited    if (organizer.isNodeBeingEdited(organizer.getSelectedNode()))      return false;     // handle if selected object is root of workspace    if (organizer.getSelectedNode().isRoot()) {      if (action.equals(NEW_EXPERIMENT_ACTION) ||          action.equals(NEW_RECIPE_ACTION) ||          action.equals(NEW_FOLDER_ACTION) ||          action.equals(RENAME_ACTION) ||          action.equals(DELETE_EXPERIMENT_FROM_DATABASE_ACTION) ||          action.equals(DELETE_RECIPE_FROM_DATABASE_ACTION))         return true;      if (doPopup)        return false;      DefaultMutableTreeNode rootNode =         (DefaultMutableTreeNode)organizer.getSelectedNode();      return isActionAllowedOnFolder(action, organizer, rootNode);    } // end handling root    Object selectedObject = organizer.getSelectedObject();    if (selectedObject instanceof String)       return isActionAllowedOnFolder(action, organizer,                                      organizer.getSelectedNode());    if (selectedObject instanceof Experiment)      return isActionAllowedOnExperiment(action, organizer,                                         (Experiment)selectedObject);    if (selectedObject instanceof SocietyComponent)      return isActionAllowedOnSociety(action, organizer,                                      (SocietyComponent)selectedObject);    if (selectedObject instanceof RecipeComponent)      return isActionAllowedOnRecipe(action, organizer,                                     (RecipeComponent)selectedObject);    System.out.println("Util: unhandled case: " + action);    return false;  }