KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > table > TableItemAction


1 package com.sslexplorer.table;
2
3 import com.sslexplorer.core.MenuItem;
4 import com.sslexplorer.policyframework.Permission;
5 import com.sslexplorer.policyframework.ResourceType;
6 import com.sslexplorer.security.SessionInfo;
7
8
9 /**
10  * Extension of {@link MenuItem} to be used for <i>Table Item Actions</i>.
11  * These are actions that may be linked to any {@link TableItemModel}
12  * via its ID and will be available for each item the model.
13  * <p>
14  * Item actions have a number of additional attributes that determine
15  * amongst other thing how they are presented to the user.
16  * <p>
17  * <ul>
18  * <li><b>Important</b>. In item action is important, it may
19  * be displayed more prominantly. For example, the default
20  * theme would render important actions as always visible
21  * icons, where unimportant actions get relegated to the
22  * &quot;More&quot; menu.</li>
23  * </ul>
24  *
25  * @author brett
26  */

27 public class TableItemAction extends MenuItem {
28     
29     // Private instance variables;
30

31     private boolean important;
32     
33     /**
34      * Constructor for all navigation contexts.
35      *
36      * @param id table model ID to
37      * @param messageResourcesKey
38      * @param weight weight
39      * @param important important
40      */

41     public TableItemAction(String JavaDoc id, String JavaDoc messageResourcesKey, int weight, boolean important) {
42         this(id, messageResourcesKey, weight, null, important);
43     }
44     
45     /**
46      * Constructor for all navigation contexts.
47      *
48      * @param id table model ID to
49      * @param messageResourcesKey
50      * @param weight weight
51      * @param target target frame
52      * @param important important
53      */

54     public TableItemAction(String JavaDoc id, String JavaDoc messageResourcesKey, int weight, String JavaDoc target, boolean important) {
55         this(id, messageResourcesKey, weight, target, important, SessionInfo.ALL_CONTEXTS);
56     }
57     
58     /**
59      * Constructor.
60      *
61      * @param id table model ID to
62      * @param messageResourcesKey
63      * @param weight weight
64      * @param important important
65      * @param navigationContext navigation context mask
66      */

67     public TableItemAction(String JavaDoc id, String JavaDoc messageResourcesKey, int weight, boolean important, int navigationContext) {
68         this(id, messageResourcesKey, weight, null, important, navigationContext);
69     }
70     
71     /**
72      * Constructor.
73      *
74      * @param id table model ID to
75      * @param messageResourcesKey
76      * @param weight weight
77      * @param target target frame
78      * @param important important
79      * @param navigationContext navigation context mask
80      */

81     public TableItemAction(String JavaDoc id, String JavaDoc messageResourcesKey, int weight, String JavaDoc target, boolean important, int navigationContext) {
82         super(id, messageResourcesKey, "", weight, true, target, navigationContext);
83         init(important);
84     }
85     
86     /**
87      * Constructor.
88      *
89      * @param id table model ID to
90      * @param messageResourcesKey
91      * @param weight weight
92      * @param target target frame
93      * @param important important
94      * @param navigationContext navigation context mask
95      * @param resourceTypeOfPermissionsRequired
96      * @param permissionsRequired
97      */

98     public TableItemAction(String JavaDoc id, String JavaDoc messageResourcesKey, int weight, String JavaDoc target, boolean important,
99                     int navigationContext, ResourceType resourceTypeOfPermissionsRequired, Permission[] permissionsRequired) {
100         super(id, messageResourcesKey, "", weight, true, target, navigationContext, resourceTypeOfPermissionsRequired, permissionsRequired);
101         init(important);
102     }
103
104     /**
105      * Get if the action is <i>Important</i>. Important actions
106      * should be renderered more prominently by the theme in
107      * use.
108      *
109      * @return action is important
110      */

111     public boolean isImportant() {
112         return important;
113     }
114     
115     void init(boolean important) {
116         this.important = important;
117     }
118     
119     /**
120      * Table Item Actions should overide this method to provide specific behaviour
121      * for the onclick event.
122      *
123      * @param availableItem available item
124      * @return onclick link
125      */

126     public String JavaDoc getOnClick(AvailableTableItemAction availableItem) {
127         return "";
128     }
129     
130     /**
131      * Table Item Actions should overide this method to provide specific behaviour
132      * for testing if the action is enabled.
133      *
134      * @param availableItem available item
135      * @return enabled
136      */

137     public boolean isEnabled(AvailableTableItemAction availableItem) {
138         return true;
139     }
140     
141     /**
142      * Table Item Actions should overide this method to provide specific behaviour
143      * for the href
144      *
145      * @param availableItem available item
146      * @return href
147      */

148     public String JavaDoc getPath(AvailableTableItemAction availableItem) {
149         return "#";
150     }
151     
152     /**
153      * If an additional attribute should be rendered. This method should
154      * return its name, otherwise an empty string should be returned.
155      *
156      * @return additional attribute name
157      */

158     public String JavaDoc getAdditionalAttributeName() {
159         return "";
160     }
161     
162     /**
163      * If an additional attribute should be rendered. This method should
164      * return its value, otherwise an empty string should be returned.
165      *
166      * @return additional attribute value
167      */

168     public String JavaDoc getAdditionalAttributeValue(AvailableTableItemAction availableItem) {
169         return "";
170     }
171     
172     /**
173      * Get this actions tooltip content location. If an empty string is returned
174      * the tooltip should is retrieved using message resources.
175      *
176      * @return tooltip content location
177      */

178     public String JavaDoc getToolTipContentLocation(AvailableTableItemAction availableItem) {
179         return "";
180     }
181     
182     /**
183      * Get this actions tooltip width
184      *
185      * @return tooltip width
186      */

187     public int getToolTipWidth(AvailableTableItemAction availableItem) {
188         /* TODO must be able to use css for this somehow. Will probably require
189          * changing the tooltip Javascript
190          */

191         return 140;
192     }
193
194 }
195
Popular Tags