KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > console > lib > gui > GuiMonitorPanel


1 /*
2 * CLIF is a Load Injection Framework
3 * Copyright (C) 2004 France Telecom R&D
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * CLIF $Name: $
20 *
21 * Contact: clif@objectweb.org
22 */

23
24 package org.objectweb.clif.console.lib.gui;
25
26
27 import org.objectweb.clif.supervisor.api.TestControl;
28 import org.objectweb.clif.console.lib.ClifDeployDefinition;
29 import javax.swing.JTabbedPane JavaDoc;
30 import java.awt.event.ContainerListener JavaDoc;
31 import java.awt.event.ContainerEvent JavaDoc;
32 import java.util.Map JavaDoc;
33 import java.util.Iterator JavaDoc;
34 import java.util.HashMap JavaDoc;
35
36
37 /**
38  *
39  * @author Bruno Dillenseger
40  */

41 public class GuiMonitorPanel
42     extends JTabbedPane JavaDoc
43     implements ContainerListener JavaDoc
44 {
45     static private final String JavaDoc INJECTOR_LABEL = "injector";
46
47
48     public GuiMonitorPanel(Map JavaDoc testPlan, TestControl testCtl)
49     {
50         super();
51         Map JavaDoc bladeKinds = new HashMap JavaDoc();
52         Iterator JavaDoc iter = testPlan.entrySet().iterator();
53         while (iter.hasNext())
54         {
55             Map.Entry JavaDoc entry = (Map.Entry JavaDoc)iter.next();
56             ClifDeployDefinition def = (ClifDeployDefinition)entry.getValue();
57             String JavaDoc key;
58             if (def.isProbe())
59             {
60                 key = (String JavaDoc)def.getContext().get("insert");
61                 key = key.substring(0, key.lastIndexOf('.'));
62                 key = key.substring(1 + key.lastIndexOf('.'));
63             }
64             else
65             {
66                 key = INJECTOR_LABEL;
67             }
68             Map JavaDoc blades = (Map JavaDoc)bladeKinds.get(key);
69             if (blades == null)
70             {
71                 blades = new HashMap JavaDoc();
72                 bladeKinds.put(key, blades);
73             }
74             blades.put(entry.getKey(), entry.getValue());
75         }
76         iter = bladeKinds.entrySet().iterator();
77         while (iter.hasNext())
78         {
79             Map.Entry JavaDoc entry = (Map.Entry JavaDoc)iter.next();
80             String JavaDoc arbitraryBladeId = (String JavaDoc)((Map JavaDoc)entry.getValue()).keySet().iterator().next();
81             GuiMonitorCard monitorCard = new GuiMonitorCard(
82                 (Map JavaDoc)entry.getValue(),
83                 testCtl.getStatLabels(arbitraryBladeId),
84                 testCtl);
85             this.addContainerListener(monitorCard);
86             add(monitorCard, entry.getKey());
87         }
88     }
89
90
91     /////////////////////////////////
92
// interface ContainerListener //
93
/////////////////////////////////
94

95
96     public void componentAdded(ContainerEvent JavaDoc ev)
97     {
98     }
99
100
101     public void componentRemoved(ContainerEvent JavaDoc ev)
102     {
103         removeAll();
104     }
105 }
106
Popular Tags