admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * To change this template, choose Tools | Templates |
| 3 | * and open the template in the editor. |
| 4 | */ |
| 5 | package tai_ofa; |
| 6 | |
| 7 | import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringStack; |
| 8 | import java.awt.Color; |
| 9 | import java.awt.TextArea; |
| 10 | import java.io.IOException; |
| 11 | import java.net.MalformedURLException; |
| 12 | import java.util.ArrayList; |
| 13 | import java.util.HashMap; |
| 14 | import java.util.Vector; |
| 15 | import java.util.logging.Level; |
| 16 | import java.util.logging.Logger; |
| 17 | import javafx.application.Application; |
| 18 | import javafx.beans.value.ChangeListener; |
| 19 | import javafx.beans.value.ObservableValue; |
| 20 | import javafx.collections.FXCollections; |
| 21 | import javafx.collections.ObservableList; |
| 22 | import javafx.event.ActionEvent; |
| 23 | import javafx.event.EventHandler; |
| 24 | import javafx.geometry.Insets; |
| 25 | import javafx.geometry.Orientation; |
| 26 | import javafx.scene.Group; |
| 27 | import javafx.scene.Scene; |
| 28 | import javafx.scene.chart.PieChart; |
| 29 | import javafx.scene.control.Button; |
| 30 | import javafx.scene.control.CheckBox; |
| 31 | import javafx.scene.control.ComboBox; |
| 32 | import javafx.scene.control.ComboBoxBuilder; |
| 33 | import javafx.scene.control.Label; |
| 34 | import javafx.scene.control.Separator; |
| 35 | import javafx.scene.control.SplitPane; |
| 36 | import javafx.scene.control.Tab; |
| 37 | import javafx.scene.control.TabPane; |
| 38 | import javafx.scene.control.TableColumn; |
| 39 | import javafx.scene.control.TableView; |
| 40 | import javafx.scene.control.TextAreaBuilder; |
| 41 | import javafx.scene.control.TextField; |
| 42 | import javafx.scene.control.TextFieldBuilder; |
| 43 | import javafx.scene.control.ToolBar; |
| 44 | import javafx.scene.control.Tooltip; |
| 45 | import javafx.scene.control.cell.PropertyValueFactory; |
| 46 | import javafx.scene.image.Image; |
| 47 | import javafx.scene.image.ImageView; |
| 48 | import javafx.scene.layout.FlowPane; |
| 49 | import javafx.scene.layout.GridPane; |
| 50 | import javafx.scene.layout.HBox; |
| 51 | import javafx.scene.layout.Pane; |
| 52 | import javafx.scene.layout.StackPane; |
| 53 | import javafx.scene.layout.VBox; |
| 54 | import javafx.scene.text.Text; |
| 55 | import javafx.stage.Stage; |
| 56 | import javafx.stage.WindowEvent; |
| 57 | import org.apache.xmlrpc.XmlRpcClient; |
| 58 | import org.apache.xmlrpc.XmlRpcException; |
| 59 | |
| 60 | /** |
| 61 | * |
| 62 | * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com) |
| 63 | |
| 64 | * TestON is free software: you can redistribute it and/or modify |
| 65 | * it under the terms of the GNU General Public License as published by |
| 66 | * the Free Software Foundation, either version 2 of the License, or |
| 67 | * (at your option) any later version. |
| 68 | |
| 69 | * TestON is distributed in the hope that it will be useful, |
| 70 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 71 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 72 | * GNU General Public License for more details. |
| 73 | |
| 74 | * You should have received a copy of the GNU General Public License |
| 75 | * along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 76 | |
| 77 | */ |
| 78 | public class OFATestSummary extends Application { |
| 79 | |
| 80 | ObservableList<SummaryTable> data; |
| 81 | ObservableList<FinalSummaryTable> summaryData; |
| 82 | ObservableList<StepTable> stepData; |
| 83 | TableView<SummaryTable> summaryTable; |
| 84 | TableView<StepTable> stepTable; |
| 85 | PieChart.Data passData = new PieChart.Data("Pass", 0); |
| 86 | PieChart.Data failData = new PieChart.Data("Fail", 0); |
| 87 | PieChart.Data abortData = new PieChart.Data("Abort", 0); |
| 88 | PieChart.Data noResult = new PieChart.Data("No Result", 0); |
| 89 | ObservableList<PieChart.Data> pieChartData; |
| 90 | TableView<FinalSummaryTable> finalSummaryTable = new TableView<FinalSummaryTable>(); |
| 91 | TableColumn testCaseIdColumn, testCaseNameColumn; |
| 92 | TableColumn testCaseStatusColumn, testCaseStartTimeColumn, testCaseEndTimeColumn; |
| 93 | Button viewLogs = new Button("Debug & Console"); |
| 94 | GridPane buttonPane = new GridPane(); |
| 95 | TableColumn stepId, stepName, stepStatus; |
| 96 | TableColumn summaryItem, information; |
| 97 | HashMap<String, String> testCaseIdAndName = new HashMap<String, String>(); |
| 98 | String caseId, caseName; |
| 99 | Stage copyStage; |
| 100 | PieChart chart; |
| 101 | StackPane rootStack; |
| 102 | TAI_OFA ofaReference; |
| 103 | Stage paramaterWindow; |
| 104 | ComboBox LogBox; |
| 105 | TabPane execWindow = new TabPane(); |
| 106 | Tab debugLog = new Tab("Debug Logs"); |
| 107 | Tab componentLog = new Tab("Test Log"); |
| 108 | Tab testSummaryTab = new Tab("Test Summary"); |
| 109 | Tab dpctlSessionTab = new Tab("FlowVisor1.session"); |
| 110 | Tab mininetSessionTab = new Tab("Mininet1.session"); |
| 111 | Tab poxSessionTab = new Tab("POX2.session"); |
| 112 | TabPane baseTabPane = new TabPane(); |
| 113 | javafx.scene.control.TextArea debugLogText = TextAreaBuilder.create().build(); |
| 114 | javafx.scene.control.TextArea compononetLogText = TextAreaBuilder.create().build(); |
| 115 | javafx.scene.control.TextArea flowVisorSessionText = TextAreaBuilder.create().build(); |
| 116 | javafx.scene.control.TextArea poxSessionText = TextAreaBuilder.create().build(); |
| 117 | javafx.scene.control.TextArea mininetSessionText = TextAreaBuilder.create().build(); |
| 118 | String variableName = ""; |
| 119 | String command = ""; |
| 120 | ToolBar quickLauchBar = new ToolBar(); |
| 121 | Double toolBarHeight; |
| 122 | Scene scene; |
| 123 | SplitPane baseSplitPane = new SplitPane(); |
| 124 | TabPane consoleTabPane; |
| 125 | |
| 126 | /** |
| 127 | * @param args the command line arguments |
| 128 | */ |
| 129 | public static void main(String[] args) { |
| 130 | launch(args); |
| 131 | } |
| 132 | |
| 133 | public OFATestSummary(TAI_OFA ofaReference, Stage paramaterWindow) { |
| 134 | this.ofaReference = ofaReference; |
| 135 | this.paramaterWindow = paramaterWindow; |
| 136 | } |
| 137 | |
| 138 | public void start(Stage primaryStage) { |
| 139 | copyStage = primaryStage; |
| 140 | primaryStage.setTitle("Test Execution Status"); |
| 141 | primaryStage.setResizable(false); |
| 142 | Group rootGroup = new Group(); |
| 143 | scene = new Scene(rootGroup, 1020, 920); |
| 144 | Pane basePanel = new Pane(); |
| 145 | HBox baseBox = new HBox(); |
| 146 | VBox consoleBox = new VBox(); |
| 147 | VBox buttonBox = new VBox(); |
| 148 | |
| 149 | getDebugTab(); |
| 150 | getToolBar(); |
| 151 | buttonBox.getChildren().addAll(buttonPane); |
| 152 | consoleBox.getChildren().addAll(quickLauchBar, baseTabPane); |
| 153 | baseBox.getChildren().addAll(consoleBox); |
| 154 | basePanel.getChildren().addAll(baseBox); |
| 155 | SplitPane sp = getTestSummary(); |
| 156 | testSummaryTab.setContent(sp); |
| 157 | testSummaryTab.setClosable(false); |
| 158 | baseTabPane.getTabs().addAll(testSummaryTab); |
| 159 | javafx.scene.control.SingleSelectionModel<Tab> selectionModel = baseTabPane.getSelectionModel(); |
| 160 | selectionModel.select(testSummaryTab); |
| 161 | baseTabPane.prefWidthProperty().bind(scene.widthProperty().subtract(200)); |
| 162 | baseTabPane.prefHeightProperty().bind(scene.heightProperty().subtract(10)); |
| 163 | primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { |
| 164 | @Override |
| 165 | public void handle(WindowEvent t) { |
| 166 | XmlRpcClient server; |
| 167 | try { |
| 168 | server = new XmlRpcClient("http://localhost:9000"); |
| 169 | Vector params = new Vector(); |
| 170 | params.add(new String("main")); |
| 171 | try { |
| 172 | server.execute("stop", new Vector()); |
| 173 | } catch (XmlRpcException ex) { |
| 174 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 175 | } catch (IOException ex) { |
| 176 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 177 | } |
| 178 | } catch (MalformedURLException ex) { |
| 179 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 180 | } |
| 181 | } |
| 182 | }); |
| 183 | |
| 184 | basePanel.prefHeightProperty().bind(scene.heightProperty()); |
| 185 | quickLauchBar.prefWidthProperty().bind(scene.widthProperty()); |
| 186 | quickLauchBar.setMinHeight(scene.heightProperty().get() / 20); |
| 187 | toolBarHeight = quickLauchBar.getMinHeight(); |
| 188 | baseTabPane.prefHeightProperty().bind(scene.heightProperty()); |
| 189 | baseBox.prefHeightProperty().bind(scene.heightProperty()); |
| 190 | consoleBox.prefHeightProperty().bind(scene.heightProperty()); |
| 191 | rootGroup.getChildren().addAll(basePanel); |
| 192 | primaryStage.setScene(scene); |
| 193 | primaryStage.show(); |
| 194 | |
| 195 | } |
| 196 | |
| 197 | public TableView getTable() { |
| 198 | return summaryTable; |
| 199 | } |
| 200 | |
| 201 | public SplitPane getTestSummary() { |
| 202 | GridPane testCaseSummaryTable = new GridPane(); |
| 203 | testCaseSummaryTable.setPadding(new Insets(10, 0, 0, 10)); |
| 204 | GridPane finalSummaryPane = new GridPane(); |
| 205 | finalSummaryPane.setPadding(new Insets(300, 0, 0, 20)); |
| 206 | GridPane stepSummaryPane = new GridPane(); |
| 207 | stepSummaryPane.setPadding(new Insets(300, 0, 0, 20)); |
| 208 | |
| 209 | CheckBox selectTestCase = new CheckBox(); |
| 210 | summaryTable = new TableView<SummaryTable>(); |
| 211 | stepTable = new TableView<StepTable>(); |
| 212 | summaryTable.setMinWidth(580); |
| 213 | summaryTable.setMaxHeight(250); |
| 214 | testCaseIdColumn = new TableColumn(ofaReference.label.testSummaryTestCaseId); |
| 215 | testCaseIdColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseId")); |
| 216 | testCaseIdColumn.setMaxWidth(30); |
| 217 | testCaseIdColumn.setResizable(true); |
| 218 | |
| 219 | testCaseNameColumn = new TableColumn(ofaReference.label.testSummaryTestCaseName); |
| 220 | testCaseNameColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseName")); |
| 221 | testCaseNameColumn.setMinWidth(303); |
| 222 | testCaseNameColumn.setResizable(true); |
| 223 | |
| 224 | testCaseStatusColumn = new TableColumn(ofaReference.label.testSummaryExecutionStatus); |
| 225 | testCaseStatusColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseStatus")); |
| 226 | testCaseStatusColumn.setMinWidth(85); |
| 227 | testCaseStatusColumn.setResizable(true); |
| 228 | |
| 229 | testCaseStartTimeColumn = new TableColumn(ofaReference.label.testSummaryStartTest); |
| 230 | testCaseStartTimeColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseStartTime")); |
| 231 | testCaseStartTimeColumn.setMinWidth(195); |
| 232 | testCaseStartTimeColumn.setResizable(true); |
| 233 | |
| 234 | testCaseEndTimeColumn = new TableColumn(ofaReference.label.testSummaryEndTest); |
| 235 | testCaseEndTimeColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseEndTime")); |
| 236 | testCaseEndTimeColumn.setMinWidth(195); |
| 237 | testCaseEndTimeColumn.setResizable(true); |
| 238 | |
| 239 | summaryTable.setItems(data); |
| 240 | summaryTable.getColumns().addAll(testCaseIdColumn, testCaseNameColumn, testCaseStatusColumn, testCaseStartTimeColumn, testCaseEndTimeColumn); |
| 241 | |
| 242 | summaryItem = new TableColumn(ofaReference.label.summary); |
| 243 | summaryItem.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("summaryItem")); |
| 244 | summaryItem.setMinWidth(140); |
| 245 | summaryItem.setResizable(true); |
| 246 | |
| 247 | information = new TableColumn(ofaReference.label.information); |
| 248 | information.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("information")); |
| 249 | information.setMinWidth(210); |
| 250 | information.setResizable(true); |
| 251 | |
| 252 | finalSummaryTable.setMinWidth(350); |
| 253 | finalSummaryTable.setMaxHeight(300); |
| 254 | SplitPane leftPane = new SplitPane(); |
| 255 | SplitPane rightPane = new SplitPane(); |
| 256 | leftPane.setOrientation(Orientation.HORIZONTAL); |
| 257 | rightPane.setOrientation(Orientation.VERTICAL); |
| 258 | finalSummaryTable.setItems(summaryData); |
| 259 | finalSummaryTable.setVisible(false); |
| 260 | finalSummaryTable.getColumns().addAll(summaryItem, information); |
| 261 | HBox pieChart = new HBox(10); |
| 262 | pieChart.setPadding(new Insets(300, 0, 0, 300)); |
| 263 | ArrayList<PieChart.Data> dataList = new ArrayList<PieChart.Data>(); |
| 264 | |
| 265 | dataList.add(passData); |
| 266 | dataList.add(failData); |
| 267 | dataList.add(abortData); |
| 268 | dataList.add(noResult); |
| 269 | pieChartData = FXCollections.observableArrayList(dataList); |
| 270 | chart = new PieChart(pieChartData); |
| 271 | chart.setTitle(ofaReference.label.testSummaryTestSummary); |
| 272 | pieChart.getChildren().add(chart); |
| 273 | chart.setVisible(false); |
| 274 | summaryTable.setVisible(false); |
| 275 | stepTable.setVisible(true); |
| 276 | stepTable.setMinWidth(450); |
| 277 | stepTable.setMaxHeight(300); |
| 278 | |
| 279 | stepId = new TableColumn("ID"); |
| 280 | stepId.setCellValueFactory(new PropertyValueFactory<StepTable, Label>("testStepId")); |
| 281 | stepId.setMinWidth(10); |
| 282 | stepId.setResizable(true); |
| 283 | |
| 284 | stepName = new TableColumn("Name"); |
| 285 | stepName.setCellValueFactory(new PropertyValueFactory<StepTable, Label>("testStepName")); |
| 286 | stepName.setMinWidth(470); |
| 287 | stepName.setResizable(true); |
| 288 | |
| 289 | stepStatus = new TableColumn("Status"); |
| 290 | stepStatus.setCellValueFactory(new PropertyValueFactory<StepTable, Label>("testStepStatus")); |
| 291 | stepStatus.setMinWidth(40); |
| 292 | stepStatus.setResizable(true); |
| 293 | stepTable.getColumns().addAll(stepId, stepName, stepStatus); |
| 294 | stepTable.setItems(stepData); |
| 295 | stepSummaryPane.add(stepTable, 0, 2); |
| 296 | |
| 297 | finalSummaryPane.add(finalSummaryTable, 0, 2); |
| 298 | rootStack = new StackPane(); |
| 299 | testCaseSummaryTable.add(summaryTable, 0, 1); |
| 300 | rootStack.getChildren().addAll(testCaseSummaryTable, pieChart, stepSummaryPane, finalSummaryPane); |
| 301 | leftPane.getItems().addAll(rootStack); |
| 302 | consoleTabPane = new TabPane(); |
| 303 | consoleTabPane.setPrefWidth(700); |
| 304 | consoleTabPane.getTabs().addAll(componentLog, debugLog, dpctlSessionTab, mininetSessionTab, poxSessionTab); |
| 305 | |
| 306 | Image topoImage = new Image("images/topo.png", 400, 200, true, true); |
| 307 | ImageView topo = new ImageView(topoImage); |
| 308 | TabPane imageTabPane = new TabPane(); |
| 309 | Tab imageTab = new Tab("Test Topology"); |
| 310 | imageTab.setContent(topo); |
| 311 | imageTabPane.getTabs().add(imageTab); |
| 312 | imageTabPane.setMinWidth(300); |
| 313 | rightPane.getItems().addAll(imageTabPane, consoleTabPane); |
| 314 | rightPane.setDividerPosition(1, 400); |
| 315 | baseSplitPane.setDividerPosition(1, 10); |
| 316 | baseSplitPane.getItems().addAll(leftPane, rightPane); |
| 317 | return baseSplitPane; |
| 318 | } |
| 319 | |
| 320 | public void getDebugTab() { |
| 321 | poxSessionText.prefWidth(450); |
| 322 | poxSessionText.prefHeight(620); |
| 323 | poxSessionText.setStyle( |
| 324 | "-fx-text-fill: #0A0A2A;" |
| 325 | + "-fx-background-color: #EFFBFB;"); |
| 326 | poxSessionText.setEditable(false); |
| 327 | poxSessionTab.setContent(poxSessionText); |
| 328 | flowVisorSessionText.prefWidth(450); |
| 329 | flowVisorSessionText.prefHeight(620); |
| 330 | flowVisorSessionText.setStyle( |
| 331 | "-fx-text-fill: #0A0A2A;" |
| 332 | + "-fx-background-color: #EFFBFB;"); |
| 333 | flowVisorSessionText.setEditable(false); |
| 334 | dpctlSessionTab.setContent(flowVisorSessionText); |
| 335 | mininetSessionText.prefWidth(450); |
| 336 | mininetSessionText.prefHeight(620); |
| 337 | mininetSessionText.setStyle( |
| 338 | "-fx-text-fill: #0A0A2A;" |
| 339 | + "-fx-background-color: #EFFBFB;"); |
| 340 | mininetSessionText.setEditable(false); |
| 341 | mininetSessionTab.setContent(mininetSessionText); |
| 342 | debugLogText.prefWidth(450); |
| 343 | debugLogText.prefHeight(620); |
| 344 | debugLogText.setStyle( |
| 345 | "-fx-text-fill: #0A0A2A;" |
| 346 | + "-fx-background-color: #EFFBFB;"); |
| 347 | debugLogText.setEditable(false); |
| 348 | componentLog.setClosable(false); |
| 349 | compononetLogText.prefWidth(350); |
| 350 | compononetLogText.prefHeight(620); |
| 351 | compononetLogText.setStyle( |
| 352 | "-fx-text-fill: #0A0A2A;" |
| 353 | + "-fx-background-color: #EFFBFB;"); |
| 354 | compononetLogText.setEditable(false); |
| 355 | componentLog.setContent(compononetLogText); |
| 356 | debugLog.setClosable(false); |
| 357 | debugLog.setContent(debugLogText); |
| 358 | debugLog.setContent(debugLogText); |
| 359 | } |
| 360 | |
| 361 | public void getToolBar() { |
| 362 | Image pauseImage = new Image("images/Pause.png", 20.0, 20.0, true, true); |
| 363 | Button pause = new Button("", new ImageView(pauseImage)); |
| 364 | Image stopImage = new Image("images/Stop.png", 20.0, 20.0, true, true); |
| 365 | Button stop = new Button("", new ImageView(stopImage)); |
| 366 | stop.setTooltip(new Tooltip("Stop")); |
| 367 | |
| 368 | Image resumeImage = new Image("images/Resume_1.png", 20.0, 20.0, true, true); |
| 369 | Button resume = new Button("", new ImageView(resumeImage)); |
| 370 | resume.setTooltip(new Tooltip("Resume")); |
| 371 | |
| 372 | Image dumpVarImage = new Image("images/dumpvar.png", 20.0, 20.0, true, true); |
| 373 | Button dumpVar = new Button("", new ImageView(dumpVarImage)); |
| 374 | dumpVar.setTooltip(new Tooltip("Dump Var")); |
| 375 | |
| 376 | Image showlogImage = new Image("images/showlog.jpg", 20.0, 20.0, true, true); |
| 377 | Button showlog = new Button("", new ImageView(showlogImage)); |
| 378 | showlog.setTooltip(new Tooltip("Show Log")); |
| 379 | |
| 380 | Image currentCaseImage = new Image("images/currentcase.jpg", 20.0, 20.0, true, true); |
| 381 | Button currentcase = new Button("", new ImageView(currentCaseImage)); |
| 382 | currentcase.setTooltip(new Tooltip("Current Case")); |
| 383 | |
| 384 | Image currentStepImage = new Image("images/currentstep.png", 20.0, 20.0, true, true); |
| 385 | Button currentStep = new Button("", new ImageView(currentStepImage)); |
| 386 | currentStep.setTooltip(new Tooltip("Current Step")); |
| 387 | |
| 388 | Image nextStepImage = new Image("images/nextStep.jpg", 20.0, 20.0, true, true); |
| 389 | Button nextStep = new Button("", new ImageView(nextStepImage)); |
| 390 | nextStep.setTooltip(new Tooltip("Next Step")); |
| 391 | |
| 392 | Image compileImage = new Image("images/compile.jpg", 20.0, 20.0, true, true); |
| 393 | Button compile = new Button("", new ImageView(compileImage)); |
| 394 | compile.setTooltip(new Tooltip("Compile")); |
| 395 | |
| 396 | Image getTestImage = new Image("images/testname.jpg", 20.0, 20.0, true, true); |
| 397 | Button getTest = new Button("", new ImageView(getTestImage)); |
| 398 | getTest.setTooltip(new Tooltip("Get Test")); |
| 399 | |
| 400 | Image interpretImage = new Image("images/interpreter.jpg", 20.0, 20.0, true, true); |
| 401 | Button interpret = new Button("", new ImageView(interpretImage)); |
| 402 | interpret.setTooltip(new Tooltip("Interpret")); |
| 403 | |
| 404 | Image doImage = new Image("images/do.jpg", 20.0, 20.0, true, true); |
| 405 | Button doCommand = new Button("", new ImageView(doImage)); |
| 406 | doCommand.setTooltip(new Tooltip("Do")); |
| 407 | |
| 408 | Image redoImage = new Image("images/redo.png", 20.0, 20.0, true, true); |
| 409 | Button redoCommand = new Button("", new ImageView(redoImage)); |
| 410 | redoCommand.setTooltip(new Tooltip("Re-execute")); |
| 411 | |
| 412 | final Button submit = new Button("Enter"); |
| 413 | final TextField value = TextFieldBuilder.create().build(); |
| 414 | value.setMinWidth(480); |
| 415 | final ExecutionConsole execConsole = new ExecutionConsole(command, submit, value); |
| 416 | |
| 417 | redoCommand.setOnAction(new EventHandler<ActionEvent>() { |
| 418 | @Override |
| 419 | public void handle(ActionEvent t) { |
| 420 | requestServer("redo", new Vector()); |
| 421 | requestServer("resume", new Vector()); |
| 422 | } |
| 423 | }); |
| 424 | |
| 425 | getTest.setOnAction(new EventHandler<ActionEvent>() { |
| 426 | @Override |
| 427 | public void handle(ActionEvent t) { |
| 428 | requestServer("getTest", new Vector()); |
| 429 | } |
| 430 | }); |
| 431 | |
| 432 | doCommand.setOnAction(new EventHandler<ActionEvent>() { |
| 433 | @Override |
| 434 | public void handle(ActionEvent t) { |
| 435 | try { |
| 436 | command = "doCommand"; |
| 437 | execConsole.start(new Stage()); |
| 438 | execConsole.setTitles("do Command"); |
| 439 | } catch (Exception ex) { |
| 440 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 441 | } |
| 442 | } |
| 443 | }); |
| 444 | |
| 445 | interpret.setOnAction(new EventHandler<ActionEvent>() { |
| 446 | @Override |
| 447 | public void handle(ActionEvent t) { |
| 448 | try { |
| 449 | value.setEditable(true); |
| 450 | command = "interpret"; |
| 451 | execConsole.start(new Stage()); |
| 452 | execConsole.setTitles("interpret Command"); |
| 453 | } catch (Exception ex) { |
| 454 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 455 | } |
| 456 | } |
| 457 | }); |
| 458 | |
| 459 | compile.setOnAction(new EventHandler<ActionEvent>() { |
| 460 | @Override |
| 461 | public void handle(ActionEvent t) { |
| 462 | try { |
| 463 | command = "doCompile"; |
| 464 | execConsole.start(new Stage()); |
| 465 | execConsole.setTitles("compile Command"); |
| 466 | } catch (Exception ex) { |
| 467 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 468 | } |
| 469 | } |
| 470 | }); |
| 471 | |
| 472 | resume.setOnAction(new EventHandler<ActionEvent>() { |
| 473 | @Override |
| 474 | public void handle(ActionEvent t) { |
| 475 | requestServer("resume", new Vector()); |
| 476 | } |
| 477 | }); |
| 478 | |
| 479 | nextStep.setOnAction(new EventHandler<ActionEvent>() { |
| 480 | @Override |
| 481 | public void handle(ActionEvent t) { |
| 482 | requestServer("nextStep", new Vector()); |
| 483 | } |
| 484 | }); |
| 485 | |
| 486 | currentStep.setOnAction(new EventHandler<ActionEvent>() { |
| 487 | @Override |
| 488 | public void handle(ActionEvent t) { |
| 489 | requestServer("currentStep", new Vector()); |
| 490 | } |
| 491 | }); |
| 492 | |
| 493 | currentcase.setOnAction(new EventHandler<ActionEvent>() { |
| 494 | @Override |
| 495 | public void handle(ActionEvent t) { |
| 496 | requestServer("currentCase", new Vector()); |
| 497 | } |
| 498 | }); |
| 499 | |
| 500 | showlog.setOnAction(new EventHandler<ActionEvent>() { |
| 501 | @Override |
| 502 | public void handle(ActionEvent t) { |
| 503 | requestServer("showLog", new Vector()); |
| 504 | } |
| 505 | }); |
| 506 | |
| 507 | submit.setOnAction(new EventHandler<ActionEvent>() { |
| 508 | @Override |
| 509 | public void handle(ActionEvent t) { |
| 510 | variableName = value.getText(); |
| 511 | execConsole.closeWindow(); |
| 512 | Vector params = new Vector(); |
| 513 | params.add(variableName); |
| 514 | requestServer(command, params); |
| 515 | } |
| 516 | }); |
| 517 | dumpVar.setOnAction(new EventHandler<ActionEvent>() { |
| 518 | @Override |
| 519 | public void handle(ActionEvent t) { |
| 520 | try { |
| 521 | command = "dumpVar"; |
| 522 | execConsole.start(new Stage()); |
| 523 | execConsole.setTitles("dumpvar Command"); |
| 524 | } catch (Exception ex) { |
| 525 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 526 | } |
| 527 | |
| 528 | |
| 529 | } |
| 530 | }); |
| 531 | |
| 532 | pause.setOnAction(new EventHandler<ActionEvent>() { |
| 533 | @Override |
| 534 | public void handle(ActionEvent t) { |
| 535 | XmlRpcClient server; |
| 536 | try { |
| 537 | server = new XmlRpcClient("http://localhost:9000"); |
| 538 | try { |
| 539 | Object response = server.execute("pauseTest", new Vector()); |
| 540 | compononetLogText.appendText("\n Will pause the test's execution, after completion of this step.....\n\n"); |
| 541 | } catch (XmlRpcException ex) { |
| 542 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 543 | } catch (IOException ex) { |
| 544 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 545 | } |
| 546 | } catch (MalformedURLException ex) { |
| 547 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 548 | } |
| 549 | } |
| 550 | }); |
| 551 | |
| 552 | stop.setOnAction(new EventHandler<ActionEvent>() { |
| 553 | @Override |
| 554 | public void handle(ActionEvent t) { |
| 555 | XmlRpcClient server; |
| 556 | try { |
| 557 | server = new XmlRpcClient("http://localhost:9000"); |
| 558 | Vector params = new Vector(); |
| 559 | try { |
| 560 | server.execute("stop", new Vector()); |
| 561 | } catch (XmlRpcException ex) { |
| 562 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 563 | } catch (IOException ex) { |
| 564 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 565 | } |
| 566 | } catch (MalformedURLException ex) { |
| 567 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 568 | } |
| 569 | } |
| 570 | }); |
| 571 | |
| 572 | quickLauchBar.getItems().addAll(pause, resume, stop, new Separator(Orientation.VERTICAL), dumpVar, currentcase, currentStep, showlog, nextStep, |
| 573 | new Separator(Orientation.VERTICAL), getTest, compile, doCommand, interpret, redoCommand); |
| 574 | } |
| 575 | |
| 576 | public void requestServer(String request, Vector params) { |
| 577 | |
| 578 | XmlRpcClient server; |
| 579 | try { |
| 580 | server = new XmlRpcClient("http://localhost:9000"); |
| 581 | try { |
| 582 | Object response = server.execute(request, params); |
| 583 | javafx.scene.control.SingleSelectionModel<Tab> selectionModel = consoleTabPane.getSelectionModel(); |
| 584 | selectionModel.select(debugLog); |
| 585 | debugLogText.appendText(request + " Ouput \n =====================================================================\n"); |
| 586 | debugLogText.appendText(response.toString()); |
| 587 | debugLogText.appendText("\n ======================================================================\n"); |
| 588 | } catch (XmlRpcException ex) { |
| 589 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 590 | } catch (IOException ex) { |
| 591 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 592 | } |
| 593 | } catch (MalformedURLException ex) { |
| 594 | Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex); |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | public Button getVieLogsButton() { |
| 599 | return viewLogs; |
| 600 | } |
| 601 | |
| 602 | public StackPane getRoot() { |
| 603 | return rootStack; |
| 604 | } |
| 605 | |
| 606 | public ObservableList<SummaryTable> getData() { |
| 607 | return data; |
| 608 | } |
| 609 | |
| 610 | public PieChart getChart() { |
| 611 | return chart; |
| 612 | } |
| 613 | |
| 614 | public TableView getFinalSummaryTable() { |
| 615 | return finalSummaryTable; |
| 616 | } |
| 617 | |
| 618 | public ObservableList<FinalSummaryTable> getFinalSummaryData() { |
| 619 | return summaryData; |
| 620 | } |
| 621 | |
| 622 | public ObservableList<PieChart.Data> getpieChartData() { |
| 623 | return pieChartData; |
| 624 | } |
| 625 | |
| 626 | public javafx.scene.control.TextArea getTextArea(String name) { |
| 627 | if (name.equals("log")) { |
| 628 | return compononetLogText; |
| 629 | } else if (name.equals("pox")) { |
| 630 | return poxSessionText; |
| 631 | } else if (name.equals("flowvisor")) { |
| 632 | return flowVisorSessionText; |
| 633 | } else if (name.equals("mininet")) { |
| 634 | return mininetSessionText; |
| 635 | } |
| 636 | return new javafx.scene.control.TextArea(); |
| 637 | } |
| 638 | |
| 639 | public PieChart.Data getPassData() { |
| 640 | return passData; |
| 641 | } |
| 642 | |
| 643 | public PieChart.Data getFailData() { |
| 644 | return failData; |
| 645 | } |
| 646 | |
| 647 | public PieChart.Data getAbortData() { |
| 648 | return abortData; |
| 649 | } |
| 650 | |
| 651 | public PieChart.Data getNoResultData() { |
| 652 | return noResult; |
| 653 | } |
| 654 | |
| 655 | ///Step TABLE |
| 656 | public TableView getStepTable() { |
| 657 | return stepTable; |
| 658 | } |
| 659 | |
| 660 | public ObservableList<StepTable> getStepData() { |
| 661 | return stepData; |
| 662 | } |
| 663 | } |