1 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 ; 29 import javax.swing.JSplitPane ; 30 import javax.swing.JFrame ; 31 import javax.swing.JLabel ; 32 import java.util.Map ; 33 import java.awt.BorderLayout ; 34 35 36 40 public class TestPlanWindow extends JInternalFrame 41 { 42 GuiPanelBladeState guiPanelBladeState; 43 JSplitPane splitPane = null; 44 GuiMonitorPanel monitorPanel; 45 JLabel statusLine = new JLabel (" "); 46 47 48 public TestPlanWindow(JFrame frame) 49 { 50 super("Test plan definition", true, false, true, true); 51 guiPanelBladeState = new GuiPanelBladeState(frame); 52 getContentPane().setLayout(new BorderLayout ()); 53 getContentPane().add(BorderLayout.CENTER, guiPanelBladeState); 54 getContentPane().add(BorderLayout.SOUTH, statusLine); 55 } 56 57 58 public void setAvailableServers(String [] servers) 59 { 60 guiPanelBladeState.setAvailableServers(servers); 61 } 62 63 64 public Map getTestPlan() 65 { 66 return guiPanelBladeState.getTestPlan(); 67 } 68 69 70 public void setTestPlan(Map testPlan) 71 { 72 guiPanelBladeState.setTestPlan(testPlan); 73 } 74 75 76 public void setBladeState(String 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 (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 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 |