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: * SessionDisplay.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.JLabel;
053: import javax.swing.table.*; // widgets
054: import org.netbeans.modules.web.monitor.data.*;
055: import org.openide.util.NbBundle;
056: import java.util.*;
057:
058: public class SessionDisplay extends DataDisplay {
059:
060: private final static boolean debug = false;
061:
062: public SessionDisplay() {
063: super ();
064: }
065:
066: // We're treating these as if they are all strings at the
067: // moment. In reality they can be of different types, though maybe
068: // that does not matter...
069: public void setData(DataRecord md) {
070:
071: if (debug)
072: System.out.println("in SessionDisplay.setData()"); //NOI18N
073: this .removeAll();
074: if (md == null)
075: return;
076:
077: SessionData sd = md.getSessionData();
078: int gridy = -1;
079:
080: if (sd == null
081: || ("false".equals(sd.getAttributeValue("before")) && //NOI18N
082: "false".equals(sd.getAttributeValue("after")))) { //NOI18N
083:
084: addGridBagComponent(this , createTopSpacer(), 0, ++gridy,
085: fullGridWidth, 1, 0, 0,
086: java.awt.GridBagConstraints.WEST,
087: java.awt.GridBagConstraints.NONE, topSpacerInsets,
088: 0, 0);
089:
090: addGridBagComponent(this , createDataLabel(NbBundle
091: .getBundle(SessionDisplay.class).getString(
092: "MON_No_session")), 0, ++gridy,
093: fullGridWidth, 1, 0, 0,
094: java.awt.GridBagConstraints.WEST,
095: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
096:
097: addGridBagComponent(this , createGlue(), 0, ++gridy, 1, 1,
098: 1.0, 1.0, java.awt.GridBagConstraints.WEST,
099: java.awt.GridBagConstraints.BOTH, zeroInsets, 0, 0);
100: return;
101: }
102:
103: String headerIn;
104: String lastAccessed = null;
105: String maxInactiveBefore = null;
106: String maxInactiveAfter = null;
107:
108: addGridBagComponent(this , createTopSpacer(), 0, ++gridy,
109: fullGridWidth, 1, 0, 0,
110: java.awt.GridBagConstraints.WEST,
111: java.awt.GridBagConstraints.NONE, topSpacerInsets, 0, 0);
112:
113: // We need to refer to this label below, don't use the other
114: // createHeader method.
115: JLabel sessionHeaderLabel = createHeaderLabel(NbBundle
116: .getBundle(SessionDisplay.class).getString(
117: "MON_Session_24"));
118: sessionHeaderLabel
119: .getAccessibleContext()
120: .setAccessibleDescription(
121: NbBundle
122: .getBundle(SessionDisplay.class)
123: .getString("ACS_MON_Session_24A11yDesc"));
124:
125: addGridBagComponent(this , sessionHeaderLabel, 0, ++gridy,
126: fullGridWidth, 1, 0, 0,
127: java.awt.GridBagConstraints.WEST,
128: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
129:
130: String msg;
131: if ("true".equals(sd.getAttributeValue("before"))) { //NOI18N
132: msg = NbBundle.getBundle(SessionDisplay.class).getString(
133: "MON_Session_existed");
134: lastAccessed = sd.getSessionIn().getAttributeValue(
135: "lastAccessed"); //NOI18N
136: maxInactiveBefore = sd.getSessionIn().getAttributeValue(
137: "inactiveInterval"); //NOI18N
138: } else {
139: msg = NbBundle.getBundle(SessionDisplay.class).getString(
140: "MON_Session_created");
141: lastAccessed = sd.getSessionOut().getAttributeValue(
142: "lastAccessed"); //NOI18N
143: }
144:
145: JLabel sessionDataLabel = createHeaderLabel(msg);
146: sessionDataLabel.getAccessibleContext()
147: .setAccessibleDescription(msg);
148: sessionHeaderLabel.setLabelFor(sessionDataLabel);
149: addGridBagComponent(this , sessionDataLabel, 0, ++gridy,
150: fullGridWidth, 1, 0, 0,
151: java.awt.GridBagConstraints.WEST,
152: java.awt.GridBagConstraints.NONE, indentInsets, 0, 0);
153:
154: if ("false".equals(sd.getAttributeValue("after"))) { //NOI18N
155: msg = NbBundle.getBundle(SessionDisplay.class).getString(
156: "MON_Session_invalidated");
157: addGridBagComponent(this , createDataLabel(msg), 0, ++gridy,
158: fullGridWidth, 1, 0, 0,
159: java.awt.GridBagConstraints.WEST,
160: java.awt.GridBagConstraints.NONE, indentInsets, 0,
161: 0);
162: } else {
163: maxInactiveAfter = sd.getSessionOut().getAttributeValue(
164: "inactiveInterval"); //NOI18N
165: }
166:
167: boolean inactiveChanged = false;
168:
169: if (maxInactiveBefore == null || maxInactiveBefore.equals("")) { //NOI18N
170: if (maxInactiveAfter != null)
171: maxInactiveBefore = maxInactiveAfter;
172: // Should not happen
173: else
174: maxInactiveBefore = ""; //NOI18N
175: } else if (maxInactiveAfter != null
176: && !maxInactiveBefore.equals(maxInactiveAfter))
177: inactiveChanged = true;
178:
179: // Add session properties header
180: JLabel sessionPropertiesLabel = createHeaderLabel(NbBundle
181: .getBundle(SessionDisplay.class).getString(
182: "MON_Session_properties"));
183: sessionPropertiesLabel.setDisplayedMnemonic(NbBundle.getBundle(
184: SessionDisplay.class).getString(
185: "MON_Session_properties_Mnemonic").charAt(0));
186: sessionPropertiesLabel
187: .getAccessibleContext()
188: .setAccessibleDescription(
189: NbBundle
190: .getBundle(SessionDisplay.class)
191: .getString(
192: "ACS_MON_Session_propertiesA11yDesc"));
193: addGridBagComponent(this , sessionPropertiesLabel, 0, ++gridy,
194: fullGridWidth, 1, 0, 0,
195: java.awt.GridBagConstraints.WEST,
196: java.awt.GridBagConstraints.NONE, labelInsets, 0, 0);
197:
198: DisplayTable dt = null;
199:
200: if (!inactiveChanged) {
201: String data[] = { sd.getAttributeValue("id"), //NOI18N
202: sd.getAttributeValue("created"), //NOI18N
203: lastAccessed, maxInactiveBefore, };
204:
205: String[] props = {
206: NbBundle.getBundle(SessionDisplay.class).getString(
207: "MON_Session_ID"),
208: NbBundle.getBundle(SessionDisplay.class).getString(
209: "MON_Created"),
210: NbBundle.getBundle(SessionDisplay.class).getString(
211: "MON_Last_accessed"),
212: NbBundle.getBundle(SessionDisplay.class).getString(
213: "MON_Max_inactive"), };
214:
215: dt = new DisplayTable(props, data);
216: } else {
217: String data[] = { sd.getAttributeValue("id"), //NOI18N
218: sd.getAttributeValue("created"), //NOI18N
219: lastAccessed, maxInactiveBefore, maxInactiveAfter, };
220:
221: String[] props2 = {
222: NbBundle.getBundle(SessionDisplay.class).getString(
223: "MON_Session_ID"),
224: NbBundle.getBundle(SessionDisplay.class).getString(
225: "MON_Created"),
226: NbBundle.getBundle(SessionDisplay.class).getString(
227: "MON_Last_accessed"),
228: NbBundle.getBundle(SessionDisplay.class).getString(
229: "MON_Max_inactive_before"),
230: NbBundle.getBundle(SessionDisplay.class).getString(
231: "MON_Max_inactive_after"), };
232: dt = new DisplayTable(props2, data);
233: }
234:
235: sessionPropertiesLabel.setLabelFor(dt);
236: dt.getAccessibleContext().setAccessibleName(
237: NbBundle.getBundle(SessionDisplay.class).getString(
238: "ACS_MON_Session_propertiesTableA11yName"));
239: dt.setToolTipText(NbBundle.getBundle(SessionDisplay.class)
240: .getString("ACS_MON_Session_propertiesTableA11yDesc"));
241: addGridBagComponent(this , dt, 0, ++gridy, fullGridWidth, 1,
242: tableWeightX, tableWeightY,
243: java.awt.GridBagConstraints.WEST,
244: java.awt.GridBagConstraints.BOTH, tableInsets, 0, 0);
245:
246: // Attributes before and after
247: if ("true".equals(sd.getAttributeValue("before"))) { //NOI18N
248: Param[] param = null;
249: try {
250: param = sd.getSessionIn().getParam();
251: } catch (Exception ex) {
252: }
253:
254: if (param == null || param.length == 0) {
255: addGridBagComponent(this , createDataLabel(NbBundle
256: .getBundle(SessionDisplay.class).getString(
257: "MON_Session_no_att_before")), 0,
258: ++gridy, fullGridWidth, 1, 0, 0,
259: java.awt.GridBagConstraints.WEST,
260: java.awt.GridBagConstraints.NONE, tableInsets,
261: 0, 0);
262: } else {
263: JLabel sessionBeforeLabel = createHeaderLabel(NbBundle
264: .getBundle(SessionDisplay.class).getString(
265: "MON_Session_att_before"));
266: sessionBeforeLabel.setDisplayedMnemonic(NbBundle
267: .getBundle(SessionDisplay.class).getString(
268: "MON_Session_att_before_Mnemonic")
269: .charAt(0));
270: sessionBeforeLabel
271: .getAccessibleContext()
272: .setAccessibleDescription(
273: NbBundle
274: .getBundle(SessionDisplay.class)
275: .getString(
276: "ACS_MON_Session_att_beforeA11yDesc"));
277: addGridBagComponent(this , sessionBeforeLabel, 0,
278: ++gridy, fullGridWidth, 1, 0, 0,
279: java.awt.GridBagConstraints.WEST,
280: java.awt.GridBagConstraints.NONE, labelInsets,
281: 0, 0);
282: dt = new DisplayTable(param);
283: sessionBeforeLabel.setLabelFor(dt);
284: dt
285: .getAccessibleContext()
286: .setAccessibleName(
287: NbBundle
288: .getBundle(SessionDisplay.class)
289: .getString(
290: "ACS_MON_Session_att_beforeTableA11yName"));
291: dt.setToolTipText(NbBundle.getBundle(
292: SessionDisplay.class).getString(
293: "ACS_MON_Session_att_beforeTableA11yDesc"));
294: addGridBagComponent(this , dt, 0, ++gridy,
295: fullGridWidth, 1, tableWeightX, tableWeightY,
296: java.awt.GridBagConstraints.WEST,
297: java.awt.GridBagConstraints.BOTH, tableInsets,
298: 0, 0);
299: }
300: }
301:
302: if ("true".equals(sd.getAttributeValue("after"))) { //NOI18N
303: Param[] param = null;
304: try {
305: param = sd.getSessionOut().getParam();
306: } catch (Exception ex) {
307: }
308:
309: if (param == null || param.length == 0) {
310: addGridBagComponent(this , createDataLabel(NbBundle
311: .getBundle(SessionDisplay.class).getString(
312: "MON_Session_no_att_after")), 0,
313: ++gridy, fullGridWidth, 1, 0, 0,
314: java.awt.GridBagConstraints.WEST,
315: java.awt.GridBagConstraints.NONE, tableInsets,
316: 0, 0);
317: } else {
318: JLabel sessionAfterLabel = createHeaderLabel(NbBundle
319: .getBundle(SessionDisplay.class).getString(
320: "MON_Session_att_after"));
321: sessionAfterLabel.setDisplayedMnemonic(NbBundle
322: .getBundle(SessionDisplay.class).getString(
323: "MON_Session_att_after_Mnemonic")
324: .charAt(0));
325: sessionAfterLabel
326: .getAccessibleContext()
327: .setAccessibleDescription(
328: NbBundle
329: .getBundle(SessionDisplay.class)
330: .getString(
331: "ACS_MON_Session_att_afterA11yDesc"));
332: addGridBagComponent(this , sessionAfterLabel, 0,
333: ++gridy, fullGridWidth, 1, 0, 0,
334: java.awt.GridBagConstraints.WEST,
335: java.awt.GridBagConstraints.NONE, labelInsets,
336: 0, 0);
337: dt = new DisplayTable(param);
338: sessionAfterLabel.setLabelFor(dt);
339: dt
340: .getAccessibleContext()
341: .setAccessibleName(
342: NbBundle
343: .getBundle(SessionDisplay.class)
344: .getString(
345: "ACS_MON_Session_att_afterTableA11yName"));
346: dt.setToolTipText(NbBundle.getBundle(
347: SessionDisplay.class).getString(
348: "ACS_MON_Session_att_afterTableA11yDesc"));
349: addGridBagComponent(this , dt, 0, ++gridy,
350: fullGridWidth, 1, tableWeightX, tableWeightY,
351: java.awt.GridBagConstraints.WEST,
352: java.awt.GridBagConstraints.BOTH, tableInsets,
353: 0, 0);
354: }
355: this .add(createRigidArea());
356: }
357:
358: addGridBagComponent(this , createGlue(), 0, ++gridy, 1, 1, 1.0,
359: 1.0, java.awt.GridBagConstraints.WEST,
360: java.awt.GridBagConstraints.BOTH, zeroInsets, 0, 0);
361:
362: this .setMaximumSize(this .getPreferredSize());
363: this .repaint();
364: }
365: } // SessionDisplay
|