KickJava   Java API By Example, From Geeks To Geeks.

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


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  * HeaderDisplay.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.*; // widgets
33
import javax.swing.table.*; // widgets
34
import java.awt.Component JavaDoc;
35 import java.awt.FlowLayout JavaDoc;
36 import java.awt.Dimension JavaDoc;
37
38 import java.awt.Component JavaDoc;
39 import java.awt.Container JavaDoc;
40 import java.awt.GridBagLayout JavaDoc;
41 import java.awt.GridBagConstraints JavaDoc;
42 import java.awt.Insets JavaDoc;
43
44 import org.netbeans.modules.web.monitor.data.*;
45 import org.openide.util.NbBundle;
46 import java.util.*;
47
48
49 public class HeaderDisplay extends DataDisplay {
50     
51     private final static boolean debug = false;
52
53     private DisplayTable dt = null;
54         
55     public HeaderDisplay() {
56
57     super();
58     }
59
60
61     // We're treating these as if they are all strings at the
62
// moment. In reality they can be of different types, though maybe
63
// that does not matter...
64
public void setData(DataRecord md) {
65
66     if(debug) System.out.println("in HeaderDisplay.setData()"); //NOI18N
67

68     this.removeAll();
69     if (md == null)
70         return;
71     
72     this.setLayout(new GridBagLayout JavaDoc());
73
74     int gridy = -1;
75     double tableWeightX = 1.0;
76     double tableWeightY = 0;
77     int fullGridWidth = java.awt.GridBagConstraints.REMAINDER;
78
79     // add the headers
80
RequestData rd = md.getRequestData();
81     Param[] params = rd.getHeaders().getParam();
82     String JavaDoc msg;
83     Component JavaDoc hLabel;
84     DisplayTable headerTable = null;
85
86     if(params == null || params.length == 0) {
87         msg = NbBundle.getBundle(HeaderDisplay.class).getString("MON_No_headers");
88         hLabel = createDataLabel(msg);
89     } else {
90         msg = NbBundle.getBundle(HeaderDisplay.class).getString("MON_HTTP_Headers");
91         headerTable = new DisplayTable(params, true);
92             headerTable.getAccessibleContext().setAccessibleName(NbBundle.getBundle(HeaderDisplay.class).getString("ACS_MON_HTTP_HeadersTableA11yName"));
93             headerTable.setToolTipText(NbBundle.getBundle(HeaderDisplay.class).getString("ACS_MON_HTTP_HeadersTableA11yDesc"));
94         hLabel = createSortButtonLabel(msg, headerTable, NbBundle.getBundle(HeaderDisplay.class).getString("MON_HTTP_Headers_Mnemonic").charAt(0), NbBundle.getBundle(HeaderDisplay.class).getString("ACS_MON_HTTP_HeadersA11yDesc"));
95     }
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     addGridBagComponent(this, hLabel, 0, ++gridy,
105                 1, 1, 0, 0,
106                 java.awt.GridBagConstraints.WEST,
107                 java.awt.GridBagConstraints.NONE,
108                 labelInsets,
109                 0, 0);
110
111
112     if(params != null && params.length > 0) {
113         addGridBagComponent(this, headerTable, 0, ++gridy,
114                 fullGridWidth, 1, tableWeightX, tableWeightY,
115                 java.awt.GridBagConstraints.WEST,
116                 java.awt.GridBagConstraints.HORIZONTAL,
117                 tableInsets,
118                 0, 0);
119     }
120
121     addGridBagComponent(this, Box.createGlue(), 0, ++gridy,
122                 1, 1, 1.0, 1.0,
123                 java.awt.GridBagConstraints.WEST,
124                 java.awt.GridBagConstraints.BOTH,
125                 zeroInsets,
126                 0, 0);
127
128     this.setMaximumSize(this.getPreferredSize());
129     this.repaint();
130     }
131 } // HeaderDisplay
132
Popular Tags