1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.extremecomponents.tree.model;
17
18 import java.io.InputStream;
19 import java.util.Properties;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24
25 /***
26 * Load up the properties file that will be used by the Model.
27 * The properties file contains default table attributes.
28 * TODO: should be able to load up a properties file that cooresponds
29 * with the current table if want to.
30 *
31 * @author Jeff Johnston
32 */
33 public class TreeProperties
34 {
35 private static Log logger = LogFactory.getLog(TreeProperties.class);
36 public final static String EXTREMECOMPONENTS_PROPERTIES = "extremecomponents.properties";
37 public final static String EXTREMETABLE_PROPERTIES = "extremetree.properties";
38
39 public final static String AUTO_INCLUDE_PARAMETERS = "tree.autoIncludeParameters";
40 public final static String BORDER = "tree.border";
41 public final static String CELL = "tree.cell_";
42 public final static String CELLPADDING = "tree.cellpadding";
43 public final static String CELLSPACING = "tree.cellspacing";
44 public final static String EXPORT = "tree.export";
45 public final static String FILTER = "tree.filter";
46 public final static String FORMAT = "tree.format_";
47 public final static String HEADER_CLASS = "tree.headerClass";
48 public final static String HEADER_SORT_CLASS = "tree.headerSortClass";
49 public final static String IMAGE_PATH = "tree.imagePath";
50 public final static String MAX_ROWS = "tree.maxRows";
51 public final static String METHOD = "tree.method";
52 public final static String PAGINATION = "tree.pagination";
53 public final static String PARSE = "tree.parse_";
54 public final static String PROCESS_COLUMN = "tree.processColumn";
55 public final static String SORT = "tree.sort";
56 public final static String STYLE_CLASS = "tree.styleClass";
57 public final static String VIEW = "tree.view_";
58 public final static String VIEW_HTML= "tree.view_html";
59 public final static String WIDTH = "table.width";
60
61 private Properties properties;
62
63 public TreeProperties()
64 {
65 try
66 {
67 properties = new Properties();
68 properties.load(this.getClass().getResourceAsStream(EXTREMETABLE_PROPERTIES));
69
70 InputStream input = this.getClass().getResourceAsStream("/" + EXTREMECOMPONENTS_PROPERTIES);
71 if (input != null)
72 {
73 properties.load(input);
74 }
75 }
76 catch (Exception e)
77 {
78 logger.error("Could not load the Properties.", e);
79 }
80 }
81
82 /***
83 * Get the default property.
84 */
85 public String getProperty(String name)
86 {
87 return (String) properties.get(name);
88 }
89
90 /***
91 * add/override properties.
92 */
93 public void setProperty(String name, String value)
94 {
95 properties.setProperty(name, value);
96 }
97
98 public void destroy()
99 {
100 properties = null;
101 }
102 }