KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.objectweb.clif.supervisor.api.BladeState;
27 import org.objectweb.clif.supervisor.api.TestControl;
28 import javax.swing.JInternalFrame JavaDoc;
29 import javax.swing.JSplitPane JavaDoc;
30 import javax.swing.JFrame JavaDoc;
31 import javax.swing.JLabel JavaDoc;
32 import java.util.Map JavaDoc;
33 import java.awt.BorderLayout JavaDoc;
34
35
36 /**
37  *
38  * @author Bruno Dillenseger
39  */

40 public class TestPlanWindow extends JInternalFrame JavaDoc
41 {
42     GuiPanelBladeState guiPanelBladeState;
43     JSplitPane JavaDoc splitPane = null;
44     GuiMonitorPanel monitorPanel;
45     JLabel JavaDoc statusLine = new JLabel JavaDoc(" ");
46
47
48     public TestPlanWindow(JFrame JavaDoc frame)
49     {
50         super("Test plan definition", true, false, true, true);
51         guiPanelBladeState = new GuiPanelBladeState(frame);
52         getContentPane().setLayout(new BorderLayout JavaDoc());
53         getContentPane().add(BorderLayout.CENTER, guiPanelBladeState);
54         getContentPane().add(BorderLayout.SOUTH, statusLine);
55     }
56
57
58     public void setAvailableServers(String JavaDoc[] servers)
59     {
60         guiPanelBladeState.setAvailableServers(servers);
61     }
62
63
64     public Map JavaDoc getTestPlan()
65     {
66         return guiPanelBladeState.getTestPlan();
67     }
68
69
70     public void setTestPlan(Map JavaDoc testPlan)
71     {
72         guiPanelBladeState.setTestPlan(testPlan);
73     }
74
75
76     public void setBladeState(String JavaDoc bladeId, BladeState state)
77     {
78         guiPanelBladeState.setBladeState(bladeId, state);
79     }
80
81
82     public synchronized void initTest(TestControl testCtl)
83     {
84         setEditable(false);
85         if (splitPane == null)
86         {
87             monitorPanel = new GuiMonitorPanel(getTestPlan(), testCtl);
88             getContentPane().remove(guiPanelBladeState);
89             getContentPane().addContainerListener(monitorPanel);
90             splitPane = new JSplitPane JavaDoc(JSplitPane.VERTICAL_SPLIT, guiPanelBladeState, monitorPanel);
91             splitPane.setDividerLocation(getContentPane().getHeight()/2);
92             splitPane.setOneTouchExpandable(true);
93             getContentPane().add(BorderLayout.CENTER, splitPane);
94             validate();
95         }
96     }
97
98
99     public synchronized void setEditable(boolean editable)
100     {
101         guiPanelBladeState.setEditable(editable);
102         if (editable && splitPane != null)
103         {
104             getContentPane().remove(splitPane);
105             getContentPane().add(BorderLayout.CENTER, guiPanelBladeState);
106             guiPanelBladeState.setEditable(true);
107             getContentPane().removeContainerListener(monitorPanel);
108             monitorPanel = null;
109             splitPane = null;
110             validate();
111         }
112     }
113
114
115     public boolean isDeployable()
116     {
117         return guiPanelBladeState.isDeployable();
118     }
119
120
121     public boolean isEmpty()
122     {
123         return guiPanelBladeState.isEmpty();
124     }
125
126
127     public void setStatusLine(BladeState status, long ellapsedTime)
128     {
129         String JavaDoc line = status.toString();
130         if (status.equals(BladeState.RUNNING)
131             || status.equals(BladeState.SUSPENDED)
132             || status.equals(BladeState.STOPPED))
133         {
134             ellapsedTime /= 1000;
135             int sec = (int)ellapsedTime % 60;
136             ellapsedTime /= 60;
137             int min = (int)ellapsedTime % 60;
138             ellapsedTime /= 60;
139             int hour = (int)ellapsedTime % 60;
140             line += " - ellapsed time " + hour + ":" + min + ":" + sec;
141         }
142         statusLine.setText(line);
143     }
144 }
145
Popular Tags