01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.plaf.css;
14:
15: import org.wings.session.Browser;
16: import org.wings.session.SessionManager;
17: import org.wings.util.PropertyDiscovery;
18: import org.wings.util.SStringBuilder;
19:
20: import java.io.IOException;
21: import java.util.Properties;
22:
23: public class CSSLookAndFeel extends org.wings.plaf.LookAndFeel {
24: private static final long serialVersionUID = 1L;
25: private static final String PROPERTIES_DEFAULTFILE_PREFIX = "org/wings/plaf/css/default";
26:
27: public CSSLookAndFeel() throws IOException {
28: super (loadProperties());
29: }
30:
31: private static Properties loadProperties() throws IOException {
32: final SStringBuilder propertyFile = new SStringBuilder();
33:
34: // check for default PLAF properties under org/wings/plaf/css/default.properties
35: propertyFile.append(PROPERTIES_DEFAULTFILE_PREFIX).append(
36: ".properties");
37: Properties properties = PropertyDiscovery
38: .loadRequiredProperties(propertyFile.toString());
39:
40: // check for browser dependent properties under org/wings/plaf/css/default_msie.properties
41: final Browser userAgent = SessionManager.getSession()
42: .getUserAgent();
43: final String browserType = userAgent.getBrowserType()
44: .getShortName();
45: propertyFile.setLength(0);
46: propertyFile.append(PROPERTIES_DEFAULTFILE_PREFIX).append("_")
47: .append(browserType).append(".properties");
48: properties.putAll(PropertyDiscovery
49: .loadOptionalProperties(propertyFile.toString()));
50:
51: // check for browser dependent and VERSION dependen properties under org/wings/plaf/css/default_msie7.properties
52: propertyFile.setLength(0);
53: propertyFile.append(PROPERTIES_DEFAULTFILE_PREFIX).append("_")
54: .append(browserType)
55: .append(userAgent.getMajorVersion()).append(
56: ".properties");
57: properties.putAll(PropertyDiscovery
58: .loadOptionalProperties(propertyFile.toString()));
59:
60: return properties;
61: }
62: }
|