001: /*
002: * Version: MPL 1.1/GPL 2.0/LGPL 2.1
003: *
004: * "The contents of this file are subject to the Mozilla Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License at
007: * http://www.mozilla.org/MPL/
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
011: * License for the specific language governing rights and limitations under
012: * the License.
013: *
014: * The Original Code is ICEfaces 1.5 open source software code, released
015: * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
016: * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
017: * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
018: *
019: * Contributor(s): _____________________.
020: *
021: * Alternatively, the contents of this file may be used under the terms of
022: * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
023: * License), in which case the provisions of the LGPL License are
024: * applicable instead of those above. If you wish to allow use of your
025: * version of this file only under the terms of the LGPL License and not to
026: * allow others to use your version of this file under the MPL, indicate
027: * your decision by deleting the provisions above and replace them with
028: * the notice and other provisions required by the LGPL License. If you do
029: * not delete the provisions above, a recipient may use your version of
030: * this file under either the MPL or the LGPL License."
031: *
032: */
033:
034: package com.icesoft.faces.component.outputconnectionstatus;
035:
036: import com.icesoft.faces.component.CSS_DEFAULT;
037: import com.icesoft.faces.component.ext.taglib.Util;
038:
039: import javax.faces.component.html.HtmlPanelGroup;
040: import javax.faces.context.FacesContext;
041: import javax.faces.el.ValueBinding;
042:
043: /**
044: * OutputConnectionStatus is a JSF component class representing an ICEfaces
045: * output connection status state indicator.
046: * <p/>
047: * This component extends the JSF HtmlPanelGroup component.
048: * <p/>
049: * By default the OutputConnectionStatus is rendered by the
050: * "com.icesoft.faces.OutputConnectionStatusRenderer" renderer type.
051: */
052:
053: public class OutputConnectionStatus extends HtmlPanelGroup {
054: public static final String COMPONENT_TYPE = "com.icesoft.faces.OutputConnectionStatus";
055: public static final String RENDERER_TYPE = "com.icesoft.faces.OutputConnectionStatusRenderer";
056: public static final String COMPONENT_FAMILY = "javax.faces.Panel";
057: private static final String DEFAULT_LABEL = "";
058: private java.lang.String style;
059: private java.lang.String styleClass;
060: private java.lang.String inactiveLabel;
061: private java.lang.String activeLabel;
062: private java.lang.String cautionLabel;
063: private java.lang.String disconnectedLabel;
064: private java.lang.String renderedOnUserRole;
065:
066: /**
067: * <p>Return the value of the <code>COMPONENT_FAMILY</code> of this
068: * component.</p>
069: */
070: public String getFamily() {
071: return COMPONENT_FAMILY;
072: }
073:
074: /**
075: * <p>Return the value of the <code>RENDERER_TYPE</code> of this
076: * component.</p>
077: */
078: public String getRendererType() {
079: return RENDERER_TYPE;
080: }
081:
082: /**
083: * <p>Return the value of the <code>COMPONENT_TYPE</code> of this
084: * component.</p>
085: */
086: public String getComponentType() {
087: return COMPONENT_TYPE;
088: }
089:
090: /**
091: * <p>Return the value of the <code>activeClass</code> property.</p>
092: */
093: public String getActiveClass() {
094: return Util
095: .getQualifiedStyleClass(
096: this ,
097: CSS_DEFAULT.OUTPUT_CONNECTION_STATUS_DEFAULT_ACTIVE_CLASS);
098: }
099:
100: /**
101: * <p>Set the value of the <code>activeLabel</code> property.</p>
102: */
103: public void setActiveLabel(java.lang.String activeLabel) {
104: this .activeLabel = activeLabel;
105: }
106:
107: /**
108: * <p>Return the value of the <code>activeLabel</code> property.</p>
109: */
110: public String getActiveLabel() {
111: if (activeLabel != null) {
112: return activeLabel;
113: }
114: ValueBinding vb = getValueBinding("activeLabel");
115: return vb != null ? (String) vb.getValue(getFacesContext())
116: : DEFAULT_LABEL;
117: }
118:
119: /**
120: * <p>Return the value of the <code>cautionClass</code> property.</p>
121: */
122: public String getCautionClass() {
123: return Util
124: .getQualifiedStyleClass(
125: this ,
126: CSS_DEFAULT.OUTPUT_CONNECTION_STATUS_DEFAULT_CAUTION_CLASS);
127: }
128:
129: /**
130: * <p>Set the value of the <code>cautionLabel</code> property.</p>
131: */
132: public void setCautionLabel(java.lang.String cautionLabel) {
133: this .cautionLabel = cautionLabel;
134: }
135:
136: /**
137: * <p>Return the value of the <code>cautionLabel</code> property.</p>
138: */
139: public String getCautionLabel() {
140: if (cautionLabel != null) {
141: return cautionLabel;
142: }
143: ValueBinding vb = getValueBinding("cautionLabel");
144: return vb != null ? (String) vb.getValue(getFacesContext())
145: : DEFAULT_LABEL;
146: }
147:
148: /**
149: * <p>Return the value of the <code>disconnectedClass</code> property.</p>
150: */
151: public String getDisconnectedClass() {
152: return Util
153: .getQualifiedStyleClass(
154: this ,
155: CSS_DEFAULT.OUTPUT_CONNECTION_STATUS_DEFAULT_DISCONNECT_CLASS);
156: }
157:
158: /**
159: * <p>Set the value of the <code>disconnectedLabel</code> property.</p>
160: */
161: public void setDisconnectedLabel(java.lang.String disconnectedLabel) {
162: this .disconnectedLabel = disconnectedLabel;
163: }
164:
165: /**
166: * <p>Return the value of the <code>disconnectedLabel</code> property.</p>
167: */
168: public String getDisconnectedLabel() {
169: if (disconnectedLabel != null) {
170: return disconnectedLabel;
171: }
172: ValueBinding vb = getValueBinding("disconnectedLabel");
173: return vb != null ? (String) vb.getValue(getFacesContext())
174: : DEFAULT_LABEL;
175: }
176:
177: /**
178: * <p>Return the value of the <code>inactiveClass</code> property.</p>
179: */
180: public String getInactiveClass() {
181: return Util
182: .getQualifiedStyleClass(
183: this ,
184: CSS_DEFAULT.OUTPUT_CONNECTION_STATUS_DEFAULT_INACTIVE_CLASS);
185: }
186:
187: /**
188: * <p>Set the value of the <code>inactiveLabel</code> property.</p>
189: */
190: public void setInactiveLabel(java.lang.String inactiveLabel) {
191: this .inactiveLabel = inactiveLabel;
192: }
193:
194: /**
195: * <p>Return the value of the <code>inactiveLabel</code> property.</p>
196: */
197: public String getInactiveLabel() {
198: if (inactiveLabel != null) {
199: return inactiveLabel;
200: }
201: ValueBinding vb = getValueBinding("inactiveLabel");
202: return vb != null ? (String) vb.getValue(getFacesContext())
203: : DEFAULT_LABEL;
204: }
205:
206: /**
207: * <p>Set the value of the <code>style</code> property.</p>
208: */
209: public void setStyle(java.lang.String style) {
210: this .style = style;
211: }
212:
213: /**
214: * <p>Return the value of the <code>style</code> property.</p>
215: */
216: public String getStyle() {
217: if (style != null) {
218: return style;
219: }
220: ValueBinding vb = getValueBinding("style");
221: return vb != null ? (String) vb.getValue(getFacesContext())
222: : null;
223: }
224:
225: /**
226: * <p>Set the value of the <code>styleClass</code> property.</p>
227: */
228: public void setStyleClass(java.lang.String styleClass) {
229: this .styleClass = styleClass;
230: }
231:
232: /**
233: * <p>Return the value of the <code>styleClass</code> property.</p>
234: */
235: public String getStyleClass() {
236: return Util
237: .getQualifiedStyleClass(
238: this ,
239: styleClass,
240: CSS_DEFAULT.OUTPUT_CONNECTION_STATUS_DEFAULT_STYLE_CLASS,
241: "styleClass");
242: }
243:
244: /**
245: * <p>Set the value of the <code>renderedOnUserRole</code> property.</p>
246: */
247: public void setRenderedOnUserRole(String renderedOnUserRole) {
248: this .renderedOnUserRole = renderedOnUserRole;
249: }
250:
251: /**
252: * <p>Return the value of the <code>renderedOnUserRole</code> property.</p>
253: */
254: public String getRenderedOnUserRole() {
255: if (renderedOnUserRole != null) {
256: return renderedOnUserRole;
257: }
258: ValueBinding vb = getValueBinding("renderedOnUserRole");
259: return vb != null ? (String) vb.getValue(getFacesContext())
260: : null;
261: }
262:
263: /**
264: * <p>Return the value of the <code>rendered</code> property.</p>
265: */
266: public boolean isRendered() {
267: if (!Util.isRenderedOnUserRole(this )) {
268: return false;
269: }
270: return super .isRendered();
271: }
272:
273: /**
274: * <p>Gets the state of the instance as a <code>Serializable</code>
275: * Object.</p>
276: */
277: public Object saveState(FacesContext context) {
278: Object values[] = new Object[11];
279: values[0] = super .saveState(context);
280: values[1] = style;
281: values[2] = styleClass;
282: values[3] = inactiveLabel;
283: values[4] = activeLabel;
284: values[5] = cautionLabel;
285: values[6] = disconnectedLabel;
286: values[7] = renderedOnUserRole;
287: return ((Object) (values));
288: }
289:
290: /**
291: * <p>Perform any processing required to restore the state from the entries
292: * in the state Object.</p>
293: */
294: public void restoreState(FacesContext context, Object state) {
295: Object values[] = (Object[]) state;
296: super .restoreState(context, values[0]);
297: style = (String) values[1];
298: styleClass = (String) values[2];
299: inactiveLabel = (String) values[3];
300: activeLabel = (String) values[4];
301: cautionLabel = (String) values[5];
302: disconnectedLabel = (String) values[6];
303: renderedOnUserRole = (String) values[7];
304: }
305: }
|