예제 #1
0
  public String toMenuLocationDebug(final String profileID, final Locale locale) {
    final String SEPARATOR =
        LocaleHelper.getLocalizedMessage(locale, Config.Display_SettingNavigationSeparator, null);
    final StringBuilder sb = new StringBuilder();

    PwmSettingCategory nextCategory = this;
    while (nextCategory != null) {
      if (nextCategory != this) {
        sb.insert(0, nextCategory.getLabel(locale) + SEPARATOR);
      } else {
        sb.insert(0, nextCategory.getLabel(locale));
      }
      nextCategory = nextCategory.getParent();
    }

    if (this.hasProfiles()) {
      if (profileID != null) {
        sb.append(SEPARATOR);
        sb.append(profileID);
      } else {
        final String NULL_PROFILE =
            LocaleHelper.getLocalizedMessage(
                locale, Config.Display_SettingNavigationNullProfile, null);
        sb.append(SEPARATOR);
        sb.append(NULL_PROFILE);
      }
    }

    return sb.toString();
  }
예제 #2
0
 public static Collection<PwmSettingCategory> topCategories() {
   final ArrayList<PwmSettingCategory> returnObj = new ArrayList<>();
   for (final PwmSettingCategory category : values()) {
     if (category.isTopCategory()) {
       returnObj.add(category);
     }
   }
   return returnObj;
 }
예제 #3
0
 public Collection<PwmSettingCategory> getChildCategories() {
   final ArrayList<PwmSettingCategory> returnObj = new ArrayList<>();
   for (final PwmSettingCategory category : values()) {
     if (this == category.getParent()) {
       returnObj.add(category);
     }
   }
   return returnObj;
 }
예제 #4
0
 public Collection<PwmSettingCategory> getParents() {
   final ArrayList<PwmSettingCategory> returnObj = new ArrayList<>();
   PwmSettingCategory currentCategory = this.getParent();
   while (currentCategory != null) {
     returnObj.add(0, currentCategory);
     currentCategory = currentCategory.getParent();
   }
   return returnObj;
 }
예제 #5
0
 public static List<PwmSettingCategory> sortedValues(final Locale locale) {
   if (cached_sortedSettings == null) {
     int counter = 0; // prevents dupes from being eliminated;
     final Map<String, PwmSettingCategory> sortedCategories =
         new TreeMap<String, PwmSettingCategory>();
     for (final PwmSettingCategory category : PwmSettingCategory.values()) {
       final String sortValue = category.toMenuLocationDebug(null, locale) + (counter++);
       sortedCategories.put(sortValue, category);
     }
     cached_sortedSettings =
         Collections.unmodifiableList(new ArrayList<>(sortedCategories.values()));
   }
   return cached_sortedSettings;
 }
예제 #6
0
 public boolean isHidden() {
   if (hidden == null) {
     final Element settingElement = PwmSettingXml.readCategoryXml(this);
     final Attribute hiddenElement = settingElement.getAttribute("hidden");
     if (hiddenElement != null && "true".equalsIgnoreCase(hiddenElement.getValue())) {
       hidden = true;
     } else {
       for (final PwmSettingCategory parentCategory : getParents()) {
         if (parentCategory.isHidden()) {
           hidden = true;
         }
       }
     }
     if (hidden == null) {
       hidden = false;
     }
   }
   return hidden;
 }