KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > properties > attributes > AttributeDefinitionItem


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;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23
24 import org.apache.struts.util.MessageResources;
25
26 import com.sslexplorer.core.CoreUtil;
27 import com.sslexplorer.table.TableItem;
28
29 /**
30  * Implementation of a {@link com.sslexplorer.table.TableItem} that is used to
31  * wrap {@link com.sslexplorer.security.AuthenticationScheme} objects for
32  * display.
33  *
34  * @author Brett Smith <a HREF="mailto:brett@3sp.com">&lt;brett@3sp.com&gt;</a>
35  */

36 public class AttributeDefinitionItem implements TableItem {
37
38     // Private instance variables
39

40     private AttributeDefinition definition;
41     private String JavaDoc categoryLabel;
42     private String JavaDoc description;
43     private String JavaDoc label;
44
45     /**
46      * Constructor
47      *
48      * @param definition definition
49      * @param messageResources message resources for label, categoryLabel and
50      * description. Or <code>null</code> to use values in definition
51      */

52     public AttributeDefinitionItem(AttributeDefinition definition, MessageResources messageResources) {
53         
54         try {
55             this.definition = definition;
56             String JavaDoc s = messageResources == null ? null : messageResources.getMessage("attributeCategory." + definition.getCategory() + ".title");
57             if (s != null && !s.equals("")) {
58                 categoryLabel = s;
59             } else {
60                 categoryLabel = definition.getCategoryLabel() != null && !definition.getCategoryLabel().equals("") ? definition.getCategoryLabel() : "Attributes";
61             }
62             s = messageResources == null ? null : messageResources.getMessage("attribute." + definition.getName() + ".title");
63             if (s != null && !s.equals("")) {
64                 label = s;
65             } else {
66                 label = definition.getLabel() != null && !definition.getLabel().equals("") ? definition.getLabel() : definition.getName();
67             }
68             s = messageResources == null ? null : messageResources.getMessage("attribute." + definition.getName() + ".description");
69             if (s != null && !s.equals("")) {
70                 description = s;
71             } else {
72                 description = definition.getDescription() != null && !definition.getDescription().equals("") ? definition.getDescription() : label;
73             }
74         } catch(Throwable JavaDoc t) {
75             t.printStackTrace();
76         }
77     }
78
79     /**
80      * Get the description
81      *
82      * @return description
83      */

84     public String JavaDoc getDescription() {
85         return description;
86     }
87
88     /**
89      * Set the description
90      *
91      * @param description description
92      */

93     public void setDescription(String JavaDoc description) {
94         this.description = description;
95     }
96
97     /**
98      * Get the label
99      *
100      * @return label
101      */

102     public String JavaDoc getLabel() {
103         return label;
104     }
105
106     /**
107      * Set the label
108      *
109      * @param label label
110      */

111     public void setLabel(String JavaDoc label) {
112         this.label = label;
113     }
114
115     /**
116      * Get the attribute definition object this item wraps
117      *
118      * @return attribute definition
119      */

120     public AttributeDefinition getDefinition() {
121         return definition;
122     }
123
124     /**
125      * Get the category label
126      *
127      * @return category label
128      */

129     public String JavaDoc getCategoryLabel() {
130         return categoryLabel;
131     }
132
133     /*
134      * (non-Javadoc)
135      *
136      * @see com.sslexplorer.table.TableItem#getColumnValue(int)
137      */

138     public Object JavaDoc getColumnValue(int col) {
139         switch (col) {
140             case 0:
141                 return getDefinition().getName();
142             default:
143                 return getDefinition().getLabel();
144         }
145     }
146
147     public String JavaDoc getSmallIconPath(HttpServletRequest JavaDoc request) {
148         return CoreUtil.getThemePath(request.getSession()) + "/images/actions/attributeDefinition.gif";
149     }
150
151 }
152
Popular Tags