KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > monitor > client > SessionDisplay


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /**
21  * SessionDisplay.java
22  *
23  *
24  * Created: Wed Jan 31 18:04:22 2001
25  *
26  * @author Ana von Klopp
27  * @version
28  */

29
30 package org.netbeans.modules.web.monitor.client;
31
32 import javax.swing.JLabel JavaDoc;
33 import javax.swing.table.*; // widgets
34
import org.netbeans.modules.web.monitor.data.*;
35 import org.openide.util.NbBundle;
36 import java.util.*;
37
38
39 public class SessionDisplay extends DataDisplay {
40
41     private final static boolean debug = false;
42
43     public SessionDisplay() {
44     super();
45     }
46
47     // We're treating these as if they are all strings at the
48
// moment. In reality they can be of different types, though maybe
49
// that does not matter...
50
public void setData(DataRecord md) {
51
52     if(debug) System.out.println("in SessionDisplay.setData()"); //NOI18N
53
this.removeAll();
54     if (md == null)
55         return;
56      
57     SessionData sd = md.getSessionData();
58     int gridy=-1;
59
60     if(sd == null ||
61        ("false".equals(sd.getAttributeValue("before")) && //NOI18N
62
"false".equals(sd.getAttributeValue("after")))) { //NOI18N
63

64
65
66         addGridBagComponent(this, createTopSpacer(), 0, ++gridy,
67                 fullGridWidth, 1, 0, 0,
68                 java.awt.GridBagConstraints.WEST,
69                 java.awt.GridBagConstraints.NONE,
70                 topSpacerInsets,
71                 0, 0);
72
73         addGridBagComponent(this,
74                 createDataLabel
75                 (NbBundle.getBundle(SessionDisplay.class).getString("MON_No_session")),
76                 0, ++gridy,
77                 fullGridWidth, 1, 0, 0,
78                 java.awt.GridBagConstraints.WEST,
79                 java.awt.GridBagConstraints.NONE,
80                 labelInsets,
81                 0, 0);
82
83         addGridBagComponent(this, createGlue(), 0, ++gridy,
84                 1, 1, 1.0, 1.0,
85                 java.awt.GridBagConstraints.WEST,
86                 java.awt.GridBagConstraints.BOTH,
87                 zeroInsets,
88                 0, 0);
89         return;
90     }
91
92     String JavaDoc headerIn;
93     String JavaDoc lastAccessed = null;
94     String JavaDoc maxInactiveBefore = null;
95     String JavaDoc maxInactiveAfter = null;
96
97     addGridBagComponent(this, createTopSpacer(), 0, ++gridy,
98                 fullGridWidth, 1, 0, 0,
99                 java.awt.GridBagConstraints.WEST,
100                 java.awt.GridBagConstraints.NONE,
101                 topSpacerInsets,
102                 0, 0);
103
104     // We need to refer to this label below, don't use the other
105
// createHeader method.
106
JLabel JavaDoc sessionHeaderLabel =
107         createHeaderLabel(NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_24"));
108     sessionHeaderLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_24A11yDesc"));
109     
110     addGridBagComponent(this,
111                 sessionHeaderLabel,
112                 0, ++gridy,
113                 fullGridWidth, 1, 0, 0,
114                 java.awt.GridBagConstraints.WEST,
115                 java.awt.GridBagConstraints.NONE,
116                 labelInsets,
117                 0, 0);
118     
119     String JavaDoc msg;
120     if("true".equals(sd.getAttributeValue("before"))) { //NOI18N
121
msg = NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_existed");
122         lastAccessed =
123         sd.getSessionIn().getAttributeValue("lastAccessed"); //NOI18N
124
maxInactiveBefore =
125         sd.getSessionIn().getAttributeValue("inactiveInterval"); //NOI18N
126
}
127     else {
128         msg = NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_created");
129         lastAccessed =
130         sd.getSessionOut().getAttributeValue("lastAccessed"); //NOI18N
131
}
132     
133         JLabel JavaDoc sessionDataLabel = createHeaderLabel(msg);
134         sessionDataLabel.getAccessibleContext().setAccessibleDescription(msg);
135         sessionHeaderLabel.setLabelFor(sessionDataLabel);
136     addGridBagComponent(this, sessionDataLabel, 0, ++gridy,
137                 fullGridWidth, 1, 0, 0,
138                 java.awt.GridBagConstraints.WEST,
139                 java.awt.GridBagConstraints.NONE,
140                 indentInsets,
141                 0, 0);
142
143
144     if("false".equals(sd.getAttributeValue("after"))) { //NOI18N
145
msg = NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_invalidated");
146         addGridBagComponent(this, createDataLabel(msg), 0, ++gridy,
147                 fullGridWidth, 1, 0, 0,
148                 java.awt.GridBagConstraints.WEST,
149                 java.awt.GridBagConstraints.NONE,
150                 indentInsets,
151                 0, 0);
152     }
153     else {
154         maxInactiveAfter =
155         sd.getSessionOut().getAttributeValue("inactiveInterval"); //NOI18N
156
}
157     
158
159     boolean inactiveChanged = false;
160     
161     if(maxInactiveBefore == null || maxInactiveBefore.equals("")) { //NOI18N
162
if(maxInactiveAfter != null)
163         maxInactiveBefore = maxInactiveAfter;
164         // Should not happen
165
else maxInactiveBefore = ""; //NOI18N
166
}
167     else if(maxInactiveAfter != null &&
168         !maxInactiveBefore.equals(maxInactiveAfter))
169         inactiveChanged = true;
170     
171     // Add session properties header
172
JLabel JavaDoc sessionPropertiesLabel = createHeaderLabel(NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_properties"));
173         sessionPropertiesLabel.setDisplayedMnemonic(NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_properties_Mnemonic").charAt(0));
174         sessionPropertiesLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_propertiesA11yDesc"));
175     addGridBagComponent(this, sessionPropertiesLabel, 0, ++gridy,
176                 fullGridWidth, 1, 0, 0,
177                 java.awt.GridBagConstraints.WEST,
178                 java.awt.GridBagConstraints.NONE,
179                 labelInsets,
180                 0, 0);
181
182     DisplayTable dt = null;
183        
184     if(!inactiveChanged) {
185         String JavaDoc data[] = {
186         sd.getAttributeValue("id"), //NOI18N
187
sd.getAttributeValue("created"), //NOI18N
188
lastAccessed,
189         maxInactiveBefore,
190         };
191
192         String JavaDoc[] props = {
193         NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_ID"),
194         NbBundle.getBundle(SessionDisplay.class).getString("MON_Created"),
195         NbBundle.getBundle(SessionDisplay.class).getString("MON_Last_accessed"),
196         NbBundle.getBundle(SessionDisplay.class).getString("MON_Max_inactive"),
197         };
198
199         dt = new DisplayTable(props, data);
200     }
201     else {
202         String JavaDoc data[] = {
203         sd.getAttributeValue("id"), //NOI18N
204
sd.getAttributeValue("created"), //NOI18N
205
lastAccessed,
206         maxInactiveBefore,
207         maxInactiveAfter,
208         };
209
210         String JavaDoc[] props2 = {
211         NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_ID"),
212         NbBundle.getBundle(SessionDisplay.class).getString("MON_Created"),
213         NbBundle.getBundle(SessionDisplay.class).getString("MON_Last_accessed"),
214         NbBundle.getBundle(SessionDisplay.class).getString("MON_Max_inactive_before"),
215         NbBundle.getBundle(SessionDisplay.class).getString("MON_Max_inactive_after"),
216         };
217         dt = new DisplayTable(props2, data);
218     }
219
220
221         sessionPropertiesLabel.setLabelFor(dt);
222         dt.getAccessibleContext().setAccessibleName(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_propertiesTableA11yName"));
223         dt.setToolTipText(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_propertiesTableA11yDesc"));
224     addGridBagComponent(this, dt, 0, ++gridy,
225                 fullGridWidth, 1, tableWeightX, tableWeightY,
226                 java.awt.GridBagConstraints.WEST,
227                 java.awt.GridBagConstraints.BOTH,
228                 tableInsets,
229                 0, 0);
230
231     // Attributes before and after
232
if("true".equals(sd.getAttributeValue("before"))) { //NOI18N
233
Param[] param = null;
234         try {
235         param = sd.getSessionIn().getParam();
236         }
237         catch(Exception JavaDoc ex) {
238         }
239         
240         if(param == null || param.length == 0) {
241         addGridBagComponent(this, createDataLabel(NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_no_att_before")), 0, ++gridy,
242                     fullGridWidth, 1, 0, 0,
243                     java.awt.GridBagConstraints.WEST,
244                     java.awt.GridBagConstraints.NONE,
245                     tableInsets,
246                     0, 0);
247         } else {
248                 JLabel JavaDoc sessionBeforeLabel = createHeaderLabel(NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_att_before"));
249                 sessionBeforeLabel.setDisplayedMnemonic(NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_att_before_Mnemonic").charAt(0));
250                 sessionBeforeLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_att_beforeA11yDesc"));
251         addGridBagComponent(this, sessionBeforeLabel, 0, ++gridy,
252                     fullGridWidth, 1, 0, 0,
253                     java.awt.GridBagConstraints.WEST,
254                     java.awt.GridBagConstraints.NONE,
255                     labelInsets,
256                     0, 0);
257         dt = new DisplayTable(param);
258                 sessionBeforeLabel.setLabelFor(dt);
259                 dt.getAccessibleContext().setAccessibleName(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_att_beforeTableA11yName"));
260                 dt.setToolTipText(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_att_beforeTableA11yDesc"));
261         addGridBagComponent(this, dt, 0, ++gridy,
262                     fullGridWidth, 1, tableWeightX, tableWeightY,
263                     java.awt.GridBagConstraints.WEST,
264                     java.awt.GridBagConstraints.BOTH,
265                     tableInsets,
266                     0, 0);
267         }
268     }
269     
270
271     if("true".equals(sd.getAttributeValue("after"))) { //NOI18N
272
Param[] param = null;
273         try {
274         param = sd.getSessionOut().getParam();
275         }
276         catch(Exception JavaDoc ex) {
277         }
278
279         if(param == null || param.length == 0) {
280         addGridBagComponent(this, createDataLabel(NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_no_att_after")), 0, ++gridy,
281                     fullGridWidth, 1, 0, 0,
282                     java.awt.GridBagConstraints.WEST,
283                     java.awt.GridBagConstraints.NONE,
284                     tableInsets,
285                     0, 0);
286         } else {
287                 JLabel JavaDoc sessionAfterLabel = createHeaderLabel(NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_att_after"));
288                 sessionAfterLabel.setDisplayedMnemonic(NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_att_after_Mnemonic").charAt(0));
289                 sessionAfterLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_att_afterA11yDesc"));
290         addGridBagComponent(this, sessionAfterLabel, 0, ++gridy,
291                     fullGridWidth, 1, 0, 0,
292                     java.awt.GridBagConstraints.WEST,
293                     java.awt.GridBagConstraints.NONE,
294                     labelInsets,
295                     0, 0);
296         dt = new DisplayTable(param);
297                 sessionAfterLabel.setLabelFor(dt);
298                 dt.getAccessibleContext().setAccessibleName(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_att_afterTableA11yName"));
299                 dt.setToolTipText(NbBundle.getBundle(SessionDisplay.class).getString("ACS_MON_Session_att_afterTableA11yDesc"));
300         addGridBagComponent(this, dt, 0, ++gridy,
301                     fullGridWidth, 1, tableWeightX, tableWeightY,
302                     java.awt.GridBagConstraints.WEST,
303                     java.awt.GridBagConstraints.BOTH,
304                     tableInsets,
305                     0, 0);
306         }
307         this.add(createRigidArea());
308     }
309
310     addGridBagComponent(this, createGlue(), 0, ++gridy,
311                 1, 1, 1.0, 1.0,
312                 java.awt.GridBagConstraints.WEST,
313                 java.awt.GridBagConstraints.BOTH,
314                 zeroInsets,
315                 0, 0);
316
317     this.setMaximumSize(this.getPreferredSize());
318     this.repaint();
319     }
320 } // SessionDisplay
321
Popular Tags