1 package net.mlw.vlh.web; 2 3 import java.util.HashMap ; 4 import java.util.Map ; 5 6 import net.mlw.vlh.web.tag.support.CellInterceptor; 7 import net.mlw.vlh.web.tag.support.CsvDisplayProvider; 8 import net.mlw.vlh.web.tag.support.DefaultLinkEncoder; 9 import net.mlw.vlh.web.tag.support.DisplayProvider; 10 import net.mlw.vlh.web.tag.support.ExcelDisplayProvider; 11 import net.mlw.vlh.web.tag.support.GroupingCellInterceptor; 12 import net.mlw.vlh.web.tag.support.HtmlDisplayProvider; 13 import net.mlw.vlh.web.tag.support.LinkEncoder; 14 import net.mlw.vlh.web.util.DisplayHelper; 15 import net.mlw.vlh.web.util.PassThroughDisplayHelper; 16 17 import org.springframework.context.MessageSource; 18 import org.springframework.context.support.ResourceBundleMessageSource; 19 import org.springframework.web.servlet.LocaleResolver; 20 import org.springframework.web.servlet.i18n.SessionLocaleResolver; 21 22 28 public class ValueListConfigBean 29 { 30 31 public static final String DEFAULT_NAME = "classicLook"; 32 33 public static final CellInterceptor DEFAULT_CELL_INTERCEPTOR = new GroupingCellInterceptor(); 34 35 public static final int DEFAULT_STYLE_COUNT = 2; 36 37 public static final String DEFAULT_STYLE_PREFIX = "classicLook"; 38 39 public static final DisplayProvider DEFAULT_DISPLAY_PROVIDER = new HtmlDisplayProvider(); 40 41 public static final LocaleResolver DEFAULT_LOCALE_RESOLVER = new SessionLocaleResolver(); 42 43 public static final DisplayHelper DEFAULT_DISPLAY_HELPER = new PassThroughDisplayHelper(); 44 45 public static final LinkEncoder DEFAULT_LINK_ENCODER = new DefaultLinkEncoder(); 46 47 public static final ResourceBundleMessageSource DEFAULT_MESSAGE_SOURCE = new ResourceBundleMessageSource(); 48 49 public static final Map DEFAULT_DISPLAY_PROVIDERS = new HashMap (); 50 static 51 { 52 DEFAULT_MESSAGE_SOURCE.setBasename("classicLook"); 53 54 DEFAULT_DISPLAY_PROVIDERS.put("html", new HtmlDisplayProvider()); 55 DEFAULT_DISPLAY_PROVIDERS.put("csv", new CsvDisplayProvider()); 56 DEFAULT_DISPLAY_PROVIDERS.put("excel", new ExcelDisplayProvider()); 57 58 } 59 60 private CellInterceptor cellInterceptor = DEFAULT_CELL_INTERCEPTOR; 61 62 private String nullToken = "-"; 63 64 private int styleCount = DEFAULT_STYLE_COUNT; 65 66 private String stylePrefix = DEFAULT_STYLE_PREFIX; 67 68 private MessageSource messageSource = DEFAULT_MESSAGE_SOURCE; 69 70 private DisplayHelper displayHelper = DEFAULT_DISPLAY_HELPER; 71 72 private LocaleResolver localeResolver = DEFAULT_LOCALE_RESOLVER; 73 74 private Map displayProviders; 75 76 private LinkEncoder linkEncoder = DEFAULT_LINK_ENCODER; 77 78 private String imageRoot = "/images"; 79 82 public DisplayProvider getDisplayProvider(String name) 83 { 84 if (displayProviders == null) 85 { 86 return DEFAULT_DISPLAY_PROVIDER; 87 } 88 89 DisplayProvider display = (DisplayProvider) displayProviders.get(name); 90 if (display == null) 91 { 92 display = (DisplayProvider) DEFAULT_DISPLAY_PROVIDERS.get(name); 93 } 94 if (display == null) 95 { 96 display = DEFAULT_DISPLAY_PROVIDER; 97 } 98 99 return display; 100 } 101 102 106 public void setDisplayProviders(Map displayProviders) 107 { 108 this.displayProviders = displayProviders; 109 } 110 111 114 public DisplayHelper getDisplayHelper() 115 { 116 return displayHelper; 117 } 118 119 123 public void setDisplayHelper(DisplayHelper displayHelper) 124 { 125 this.displayHelper = displayHelper; 126 } 127 128 131 public String getNullToken() 132 { 133 return nullToken; 134 } 135 136 140 public void setNullToken(String nullToken) 141 { 142 this.nullToken = nullToken; 143 } 144 145 148 public int getStyleCount() 149 { 150 return styleCount; 151 } 152 153 157 public void setStyleCount(int styleCount) 158 { 159 this.styleCount = styleCount; 160 } 161 162 165 public String getStylePrefix() 166 { 167 return stylePrefix; 168 } 169 170 174 public void setStylePrefix(String stylePrefix) 175 { 176 this.stylePrefix = stylePrefix; 177 } 178 179 182 public MessageSource getMessageSource() 183 { 184 if (messageSource == null) 185 { 186 ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); 187 messageSource.setBasename("classicLook"); 188 this.messageSource = messageSource; 189 } 190 191 return messageSource; 192 } 193 194 198 public void setMessageSource(MessageSource messageSource) 199 { 200 this.messageSource = messageSource; 201 } 202 203 206 public LocaleResolver getLocaleResolver() 207 { 208 return localeResolver; 209 } 210 211 215 public void setLocaleResolver(LocaleResolver localeResolver) 216 { 217 this.localeResolver = localeResolver; 218 } 219 220 223 public LinkEncoder getLinkEncoder() 224 { 225 return linkEncoder; 226 } 227 228 231 public void setLinkEncoder(LinkEncoder linkEncoder) 232 { 233 this.linkEncoder = linkEncoder; 234 } 235 236 239 public String getFocusedRowStyle() { 240 return getStylePrefix()+"FocusedRow"; 241 } 242 245 public CellInterceptor getCellInterceptor() 246 { 247 return cellInterceptor; 248 } 249 252 public void setCellInterceptor(CellInterceptor cellInterceptor) 253 { 254 this.cellInterceptor = cellInterceptor; 255 } 256 259 public String getImageRoot() 260 { 261 return imageRoot; 262 } 263 266 public void setImageRoot(String imageRoot) 267 { 268 this.imageRoot = imageRoot; 269 } 270 } | Popular Tags |