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: * HeaderDisplay.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 javax.swing.*; // widgets
053: import javax.swing.table.*; // widgets
054: import java.awt.Component;
055: import java.awt.FlowLayout;
056: import java.awt.Dimension;
057:
058: import java.awt.Component;
059: import java.awt.Container;
060: import java.awt.GridBagLayout;
061: import java.awt.GridBagConstraints;
062: import java.awt.Insets;
063:
064: import org.netbeans.modules.web.monitor.data.*;
065: import org.openide.util.NbBundle;
066: import java.util.*;
067:
068: public class HeaderDisplay extends DataDisplay {
069:
070: private final static boolean debug = false;
071:
072: private DisplayTable dt = null;
073:
074: public HeaderDisplay() {
075:
076: super ();
077: }
078:
079: // We're treating these as if they are all strings at the
080: // moment. In reality they can be of different types, though maybe
081: // that does not matter...
082: public void setData(DataRecord md) {
083:
084: if (debug)
085: System.out.println("in HeaderDisplay.setData()"); //NOI18N
086:
087: this .removeAll();
088: if (md == null)
089: return;
090:
091: this .setLayout(new GridBagLayout());
092:
093: int gridy = -1;
094: double tableWeightX = 1.0;
095: double tableWeightY = 0;
096: int fullGridWidth = java.awt.GridBagConstraints.REMAINDER;
097:
098: // add the headers
099: RequestData rd = md.getRequestData();
100: Param[] params = rd.getHeaders().getParam();
101: String msg;
102: Component hLabel;
103: DisplayTable headerTable = null;
104:
105: if (params == null || params.length == 0) {
106: msg = NbBundle.getBundle(HeaderDisplay.class).getString(
107: "MON_No_headers");
108: hLabel = createDataLabel(msg);
109: } else {
110: msg = NbBundle.getBundle(HeaderDisplay.class).getString(
111: "MON_HTTP_Headers");
112: headerTable = new DisplayTable(params, true);
113: headerTable.getAccessibleContext().setAccessibleName(
114: NbBundle.getBundle(HeaderDisplay.class).getString(
115: "ACS_MON_HTTP_HeadersTableA11yName"));
116: headerTable.setToolTipText(NbBundle.getBundle(
117: HeaderDisplay.class).getString(
118: "ACS_MON_HTTP_HeadersTableA11yDesc"));
119: hLabel = createSortButtonLabel(msg, headerTable, NbBundle
120: .getBundle(HeaderDisplay.class).getString(
121: "MON_HTTP_Headers_Mnemonic").charAt(0),
122: NbBundle.getBundle(HeaderDisplay.class).getString(
123: "ACS_MON_HTTP_HeadersA11yDesc"));
124: }
125:
126: addGridBagComponent(this , createTopSpacer(), 0, ++gridy,
127: fullGridWidth, 1, 0, 0,
128: java.awt.GridBagConstraints.WEST,
129: java.awt.GridBagConstraints.NONE, topSpacerInsets, 0, 0);
130:
131: addGridBagComponent(this , hLabel, 0, ++gridy, 1, 1, 0, 0,
132: java.awt.GridBagConstraints.WEST,
133: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
134:
135: if (params != null && params.length > 0) {
136: addGridBagComponent(this , headerTable, 0, ++gridy,
137: fullGridWidth, 1, tableWeightX, tableWeightY,
138: java.awt.GridBagConstraints.WEST,
139: java.awt.GridBagConstraints.HORIZONTAL,
140: tableInsets, 0, 0);
141: }
142:
143: addGridBagComponent(this , Box.createGlue(), 0, ++gridy, 1, 1,
144: 1.0, 1.0, java.awt.GridBagConstraints.WEST,
145: java.awt.GridBagConstraints.BOTH, zeroInsets, 0, 0);
146:
147: this .setMaximumSize(this .getPreferredSize());
148: this .repaint();
149: }
150: } // HeaderDisplay
|