KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > properties > attributes > forms > AttributeDefinitionsForm


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.properties.attributes.forms;
21
22 import java.util.Collection JavaDoc;
23
24 import javax.servlet.http.HttpSession JavaDoc;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28 import org.apache.struts.util.MessageResources;
29
30 import com.sslexplorer.core.CoreUtil;
31 import com.sslexplorer.properties.attributes.AttributeDefinition;
32 import com.sslexplorer.properties.attributes.AttributeDefinitionItem;
33 import com.sslexplorer.table.AbstractTableItemTableModel;
34 import com.sslexplorer.table.forms.AbstractPagerForm;
35
36 /**
37  * Implementation of a {@link com.sslexplorer.table.forms.AbstractPagerForm}
38  * that allows an administrator to list and configure <i>Attribute Definitions</i>.
39  *
40  * @author Brett Smith <a HREF="mailto:brett@3sp.com">&lt;brett@3sp.com&gt;</a>
41  */

42 public class AttributeDefinitionsForm extends AbstractPagerForm {
43
44     static Log log = LogFactory.getLog(AttributeDefinitionsForm.class);
45     
46     private String JavaDoc propertyClassName;
47
48     /**
49      * Constructor
50      */

51     public AttributeDefinitionsForm() {
52         super(new AttributeDefinitionsModel());
53     }
54
55     /**
56      * Initialise this form with a list of attribute definitions.
57      *
58      * @param session session
59      * @param definitions list of {@link com.sslexplorer.properties.attributes.AttributeDefinition} objects
60      * @throws Exception on any error
61      */

62     public void initialize(HttpSession JavaDoc session, Collection JavaDoc<AttributeDefinition> definitions) throws Exception JavaDoc {
63         super.initialize(session, "name");
64         for (AttributeDefinition def : definitions) {
65             if(def.isHidden())
66                 continue;
67             MessageResources mr = null;
68             if(def.getMessageResourcesKey() != null) {
69                 mr = CoreUtil.getMessageResources(session, def.getMessageResourcesKey());
70             }
71             AttributeDefinitionItem item = new AttributeDefinitionItem(def, mr);
72             getModel().addItem(item);
73         }
74         getPager().rebuild(getFilterText());
75     }
76
77     /**
78      * Get the property class name to create
79      *
80      * @return property class name
81      */

82     public String JavaDoc getPropertyClassName() {
83         return propertyClassName;
84     }
85
86     /**
87      * Set the property class name to create
88      *
89      * @param propertyClassName property class name to create
90      */

91     public void setPropertyClassName(String JavaDoc propertyClassName) {
92         this.propertyClassName = propertyClassName;
93     }
94
95     /*
96      * Supporting classes
97      */

98
99     /**
100      * Table model for displaying attribute definitions.
101      *
102      * @author Brett Smith <a HREF="mailto:brett@3sp.com">&lt;brett@3sp.com&gt;</a>
103      */

104     static class AttributeDefinitionsModel extends AbstractTableItemTableModel {
105
106         /*
107          * (non-Javadoc)
108          *
109          * @see com.sslexplorer.table.AbstractTableItemTableModel#getColumnWidth(int)
110          */

111         public int getColumnWidth(int col) {
112             return 0;
113         }
114
115         /*
116          * (non-Javadoc)
117          *
118          * @see com.sslexplorer.table.TableItemModel#getId()
119          */

120         public String JavaDoc getId() {
121             return "attributeDefinitions";
122         }
123
124         /*
125          * (non-Javadoc)
126          *
127          * @see com.sslexplorer.table.TableModel#getColumnCount()
128          */

129         public int getColumnCount() {
130             return 2;
131         }
132
133         /*
134          * (non-Javadoc)
135          *
136          * @see com.sslexplorer.table.TableModel#getColumnName(int)
137          */

138         public String JavaDoc getColumnName(int col) {
139             switch (col) {
140                 case 0:
141                     return "name";
142                 default:
143                     return "label";
144             }
145         }
146  
147         /*
148          * (non-Javadoc)
149          *
150          * @see com.sslexplorer.table.TableModel#getColumnClass(int)
151          */

152         public Class JavaDoc getColumnClass(int col) {
153              return String JavaDoc.class;
154         }
155
156     }
157 }
158
Popular Tags