KickJava   Java API By Example, From Geeks To Geeks.

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


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  * ContextDisplay.java
22  *
23  *
24  * Created: Wed Jan 16 14:44:11 PST 2002
25  *
26  * @author Ana von Klopp
27  * @version
28  */

29
30 package org.netbeans.modules.web.monitor.client;
31
32 import javax.swing.table.*; // widgets
33
import org.netbeans.modules.web.monitor.data.*;
34 import org.openide.util.NbBundle;
35 import java.util.*;
36
37
38 public class ContextDisplay extends DataDisplay {
39
40     private final static boolean debug = false;
41
42     DisplayTable contextTable;
43
44     public ContextDisplay() {
45     super();
46     }
47
48     // We're treating these as if they are all strings at the
49
// moment. In reality they can be of different types, though maybe
50
// that does not matter...
51
public void setData(DataRecord md) {
52
53     //boolean iplanet = false;
54
boolean servlet = true;
55     boolean failed = false;
56     
57     if(debug) System.out.println("in ContextDisplay.setData()"); //NOI18N
58
this.removeAll();
59     if (md == null)
60         return;
61     
62     ContextData cd = md.getContextData();
63     if(cd != null) displayContextData(cd);
64     else {
65         ServletData sd = md.getServletData();
66         displayServletData(sd);
67         
68     }
69     }
70     
71     private void displayContextData(ContextData cd)
72     {
73     if(debug) System.out.println(cd.dumpBeanNode());
74
75     String JavaDoc[] props = {
76         NbBundle.getBundle(ClientDisplay.class).getString("MON_Context_name"),
77         NbBundle.getBundle(ClientDisplay.class).getString("MON_Absolute_path"),
78     };
79     
80     contextTable = new DisplayTable(props);
81
82     int gridy = -1;
83
84     addGridBagComponent(this, createTopSpacer(), 0, ++gridy,
85                 fullGridWidth, 1, 0, 0,
86                 java.awt.GridBagConstraints.WEST,
87                 java.awt.GridBagConstraints.NONE,
88                 topSpacerInsets,
89                 0, 0);
90
91     // context data
92
addGridBagComponent(this,
93                 createHeaderLabel
94                 (NbBundle.getBundle(ClientDisplay.class).getString("MON_Servlet_context"), NbBundle.getBundle(ClientDisplay.class).getString("MON_Servlet_context_Mnemonic").charAt(0), NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Servlet_contextA11yDesc"), contextTable),
95                 0, ++gridy,
96                 fullGridWidth, 1, 0, 0,
97                 java.awt.GridBagConstraints.WEST,
98                 java.awt.GridBagConstraints.NONE,
99                 labelInsets,
100                 0, 0);
101
102     
103     contextTable.setValueAt(cd.getAttributeValue("contextName"), 0, 1); //NOI18N
104
contextTable.setValueAt(cd.getAttributeValue("absPath"), 1, 1); //NOI18N
105
contextTable.getAccessibleContext().setAccessibleName(NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Servlet_contextTableA11yName"));
106         contextTable.setToolTipText(NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Servlet_contextTableA11yDesc"));
107     addGridBagComponent(this, contextTable, 0, ++gridy,
108                 fullGridWidth, 1, tableWeightX, tableWeightY,
109                 java.awt.GridBagConstraints.WEST,
110                 java.awt.GridBagConstraints.BOTH,
111                 tableInsets,
112                 0, 0);
113     
114     
115     Param[] ctxtparam = null;
116     try {
117         ctxtparam = cd.getContextAttributes().getParam();
118     }
119     catch(Exception JavaDoc ex) {
120     }
121
122     if(ctxtparam != null && ctxtparam.length > 0) {
123
124         DisplayTable dt = new DisplayTable(ctxtparam);
125         addGridBagComponent(this,
126                 createHeaderLabel
127                 (NbBundle.getBundle(ClientDisplay.class).getString("MON_Context_att"),
128                  NbBundle.getBundle(ClientDisplay.class).getString("MON_Context_att_Mnemonic").charAt(0),
129                  NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Context_att_A11yDesc"),
130                  dt),
131                 0, ++gridy,
132                 fullGridWidth, 1, 0, 0,
133                 java.awt.GridBagConstraints.WEST,
134                 java.awt.GridBagConstraints.NONE,
135                 labelInsets,
136                 0, 0);
137         dt.getAccessibleContext().setAccessibleName(NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Context_att_TableA11yName"));
138         dt.setToolTipText(NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Context_att_TableA11yDesc"));
139         addGridBagComponent(this, dt, 0, ++gridy,
140                 fullGridWidth, 1, tableWeightX, tableWeightY,
141                 java.awt.GridBagConstraints.WEST,
142                 java.awt.GridBagConstraints.BOTH,
143                 tableInsets,
144                 0, 0);
145     }
146
147     // Init parameters
148
Param[] param = cd.getParam();
149     if(param == null || param.length == 0)
150         addGridBagComponent(this,
151                 createDataLabel
152                 (NbBundle.getBundle(ClientDisplay.class).getString("MON_No_init")),
153                 0,
154                 ++gridy,
155                 fullGridWidth,
156                 1, 0, 0,
157                 java.awt.GridBagConstraints.WEST,
158                 java.awt.GridBagConstraints.NONE,
159                 labelInsets,
160                 0, 0);
161     else {
162
163         DisplayTable paramTable = new DisplayTable(param);
164         paramTable.getAccessibleContext().setAccessibleName(NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Init_parametersTableA11yName"));
165         paramTable.setToolTipText(NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Init_parametersTableA11yDesc"));
166         addGridBagComponent(this,
167                 createHeaderLabel
168                 (NbBundle.getBundle(ClientDisplay.class).getString("MON_Init_parameters"),
169                  NbBundle.getBundle(ClientDisplay.class).getString("MON_Init_parameters_Mnemonic").charAt(0),
170                  NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Init_parametersA11yDesc"),
171                  paramTable),
172                 0, ++gridy,
173                 fullGridWidth, 1, 0, 0,
174                 java.awt.GridBagConstraints.WEST,
175                 java.awt.GridBagConstraints.NONE,
176                 labelInsets,
177                 0, 0);
178         addGridBagComponent(this, paramTable, 0, ++gridy,
179                 fullGridWidth, 1, tableWeightX,
180                 tableWeightY,
181                 java.awt.GridBagConstraints.WEST,
182                 java.awt.GridBagConstraints.BOTH,
183                 tableInsets,
184                 0, 0);
185     }
186
187     addGridBagComponent(this, createGlue(), 0, ++gridy,
188                 1, 1, 1.0, 1.0,
189                 java.awt.GridBagConstraints.WEST,
190                 java.awt.GridBagConstraints.BOTH,
191                 zeroInsets,
192                 0, 0);
193     }
194
195     // This method is for backwards compatibility only, it will
196
// display context data recorded with FFJ 3.0
197
private void displayServletData(ServletData sd)
198     {
199     if(debug) System.out.println(sd.dumpBeanNode());
200
201     String JavaDoc[] props = {
202         NbBundle.getBundle(ClientDisplay.class).getString("MON_Context_name"),
203         NbBundle.getBundle(ClientDisplay.class).getString("MON_Absolute_path"),
204     };
205
206     contextTable = new DisplayTable(props);
207     
208     int gridy = -1;
209
210     addGridBagComponent(this, createTopSpacer(), 0, ++gridy,
211                 fullGridWidth, 1, 0, 0,
212                 java.awt.GridBagConstraints.WEST,
213                 java.awt.GridBagConstraints.NONE,
214                 topSpacerInsets,
215                 0, 0);
216
217     // context data
218
addGridBagComponent(this,
219                 createHeaderLabel
220                 (NbBundle.getBundle(ClientDisplay.class).getString("MON_Servlet_context"), NbBundle.getBundle(ClientDisplay.class).getString("MON_Servlet_context_Mnemonic").charAt(0), NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Servlet_contextA11yDesc"), contextTable),
221                 0, ++gridy,
222                 fullGridWidth, 1, 0, 0,
223                 java.awt.GridBagConstraints.WEST,
224                 java.awt.GridBagConstraints.NONE,
225                 labelInsets,
226                 0, 0);
227
228     
229     contextTable.setValueAt(sd.getAttributeValue("contextName"), 0, 1); //NOI18N
230
contextTable.setValueAt(sd.getAttributeValue("absPath"), 1, 1); //NOI18N
231
contextTable.getAccessibleContext().setAccessibleName(NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Servlet_contextTableA11yName"));
232         contextTable.setToolTipText(NbBundle.getBundle(ClientDisplay.class).getString("ACS_MON_Servlet_contextTableA11yDesc"));
233     addGridBagComponent(this, contextTable, 0, ++gridy,
234                 fullGridWidth, 1, tableWeightX, tableWeightY,
235                 java.awt.GridBagConstraints.WEST,
236                 java.awt.GridBagConstraints.BOTH,
237                 tableInsets,
238                 0, 0);
239     
240     addGridBagComponent(this, createGlue(), 0, ++gridy,
241                 1, 1, 1.0, 1.0,
242                 java.awt.GridBagConstraints.WEST,
243                 java.awt.GridBagConstraints.BOTH,
244                 zeroInsets,
245                 0, 0);
246     }
247 } // ContextDisplay
248
Popular Tags