blob: 91d31935951c637ae72579801dea9c97a3d441b6 [file] [log] [blame]
adminbae64d82013-08-01 10:50:15 -07001/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package tai_ofa;
6
7import java.util.Iterator;
8import javafx.application.Application;
9import javafx.application.Platform;
10import javafx.collections.ObservableList;
11import javafx.event.ActionEvent;
12import javafx.event.EventHandler;
13import javafx.geometry.Insets;
14import javafx.scene.Scene;
15import javafx.scene.control.Button;
16import javafx.scene.control.CheckBox;
17import javafx.scene.control.ComboBox;
18import javafx.scene.control.Label;
19import javafx.scene.control.TextField;
20import javafx.scene.control.TreeItem;
21import javafx.scene.control.TreeView;
22import javafx.scene.layout.GridPane;
23import javafx.scene.layout.HBox;
24import javafx.scene.layout.StackPane;
25import javafx.stage.Stage;
26
27/**
28 *
29 * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
30
31 * TestON is free software: you can redistribute it and/or modify
32 * it under the terms of the GNU General Public License as published by
33 * the Free Software Foundation, either version 2 of the License, or
34 * (at your option) any later version.
35
36 * TestON is distributed in the hope that it will be useful,
37 * but WITHOUT ANY WARRANTY; without even the implied warranty of
38 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39 * GNU General Public License for more details.
40
41 * You should have received a copy of the GNU General Public License
42 * along with TestON. If not, see <http://www.gnu.org/licenses/>.
43
44 */
45public class OFATestParameters extends Application {
46
47 Stage stage;
48 TAI_OFA ofaReferernce;
49 TreeView<String> projectExplorerTreeView;
50 OFATestSummary testSummaryPop;
51 TreeItem<String> selectetdTest;
52 ObservableList<TreeItem<String>> listProject;
53 ObservableList<TreeItem<String>> paramFile;
54 ComboBox<String> paramList;
55 ComboBox<String> topologyList;
56 String projectToRun;
57 /**
58 * @param args the command line arguments
59 */
60 Button selectTestCase = new Button("Select TestCases");
61 Button startTest = new Button("Start Test");
62 Button cancelButton = new Button("Cancel");
63
64 public void setProjectView(TreeView<String> tree) {
65 projectExplorerTreeView = tree;
66 }
67
68 public OFATestParameters(TAI_OFA ofaReference) {
69 this.ofaReferernce = ofaReference;
70 }
71
72 public void setProjectList(ObservableList<TreeItem<String>> list) {
73 listProject = list;
74 }
75
76 public static void main(String[] args) {
77 launch(args);
78 }
79
80 @Override
81 public void start(Stage primaryStage) {
82 testSummaryPop = new OFATestSummary(ofaReferernce, stage);
83 stage = primaryStage;
84 primaryStage.setTitle("Test ParaMeter");
85 primaryStage.setResizable(false);
86 GridPane testParameterGrid = new GridPane();
87 testParameterGrid.setPadding(new Insets(100, 0, 0, 60));
88 testParameterGrid.setVgap(8);
89 testParameterGrid.setHgap(2);
90
91 selectTestCase.setDisable(true);
92 startTest.setDisable(true);
93 Label projectName = new Label("Test Name :");;
94 testParameterGrid.add(projectName, 0, 1);
95 final ComboBox<String> projectNameList = new ComboBox<String>();
96 projectNameList.setMinWidth(170);
97
98 ObservableList<String> dataForProject = projectNameList.getItems();
99 final Iterator<TreeItem<String>> projectIterator = listProject.iterator();
100 while (projectIterator.hasNext()) {
101 final TreeItem<String> treeItem = projectIterator.next();
102 dataForProject.add(treeItem.getValue());
103 ObservableList<TreeItem<String>> list = treeItem.getChildren();
104 Iterator<TreeItem<String>> it = list.iterator();
105 }
106 projectNameList.setItems(dataForProject);
107 testParameterGrid.add(projectNameList, 1, 1);
108 projectNameList.setOnAction(new EventHandler<ActionEvent>() {
109 @Override
110 public void handle(ActionEvent arg0) {
111 final Iterator<TreeItem<String>> projectIterator = listProject.iterator();
112 while (projectIterator.hasNext()) {
113 final TreeItem<String> treeItem = projectIterator.next();
114 ObservableList<TreeItem<String>> list = treeItem.getChildren();
115 if (treeItem.getValue().equalsIgnoreCase(projectNameList.getSelectionModel().getSelectedItem())) {
116 ObservableList<TreeItem<String>> children = treeItem.getChildren();
117 final Iterator<TreeItem<String>> testListIterator = children.iterator();
118 while (testListIterator.hasNext()) {
119 selectetdTest = testListIterator.next();
120 paramFile = selectetdTest.getChildren();
121 if (selectetdTest.getGraphic().getId().equals(".params")) {
122 paramList.getItems().add(selectetdTest.getValue());
123 }
124
125 if (selectetdTest.getGraphic().getId().equals(".topo")) {
126 topologyList.getItems().add(selectetdTest.getValue());
127 }
128 selectTestCase.setDisable(false);
129 startTest.setDisable(false);
130 }
131 }
132 }
133 }
134 });
135
136 Label params = new Label("Params");
137 testParameterGrid.add(params, 0, 3);
138 paramList = new ComboBox<String>();
139 paramList.setMinWidth(170);
140 testParameterGrid.add(paramList, 1, 3);
141
142 Label topology = new Label("Topology");
143 testParameterGrid.add(topology, 0, 4);
144 topologyList = new ComboBox<String>();
145 topologyList.setMinWidth(170);
146 testParameterGrid.add(topologyList, 1, 4);
147
148 Label logFolder = new Label("Log Folder");
149 testParameterGrid.add(logFolder, 0, 5);
150 TextField logFolderPath = new TextField();
151 logFolderPath.setMaxWidth(170);
152 testParameterGrid.add(logFolderPath, 1, 5);
153 Label cliOption = new Label("CLI Options:");
154 testParameterGrid.add(cliOption, 0, 6);
155
156 HBox testDirBox = new HBox(5);
157 CheckBox testDirCheck = new CheckBox("Test Directory");
158 TextField testDirPath = new TextField();
159 testDirPath.setMaxWidth(140);
160 testDirBox.getChildren().addAll(testDirCheck, testDirPath);
161 testParameterGrid.add(testDirBox, 1, 7);
162
163 HBox emailBox = new HBox(5);
164 CheckBox emailIdCheck = new CheckBox("Email Id ");
165 TextField emailText = new TextField();
166 emailText.setMaxWidth(140);
167 emailBox.getChildren().addAll(emailIdCheck, emailText);
168 testParameterGrid.add(emailBox, 1, 8);
169
170 HBox optionButton = new HBox(5);
171 optionButton.setPadding(new Insets(0, 0, 0, 0));
172 optionButton.getChildren().addAll(selectTestCase, startTest, cancelButton);
173 testParameterGrid.add(optionButton, 1, 11);
174
175 selectTestCase.setOnAction(new EventHandler<ActionEvent>() {
176 @Override
177 public void handle(ActionEvent arg0) {
178 String testName = projectNameList.getSelectionModel().getSelectedItem();
179 String paramsFileName = paramList.getSelectionModel().getSelectedItem();
180 OFATestCaseSelection testCasePop = new OFATestCaseSelection(testName, paramsFileName);
181 testCasePop.start(new Stage());
182 }
183 });
184
185 startTest.setOnAction(new EventHandler<ActionEvent>() {
186 @Override
187 public void handle(ActionEvent arg0) {
188 testSummaryPop.start(new Stage());
189 Runnable firstRunnable = new Runnable() {
190 public void run() {
191 try {
192 } catch (Exception e) {
193 e.printStackTrace();
194 }
195 }
196 };
197
198 Runnable secondRunnable = new Runnable() {
199 public void run() {
200 try {
201 ExecuteTest tail = new ExecuteTest(testSummaryPop.getTable(), testSummaryPop.getData(), testSummaryPop.getChart(),
202 testSummaryPop.getFinalSummaryTable(), testSummaryPop.getFinalSummaryData(),
203 testSummaryPop.getVieLogsButton(), testSummaryPop.getpieChartData(),
204 testSummaryPop.getPassData(), testSummaryPop.getFailData(), testSummaryPop.getAbortData(),
205 testSummaryPop.getNoResultData(), projectNameList.getSelectionModel().getSelectedItem().toString(), testSummaryPop.getTextArea("log"), testSummaryPop.getStepTable(), testSummaryPop.getStepData(), testSummaryPop.getTextArea("pox"), testSummaryPop.getTextArea("mininet"), testSummaryPop.getTextArea("flowvisor"));
206 tail.runTest();
207 } catch (Exception iex) {
208 }
209 }
210 };
211 Platform.runLater(firstRunnable);
212 Platform.runLater(secondRunnable);
213 stage.close();
214 }
215 });
216 StackPane root = new StackPane();
217 root.getChildren().add(testParameterGrid);
218 primaryStage.setScene(new Scene(root, 460, 360));
219 primaryStage.show();
220 }
221}