KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > web > ui > common > component > data > UIColumn


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.web.ui.common.component.data;
18
19 import javax.faces.component.UIComponent;
20 import javax.faces.component.UIComponentBase;
21 import javax.faces.context.FacesContext;
22 import javax.faces.el.ValueBinding;
23
24 /**
25  * @author Kevin Roast
26  */

27 public class UIColumn extends UIComponentBase
28 {
29    // ------------------------------------------------------------------------------
30
// Component implementation
31

32    /**
33     * @see javax.faces.component.UIComponent#getFamily()
34     */

35    public String JavaDoc getFamily()
36    {
37       return "org.alfresco.faces.Data";
38    }
39    
40    /**
41     * Return the UI Component to be used as the header for this column
42     *
43     * @return UIComponent
44     */

45    public UIComponent getHeader()
46    {
47       return getFacet("header");
48    }
49    
50    /**
51     * Return the UI Component to be used as the footer for this column
52     *
53     * @return UIComponent
54     */

55    public UIComponent getFooter()
56    {
57       return getFacet("footer");
58    }
59    
60    /**
61     * Return the UI Component to be used as the large icon for this column
62     *
63     * @return UIComponent
64     */

65    public UIComponent getLargeIcon()
66    {
67       return getFacet("large-icon");
68    }
69    
70    /**
71     * Return the UI Component to be used as the small icon for this column
72     *
73     * @return UIComponent
74     */

75    public UIComponent getSmallIcon()
76    {
77       return getFacet("small-icon");
78    }
79    
80    /**
81     * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
82     */

83    public void restoreState(FacesContext context, Object JavaDoc state)
84    {
85       Object JavaDoc values[] = (Object JavaDoc[])state;
86       // standard component attributes are restored by the super class
87
super.restoreState(context, values[0]);
88       this.primary = ((Boolean JavaDoc)values[1]).booleanValue();
89       this.actions = ((Boolean JavaDoc)values[2]).booleanValue();
90    }
91    
92    /**
93     * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
94     */

95    public Object JavaDoc saveState(FacesContext context)
96    {
97       Object JavaDoc values[] = new Object JavaDoc[3];
98       // standard component attributes are saved by the super class
99
values[0] = super.saveState(context);
100       values[1] = (this.primary ? Boolean.TRUE : Boolean.FALSE);
101       values[2] = (this.actions ? Boolean.TRUE : Boolean.FALSE);
102       return (values);
103    }
104    
105    
106    // ------------------------------------------------------------------------------
107
// Strongly typed component property accessors
108

109    /**
110     * @return true if this is the primary column
111     */

112    public boolean getPrimary()
113    {
114       ValueBinding vb = getValueBinding("primary");
115       if (vb != null)
116       {
117          this.primary = (Boolean JavaDoc)vb.getValue(getFacesContext());
118       }
119       return this.primary;
120    }
121    
122    /**
123     * @param primary True if this is the primary column, false otherwise
124     */

125    public void setPrimary(boolean primary)
126    {
127       this.primary = primary;
128    }
129    
130    /**
131     * @return true if this is the column containing actions for the current row
132     */

133    public boolean getActions()
134    {
135       ValueBinding vb = getValueBinding("actions");
136       if (vb != null)
137       {
138          this.actions = (Boolean JavaDoc)vb.getValue(getFacesContext());
139       }
140       return this.actions;
141    }
142    
143    /**
144     * @param actions True if this is the column containing actions for the current row
145     */

146    public void setActions(boolean actions)
147    {
148       this.actions = actions;
149    }
150    
151    
152    // ------------------------------------------------------------------------------
153
// Private data
154

155    private boolean primary = false;
156    private boolean actions = false;
157 }
158
Popular Tags