code: public List<CmsResourceTypeBean> buildTypesList(
          List<I_CmsResourceType> resourceTypes,
          Set<String> creatableTypes,
          Set<String> deactivatedTypes,
          final List<String> typesForTypeTab) {
  
          List<CmsResourceTypeBean> result = buildTypesList(resourceTypes, creatableTypes);
  
          for (CmsResourceTypeBean typeBean : result) {
              if ((typesForTypeTab != null) && (typesForTypeTab.size() > 0)) {
                  if (!typesForTypeTab.contains(typeBean.getType())) {
                      if (typeBean.getVisibility() != TypeVisibility.hidden) {
                          typeBean.setVisibility(TypeVisibility.showOptional);
                      }
                  }
              }
              typeBean.setDeactivated(deactivatedTypes.contains(typeBean.getType()));
          }
          if ((typesForTypeTab != null) && (typesForTypeTab.size() > 0)) {
              Collections.sort(result, new Comparator<CmsResourceTypeBean>() {
  
                  public int compare(CmsResourceTypeBean first, CmsResourceTypeBean second) {
  
                      return ComparisonChain.start().compare(searchTypeRank(first), searchTypeRank(second)).compare(
                          first.getTitle(),
                          second.getTitle(),
                          Collator.getInstance(getWorkplaceLocale())).compare(first.getType(), second.getType()).result();
                  }
  
                  int searchTypeRank(CmsResourceTypeBean type) {
  
                      int index = typesForTypeTab.indexOf(type.getType());
                      if (index == -1) {
                          return Integer.MAX_VALUE;
                      } else {
                          return index;
                      }
                  }
              });
  
          }
          return result;
      }
docs: Returns the resource types beans.<p>
  
  @param resourceTypes the resource types
  @param creatableTypes the creatable types
  @param deactivatedTypes the deactivated types
  @param typesForTypeTab the types which should be shown in the types tab according to the gallery configuration
  
  @return the resource types