1 19 20 29 30 package org.netbeans.modules.web.monitor.client; 31 32 import java.util.ResourceBundle ; 33 import javax.accessibility.AccessibleContext ; 34 import javax.accessibility.AccessibleRelation ; 35 import javax.swing.JLabel ; 36 37 import org.openide.util.NbBundle; 38 39 import org.netbeans.modules.web.monitor.data.*; 40 41 46 public class CookieDisplay extends DataDisplay { 47 48 private final static boolean debug = false; 49 50 public CookieDisplay() { 51 super(); 52 } 53 54 public void setData(DataRecord md) { 58 59 if(debug) System.out.println("in CookieDisplay.setData()"); this.removeAll(); 61 if (md == null) 62 return; 63 64 CookiesData cd = md.getCookiesData(); 65 CookieIn[] in = cd.getCookieIn(); 66 CookieOut[] out = cd.getCookieOut(); 67 68 int gridy = -1; 69 String headerIn; 70 JLabel incomingLabel; 71 if(in == null || in.length == 0) { 72 headerIn = NbBundle.getBundle(CookieDisplay.class).getString("MON_No_incoming"); 73 incomingLabel = createDataLabel(headerIn); 74 75 } else { 76 headerIn = NbBundle.getBundle(CookieDisplay.class).getString("MON_Incoming_cookie"); 77 incomingLabel = createHeaderLabel(headerIn, NbBundle.getBundle(CookieDisplay.class).getString("MON_Incoming_cookie_Mnemonic").charAt(0), NbBundle.getBundle(CookieDisplay.class).getString("ACS_MON_Incoming_cookieA11yDesc"), null); 78 } 79 80 addGridBagComponent(this, createTopSpacer(), 0, ++gridy, 81 fullGridWidth, 1, 0, 0, 82 java.awt.GridBagConstraints.WEST, 83 java.awt.GridBagConstraints.NONE, 84 topSpacerInsets, 85 0, 0); 86 87 addGridBagComponent(this, incomingLabel, 0, ++gridy, 88 fullGridWidth, 1, 0, 0, 89 java.awt.GridBagConstraints.WEST, 90 java.awt.GridBagConstraints.HORIZONTAL, 91 labelInsets, 92 0, 0); 93 94 AccessibleContext aCtx; 95 AccessibleRelation aRel; 96 DisplayTable dt; 97 98 if(in != null && in.length > 0) { 99 100 for(int i=0; i<in.length; ++i) { 101 String [] data = { 102 in[i].getAttributeValue("name"), in[i].getAttributeValue("value") }; 105 106 String [] categoriesIn = { 107 NbBundle.getBundle(CookieDisplay.class).getString("MON_Name"), 108 NbBundle.getBundle(CookieDisplay.class).getString("MON_Value"), 109 }; 110 111 dt = new DisplayTable(categoriesIn, data); 112 aCtx = dt.getAccessibleContext(); 113 aCtx.setAccessibleName 114 (NbBundle.getMessage(CookieDisplay.class, 115 "ACS_MON_Incoming_cookieTableA11yName")); aCtx.setAccessibleDescription 117 (NbBundle.getMessage(CookieDisplay.class, 118 "ACS_MON_Incoming_cookieTableA11yDesc")); dt.setToolTipText 120 (NbBundle.getMessage(CookieDisplay.class, 121 "ACS_MON_Incoming_cookieTableA11yDesc")); aRel = new AccessibleRelation (AccessibleRelation.LABELED_BY, 123 incomingLabel); 124 aCtx.getAccessibleRelationSet().add(aRel); 125 addGridBagComponent(this, dt, 0, ++gridy, 126 fullGridWidth, 1, tableWeightX, tableWeightY, 127 java.awt.GridBagConstraints.WEST, 128 java.awt.GridBagConstraints.BOTH, 129 tableInsets, 130 0, 0); 131 } 132 } 133 134 String headerOut; 135 JLabel outgoingLabel; 136 if(out == null || out.length == 0) { 137 headerOut = NbBundle.getBundle(CookieDisplay.class).getString("MON_No_outgoing"); 138 outgoingLabel = createDataLabel(headerOut); 139 } else { 140 headerOut = NbBundle.getBundle(CookieDisplay.class).getString("MON_Outgoing_cookie"); 141 outgoingLabel = createHeaderLabel(headerOut, NbBundle.getBundle(CookieDisplay.class).getString("MON_Outgoing_cookie_Mnemonic").charAt(0), NbBundle.getBundle(CookieDisplay.class).getString("ACS_MON_Outgoing_cookieA11yDesc"), null); 142 } 143 addGridBagComponent(this, outgoingLabel, 0, ++gridy, 144 fullGridWidth, 1, 0, 0, 145 java.awt.GridBagConstraints.WEST, 146 java.awt.GridBagConstraints.NONE, 147 labelInsets, 148 0, 0); 149 150 if(out != null && out.length > 0) { 151 152 for(int i=0; i<out.length; ++i) { 153 String cookieMaxAge = 154 out[i].getAttributeValue("maxAge"); if(cookieMaxAge.equals("-1")) cookieMaxAge = NbBundle.getBundle(CookieDisplay.class).getString("MON_this_session"); 157 158 String [] data = { 159 out[i].getAttributeValue("name"), out[i].getAttributeValue("value"), out[i].getAttributeValue("domain"), out[i].getAttributeValue("path"), cookieMaxAge, 164 out[i].getAttributeValue("version"), out[i].getAttributeValue("secure"), out[i].getAttributeValue("comment") }; 168 169 String [] categoriesOut = { 170 NbBundle.getBundle(CookieDisplay.class).getString("MON_Name"), 171 NbBundle.getBundle(CookieDisplay.class).getString("MON_Value"), 172 NbBundle.getBundle(CookieDisplay.class).getString("MON_Domain"), 173 NbBundle.getBundle(CookieDisplay.class).getString("MON_Path"), 174 NbBundle.getBundle(CookieDisplay.class).getString("MON_Max_age"), 175 NbBundle.getBundle(CookieDisplay.class).getString("MON_Version"), 176 NbBundle.getBundle(CookieDisplay.class).getString("MON_Secure"), 177 NbBundle.getBundle(CookieDisplay.class).getString("MON_Comment"), 178 }; 179 180 dt = new DisplayTable(categoriesOut, data); 181 aCtx = dt.getAccessibleContext(); 182 aCtx.setAccessibleName 183 (NbBundle.getMessage(CookieDisplay.class, 184 "ACS_MON_Outgoing_cookieTableA11yName")); aCtx.setAccessibleDescription 186 (NbBundle.getMessage(CookieDisplay.class, 187 "ACS_MON_Outgoing_cookieTableA11yDesc")); dt.setToolTipText 189 (NbBundle.getMessage(CookieDisplay.class, 190 "ACS_MON_Outgoing_cookieTableA11yDesc")); aRel = new AccessibleRelation (AccessibleRelation.LABELED_BY, 192 outgoingLabel); 193 aCtx.getAccessibleRelationSet().add(aRel); 194 addGridBagComponent(this, dt, 0, ++gridy, 195 fullGridWidth, 1, tableWeightX, tableWeightY, 196 java.awt.GridBagConstraints.WEST, 197 java.awt.GridBagConstraints.BOTH, 198 tableInsets, 199 0, 0); 200 } 201 } 202 203 addGridBagComponent(this, createGlue(), 0, ++gridy, 204 1, 1, 1.0, 1.0, 205 java.awt.GridBagConstraints.WEST, 206 java.awt.GridBagConstraints.BOTH, 207 zeroInsets, 208 0, 0); 209 210 this.setMaximumSize(this.getPreferredSize()); 211 this.repaint(); 212 } 213 } | Popular Tags |