1 19 20 29 30 package org.netbeans.modules.web.monitor.client; 31 32 import javax.swing.JLabel ; 33 import javax.swing.table.*; 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 public void setData(DataRecord md) { 51 52 if(debug) System.out.println("in SessionDisplay.setData()"); 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")) && "false".equals(sd.getAttributeValue("after")))) { 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 headerIn; 93 String lastAccessed = null; 94 String maxInactiveBefore = null; 95 String 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 JLabel 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 msg; 120 if("true".equals(sd.getAttributeValue("before"))) { msg = NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_existed"); 122 lastAccessed = 123 sd.getSessionIn().getAttributeValue("lastAccessed"); maxInactiveBefore = 125 sd.getSessionIn().getAttributeValue("inactiveInterval"); } 127 else { 128 msg = NbBundle.getBundle(SessionDisplay.class).getString("MON_Session_created"); 129 lastAccessed = 130 sd.getSessionOut().getAttributeValue("lastAccessed"); } 132 133 JLabel 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"))) { 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"); } 157 158 159 boolean inactiveChanged = false; 160 161 if(maxInactiveBefore == null || maxInactiveBefore.equals("")) { if(maxInactiveAfter != null) 163 maxInactiveBefore = maxInactiveAfter; 164 else maxInactiveBefore = ""; } 167 else if(maxInactiveAfter != null && 168 !maxInactiveBefore.equals(maxInactiveAfter)) 169 inactiveChanged = true; 170 171 JLabel 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 data[] = { 186 sd.getAttributeValue("id"), sd.getAttributeValue("created"), lastAccessed, 189 maxInactiveBefore, 190 }; 191 192 String [] 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 data[] = { 203 sd.getAttributeValue("id"), sd.getAttributeValue("created"), lastAccessed, 206 maxInactiveBefore, 207 maxInactiveAfter, 208 }; 209 210 String [] 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 if("true".equals(sd.getAttributeValue("before"))) { Param[] param = null; 234 try { 235 param = sd.getSessionIn().getParam(); 236 } 237 catch(Exception 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 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"))) { Param[] param = null; 273 try { 274 param = sd.getSessionOut().getParam(); 275 } 276 catch(Exception 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 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 } | Popular Tags |