Source code: info/crossbar/state/NavMenuPrefs.java
1 /*
2 * @(#)NavMenuPrefs.java $Revision: 1.3 $ $Date: 2003/06/04 04:55:32 $
3 *
4 * Copyright 2002 by Daniel Kehoe <kehoe@fortuity.com>
5 * All Rights Reserved
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28 package info.crossbar.state;
29
30 import java.util.logging.Logger;
31
32 import java.util.prefs.*;
33
34 import javax.servlet.ServletException;
35
36 import info.crossbar.state.App;
37
38 /**
39 * NavMenuPrefs class for use by <a href="http://www.crossbar.info/">Crossbar</a>
40 *
41 * @author Daniel Kehoe, <a href="http://www.fortuity.com/">Fortuity Consulting</a>
42 * @version <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/crossbar/crossbar-sitemap/src/java/info/crossbar/state/NavMenuPrefs.java">View source, revision history</a>
43 * $Revision: 1.3 $ $Date: 2003/06/04 04:55:32 $
44 * <p>
45 * DESCRIPTION:
46 * The NavMenuPrefs class encapsulates a Java Preferences object. This class can be
47 * used as a bean with Java Server Faces to set preferences values.
48 */
49
50 public class NavMenuPrefs {
51
52 /**
53 * Set up logging.
54 */
55 private static Logger log = Logger.getLogger(NavMenuPrefs.class.getName());
56
57 /**
58 * Application preferences object.
59 */
60 private Preferences prefs;
61
62 /**
63 * Constructor. Obtains the application preferences object.
64 *
65 * @exception ServletException thrown by any error
66 */
67 public NavMenuPrefs()
68 throws ServletException {
69 // Obtain the menu preferences object
70 // (it needs to be qualified with the application name):
71 this.prefs = (Preferences.systemNodeForPackage(
72 NavMenuPrefs.class)).node(App.context.getServletContextName());
73 }
74
75 public void setRows(String value) {
76 this.prefs.put("rows", value);
77 }
78 public String getRows() {
79 return this.prefs.get("rows", "0");
80 }
81
82 public void setMenuPlacement(String value) {
83 this.prefs.put("menuPlacement", value);
84 }
85 public String getMenuPlacement() {
86 return this.prefs.get("menuPlacement", "'center'");
87 }
88
89 public void setFromLeft(String value) {
90 this.prefs.put("fromLeft", value);
91 }
92 public String getFromLeft() {
93 return this.prefs.get("fromLeft", "0");
94 }
95
96 public void setFromTop(String value) {
97 this.prefs.put("fromTop", value);
98 }
99 public String getFromTop() {
100 return this.prefs.get("fromTop", "90");
101 }
102
103 public void setPxBetween(String value) {
104 this.prefs.put("pxBetween", value);
105 }
106 public String getPxBetween() {
107 return this.prefs.get("pxBetween", "0");
108 }
109
110 public void setWidth(String value) {
111 this.prefs.put("width", value);
112 }
113 public String getWidth() {
114 return this.prefs.get("width", "80");
115 }
116
117 public void setHeight(String value) {
118 this.prefs.put("height", value);
119 }
120 public String getHeight() {
121 return this.prefs.get("height", "25");
122 }
123
124 public void setAlign(String value) {
125 this.prefs.put("align", value);
126 }
127 public String getAlign() {
128 return this.prefs.get("align", "'bottom'");
129 }
130
131 public void setOffsetX(String value) {
132 this.prefs.put("offsetX", value);
133 }
134 public String getOffsetX() {
135 return this.prefs.get("offsetX", "0");
136 }
137
138 public void setOffsetY(String value) {
139 this.prefs.put("offsetY", value);
140 }
141 public String getOffsetY() {
142 return this.prefs.get("offsetY", "0");
143 }
144
145 public void setUseBar(String value) {
146 this.prefs.put("useBar", value);
147 }
148 public String getUseBar() {
149 return this.prefs.get("useBar", "1");
150 }
151
152 public void setBarWidth(String value) {
153 this.prefs.put("barWidth", value);
154 }
155 public String getBarWidth() {
156 return this.prefs.get("barWidth", "'menu'");
157 }
158
159 public void setBarHeight(String value) {
160 this.prefs.put("barHeight", value);
161 }
162 public String getBarHeight() {
163 return this.prefs.get("barHeight", "'menu'");
164 }
165
166 public void setBarX(String value) {
167 this.prefs.put("barX", value);
168 }
169 public String getBarX() {
170 return this.prefs.get("barX", "'menu'");
171 }
172
173 public void setBarY(String value) {
174 this.prefs.put("barY", value);
175 }
176 public String getBarY() {
177 return this.prefs.get("barY", "'menu'");
178 }
179
180 public void setBarBorderX(String value) {
181 this.prefs.put("barBorderX", value);
182 }
183 public String getBarBorderX() {
184 return this.prefs.get("barBorderX", "1");
185 }
186
187 public void setBarBorderY(String value) {
188 this.prefs.put("barBorderY", value);
189 }
190 public String getBarBorderY() {
191 return this.prefs.get("barBorderY", "1");
192 }
193 }// end of class NavMenuPrefs
194