if (action.equals(SAVE_TO_DATABASE_ACTION)) { return false; } else if (action.equals(BUILD_ACTION)) { return !CSMART.isSocietyInEditor(society); } else if (action.equals(DELETE_ACTION) || action.equals(RENAME_ACTION) || action.equals(CONFIGURE_ACTION)) {
else if (action.equals(BUILD_ACTION) || action.equals(DELETE_ACTION) || action.equals(RENAME_ACTION) || action.equals(CONFIGURE_ACTION))
  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;      }    }    if (organizer.getSelectedNode().isRoot()) {      if (action.equals(NEW_EXPERIMENT_ACTION) ||          action.equals(NEW_SOCIETY_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;      } else if (doPopup) {        return false;      } else {        if (action.equals(CONFIGURE_ACTION)) {          RecipeComponent[] recipes = organizer.getSelectedRecipes();          if (recipes != null) {            for (int i = 0; i < recipes.length; i++)               if (!CSMART.isRecipeInEditor(recipes[i]))                return true;          }          return false;        } else if (action.equals(BUILD_ACTION)) {          Experiment[] experiments = organizer.getSelectedExperiments();          if (experiments != null) {            for (int i = 0; i < experiments.length; i++)              if (!CSMART.isExperimentInEditor(experiments[i]))                return true;          }          return false;        } else if (action.equals(RUN_ACTION)) {          Experiment[] experiments = organizer.getSelectedExperiments();          if (experiments != null) {            for (int i = 0; i < experiments.length; i++)              if (experiments[i].isRunnable())                return true;          }          return false;        } else          return false;      }    } // end if selected object is root    Object selectedObject = organizer.getSelectedObject();    if (selectedObject instanceof String) { // folder selected      if (action.equals(DELETE_ACTION)) {        RecipeComponent[] recipes = organizer.getSelectedRecipes();        if (recipes != null) {          for (int i = 0; i < recipes.length; i++)             if (CSMART.isRecipeInEditor(recipes[i]))              return false;        }         Experiment[] experiments = organizer.getSelectedExperiments();        if (experiments != null) {          for (int i = 0; i < experiments.length; i++)            if (CSMART.isExperimentInEditor(experiments[i]) ||                experiments[i].isRunInProgress())              return false;        }        return true;      }      else if (action.equals(NEW_EXPERIMENT_ACTION) ||               action.equals(NEW_SOCIETY_ACTION) ||               action.equals(NEW_RECIPE_ACTION) ||               action.equals(NEW_FOLDER_ACTION) ||               action.equals(RENAME_ACTION)) {        return true;      } else {        if (action.equals(CONFIGURE_ACTION)) {          RecipeComponent[] recipes = organizer.getSelectedRecipes();          if (recipes != null) {            for (int i = 0; i < recipes.length; i++)               if (!CSMART.isRecipeInEditor(recipes[i]))                return true;          }          return false;        }        else if (action.equals(BUILD_ACTION)) {          Experiment[] experiments = organizer.getSelectedExperiments();          if (experiments != null) {            for (int i = 0; i < experiments.length; i++)              if (!CSMART.isExperimentInEditor(experiments[i]))                return true;          }          return false;        }        else if (action.equals(RUN_ACTION)) {          Experiment[] experiments = organizer.getSelectedExperiments();          if (experiments != null) {            for (int i = 0; i < experiments.length; i++)              if (experiments[i].isRunnable())                return true;          }          return false;        }        else return false;      }    } // end if selected object is folder    // TODO: probably need to make running configuration tool more selective    // for now, if experiment is selected, allow user to    // configure the society in it    if (selectedObject instanceof Experiment) {      Experiment experiment = (Experiment)selectedObject;      if (action.equals(DUPLICATE_ACTION) ||          action.equals(SAVE_TO_DATABASE_ACTION)) {        return true;      } else if (action.equals(CONFIGURE_ACTION)) {        return true;      } else if (action.equals(BUILD_ACTION)) {        return !CSMART.isExperimentInEditor(experiment);      } else if (action.equals(RUN_ACTION)) {        return experiment.isRunnable();      } else if (action.equals(DELETE_ACTION) ||                  action.equals(RENAME_ACTION)) {        return (!experiment.isEditInProgress() &&                !experiment.isRunInProgress());      } else        return false;    } // end if selected object is experiment    if (selectedObject instanceof SocietyComponent) {      SocietyComponent society = (SocietyComponent)selectedObject;      if (action.equals(DUPLICATE_ACTION))        return true;      if (action.equals(SAVE_TO_DATABASE_ACTION)) {        return false;      } else if (action.equals(BUILD_ACTION)) {        return !CSMART.isSocietyInEditor(society);      } else if (action.equals(DELETE_ACTION) ||                 action.equals(RENAME_ACTION) ||                 action.equals(CONFIGURE_ACTION)) {        return (!CSMART.isSocietyInEditor(society));      } else if (action.equals(BUILD_ACTION)) { // TODO: should return true only if society not in experiment????        return true;      } else        return false;    } // end if selected object is society    if (selectedObject instanceof RecipeComponent) {      RecipeComponent recipe = (RecipeComponent)selectedObject;      if (action.equals(DUPLICATE_ACTION) ||          action.equals(SAVE_TO_DATABASE_ACTION))        return true;      else if (action.equals(DELETE_ACTION) ||               action.equals(RENAME_ACTION) ||               action.equals(CONFIGURE_ACTION))        return (!CSMART.isRecipeInEditor(recipe));      else        return false;    } // end if selected object is recipe    System.out.println("Util: unhandled case: " + action);    return false;  }