KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > icefaces > samples > showcase > components > progressBar > OutputProgressPropertyBean


1 /*
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * "The contents of this file are subject to the Mozilla Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11  * License for the specific language governing rights and limitations under
12  * the License.
13  *
14  * The Original Code is ICEfaces 1.5 open source software code, released
15  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
16  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
17  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
18  *
19  * Contributor(s): _____________________.
20  *
21  * Alternatively, the contents of this file may be used under the terms of
22  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
23  * License), in which case the provisions of the LGPL License are
24  * applicable instead of those above. If you wish to allow use of your
25  * version of this file only under the terms of the LGPL License and not to
26  * allow others to use your version of this file under the MPL, indicate
27  * your decision by deleting the provisions above and replace them with
28  * the notice and other provisions required by the LGPL License. If you do
29  * not delete the provisions above, a recipient may use your version of
30  * this file under either the MPL or the LGPL License."
31  *
32  */

33
34 package com.icesoft.icefaces.samples.showcase.components.progressBar;
35
36 import javax.faces.event.ValueChangeEvent;
37
38 /**
39  * <p>The OutputProgressPropertyBean class manages the customizable aspects of
40  * the outputProgress component. These values for custom labels and alignment
41  * etc. are shared between the two separate outputProgress components
42  * (determinate and indeterminate).</p>
43  *
44  * @see OutputProgressRenderBean
45  * @since 1.0
46  */

47 public class OutputProgressPropertyBean {
48
49     // switch between standard and indeterminate modes
50
private String JavaDoc mode = "standard";
51     
52     // position of label with respect to the progress bar
53
private String JavaDoc labelPosition = "top";
54     
55     // values stored in selectBooleanCheckbox and inputText for custom progress
56
private boolean customProgress;
57     private String JavaDoc progressLabel;
58
59     // values stored in selectBooleanCheckbox and inputText for custom completion
60
private boolean customComplete;
61     private String JavaDoc progressCompleteLabel;
62
63
64     /**
65      * Sets the mode of the progress bar.
66      *
67      * @param mode the mode of the progress bar
68      */

69     public void setMode(String JavaDoc mode) {
70         this.mode = mode;
71     }
72
73     /**
74      * Gets the mode of the progress bar.
75      *
76      * @return the mode of the progress bar
77      */

78     public String JavaDoc getMode() {
79         return mode;
80     }
81
82     /**
83      * Sets the label position. Values can be as follows: left, right, top,
84      * topcenter, topright, bottom, bottomcenter, bottomright, embed.
85      *
86      * @param labelPosition new label position.
87      */

88     public void setLabelPosition(String JavaDoc labelPosition) {
89         this.labelPosition = labelPosition;
90     }
91
92     /**
93      * Gets the current position of the label.
94      *
95      * @return current position of label.
96      */

97     public String JavaDoc getLabelPosition() {
98         return labelPosition;
99     }
100
101     /**
102      * Sets the state of the custom progress label.
103      *
104      * @param customProgress the status of the custom progress label
105      */

106     public void setCustomProgress(boolean customProgress) {
107         this.customProgress = customProgress;
108     }
109
110     /**
111      * Determines whether a custom progress label is used.
112      *
113      * @return the status of custom progress label
114      */

115     public boolean isCustomProgress() {
116         return customProgress;
117     }
118
119     /**
120      * Sets the value of the progress Label.
121      *
122      * @param newLabel new value for label.
123      */

124     public void setProgressLabel(String JavaDoc newLabel) {
125         progressLabel = newLabel;
126     }
127     
128     /**
129      * Gets the current progress label.
130      *
131      * @return progress label, null if there is no progress label.
132      */

133     public String JavaDoc getProgressLabel() {
134         return progressLabel;
135     }
136
137     /**
138      * @return
139      */

140     public String JavaDoc getProgressLabelAfter() {
141         //by default, indeterminate mode has no in-progress label
142
if (mode.equals("indeterminate")) {
143             if (!customProgress)
144                 return "";
145         }
146         // if there's a custom progress label, use it, otherwise
147
// returning null will make the component use the default
148
if (customProgress) {
149             return progressLabel;
150         } else return null;
151     }
152
153     /**
154      * Sets the state of the custom complete label.
155      *
156      * @param customComplete
157      */

158     public void setCustomComplete(boolean customComplete) {
159         this.customComplete = customComplete;
160     }
161     
162     /**
163      * Determines whether a custom complete label is used.
164      *
165      * @return the status of custom complete label
166      */

167     public boolean isCustomComplete() {
168         return customComplete;
169     }
170     
171     /**
172      * Sets the value of the progress complete label.
173      *
174      * @param newLabel new value for the complete label.
175      */

176     public void setProgressCompleteLabel(String JavaDoc newLabel) {
177         progressCompleteLabel = newLabel;
178     }
179
180     /**
181      * Gets the current progress label.
182      *
183      * @return progress label, null if there is no progress label.
184      */

185     public String JavaDoc getProgressCompleteLabel() {
186         return progressCompleteLabel;
187     }
188
189     /**
190      * @return
191      */

192     public String JavaDoc getProgressCompleteLabelAfter() {
193         if (customComplete) {
194             return progressCompleteLabel;
195         } else return null;
196     }
197     
198     /**
199      * Progress label postion has changed. Update the state of the progress
200      * label position and calls a render on the persistent faces context.
201      *
202      * @param event values changed event containing new position information.
203      */

204     public void progressPositionChanged(ValueChangeEvent event) {
205         labelPosition = (String JavaDoc) event.getNewValue();
206     }
207 }
Popular Tags