1 18 19 package cowsultants.itracker.ejb.client.util; 20 21 import java.text.*; 22 import java.util.*; 23 24 import cowsultants.itracker.ejb.client.resources.ITrackerResources; 25 26 public class CustomFieldUtilities { 27 public static final int TYPE_UNKNOWN = -1; 28 public static final int TYPE_STRING = 1; 29 public static final int TYPE_INTEGER = 2; 30 public static final int TYPE_DATE = 3; 31 public static final int TYPE_LIST = 4; 32 33 public static final String DATE_FORMAT_UNKNOWN = "UNKNOWN"; 34 public static final String DATE_FORMAT_FULL = "full"; 35 public static final String DATE_FORMAT_DATEONLY = "dateonly"; 36 public static final String DATE_FORMAT_TIMEONLY = "timeonly"; 37 38 43 public static String getTypeString(int type) { 44 return getTypeString(type, ITrackerResources.getLocale()); 45 } 46 47 53 public static String getTypeString(int type, Locale locale) { 54 if(type == TYPE_STRING) { 55 return ITrackerResources.getString(ITrackerResources.KEY_BASE_CUSTOMFIELD_TYPE + "string", locale); 56 } else if(type == TYPE_INTEGER) { 57 return ITrackerResources.getString(ITrackerResources.KEY_BASE_CUSTOMFIELD_TYPE + "integer", locale); 58 } else if(type == TYPE_DATE) { 59 return ITrackerResources.getString(ITrackerResources.KEY_BASE_CUSTOMFIELD_TYPE + "date", locale); 60 } else if(type == TYPE_LIST) { 61 return ITrackerResources.getString(ITrackerResources.KEY_BASE_CUSTOMFIELD_TYPE + "list", locale); 62 } 63 64 return ITrackerResources.getString(ITrackerResources.KEY_BASE_CUSTOMFIELD_TYPE + "unknown", locale); 65 } 66 67 73 public static String getCustomFieldLabelKey(Integer fieldId) { 74 return ITrackerResources.KEY_BASE_CUSTOMFIELD + fieldId + ITrackerResources.KEY_BASE_CUSTOMFIELD_LABEL; 75 } 76 77 84 public static String getCustomFieldOptionLabelKey(Integer fieldId, Integer optionId) { 85 return ITrackerResources.KEY_BASE_CUSTOMFIELD + fieldId + ITrackerResources.KEY_BASE_CUSTOMFIELD_OPTION + optionId + ITrackerResources.KEY_BASE_CUSTOMFIELD_LABEL; 86 } 87 88 93 public static String getCustomFieldName(Integer fieldId) { 94 return getCustomFieldName(fieldId, ITrackerResources.getLocale()); 95 } 96 97 103 public static String getCustomFieldName(Integer fieldId, Locale locale) { 104 return ITrackerResources.getString(CustomFieldUtilities.getCustomFieldLabelKey(fieldId), locale); 105 } 106 107 113 public static String getCustomFieldOptionName(Integer fieldId, Integer optionId) { 114 return getCustomFieldOptionName(fieldId, optionId, ITrackerResources.getLocale()); 115 } 116 117 124 public static String getCustomFieldOptionName(Integer fieldId, Integer optionId, Locale locale) { 125 if(fieldId != null && optionId != null) { 126 return ITrackerResources.getString(CustomFieldUtilities.getCustomFieldOptionLabelKey(fieldId, optionId), locale); 127 } 128 return ""; 129 } 130 } 131 | Popular Tags |