001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /**
043: * CookieDisplay.java
044: *
045: *
046: * Created: Wed Jan 31 18:04:22 2001
047: *
048: * @author Ana von Klopp
049: * @version
050: */package org.netbeans.modules.web.monitor.client;
051:
052: import java.util.ResourceBundle;
053: import javax.accessibility.AccessibleContext;
054: import javax.accessibility.AccessibleRelation;
055: import javax.swing.JLabel;
056:
057: import org.openide.util.NbBundle;
058:
059: import org.netbeans.modules.web.monitor.data.*;
060:
061: // PENDING: can be more helpful with what the cookie data means. Like
062: // I had the expires at the end of this session before, that was kind
063: // of useful. Could also show the actual date that the cookie
064: // expires.
065:
066: public class CookieDisplay extends DataDisplay {
067:
068: private final static boolean debug = false;
069:
070: public CookieDisplay() {
071: super ();
072: }
073:
074: // We're treating these as if they are all strings at the
075: // moment. In reality they can be of different types, though maybe
076: // that does not matter...
077: public void setData(DataRecord md) {
078:
079: if (debug)
080: System.out.println("in CookieDisplay.setData()"); //NOI18N
081: this .removeAll();
082: if (md == null)
083: return;
084:
085: CookiesData cd = md.getCookiesData();
086: CookieIn[] in = cd.getCookieIn();
087: CookieOut[] out = cd.getCookieOut();
088:
089: int gridy = -1;
090: String headerIn;
091: JLabel incomingLabel;
092: if (in == null || in.length == 0) {
093: headerIn = NbBundle.getBundle(CookieDisplay.class)
094: .getString("MON_No_incoming");
095: incomingLabel = createDataLabel(headerIn);
096:
097: } else {
098: headerIn = NbBundle.getBundle(CookieDisplay.class)
099: .getString("MON_Incoming_cookie");
100: incomingLabel = createHeaderLabel(headerIn, NbBundle
101: .getBundle(CookieDisplay.class).getString(
102: "MON_Incoming_cookie_Mnemonic").charAt(0),
103: NbBundle.getBundle(CookieDisplay.class).getString(
104: "ACS_MON_Incoming_cookieA11yDesc"), null);
105: }
106:
107: addGridBagComponent(this , createTopSpacer(), 0, ++gridy,
108: fullGridWidth, 1, 0, 0,
109: java.awt.GridBagConstraints.WEST,
110: java.awt.GridBagConstraints.NONE, topSpacerInsets, 0, 0);
111:
112: addGridBagComponent(this , incomingLabel, 0, ++gridy,
113: fullGridWidth, 1, 0, 0,
114: java.awt.GridBagConstraints.WEST,
115: java.awt.GridBagConstraints.HORIZONTAL, labelInsets, 0,
116: 0);
117:
118: AccessibleContext aCtx;
119: AccessibleRelation aRel;
120: DisplayTable dt;
121:
122: if (in != null && in.length > 0) {
123:
124: for (int i = 0; i < in.length; ++i) {
125: String[] data = { in[i].getAttributeValue("name"), //NOI18N
126: in[i].getAttributeValue("value") //NOI18N
127: };
128:
129: String[] categoriesIn = {
130: NbBundle.getBundle(CookieDisplay.class)
131: .getString("MON_Name"),
132: NbBundle.getBundle(CookieDisplay.class)
133: .getString("MON_Value"), };
134:
135: dt = new DisplayTable(categoriesIn, data);
136: aCtx = dt.getAccessibleContext();
137: aCtx.setAccessibleName(NbBundle.getMessage(
138: CookieDisplay.class,
139: "ACS_MON_Incoming_cookieTableA11yName"));//NOI18N
140: aCtx.setAccessibleDescription(NbBundle.getMessage(
141: CookieDisplay.class,
142: "ACS_MON_Incoming_cookieTableA11yDesc"));//NOI18N
143: dt.setToolTipText(NbBundle.getMessage(
144: CookieDisplay.class,
145: "ACS_MON_Incoming_cookieTableA11yDesc")); //NOI18N
146: aRel = new AccessibleRelation(
147: AccessibleRelation.LABELED_BY, incomingLabel);
148: aCtx.getAccessibleRelationSet().add(aRel);
149: addGridBagComponent(this , dt, 0, ++gridy,
150: fullGridWidth, 1, tableWeightX, tableWeightY,
151: java.awt.GridBagConstraints.WEST,
152: java.awt.GridBagConstraints.BOTH, tableInsets,
153: 0, 0);
154: }
155: }
156:
157: String headerOut;
158: JLabel outgoingLabel;
159: if (out == null || out.length == 0) {
160: headerOut = NbBundle.getBundle(CookieDisplay.class)
161: .getString("MON_No_outgoing");
162: outgoingLabel = createDataLabel(headerOut);
163: } else {
164: headerOut = NbBundle.getBundle(CookieDisplay.class)
165: .getString("MON_Outgoing_cookie");
166: outgoingLabel = createHeaderLabel(headerOut, NbBundle
167: .getBundle(CookieDisplay.class).getString(
168: "MON_Outgoing_cookie_Mnemonic").charAt(0),
169: NbBundle.getBundle(CookieDisplay.class).getString(
170: "ACS_MON_Outgoing_cookieA11yDesc"), null);
171: }
172: addGridBagComponent(this , outgoingLabel, 0, ++gridy,
173: fullGridWidth, 1, 0, 0,
174: java.awt.GridBagConstraints.WEST,
175: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
176:
177: if (out != null && out.length > 0) {
178:
179: for (int i = 0; i < out.length; ++i) {
180: String cookieMaxAge = out[i]
181: .getAttributeValue("maxAge"); //NOI18N
182: if (cookieMaxAge.equals("-1")) //NOI18N
183: cookieMaxAge = NbBundle.getBundle(
184: CookieDisplay.class).getString(
185: "MON_this_session");
186:
187: String[] data = {
188: out[i].getAttributeValue("name"), //NOI18N
189: out[i].getAttributeValue("value"), //NOI18N
190: out[i].getAttributeValue("domain"), //NOI18N
191: out[i].getAttributeValue("path"), //NOI18N
192: cookieMaxAge,
193: out[i].getAttributeValue("version"), //NOI18N
194: out[i].getAttributeValue("secure"), //NOI18N
195: out[i].getAttributeValue("comment") //NOI18N
196: };
197:
198: String[] categoriesOut = {
199: NbBundle.getBundle(CookieDisplay.class)
200: .getString("MON_Name"),
201: NbBundle.getBundle(CookieDisplay.class)
202: .getString("MON_Value"),
203: NbBundle.getBundle(CookieDisplay.class)
204: .getString("MON_Domain"),
205: NbBundle.getBundle(CookieDisplay.class)
206: .getString("MON_Path"),
207: NbBundle.getBundle(CookieDisplay.class)
208: .getString("MON_Max_age"),
209: NbBundle.getBundle(CookieDisplay.class)
210: .getString("MON_Version"),
211: NbBundle.getBundle(CookieDisplay.class)
212: .getString("MON_Secure"),
213: NbBundle.getBundle(CookieDisplay.class)
214: .getString("MON_Comment"), };
215:
216: dt = new DisplayTable(categoriesOut, data);
217: aCtx = dt.getAccessibleContext();
218: aCtx.setAccessibleName(NbBundle.getMessage(
219: CookieDisplay.class,
220: "ACS_MON_Outgoing_cookieTableA11yName"));//NOI18N
221: aCtx.setAccessibleDescription(NbBundle.getMessage(
222: CookieDisplay.class,
223: "ACS_MON_Outgoing_cookieTableA11yDesc"));//NOI18N
224: dt.setToolTipText(NbBundle.getMessage(
225: CookieDisplay.class,
226: "ACS_MON_Outgoing_cookieTableA11yDesc")); //NOI18N
227: aRel = new AccessibleRelation(
228: AccessibleRelation.LABELED_BY, outgoingLabel);
229: aCtx.getAccessibleRelationSet().add(aRel);
230: addGridBagComponent(this , dt, 0, ++gridy,
231: fullGridWidth, 1, tableWeightX, tableWeightY,
232: java.awt.GridBagConstraints.WEST,
233: java.awt.GridBagConstraints.BOTH, tableInsets,
234: 0, 0);
235: }
236: }
237:
238: addGridBagComponent(this , createGlue(), 0, ++gridy, 1, 1, 1.0,
239: 1.0, java.awt.GridBagConstraints.WEST,
240: java.awt.GridBagConstraints.BOTH, zeroInsets, 0, 0);
241:
242: this .setMaximumSize(this .getPreferredSize());
243: this .repaint();
244: }
245: } // CookieDisplay
|