adding TestON
diff --git a/TestON/TAI/src/tai_ofa/AddParams.java b/TestON/TAI/src/tai_ofa/AddParams.java
new file mode 100644
index 0000000..8d35046
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/AddParams.java
@@ -0,0 +1,435 @@
+/*
+
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Observable;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javafx.beans.property.SimpleStringProperty;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.Event;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.geometry.Orientation;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.SplitPane;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableColumn.CellEditEvent;
+import javafx.scene.control.TableView;
+import javafx.scene.control.TextField;
+import javafx.scene.control.TextFieldBuilder;
+import javafx.scene.control.TreeItem;
+import javafx.scene.control.TreeView;
+import javafx.scene.control.cell.PropertyValueFactory;
+import javafx.scene.control.cell.TextFieldTableCell;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.VBox;
+import javafx.scene.paint.Color;
+import javafx.scene.text.Font;
+import javafx.scene.text.Text;
+import javafx.stage.Stage;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+
+ */
+public class AddParams {
+
+ TAI_OFA referenceOFA;
+ boolean splitFlag = false;
+ Map<String, Object> paramsHash;
+ TreeView<String> paramsTreeView;
+ TextField Value, tableAttrib, tableValue;
+ TableView<ParamsAttribute> attributeTable;
+ ObservableList<ParamsAttribute> data;
+ Button save, Cancel, edit, add, saveParams;
+ HBox buttonBox, tableViewBox, baseLeftPane;
+ VBox box, buttonTableVBox;
+ GridPane buttonBoxPane, baseRightPane;
+ TreeItem<String> params;
+ Pane tableViewPane;
+ Text Heading;
+ String tabValue, tabs;
+ OFAWizard wizard;
+ OFAFileOperations fileOperations;
+ Tab baseTab;
+ Button delete;
+
+ public void setOFA(TAI_OFA ofa) {
+ this.referenceOFA = ofa;
+ }
+
+ public void getNewParams() {
+ baseTab = new Tab();
+ paramsHash = new HashMap<String, Object>();
+ fileOperations = new OFAFileOperations();
+ final SplitPane basePane = new SplitPane();
+ basePane.setOrientation(Orientation.HORIZONTAL);
+ baseLeftPane = new HBox(30);
+ params = new TreeItem<String>();
+ params.setValue("params");
+ TreeItem<String> log_dir = new TreeItem<String>();
+ log_dir.setValue("log_dir");
+ ImageView logIView = new ImageView(new Image("images/parameter.jpg", 20, 20, true, true));
+ logIView.setId("/home/paxterra/");
+ log_dir.setGraphic(logIView);
+ TreeItem<String> mail = new TreeItem<String>();
+ mail.setValue("mail");
+ ImageView mailIView = new ImageView(new Image("images/parameter.jpg", 20, 20, true, true));
+ mailIView.setId("raghavkashyap@paxterrasolution.com");
+ mail.setGraphic(mailIView);
+ TreeItem<String> testcases = new TreeItem<String>();
+ testcases.setValue("testcases");
+ ImageView testIView = new ImageView(new Image("images/parameter.jpg", 20, 20, true, true));
+ testIView.setId("1");
+ testcases.setGraphic(testIView);
+ data = FXCollections.observableArrayList();
+ params.getChildren().addAll(testcases, mail, log_dir);
+ paramsTreeView = new TreeView<String>(params);
+ saveParams = new Button("Save");
+ delete = new Button("Delete");
+ baseLeftPane.getChildren().addAll(paramsTreeView, saveParams, delete);
+ baseRightPane = new GridPane();
+ Value = TextFieldBuilder.create().build();
+ delete.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ removeParamsValue(paramsTreeView.getSelectionModel().getSelectedItem());
+ }
+ });
+
+ saveParams.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ tabs = getParams(params);
+ referenceOFA.paramsFileContent = tabs;
+ wizard = new OFAWizard(referenceOFA.projectExplorerTree, 2, referenceOFA.projectExplorerTree.getChildren(), referenceOFA.projectExplorerTreeView);
+ wizard.setOFA(referenceOFA);
+ try {
+ wizard.start(new Stage());
+ } catch (Exception ex) {
+ Logger.getLogger(AddParams.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+ });
+ save = new Button("Save");
+ Cancel = new Button("Cancel");
+ edit = new Button("Edit");
+ attributeTable = new TableView<ParamsAttribute>();
+ attributeTable.setEditable(true);
+ TableColumn attribColumn = new TableColumn("Attribute");
+ attribColumn.setCellValueFactory(new PropertyValueFactory<ParamsAttribute, String>("Attribute"));
+ TableColumn valueColumn = new TableColumn("Value");
+ valueColumn.setCellValueFactory(new PropertyValueFactory<ParamsAttribute, String>("Values"));
+ attributeTable.setItems(data);
+ attributeTable.getColumns().addAll(attribColumn, valueColumn);
+ baseRightPane.setPadding(new Insets(30, 0, 10, 30));
+ baseRightPane.prefHeight(referenceOFA.scene.heightProperty().get());
+ baseRightPane.setVgap(9);
+ baseRightPane.add(new Label("Value :"), 4, 4);
+ baseRightPane.add(Value, 5, 4);
+ box = new VBox();
+ buttonBox = new HBox();
+ buttonBoxPane = new GridPane();
+ buttonBoxPane.setPadding(new Insets(30, 0, 10, 30));
+ buttonBoxPane.setHgap(3);
+ buttonBoxPane.add(save, 2, 7);
+ buttonBoxPane.add(Cancel, 4, 7);
+ buttonBoxPane.add(edit, 6, 7);
+ buttonBox.getChildren().addAll(buttonBoxPane);
+ tableAttrib = TextFieldBuilder.create().build();
+ tableValue = TextFieldBuilder.create().build();
+ add = new Button("Add");
+ tableViewPane = new Pane();
+ buttonTableVBox = new VBox();
+ tableViewBox = new HBox();
+ tableViewBox.getChildren().addAll(tableAttrib, tableValue, add);
+ buttonTableVBox.getChildren().addAll(attributeTable);
+ box.getChildren().addAll(baseRightPane, buttonTableVBox, buttonBoxPane);
+
+ attributeTable.setEditable(true);
+ attribColumn.setCellFactory(TextFieldTableCell.forTableColumn());
+ attribColumn.setOnEditCommit(new EventHandler<CellEditEvent<ParamsAttribute, String>>() {
+ @Override
+ public void handle(CellEditEvent<ParamsAttribute, String> t) {
+
+ for (int i = 0; i < paramsTreeView.getSelectionModel().getSelectedItem().getChildren().size(); i++) {
+
+ if (paramsTreeView.getSelectionModel().getSelectedItem().getChildren().get(i).getValue().equals(t.getOldValue())) {
+ paramsTreeView.getSelectionModel().getSelectedItem().getChildren().get(i).setValue(t.getNewValue());
+ }
+ }
+ ((ParamsAttribute) t.getTableView().getItems().get(
+ t.getTablePosition().getRow())).setAttribute(t.getNewValue());
+
+ }
+ });
+
+ valueColumn.setCellFactory(TextFieldTableCell.forTableColumn());
+ valueColumn.setOnEditCommit(new EventHandler<CellEditEvent<ParamsAttribute, String>>() {
+ @Override
+ public void handle(CellEditEvent<ParamsAttribute, String> t) {
+ for (int i = 0; i < paramsTreeView.getSelectionModel().getSelectedItem().getChildren().size(); i++) {
+ if (paramsTreeView.getSelectionModel().getSelectedItem().getChildren().get(i).getValue().equals(t.getOldValue())) {
+ paramsTreeView.getSelectionModel().getSelectedItem().getChildren().get(i).getGraphic().setId(t.getNewValue());
+ }
+ }
+ ((ParamsAttribute) t.getTableView().getItems().get(
+ t.getTablePosition().getRow())).setValues(t.getNewValue());
+ }
+ });
+
+ Value.setOnKeyReleased(new EventHandler<KeyEvent>() {
+ @Override
+ public void handle(KeyEvent t) {
+ if (Value.getText().isEmpty()) {
+ edit.setDisable(false);
+ } else {
+ edit.setDisable(true);
+ }
+ }
+ });
+
+ Cancel.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ basePane.getItems().removeAll(box);
+ splitFlag = false;
+ baseRightPane.getChildren().remove(Heading);
+ edit.setDisable(false);
+ }
+ });
+
+ save.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ String selected = paramsTreeView.getSelectionModel().getSelectedItem().getValue();
+ TreeItem<String> selectedTreeItem = paramsTreeView.getSelectionModel().getSelectedItem();
+ String attribVal = Value.getText();
+ basePane.getItems().removeAll(box);
+ splitFlag = false;
+ Map<String, Object> prevParent = new HashMap<String, Object>();
+ ArrayList<String> names = new ArrayList<String>();
+ if (!edit.isDisabled()) {
+ for (int i = 0; i < attributeTable.getItems().size(); i++) {
+ ParamsAttribute table = attributeTable.getItems().get(i);
+ if (selectedTreeItem.getChildren().size() == 0) {
+ TreeItem<String> childNode = new TreeItem<String>();
+ childNode.setValue(table.getAttribute());
+ selectedTreeItem.getChildren().add(childNode);
+ selectedTreeItem.setExpanded(true);
+ Image chidlImage = new Image("images/parameter.jpg", 20, 20, true, true);
+ ImageView childImageView = new ImageView();
+ childImageView.setImage(chidlImage);
+ childImageView.setId(table.getValues());
+ childNode.setGraphic(childImageView);
+ } else if (selectedTreeItem.getChildren().size() > 0) {
+ names.clear();
+ for (int index = 0; index < selectedTreeItem.getChildren().size(); index++) {
+ names.add(selectedTreeItem.getChildren().get(index).getValue());
+ }
+ if (!names.contains(table.getAttribute())) {
+ TreeItem<String> childNode = new TreeItem<String>();
+ childNode.setValue(table.getAttribute());
+ selectedTreeItem.getChildren().addAll(childNode);
+ selectedTreeItem.setExpanded(true);
+ Image chidlImage = new Image("images/parameter.jpg", 20, 20, true, true);
+ ImageView childImageView = new ImageView();
+ childImageView.setImage(chidlImage);
+ childImageView.setId(table.getValues());
+ childNode.setGraphic(childImageView);
+ }
+ }
+ }
+ } else {
+ TreeItem<String> selectTreeItem = paramsTreeView.getSelectionModel().getSelectedItem();
+ if (!Value.getText().isEmpty()) {
+ paramsTreeView.getSelectionModel().getSelectedItem().getGraphic().setId(Value.getText());
+ }
+ }
+ baseRightPane.getChildren().remove(Heading);
+ buttonTableVBox.getChildren().removeAll(tableViewBox);
+ Value.clear();
+ }
+ });
+
+ add.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+
+ if (tableAttrib.getText().isEmpty() && tableValue.getText().isEmpty()) {
+ } else {
+ data.add(new ParamsAttribute(tableAttrib.getText(), tableValue.getText()));
+ tableAttrib.clear();
+ tableValue.clear();
+ }
+ }
+ });
+
+
+ edit.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+
+ buttonTableVBox.getChildren().addAll(tableViewBox);
+
+ Value.setEditable(false);
+
+ }
+ });
+
+ basePane.getItems().addAll(baseLeftPane);
+ paramsTreeView.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent args0) {
+ String selected = paramsTreeView.getSelectionModel().getSelectedItem().getValue();
+ TreeItem<String> selectItem = paramsTreeView.getSelectionModel().getSelectedItem();
+ if (args0.getClickCount() == 2 & !splitFlag) {
+ Value.setEditable(true);
+ Heading = new Text(selected);
+ Heading.setFont(Font.font("Arial", 20));
+ Heading.setFill(Color.BLUE);
+ baseRightPane.add(Heading, 6, 1);
+
+ if (selectItem.isLeaf()) {
+ Value.setDisable(false);
+ if (!selectItem.getGraphic().getId().equals("")) {
+ basePane.getItems().addAll(box);
+ splitFlag = true;
+ Value.setText(selectItem.getGraphic().getId());
+ edit.setDisable(true);
+ data.clear();
+ } else {
+ basePane.getItems().addAll(box);
+ splitFlag = true;
+ Value.clear();
+ edit.setDisable(false);
+ data.clear();
+ }
+ } else if (!selectItem.isLeaf()) {
+ Value.clear();
+ Value.setDisable(true);
+ basePane.getItems().addAll(box);
+ splitFlag = true;
+ data.clear();
+ for (int i = 0; i < selectItem.getChildren().size(); i++) {
+
+ data.add(new ParamsAttribute(selectItem.getChildren().get(i).getValue(), selectItem.getChildren().get(i).getGraphic().getId()));
+ }
+ }
+
+ }
+ }
+ });
+ basePane.prefWidthProperty().bind(referenceOFA.scene.widthProperty().subtract(300));
+ basePane.prefHeightProperty().bind(referenceOFA.scene.heightProperty().subtract(120));
+ baseTab.setContent(basePane);
+ baseTab.setText("Unnamed.params");
+ referenceOFA.editorTabPane.getTabs().addAll(baseTab);
+ }
+
+ public String getParams(TreeItem<String> treeNode) {
+ tabValue = "";
+ tabValue = tabValue + "<" + treeNode.getValue() + ">\n";
+ if (!treeNode.isLeaf()) {
+ for (int i = 0; i < treeNode.getChildren().size(); i++) {
+ if (treeNode.getChildren().get(i).isLeaf()) {
+ tabValue = tabValue + "\n<" + treeNode.getChildren().get(i).getValue() + ">" + treeNode.getChildren().get(i).getGraphic().getId()
+ + "</" + treeNode.getChildren().get(i).getValue() + ">\n";
+ } else if (!treeNode.getChildren().get(i).isLeaf()) {
+ int index = 0;
+ tabValue = tabValue + "\n<" + treeNode.getChildren().get(i).getValue() + ">\n";
+ while (index < treeNode.getChildren().get(i).getChildren().size()) {
+ tabValue = tabValue + getParams(treeNode.getChildren().get(i).getChildren().get(index));
+ index++;
+ }
+ tabValue = tabValue + "\n</" + treeNode.getChildren().get(i).getValue() + ">\n";
+ }
+ }
+ } else if (treeNode.isLeaf()) {
+ tabValue = tabValue + treeNode.getGraphic().getId();
+ }
+ tabValue = tabValue + "\n</" + treeNode.getValue() + ">";
+ return tabValue;
+ }
+
+ public void removeParamsValue(TreeItem treeItem) {
+ for (int i = 0; i < paramsTreeView.getRoot().getChildren().size(); i++) {
+ if (paramsTreeView.getRoot().getChildren().get(i).isLeaf()) {
+ if (paramsTreeView.getRoot().getChildren().get(i).getValue().equals(treeItem.getValue())) {
+ paramsTreeView.getRoot().getChildren().remove(paramsTreeView.getRoot().getChildren().get(i));
+ }
+ } else if (!paramsTreeView.getRoot().getChildren().get(i).isLeaf()) {
+ if (paramsTreeView.getRoot().getChildren().get(i).getValue().equals(treeItem.getValue())) {
+ paramsTreeView.getRoot().getChildren().remove(paramsTreeView.getRoot().getChildren().get(i));
+ } else {
+ for (int index = 0; index < paramsTreeView.getRoot().getChildren().get(i).getChildren().size(); index++) {
+ if (paramsTreeView.getRoot().getChildren().get(i).getChildren().get(index).getValue().equals(treeItem.getValue())) {
+ paramsTreeView.getRoot().getChildren().get(i).getChildren().remove(paramsTreeView.getRoot().getChildren().get(i).getChildren().get(index));
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ public static class ParamsAttribute {
+ private final SimpleStringProperty Attributes;
+ private final SimpleStringProperty Values;
+
+ private ParamsAttribute(String attrib, String val) {
+ this.Attributes = new SimpleStringProperty(attrib);
+ this.Values = new SimpleStringProperty(val);
+ }
+
+ public String getAttribute() {
+ return Attributes.get();
+ }
+
+ public void setAttribute(String attrib) {
+ Attributes.set(attrib);
+ }
+
+ public String getValues() {
+ return Values.get();
+ }
+
+ public void setValues(String val) {
+ Values.set(val);
+ }
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/CodeEditor.java b/TestON/TAI/src/tai_ofa/CodeEditor.java
new file mode 100644
index 0000000..c645aac
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/CodeEditor.java
@@ -0,0 +1,220 @@
+package tai_ofa;
+
+import java.util.Locale;
+import javafx.scene.layout.StackPane;
+import javafx.scene.web.WebView;
+import javax.print.Doc;
+import javax.swing.tree.DefaultTreeCellEditor;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/*
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+
+*/
+
+public class CodeEditor extends StackPane {
+
+ /**
+ * a webview used to encapsulate the JavaScript.
+ */
+ final WebView webview = new WebView();
+ /**
+ * a snapshot of the code to be edited kept for easy initialization and
+ * reversion of editable code.
+ */
+ private String editingCode;
+ /**
+ * a template for editing code - this can be changed to any template derived
+ * from the supported modes at java to allow syntax highlighted editing of a
+ * wide variety of languages.
+ */
+ TAILocale label = new TAILocale(new Locale("en", "EN"));
+ String editorScriptsPath = label.OFAHarnessPath;
+ private final String editingTemplate =
+ "<!doctype html>"
+ + "<html>"
+ + "<head>"
+ + " <link rel=\"stylesheet\" href=\"file://editorScriptPath/codemirror.css\">".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/codemirror.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/clike.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/javascript-hint.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/search.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/dialog.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/searchcursor.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/simple-hint.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <link rel=\"stylesheet\" href=\"file://editorScriptPath/simple-hint.css\">".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/javascript-hint.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/foldcode.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/perl.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + " <script src=\"file://editorScriptPath/xml.js\"></script>".replace("editorScriptPath", editorScriptsPath + "/EditorScripts")
+ + "</head>"
+ + "<body>"
+ + "<form><textarea id=\"code\" name=\"code\">\n"
+ + "${code}"
+ + "</textarea></form>"
+ + "<script>"
+ + "var editor;"
+ + "editor = CodeMirror.fromTextArea(document.getElementById(\"code\"), {"
+ + "mode: \"perl\","
+ + "lineNumbers: true,"
+ + " });"
+ + "</script>"
+ + "</body>"
+ + "</html>";
+
+ /**
+ * applies the editing template to the editing code to create the
+ * html+javascript source for a code editor.
+ */
+ private String applyEditingTemplate() {
+
+ editingTemplate.replace("${code}", editingCode);
+ return editingTemplate.replace("${code}", editingCode);
+
+ }
+
+ /**
+ * sets the current code in the editor and creates an editing snapshot of
+ * the code which can be reverted to.
+ */
+ public void setCode(String newCode) {
+ this.editingCode = newCode;
+ webview.getEngine().loadContent(applyEditingTemplate());
+
+ // webview.getStylesheets().add("eclipse.css");
+ }
+
+ public String getCurrentLine() {
+ return (String) webview.getEngine().executeScript("editor.getLine(editor.getCursor().line);");
+ }
+
+ public String getCurrentLineNumber() {
+
+ return webview.getEngine().executeScript("editor.getLineNumber(editor.getCursor().line);").toString();
+
+ }
+
+ public String getCurrentLine(int lineNumber) {
+ Integer lines = lineNumber;
+ return (String) webview.getEngine().executeScript("editor.getLine(line);".replace("line", lines.toString()));
+
+ }
+
+ public void setLine(int lineNumber, String text) {
+ String lineToSet = "editor.setLine(" + lineNumber + ",'lineText');";
+ webview.getEngine().executeScript(lineToSet.replace("lineText", text));
+ }
+
+ /**
+ * returns the current code in the editor and updates an editing snapshot of
+ * the code which can be reverted to.
+ */
+ public String getCodeAndSnapshot() {
+ //Document doc = webview.getEngine().getDocument();
+// Element el = doc.getElementById("code");
+ webview.getEngine().executeScript("editor.refresh();");
+ this.editingCode = (String) webview.getEngine().executeScript("editor.getValue();");
+
+ return editingCode;
+ }
+
+ public int cursorPosfromTop() {
+ return (Integer) webview.getEngine().executeScript("editor.cursorTopPos();");
+
+ }
+
+ public int cursorPosfromLeft() {
+ return (Integer) webview.getEngine().executeScript("editor.cursorLeftPos();");
+
+ }
+
+ public String test() {
+ return (String) webview.getEngine().executeScript("editor.find();");
+
+ }
+
+ public void clearMarker(String line) {
+ int lineNumber = Integer.parseInt(line) - 1;
+ String lineNumberString = "editor.clearMarker(clearGutter);".replace("clearGutter", String.valueOf(lineNumber));
+ webview.getEngine().executeScript(lineNumberString);
+ }
+
+ public void SetError(String line, final String errorType) {
+
+ final String tooltip = "editor.setMarker(line-1, \"<a id='error' title='errorType \" + \"'><img src='file://editorScriptPath/Delete.png'/></a>%N%\"); ".replace("editorScriptPath", editorScriptsPath + "/EditorScripts");
+ Integer lineCount = (Integer) webview.getEngine().executeScript("editor.lineCount();");
+ int i;
+ for (i = 1; i <= lineCount; i++) {
+ String tooltipToExcute = tooltip.replace("line", line).replace("errorType", errorType);
+ if (!"".equals(errorType)) {
+ webview.getEngine().executeScript(tooltipToExcute);
+ }
+ }
+
+ }
+
+ public void SetWarning(String line, final String errorType) {
+
+ final String tooltip = "editor.setMarker(line-1, \"<a id='error' title='errorType \" + \"'><img src='file://editorScriptPath/Warning.png'/></a>%N%\"); ".replace("editorScriptPath", editorScriptsPath + "/EditorScripts");
+ Integer lineCount = (Integer) webview.getEngine().executeScript("editor.lineCount();");
+ int i;
+ for (i = 1; i <= lineCount; i++) {
+ String tooltipToExcute = tooltip.replace("line", line).replace("errorType", errorType);
+ if (!"".equals(errorType)) {
+ webview.getEngine().executeScript(tooltipToExcute);
+ }
+ }
+
+ }
+
+ public void SetInfo(String line, final String errorType) {
+
+ final String tooltip = "editor.setMarker(line-1, \"<a id='error' title='errorType \" + \"'><img src='file://editorScriptPath/info.jpg'/></a>%N%\"); ".replace("editorScriptPath", editorScriptsPath + "/EditorScripts");
+ Integer lineCount = (Integer) webview.getEngine().executeScript("editor.lineCount();");
+ int i;
+ for (i = 1; i <= lineCount; i++) {
+ String tooltipToExcute = tooltip.replace("line", line).replace("errorType", errorType);
+ if (!"".equals(errorType)) {
+ webview.getEngine().executeScript(tooltipToExcute);
+ }
+ }
+
+ }
+
+ /**
+ * revert edits of the code to the last edit snapshot taken.
+ */
+ public void revertEdits() {
+ setCode(editingCode);
+ }
+
+ /**
+ * Create a new code editor.
+ *
+ * @param editingCode the initial code to be edited in the code editor.
+ */
+ CodeEditor(String editingCode) {
+ this.editingCode = editingCode;
+
+ // webview.setPrefSize(650, 325);
+ // webview.setMinSize(150, 325);
+ webview.getEngine().loadContent(applyEditingTemplate());
+
+
+ this.getChildren().add(webview);
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/CodeEditorParams.java b/TestON/TAI/src/tai_ofa/CodeEditorParams.java
new file mode 100644
index 0000000..99ed8e1
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/CodeEditorParams.java
@@ -0,0 +1,207 @@
+package tai_ofa;
+
+import com.sun.org.apache.xerces.internal.parsers.IntegratedParserConfiguration;
+import java.awt.TextArea;
+import java.util.ArrayList;
+import java.util.Locale;
+import javafx.event.EventHandler;
+import javafx.scene.Group;
+import javafx.scene.Node;
+import javafx.scene.control.Button;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.MenuItem;
+import javafx.scene.control.Tab;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.StackPane;
+import javafx.scene.web.PopupFeatures;
+import javafx.scene.web.WebEngine;
+import javafx.scene.web.WebView;
+import javafx.util.Callback;
+import javax.swing.JOptionPane;
+
+
+/*
+ * To change this template, choose Tools | Templates and open the template in
+ * the editor.
+ */
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ * /**
+ */
+public class CodeEditorParams extends StackPane {
+
+ TAI_OFA OFAReference;
+ WebView webview = new WebView();
+ private String editingCode;
+ ContextMenu contextMenu;
+ TAILocale label = new TAILocale(new Locale("en", "EN"));
+ String editorScriptsPath = label.OFAHarnessPath;
+ private final String editingTemplate =
+ "<!doctype html>"
+ + "<html>"
+ + "<head>"
+ + " <link rel=\"stylesheet\"href=\"file://editorScriptPath/codemirror.css\">".replace("editorScriptPath", editorScriptsPath+"/EditorScripts")
+ + " <script src=\"file://editorScriptPath/codemirror.js\"></script>".replace("editorScriptPath", editorScriptsPath+"/EditorScripts")
+ + " <script src=\"file://editorScriptPath/foldcode.js\"></script>".replace("editorScriptPath", editorScriptsPath+"/EditorScripts")
+ + " <script src=\"file://editorScriptPath/perl.js\"></script>".replace("editorScriptPath", editorScriptsPath+"/EditorScripts")
+ + " <script src=\"file://editorScriptPath/xml.js\"></script>".replace("editorScriptPath", editorScriptsPath+"/EditorScripts")
+ + " <style type=\"text/css\">"
+ + "</style>"
+ + "</head>"
+ + "<body>"
+ + "<form><textarea id=\"code\" name=\"code\">\n"
+ + "${code}"
+ + "</textarea></form>"
+ + "<script>"
+ + " var foldFunc = CodeMirror.newFoldFunction(CodeMirror.tagRangeFinder);"
+ + "var editor;"
+ + "editor = CodeMirror.fromTextArea(document.getElementById(\"code\"), {"
+ + "mode: \"perl\","
+ + " lineNumbers: true,"
+ + "onGutterClick: foldFunc,"
+ + "extraKeys: {\"Ctrl-Q\" : function(cm){foldFunc(cm, cm.getCursor().line);}}"
+ + " });"
+ + "</script>"
+ + "</body>"
+ + "</html>";
+
+ /**
+ * applies the editing template to the editing code to create the
+ * html+javascript source for a code editor.
+ */
+ private String applyEditingTemplate() {
+ editingTemplate.replace("${code}", editingCode);
+ return editingTemplate.replace("${code}", editingCode);
+ }
+
+ public void setOFA(TAI_OFA reference) {
+ OFAReference = reference;
+ }
+
+ /**
+ * sets the current code in the editor and creates an editing snapshot of
+ * the code which can be reverted to.
+ */
+ public void setCode(String newCode) {
+ this.editingCode = newCode;
+ webview.getEngine().loadContent(applyEditingTemplate());
+ }
+
+ public String getCurrentLine() {
+ return (String) webview.getEngine().executeScript("editor.getLine(editor.getCursor().line);");
+ }
+
+ public String getCurrentLineNumber() {
+ return webview.getEngine().executeScript("editor.getLineNumber(editor.getCursor().line);").toString();
+
+ }
+
+ public String getCurrentLine(int lineNumber) {
+ Integer lines = lineNumber;
+ return (String) webview.getEngine().executeScript("editor.getLine(line);".replace("line", lines.toString()));
+
+ }
+
+ /**
+ * returns the current code in the editor and updates an editing snapshot of
+ * the code which can be reverted to.
+ */
+ public String getCodeAndSnapshot() {
+ this.editingCode = (String) webview.getEngine().executeScript("editor.getValue();");
+ return editingCode;
+ }
+
+ public void alert() {
+ webview.getEngine().executeScript("editor.myFunction();");
+ }
+
+ public int cursorPosfromTop() {
+ return (Integer) webview.getEngine().executeScript("editor.cursorTopPos();");
+ }
+
+ public int cursorPosfromLeft() {
+ return (Integer) webview.getEngine().executeScript("editor.cursorLeftPos();");
+ }
+
+ public void clearMarker(String line) {
+ int lineNumber = Integer.parseInt(line) - 1;
+ String lineNumberString = "editor.clearMarker(clearGutter);".replace("clearGutter", String.valueOf(lineNumber));
+ webview.getEngine().executeScript(lineNumberString);
+ }
+
+ public void SetError(String line, final String errorType) {
+
+ final String tooltip = "editor.setMarker(line-1, \"<a id='error' title='errorType \" + \"'><img src='file://editorScriptPath/Delete.png'/></a>%N%\"); ".replace("editorScriptPath", editorScriptsPath+"/EditorScripts");
+ Integer lineCount = (Integer) webview.getEngine().executeScript("editor.lineCount();");
+ int i;
+ for (i = 1; i <= lineCount; i++) {
+ String tooltipToExcute = tooltip.replace("line", line).replace("errorType", errorType);
+ if (!"".equals(errorType)) {
+ webview.getEngine().executeScript(tooltipToExcute);
+ }
+ }
+
+ }
+
+ public void SetWarning(String line, final String errorType) {
+
+ final String tooltip = "editor.setMarker(line-1, \"<a id='error' title='errorType \" + \"'><img src='file://editorScriptPath/Warning.png'/></a>%N%\"); ".replace("editorScriptPath", editorScriptsPath+"/EditorScripts");
+ Integer lineCount = (Integer) webview.getEngine().executeScript("editor.lineCount();");
+ int i;
+ for (i = 1; i <= lineCount; i++) {
+ String tooltipToExcute = tooltip.replace("line", line).replace("errorType", errorType);
+ if (!"".equals(errorType)) {
+ webview.getEngine().executeScript(tooltipToExcute);
+ }
+ }
+
+ }
+
+ public void SetInfo(String line, final String errorType) {
+
+ final String tooltip = "editor.setMarker(line-1, \"<a id='error' title='errorType \" + \"'><img src='file://editorScriptPath/info.jpg'/></a>%N%\"); ".replace("editorScriptPath", editorScriptsPath+"/EditorScripts");
+ Integer lineCount = (Integer) webview.getEngine().executeScript("editor.lineCount();");
+ int i;
+ for (i = 1; i <= lineCount; i++) {
+ String tooltipToExcute = tooltip.replace("line", line).replace("errorType", errorType);
+ if (!"".equals(errorType)) {
+ webview.getEngine().executeScript(tooltipToExcute);
+ }
+ }
+
+ }
+
+ /**
+ * revert edits of the code to the last edit snapshot taken.
+ */
+ public void revertEdits() {
+ setCode(editingCode);
+ }
+
+ CodeEditorParams(String editingCode) {
+ this.editingCode = editingCode;
+ webview.getEngine().loadContent(applyEditingTemplate());
+ this.getChildren().add(webview);
+ }
+
+ public void contextMenu() {
+ contextMenu = new ContextMenu();
+ MenuItem myMenuItem = new MenuItem();
+ contextMenu.getItems().add(myMenuItem);
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/DraggableNode.java b/TestON/TAI/src/tai_ofa/DraggableNode.java
new file mode 100644
index 0000000..83cf191
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/DraggableNode.java
@@ -0,0 +1,82 @@
+package tai_ofa;
+
+
+import javafx.collections.ObservableList;
+import javafx.event.EventHandler;
+import javafx.scene.Parent;
+import javafx.scene.input.MouseEvent;
+
+/**
+ *
+ * @author Raghav Kashyap raghavkashyap@paxterrasolutions.com
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+
+ */
+public class DraggableNode extends Parent{
+
+ //ATTRIBUTES
+ //X AND Y postion of Node
+ double x = 0;
+ double y = 0;
+ //X AND Y position of mouse
+ double mousex=0;
+ double mousey=0;
+
+ //To make this function accessible for other Class
+ @Override
+ public ObservableList getChildren(){
+ return super.getChildren();
+ }
+
+ public DraggableNode(){
+ super();
+
+ //EventListener for MousePressed
+ onMousePressedProperty().set(new EventHandler<MouseEvent>(){
+
+ @Override
+ public void handle(MouseEvent event) {
+ //record the current mouse X and Y position on Node
+ mousex = event.getSceneX();
+ mousey= event.getSceneY();
+ //get the x and y position measure from Left-Top
+ x = getLayoutX();
+ y = getLayoutY();
+ }
+
+ });
+
+ //Event Listener for MouseDragged
+ onMouseDraggedProperty().set(new EventHandler<MouseEvent>(){
+
+ @Override
+ public void handle(MouseEvent event) {
+ //Get the exact moved X and Y
+ x += event.getSceneX()-mousex ;
+ y += event.getSceneY()-mousey ;
+
+ //set the positon of Node after calculation
+ setLayoutX(x);
+ setLayoutY(y);
+
+ //again set current Mouse x AND y position
+ mousex = event.getSceneX();
+ mousey= event.getSceneY();
+
+ }
+ });
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/ExecuteTest.java b/TestON/TAI/src/tai_ofa/ExecuteTest.java
new file mode 100644
index 0000000..d4f9197
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/ExecuteTest.java
@@ -0,0 +1,705 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+/**
+ *
+ * @author Raghavkashyap (raghavkashyap@paxterra.com)
+
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+// Import the Java classes
+import com.sun.javafx.scene.layout.region.BackgroundFill;
+import com.sun.org.apache.bcel.internal.generic.LoadInstruction;
+import java.awt.TextArea;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.io.*;
+import java.net.MalformedURLException;
+import java.nio.file.WatchService;
+import java.text.SimpleDateFormat;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javafx.application.Platform;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.scene.chart.PieChart;
+import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.Label;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.control.TableView;
+import javafx.scene.control.TextAreaBuilder;
+import javafx.scene.effect.BlendMode;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.input.ScrollEvent;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.StackPane;
+import javafx.scene.paint.Color;
+import javafx.scene.paint.Paint;
+import javafx.stage.Popup;
+import javafx.stage.Stage;
+import org.apache.xmlrpc.XmlRpcClient;
+import org.apache.xmlrpc.XmlRpcException;
+
+public class ExecuteTest {
+
+ Pattern stepPatt, casePatt, resultPatt, namePatt, summaryPatt, testStartPatt, testEndPatt, testExecutionTimePatt, testsPlannedPatt,
+ testsRunPatt, totalPassPatt, totalFailPatt, noResultPatt, totalAbortPatt, execPercentagePatt, successPercentagePatt, assertionPatt, totalreRun;
+ TableView summaryTable, finalSummaryTable, stepTable;
+ public static int noOfPassed = 0, noOfFailed = 0, noOfAborted = 0, noOfNoResult = 0, failed = 0, passed = 0, noResults = 0, aboarted = 0;
+ String summary, testStart, testEnd, testExecutionTime, testsPlanned, testsRun, totalPass,
+ totalFail, noResult, totalAbort, execPercentage, successPercentage;
+ ObservableList<SummaryTable> data;
+ ObservableList<FinalSummaryTable> finalSummaryData;
+ ObservableList<StepTable> stepSummaryData;
+ //AutoMateTestSummary summaryWindow ;
+ StackPane summaryTableRoot;
+ TreeMap<String, String> stepHash = new TreeMap<String, String>();
+ TreeMap<String, String> caseNameHash = new TreeMap<String, String>();
+ Matcher m;
+ int tableIndex = -1;
+ int stepTableIndex = -1;
+ Runnable r3;
+ Button viewLogsButton;
+ PieChart summaryChart;
+ PieChart.Data passData, failData, abortData, noResultData;
+ String selectedTest;
+ ObservableList<PieChart.Data> pieChartData;
+ javafx.scene.control.TextArea compononetLogText = TextAreaBuilder.create().build();
+ javafx.scene.control.TextArea flowVisorSessionText = TextAreaBuilder.create().build();
+ javafx.scene.control.TextArea poxSessionText = TextAreaBuilder.create().build();
+ javafx.scene.control.TextArea mininetSessionText = TextAreaBuilder.create().build();
+ Label statusImage;
+ TAILocale label = new TAILocale(Locale.ENGLISH);
+
+ public ExecuteTest(TableView summary, ObservableList<SummaryTable> dataInstance,
+ PieChart chart, TableView finalSummary, ObservableList<FinalSummaryTable> finalSummaryDataInstance,
+ Button viewLogs, ObservableList<PieChart.Data> pieChartData,
+ PieChart.Data passData, PieChart.Data failData, PieChart.Data abortData, PieChart.Data noResultData, String testName, javafx.scene.control.TextArea componentLogText,
+ TableView stepTable, ObservableList<StepTable> stepTableData, javafx.scene.control.TextArea poxText, javafx.scene.control.TextArea mininetText, javafx.scene.control.TextArea flowText) {
+ this.summaryTable = summary;
+ data = dataInstance;
+ summaryChart = chart;
+ finalSummaryTable = finalSummary;
+ finalSummaryData = finalSummaryDataInstance;
+ viewLogsButton = viewLogs;
+ this.pieChartData = pieChartData;
+ this.passData = passData;
+ this.failData = failData;
+ this.abortData = abortData;
+ this.noResultData = noResultData;
+ this.selectedTest = testName;
+ this.compononetLogText = componentLogText;
+ this.stepTable = stepTable;
+ this.stepSummaryData = stepTableData;
+ this.poxSessionText = poxText;
+ this.mininetSessionText = mininetText;
+ this.flowVisorSessionText = flowText;
+
+ }
+ String currentTestCase, testCaseName, testCaseStatus, testCaseStartTime, testCaseEndTime;
+
+ public void runTest() {
+
+
+
+ try {
+
+ summaryTable.setVisible(true);
+ getCaseName();
+ Iterator entries = caseNameHash.entrySet().iterator();
+ data = FXCollections.observableArrayList();
+ int index = 0;
+ while (entries.hasNext()) {
+ index++;
+ Map.Entry entry = (Map.Entry) entries.next();
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+ Image image = new Image(getClass().getResourceAsStream("/images/loading.gif"), 10, 10, true, true);
+ data.add(new SummaryTable(new Label(key), new Label(value), new Label("", new ImageView(image)), new Label(), new Label()));
+ }
+ summaryTable.setItems(data);
+ File file = new File(selectedTest);
+ String[] runThisFile = file.getName().split("\\.");
+ try {
+ XmlRpcClient server = new XmlRpcClient("http://localhost:9000");
+ Vector params = new Vector();
+ params.add(new String(selectedTest));
+ final Object result = server.execute("runTest", params);
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ ProcessBuilder header = new ProcessBuilder("/bin/sh", "-c", "head -20 " + result.toString());
+ Process headProcess;
+ try {
+ headProcess = header.start();
+ BufferedReader inputHeader = new BufferedReader(new InputStreamReader(headProcess.getInputStream()));
+ String lines;
+ String totalText = "";
+ while ((lines = inputHeader.readLine()) != null) {
+ try {
+ totalText = totalText + "\n" + lines;
+ updateData(lines);
+ } catch (Exception e) {
+ }
+ }
+ compononetLogText.appendText(totalText);
+ headProcess.destroy();
+ } catch (IOException ex) {
+ Logger.getLogger(ExecuteTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ String command = "tail -f " + result.toString();
+ File dir = new File(result.toString());
+ String parentPath = dir.getParent();
+ ProcessBuilder tail = new ProcessBuilder("/bin/sh", "-c", "tail -f " + result.toString());
+ Process process;
+ int nullcount = 0;
+ try {
+ while (true) {
+ process = tail.start();
+ BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
+ String line;
+ try {
+ while ((line = input.readLine()) != null) {
+ compononetLogText.appendText("\n" + line + "\n");
+ updateData(line);
+ }
+ if (input.readLine() == null) {
+ nullcount++;
+ }
+ if (nullcount == 2) {
+ process.destroy();
+ }
+
+ } catch (Exception e) {
+ }
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(ExecuteTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ String poxFileName = parentPath + "/" + "POX2.session";
+ String flowFileName = parentPath + "/" + "FlowVisor1.session";
+ String mininetFileName = parentPath + "/" + "Mininet1.session";
+ ProcessBuilder tailpox = new ProcessBuilder("/bin/sh", "-c", "tail -f " + poxFileName);
+ }
+ }).start();
+
+ r3 = new Runnable() {
+ public void run() {
+ try {
+ summaryChart.setVisible(true);
+ try {
+ pieChartData.set(0, new PieChart.Data("Pass", ExecuteTest.noOfPassed));
+ pieChartData.set(1, new PieChart.Data("Fail", ExecuteTest.noOfFailed));
+ pieChartData.set(2, new PieChart.Data("Abort", ExecuteTest.noOfAborted));
+ passData.setPieValue(1);
+ failData.setPieValue(0);
+ abortData.setPieValue(0);
+ noResultData.setPieValue(0);
+ summaryChart.getStylesheets().add(getClass().getResource("test.css").toExternalForm());
+ summaryChart.setData(pieChartData);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void updateData(String line) {
+
+ casePatt = Pattern.compile("\\s*Result\\s+summary\\s+for\\s+Testcase(\\d+)");
+ m = casePatt.matcher(line);
+ if (m.find()) {
+ Date dNow = new Date();
+ SimpleDateFormat ft = new SimpleDateFormat("hh:mm:ss a zzz dd.MM.yyyy");
+ testCaseStartTime = ft.format(dNow);
+ currentTestCase = m.group(1);
+ stepHash.clear();
+ getTestSteps(m.group(1));
+ Image image = new Image(getClass().getResourceAsStream("/images/loading.gif"), 10, 10, true, true);
+ Label statusImage = new Label("", new ImageView(image));
+ stepSummaryData = FXCollections.observableArrayList(new StepTable(new Label(""), new Label(""), new Label("")));
+ Iterator entries = stepHash.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry) entries.next();
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+ stepSummaryData.add(new StepTable(new Label(key), new Label(value), new Label("", new ImageView(image))));
+ }
+ stepTable.setItems(stepSummaryData);
+ }
+
+ namePatt = Pattern.compile("\\[(.*)\\]\\s*\\[(.*)\\]\\s*\\[\\s*CASE\\s*\\](.*)\\s*");
+ m = namePatt.matcher(line);
+
+ if (m.find()) {
+ testCaseName = m.group(3);
+ Image image = new Image(getClass().getResourceAsStream("/images/progress.png"));
+ statusImage = new Label("", new ImageView(image));
+ if (tableIndex < 0) {
+ data = FXCollections.observableArrayList(new SummaryTable(new Label(currentTestCase), new Label(testCaseName),
+ statusImage, new Label(testCaseStartTime), new Label()));
+ } else {
+ data.add(new SummaryTable(new Label(currentTestCase), new Label(testCaseName), statusImage,
+ new Label(testCaseStartTime), new Label("")));
+ }
+ tableIndex++;
+ }
+
+ stepPatt = Pattern.compile("\\[(.*)\\]\\s*\\[(.*)\\]\\s*\\[\\s*STEP\\s*\\]\\s*(\\d+)\\.(\\d+):(.*)\\s*");
+
+ m = stepPatt.matcher(line);
+ if (m.find()) {
+ String currentStepNumber = m.group(3) + "." + m.group(4);
+ for (int i = 1; i < stepSummaryData.size(); i++) {
+ if (stepSummaryData.get(i).getTestStepId().getText().equals(currentStepNumber)) {
+ Image image = new Image(getClass().getResourceAsStream("/images/progress.png"));
+ stepTableIndex = i;
+ stepSummaryData.set(i, new StepTable(new Label(stepSummaryData.get(i).getTestStepId().getText()), new Label(stepSummaryData.get(i).getTestStepName().getText()), new Label("", new ImageView(image))));
+ Image images = new Image(getClass().getResourceAsStream("/images/Pass_Icon.png"));
+ }
+ }
+
+ }
+
+ assertionPatt = Pattern.compile("\\s*(.*)\\s*-\\s*(\\w+)\\s*-\\s*(\\w+)\\s*-\\s*(.*)\\s*");
+ m = assertionPatt.matcher(line);
+ if (m.find() && stepTableIndex > -1) {
+ if (m.group(3).equals("INFO") && m.group(4).equals("Assertion Passed")) {
+ Image image = new Image(getClass().getResourceAsStream("/images/Pass_Icon.png"));
+ stepSummaryData.set(stepTableIndex, new StepTable(new Label(stepSummaryData.get(stepTableIndex).getTestStepId().getText()),
+ new Label(stepSummaryData.get(stepTableIndex).getTestStepName().getText()), new Label("", new ImageView(image))));
+ } else if (m.group(3).equals("WARNING") && m.group(4).equals("Assertion Failed")) {
+ Image image = new Image(getClass().getResourceAsStream("/images/Fail_Icon.png"));
+ stepSummaryData.set(stepTableIndex, new StepTable(new Label(stepSummaryData.get(stepTableIndex).getTestStepId().getText()),
+ new Label(stepSummaryData.get(stepTableIndex).getTestStepName().getText()), new Label("", new ImageView(image))));
+ XmlRpcClient server;
+ }
+
+ }
+
+ resultPatt = Pattern.compile("\\s*Result:\\s+(\\w+)\\s*");
+ m = resultPatt.matcher(line);
+ if (m.find()) {
+ testCaseStatus = m.group(1);
+ Date dNow = new Date();
+ Image image;
+ SimpleDateFormat ft = new SimpleDateFormat("hh:mm:ss a zzz dd.MM.yyyy");
+ testCaseEndTime = ft.format(dNow);
+ if (testCaseStatus.equalsIgnoreCase("No result")) {
+ image = new Image(getClass().getResourceAsStream("/images/noResult.png"));
+ statusImage = new Label("", new ImageView(image));;
+ ExecuteTest.noOfNoResult++;
+ }
+
+ if (testCaseStatus.equalsIgnoreCase("Pass")) {
+ image = new Image(getClass().getResourceAsStream("/images/Pass_Icon.png"));
+ statusImage = new Label("", new ImageView(image));
+ ExecuteTest.noOfPassed++;
+ }
+ if (testCaseStatus.equals("Failed")) {
+ image = new Image(getClass().getResourceAsStream("/images/Fail_Icon.png"));
+ statusImage = new Label("", new ImageView(image));
+ ExecuteTest.noOfFailed++;
+ } else if (testCaseStatus.equals("Aborted")) {
+ image = new Image(getClass().getResourceAsStream("/images/Abort_Icon.png"));
+ statusImage = new Label("", new ImageView(image));
+ this.noOfAborted++;
+ }
+ data.set(tableIndex, new SummaryTable(new Label(currentTestCase), new Label(testCaseName),
+ statusImage, new Label(testCaseStartTime), new Label(testCaseEndTime)));
+ summaryTable.setItems(data);
+ }
+
+ summaryPatt = Pattern.compile("\\s*Test+\\s+Execution(.*)");
+ m = summaryPatt.matcher(line);
+ if (m.find()) {
+ }
+
+ testStartPatt = Pattern.compile("Test\\s+Start\\s+\\:\\s+(.*)");
+ m = testStartPatt.matcher(line);
+ if (m.find()) {
+ Image image = new Image(getClass().getResourceAsStream("/images/Pass_Icon.png"));
+ statusImage = new Label("", new ImageView(image));
+ data.set(tableIndex, new SummaryTable(new Label(currentTestCase), new Label(testCaseName),
+ statusImage, new Label(testCaseStartTime), new Label(testCaseEndTime)));
+ stepTable.setVisible(false);
+ finalSummaryTable.setVisible(true);
+ summaryChart.setVisible(true);
+ finalSummaryData = FXCollections.observableArrayList(new FinalSummaryTable(new Label(""), new Label("")));
+ finalSummaryTable.setItems(finalSummaryData);
+ testStart = m.group(1);
+ finalSummaryData.set(0, new FinalSummaryTable(new Label("Test Start"), new Label(testStart)));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+ testEndPatt = Pattern.compile("Test\\s+End\\s+\\:\\s+(.*)");
+ m = testEndPatt.matcher(line);
+ if (m.find()) {
+ testEnd = m.group(1);
+ finalSummaryData.add(new FinalSummaryTable(new Label("Test End"), new Label(testEnd)));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+ testExecutionTimePatt = Pattern.compile("\\s*Execution\\s+Time\\s+\\:\\s+(.*)");
+ m = testExecutionTimePatt.matcher(line);
+ if (m.find()) {
+ testExecutionTime = m.group(1);
+ finalSummaryData.add(new FinalSummaryTable(new Label("Execution Time"), new Label(testExecutionTime)));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+ testsPlannedPatt = Pattern.compile("\\s*Total\\s+tests\\s+planned\\s+\\:\\s*(.*)");
+ m = testsPlannedPatt.matcher(line);
+ if (m.find()) {
+ testsPlanned = m.group(1);
+ finalSummaryData.add(new FinalSummaryTable(new Label("Total Tests Planned"), new Label(testsPlanned)));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+
+ testsRunPatt = Pattern.compile("\\s*Total\\s+tests\\s+Run\\s+\\:\\s+(.*)");
+ m = testsRunPatt.matcher(line);
+ if (m.find()) {
+ testsRun = m.group(1);
+ finalSummaryData.add(new FinalSummaryTable(new Label("Total Tests Run"), new Label(testsRun)));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+ totalPassPatt = Pattern.compile("Total\\s+Pass\\s+\\:\\s+(.*)");
+ m = totalPassPatt.matcher(line);
+ if (m.find()) {
+ totalPass = m.group(1);
+ Label totalPassL = new Label("Total Pass");
+ totalPassL.setTextFill(Color.GREEN);
+ totalPassL.setStyle("-fx-font-weight: bold");
+ Label totalPassValue = new Label(totalPass);
+ totalPassValue.setTextFill(Color.GREEN);
+ totalPassValue.setStyle("-fx-font-weight: bold");
+ finalSummaryData.add(new FinalSummaryTable(totalPassL, totalPassValue));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+ totalFailPatt = Pattern.compile("Total\\s+Fail\\s+\\:\\s+(.*)");
+ m = totalFailPatt.matcher(line);
+ if (m.find()) {
+ totalFail = m.group(1);
+ Label totalFailL = new Label("Total Fail");
+ totalFailL.setTextFill(Color.RED);
+ totalFailL.setStyle("-fx-font-weight: bold");
+ Label totalFailValue = new Label(totalFail);
+ totalFailValue.setTextFill(Color.RED);
+ totalFailValue.setStyle("-fx-font-weight: bold");
+ finalSummaryData.add(new FinalSummaryTable(totalFailL, totalFailValue));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+
+ totalreRun = Pattern.compile("Total\\s+Re\\-Run\\s+\\:\\s+(.*)");
+ m = totalreRun.matcher(line);
+ if (m.find()) {
+ Label totalReRun = new Label("Total Re-Run");
+ totalReRun.setTextFill(Color.BLUE);
+ totalReRun.setStyle("-fx-font-weight: bold");
+ Label totalReRunValue = new Label(m.group(1));
+ totalReRunValue.setTextFill(Color.BLUE);
+ totalReRunValue.setStyle("-fx-font-weight: bold");
+ finalSummaryData.add(new FinalSummaryTable(totalReRun, totalReRunValue));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+
+ noResultPatt = Pattern.compile("Total\\s+No\\s+Result\\s+\\:\\s+(.*)");
+ m = noResultPatt.matcher(line);
+ if (m.find()) {
+ noResult = m.group(1);
+ finalSummaryData.add(new FinalSummaryTable(new Label("Total No-Result"), new Label(noResult)));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+
+ totalAbortPatt = Pattern.compile("Total\\sabort\\s+\\:\\s+(.*)");
+ m = totalAbortPatt.matcher(line);
+ if (m.find()) {
+ totalAbort = m.group(1);
+ finalSummaryData.add(new FinalSummaryTable(new Label("Total Abort"), new Label(totalAbort)));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+ execPercentagePatt = Pattern.compile("Execution\\s+Result\\s+\\:\\s+(.*)");
+ m = execPercentagePatt.matcher(line);
+ if (m.find()) {
+ execPercentage = m.group(1);
+ finalSummaryData.add(new FinalSummaryTable(new Label("Execution Percentage"), new Label(execPercentage)));
+ finalSummaryTable.setItems(finalSummaryData);
+ Platform.runLater(r3);
+ }
+ successPercentagePatt = Pattern.compile("Success\\s+Percentage\\s+\\:\\s+(.*)");
+ m = successPercentagePatt.matcher(line);
+ if (m.find()) {
+ successPercentage = m.group(1);
+ finalSummaryData.add(new FinalSummaryTable(new Label("Success Percentage"), new Label(successPercentage)));
+ finalSummaryTable.setItems(finalSummaryData);
+ }
+ }
+
+ public ExecuteTest() {
+ }
+
+ public String getTestCase() {
+ return currentTestCase;
+ }
+
+ public void getTestSteps(String caseNumber) {
+ OFAFileOperations fileOperation = new OFAFileOperations();
+ int stepCount = 0;
+ String stepCounter = "";
+ String ospkFileName = label.hierarchyTestON + "/tests/" + selectedTest + "/" + selectedTest + ".ospk";
+ String pythonScriptName = label.hierarchyTestON + "/tests/" + selectedTest + "/" + selectedTest + ".py";
+ BufferedReader input = null;
+ ArrayList<String> contents = new ArrayList<String>();
+ File scriptName = new File(ospkFileName);
+ if (scriptName.exists()) {
+ try {
+ //use buffering, reading one line at a time
+ //FileReader always assumes default encoding is OK!
+ try {
+ input = new BufferedReader(new FileReader(scriptName));
+ } catch (Exception e) {
+ }
+
+ try {
+ String line = null; //not declared within while loop
+ while ((line = input.readLine()) != null) {
+ contents.add(line);
+ }
+ } finally {
+ try {
+ input.close();
+ } catch (Exception e) {
+ }
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ for (int i = 0; i < contents.size(); i++) {
+ Pattern casePattern = Pattern.compile("\\s*CASE\\s*(\\d+)\\s*");
+ Matcher caseMatcher = casePattern.matcher(contents.get(i));
+ if (caseMatcher.find()) {
+ if (caseMatcher.group(1).equals(caseNumber)) {
+ i++;
+ Pattern casePatterns = Pattern.compile("\\s*CASE\\s*(\\d+)\\s*");
+ Matcher caseMatchers = casePatterns.matcher(contents.get(i));
+ while (!caseMatchers.find() && i < contents.size()) {
+ Pattern casesPatterns = Pattern.compile("\\s*CASE\\s*(\\d+)\\s*");
+ Matcher casesMatchers = casesPatterns.matcher(contents.get(i));
+ if (casesMatchers.find()) {
+ break;
+ } else {
+ Pattern stepPattern = Pattern.compile("\\s*STEP\\s+\"\\s*(.*)\\s*\"\\s*");
+ Matcher stepMatcher = stepPattern.matcher(contents.get(i));
+ try {
+ if (stepMatcher.find()) {
+ stepCount++;
+ stepCounter = caseNumber + "." + String.valueOf(stepCount);
+ stepHash.put(stepCounter, stepMatcher.group(1));
+ }
+ } catch (Exception e) {
+ break;
+ }
+ i++;
+ }
+
+ }
+ i--;
+ }
+
+ }
+ }
+ } else {
+ try {
+ //use buffering, reading one line at a time
+ //FileReader always assumes default encoding is OK!
+ try {
+ input = new BufferedReader(new FileReader(pythonScriptName));
+
+ } catch (Exception e) {
+ }
+
+ try {
+ String line = null; //not declared within while loop
+
+ while ((line = input.readLine()) != null) {
+ contents.add(line);
+ }
+ } finally {
+ try {
+ input.close();
+ } catch (Exception e) {
+ }
+
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ for (int i = 0; i < contents.size(); i++) {
+ Pattern casePattern = Pattern.compile("\\s*def\\s+CASE(\\d+)\\s*\\(\\s*(.*)\\s*\\)\\s*:\\s*");
+ Matcher caseMatcher = casePattern.matcher(contents.get(i));
+ if (caseMatcher.find()) {
+ if (caseMatcher.group(1).equals(caseNumber)) {
+ i++;
+ Pattern casePatterns = Pattern.compile("\\s*def\\s+CASE(\\d+)\\s*\\(\\s*(.*)\\s*\\)\\s*:\\s*");
+ Matcher caseMatchers = casePatterns.matcher(contents.get(i));
+ while (!caseMatchers.find() && i < contents.size()) {
+ Pattern casesPatterns = Pattern.compile("\\s*def\\s+CASE(\\d+)\\s*\\(\\s*(.*)\\s*\\)\\s*:\\s*");
+ Matcher casesMatchers = casesPatterns.matcher(contents.get(i));
+ if (casesMatchers.find()) {
+ break;
+ } else {
+ Pattern stepPattern = Pattern.compile("\\s*main.step\\(\\s*\"\\s*(.*)\\s*\"\\s*\\)\\s*");
+ Matcher stepMatcher = stepPattern.matcher(contents.get(i));
+ try {
+ if (stepMatcher.find()) {
+ stepCount++;
+ stepCounter = caseNumber + "." + String.valueOf(stepCount);
+ stepHash.put(stepCounter, stepMatcher.group(1));
+ }
+ } catch (Exception e) {
+ break;
+ }
+ i++;
+ }
+ }
+ i--;
+ }
+ }
+ }
+ }
+ }
+
+ public void getCaseName() {
+ int stepCount = 0;
+ String stepCounter = "";
+ String paramFilePath = label.hierarchyTestON + "/tests/" + selectedTest + "/" + selectedTest + ".params";
+ FileInputStream fstream;
+ String testCases = "";
+ ArrayList<String> paramFileName = new ArrayList<String>();
+ ArrayList<String> nameBetweenTags = new ArrayList<String>();
+ try {
+ fstream = new FileInputStream(paramFilePath);
+ DataInputStream in = new DataInputStream(fstream);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+ try {
+ while ((strLine = br.readLine()) != null) {
+ paramFileName.add(strLine);
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(ExecuteTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(ExecuteTest.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ for (int index = 0; index < paramFileName.size(); index++) {
+ Pattern testsPattern = Pattern.compile("<testcases>\\s*(.*)\\s*</testcases>");
+ Matcher testMatcher = testsPattern.matcher(paramFileName.get(index));
+ if (testMatcher.find()) {
+ testCases = testMatcher.group(1);
+ testCases = testCases.replaceAll(" ", "");
+ }
+
+ }
+
+ String[] testArray = null;
+ testArray = testCases.split(",");
+ String ospkFileName = label.hierarchyTestON + "/tests/" + selectedTest + "/" + selectedTest + ".ospk";
+ String pythonScriptName = label.hierarchyTestON + "/tests/" + selectedTest + "/" + selectedTest + ".py";
+ BufferedReader input = null;
+ ArrayList<String> contents = new ArrayList<String>();
+ File scriptName = new File(ospkFileName);
+ String caseId = "";
+ String caseName = "";
+ if (scriptName.exists()) {
+ try {
+ FileInputStream fstream1 = new FileInputStream(ospkFileName);
+ ArrayList<String> driverFunctionName = new ArrayList<String>();
+ DataInputStream in = new DataInputStream(fstream1);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+ while ((strLine = br.readLine()) != null) {
+ Pattern casePattern = Pattern.compile("^CASE\\s+(\\d+)");
+ Matcher match = casePattern.matcher(strLine);
+ while (match.find()) {
+ driverFunctionName.add(match.group());
+ caseId = match.group(1);
+ strLine = br.readLine();
+ casePattern = Pattern.compile("NAME\\s+(\\\"+(.*)\\\")");
+ match = casePattern.matcher(strLine);
+ if (match.find()) {
+ caseName = match.group(2);
+ }
+ caseNameHash.put(caseId, caseName);
+ }
+ }
+ } catch (Exception e) {
+ }
+ } else {
+ try {
+
+ FileInputStream fstream2 = new FileInputStream(pythonScriptName);
+ ArrayList<String> driverFunctionName = new ArrayList<String>();
+ DataInputStream in = new DataInputStream(fstream2);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+ while ((strLine = br.readLine()) != null) {
+ Pattern casePattern = Pattern.compile("\\s*def\\s+CASE(\\d+)\\s*\\(\\s*(.*)\\s*\\)\\s*:\\s*");
+ Matcher match = casePattern.matcher(strLine);
+ if (match.find()) {
+ driverFunctionName.add(match.group());
+ if (Arrays.asList(testArray).contains(match.group(1))) {
+ caseId = match.group(1);
+ } else {
+ caseId = null;
+ }
+ strLine = br.readLine();
+ }
+
+ casePattern = Pattern.compile("\\s*main.case\\(\\s*\"\\s*(.*)\\s*\"\\s*\\)\\s*");
+ match = casePattern.matcher(strLine);
+
+ if (match.find()) {
+ caseName = match.group(1);
+ if (caseId != null) {
+ caseNameHash.put(caseId, caseName);
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/ExecutionConsole.java b/TestON/TAI/src/tai_ofa/ExecutionConsole.java
new file mode 100644
index 0000000..b88d586
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/ExecutionConsole.java
@@ -0,0 +1,98 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import javafx.application.Application;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.geometry.Pos;
+import javafx.scene.Group;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.control.TextField;
+import javafx.scene.control.TextFieldBuilder;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.StackPane;
+import javafx.scene.layout.VBox;
+import javafx.stage.Stage;
+
+/**
+ *
+ * @author Raghav Kashyap raghavkashyap@paxterrasolutions.com
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class ExecutionConsole extends Application {
+
+ Stage copyStage;
+ Scene scene;
+ TextField value ;
+ String Title,enteredValue ;
+ Button submit ;
+ ExecutionConsole(String Title,Button enter, TextField value) {
+ this.Title = Title;
+ this.submit = enter;
+ this.value = value;
+ }
+
+ @Override public void start(final Stage primaryStage) throws Exception {
+ copyStage = primaryStage;
+
+ Group root = new Group();
+ GridPane basePane = new GridPane();
+ basePane.setPadding(new Insets(2, 0, 2, 0));
+ basePane.setVgap(5);
+ basePane.setHgap(2);
+ value.setEditable(true);
+ value.clear();
+ enteredValue = "";
+ Label info = new Label("Please pass the appropriate value");
+
+
+ basePane.add(value, 0, 1);
+ basePane.add(submit, 1, 1);
+ basePane.add(info, 0, 0);
+ scene = new Scene(root, 550, 60);
+
+ root.getChildren().addAll(basePane);
+ primaryStage.setTitle(Title);
+ primaryStage.setScene(scene);
+ primaryStage.show();
+ }
+
+ public void closeWindow(){
+ copyStage.close();
+ }
+ public void setValue(String value){
+ enteredValue = value;
+ }
+ public String getValue(){
+ return enteredValue;
+ }
+
+ public void setTitles(String title){
+ copyStage.setTitle(title);
+ }
+
+}
diff --git a/TestON/TAI/src/tai_ofa/FinalSummaryTable.java b/TestON/TAI/src/tai_ofa/FinalSummaryTable.java
new file mode 100644
index 0000000..5ed908b
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/FinalSummaryTable.java
@@ -0,0 +1,57 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import javafx.scene.control.Label;
+
+/**
+ *
+ * @author Raghav Kashyap raghavkashyap@paxterrasolutions.com
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+
+public class FinalSummaryTable {
+ public Label summaryItem;
+ public Label information;
+
+ public FinalSummaryTable() {
+
+ }
+ public FinalSummaryTable(Label summaryItem, Label information) {
+
+ this.summaryItem = summaryItem;
+ this.information = information;
+
+ }
+
+
+ public Label getSummaryItem() {
+ return summaryItem;
+ }
+ public void setSummaryItem(Label newSummaryItem) {
+ summaryItem = newSummaryItem;
+ }
+ public Label getInformation() {
+ return information;
+ }
+ public void setInformation(Label newInformation) {
+ information = newInformation;
+ }
+
+}
+
diff --git a/TestON/TAI/src/tai_ofa/LoadDirectory.java b/TestON/TAI/src/tai_ofa/LoadDirectory.java
new file mode 100644
index 0000000..25eb317
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/LoadDirectory.java
@@ -0,0 +1,204 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.io.File;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+import javafx.event.Event;
+import javafx.event.EventHandler;
+import javafx.scene.Node;
+import javafx.scene.control.TreeItem;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class LoadDirectory extends TreeItem<String> {
+
+ //this stores the full path to the file or directory
+ OFAFileOperations fileOperation = new OFAFileOperations();
+ private String fullPath;
+
+ public String getFullPath() {
+ return (this.fullPath);
+ }
+ private boolean isDirectory;
+
+ public boolean isDirectory() {
+ return (this.isDirectory);
+ }
+
+ public LoadDirectory(Path file) {
+ super(file.toString());
+ this.fullPath = file.toString();
+
+ if (Files.isDirectory(file)) {
+ this.isDirectory = true;
+
+ if ("common".equals(file.getFileName().toString())) {
+ Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("/images/project.jpeg"), 20, 20, true, true));
+ rootIcon.setId("/images/project.jpeg");
+ this.setGraphic(rootIcon);
+ } else if ("cli".equalsIgnoreCase(file.getFileName().toString())) {
+ Node rootIcon2 = new ImageView(new Image(getClass().getResourceAsStream("/images/terminal.png"), 20, 20, true, true));
+ rootIcon2.setId("/images/terminal.png");
+ this.setGraphic(rootIcon2);
+ } else if ("api".equals(file.getFileName().toString())) {
+ Node rootIcon3 = new ImageView(new Image(getClass().getResourceAsStream("/images/api.jpg"), 20, 20, true, true));
+ rootIcon3.setId("/images/api.jpg");
+ this.setGraphic(rootIcon3);
+ } else if ("tool".equals(file.getFileName().toString())) {
+ Node rootIcon4 = new ImageView(new Image(getClass().getResourceAsStream("/images/tool.jpg"), 20, 20, true, true));
+ this.setGraphic(rootIcon4);
+ } else if ("remotesys".equals(file.getFileName().toString())) {
+ Node rootIcon5 = new ImageView(new Image(getClass().getResourceAsStream("/images/automatorui.png"), 20, 20, true, true));
+ this.setGraphic(rootIcon5);
+ } else if ("emulator".equals(file.getFileName().toString())) {
+ Node rootIcon6 = new ImageView(new Image(getClass().getResourceAsStream("/images/emulator.jpg"), 20, 20, true, true));
+ this.setGraphic(rootIcon6);
+ } else if ("controller".equals(file.getFileName().toString())) {
+ Node rootIcon6 = new ImageView(new Image(getClass().getResourceAsStream("/images/controller.jpg"), 20, 20, true, true));
+ this.setGraphic(rootIcon6);
+ } else if ("remotetestbed".equals(file.getFileName().toString())) {
+ Node rootIcon5 = new ImageView(new Image(getClass().getResourceAsStream("/images/testbed.jpg"), 20, 20, true, true));
+ this.setGraphic(rootIcon5);
+ }
+
+ } else {
+ this.isDirectory = false;
+ String fileName = file.getFileName().toString();
+ String ext = fileOperation.getExtension(fileName);
+ if (".py".equals(ext)) {
+ if ("fvtapidriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon7 = new ImageView(new Image(getClass().getResourceAsStream("/images/flowvisor.png"), 20, 20, true, true));
+ rootIcon7.setId("/images/flowvisor.png");
+ this.setGraphic(rootIcon7);
+ } else if ("mininetclidriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon8 = new ImageView(new Image(getClass().getResourceAsStream("/images/mininet.jpg"), 20, 20, true, true));
+ rootIcon8.setId("/images/mininet.jpg");
+ this.setGraphic(rootIcon8);
+ } else if ("poxclidriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon9 = new ImageView(new Image(getClass().getResourceAsStream("/images/pox.jpg"), 20, 20, true, true));
+ rootIcon9.setId("/images/pox.jpg");
+ this.setGraphic(rootIcon9);
+ } else if ("dpctlclidriver.py".equals(fileName)) {
+ Node rootIcon10 = new ImageView(new Image(getClass().getResourceAsStream("/images/dpctl.jpg"), 20, 20, true, true));
+ rootIcon10.setId("/images/dpctl.jpg");
+ this.setGraphic(rootIcon10);
+ } else if ("hpswitchclidriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon11 = new ImageView(new Image(getClass().getResourceAsStream("/images/hp.jpg"), 20, 20, true, true));
+ rootIcon11.setId("/images/hp.jpg");
+ this.setGraphic(rootIcon11);
+ } else if ("cisco.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon12 = new ImageView(new Image(getClass().getResourceAsStream("/images/Cisco.png"), 20, 20, true, true));
+ rootIcon12.setId("/images/Cisco.png");
+ this.setGraphic(rootIcon12);
+ } else if ("flowvisorclidriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon12 = new ImageView(new Image(getClass().getResourceAsStream("/images/flowvisor.png"), 20, 20, true, true));
+ rootIcon12.setId("/images/flowvisor.png");
+ this.setGraphic(rootIcon12);
+ } else if ("floodlightclidriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon11 = new ImageView(new Image(getClass().getResourceAsStream("/images/floodlight.jpg"), 20, 20, true, true));
+ rootIcon11.setId("/images/floodlight.jpg");
+ this.setGraphic(rootIcon11);
+ } else if ("remotevmdriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon11 = new ImageView(new Image(getClass().getResourceAsStream("/images/remotevm.jpg"), 20, 20, true, true));
+ rootIcon11.setId("/images/remotevm.jpg");
+ this.setGraphic(rootIcon11);
+ } else if ("remotepoxdriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon11 = new ImageView(new Image(getClass().getResourceAsStream("/images/pox.jpg"), 20, 20, true, true));
+ rootIcon11.setId("/images/pox.jpg");
+ this.setGraphic(rootIcon11);
+ } else if ("flowvisordriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon11 = new ImageView(new Image(getClass().getResourceAsStream("/images/flowvisor.png"), 20, 20, true, true));
+ rootIcon11.setId("/images/flowvisor.png");
+ this.setGraphic(rootIcon11);
+ } else if ("switchclidriver.py".equalsIgnoreCase(fileName)) {
+ Node rootIcon11 = new ImageView(new Image(getClass().getResourceAsStream("/images/switchVM.png"), 20, 20, true, true));
+ rootIcon11.setId("/images/switchVM.png");
+ this.setGraphic(rootIcon11);
+ } else {
+ Node rootIcon6 = new ImageView(new Image(getClass().getResourceAsStream("/images/defaultTerminal.png"), 20, 20, true, true));
+ rootIcon6.setId("/images/defaultTerminal.png");
+ this.setGraphic(rootIcon6);
+ }
+ }
+ //if you want different icons for different file types this is where you'd do it
+ }
+ if (!fullPath.endsWith(File.separator)) {
+ String finalValue = null;
+ String value = file.getFileName().toString();
+ String ext = fileOperation.getExtension(value);
+ if (ext == null) {
+ this.setValue(value);
+ } else {
+ if (ext.equals(".py")) {
+ finalValue = value.replace(ext, "");
+ }
+ this.setValue(finalValue);
+ }
+
+ }
+ this.addEventHandler(TreeItem.branchExpandedEvent(), new EventHandler() {
+ @Override
+ public void handle(Event e) {
+ LoadDirectory source = (LoadDirectory) e.getSource();
+ if (source.isDirectory() && source.isExpanded()) {
+ }
+ try {
+ if (source.getChildren().isEmpty()) {
+ Path path = Paths.get(source.getFullPath());
+ BasicFileAttributes attribs = Files.readAttributes(path, BasicFileAttributes.class);
+ if (attribs.isDirectory()) {
+ DirectoryStream<Path> dir = Files.newDirectoryStream(path);
+ for (Path file : dir) {
+ LoadDirectory treeNode = new LoadDirectory(file);
+ if (treeNode.getValue() != null && !treeNode.getValue().equals("__init__") && !treeNode.getValue().equals("controllerdriver") && !treeNode.getValue().equals("apidriver")
+ && !treeNode.getValue().equals("clidriver") && !treeNode.getValue().equals("controllerdriver") && !treeNode.getValue().equals("emulatordriver") && !treeNode.getValue().equals("toolsdriver") && !treeNode.getValue().equals("remotesysdriver")) //source.getChildren().add(treeNode);
+ {
+ source.getChildren().add(treeNode);
+ }
+ treeNode.setExpanded(true);
+ }
+ }
+ }
+
+ } catch (Exception ex) {
+ }
+ }
+ });
+ this.addEventHandler(TreeItem.branchCollapsedEvent(), new EventHandler() {
+ @Override
+ public void handle(Event e) {
+ LoadDirectory source = (LoadDirectory) e.getSource();
+ if (source.isDirectory() && !source.isExpanded()) {
+ ImageView iv = (ImageView) source.getGraphic();
+ }
+ }
+ });
+
+
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFAAnchorInsideImageNode.java b/TestON/TAI/src/tai_ofa/OFAAnchorInsideImageNode.java
new file mode 100644
index 0000000..1cb382b
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFAAnchorInsideImageNode.java
@@ -0,0 +1,347 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import javafx.beans.property.DoubleProperty;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.scene.Cursor;
+import javafx.scene.Node;
+import javafx.scene.control.Button;
+import javafx.scene.input.MouseButton;
+import javafx.scene.input.MouseDragEvent;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.VBox;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Circle;
+import javafx.scene.shape.Line;
+import javafx.scene.shape.StrokeLineCap;
+import javafx.stage.Stage;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+class OFAAnchorInsideImageNode {
+
+ Double increaseBindX;
+ Double increaseBindY;
+ /*Double addX and addY is passed as an argument as binding coordinates are different for Wizard
+ and toplogyNode(In the editor)*/
+
+ public OFAAnchorInsideImageNode(Double addX, Double addY) {
+ increaseBindX = addX;
+ increaseBindY = addY;
+ }
+ boolean anchorFlag = false;
+ OFATopologyLink topologyLink = new OFATopologyLink();
+ ArrayList<HashMap<String, String>> arrayOfLinkTopologyHash = new ArrayList<HashMap<String, String>>();
+
+ public void anchorsInsideImage(final TopologyWizard.Anchor anchor, final double bindLineStartx, final double bindLineStarty, final double bindLineEndx, final double bindLineEndy, final Pane hb, final DraggableNode content,
+ final VBox hbox, final Line con, final ArrayList<String> draggedImagesName, final ArrayList<HashMap<String, String>> arrayOfInterFaceHash, final HashMap<String, String> linkTopologyHash, final HashMap<Node, String> anchorNodeHash) {
+ final Line con11 = new Line();
+
+ anchor.setOnDragDetected(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ anchor.startFullDrag();
+ enableDrag(anchor);
+ }
+ });
+
+ anchor.setOnMouseDragReleased(new EventHandler<MouseDragEvent>() {
+ @Override
+ public void handle(MouseDragEvent arg0) {
+ ObservableList<Node> allNodesCanvas = hb.getChildren();
+ boolean flag = false;
+ String startNode = null;
+ String endNode = null;
+ try {
+ for (Node node : allNodesCanvas) {
+ Double x = node.getLayoutX() + increaseBindX;
+ Double y = node.getLayoutY() + increaseBindY;
+ if (node.toString().startsWith("DraggableNode")) {
+ for (int i = 0; i <= 80; i++) {
+ for (int j = 0; j <= 100; j++) {
+ Double x1 = node.getLayoutX() + increaseBindX;
+ Double y1 = node.getLayoutY() + increaseBindY;
+ Double x11 = x1 + i;
+ Double y11 = y1 + j;
+ if (x11 == arg0.getSceneX()) {
+ if (y11 == arg0.getSceneY()) {
+ con11.setStrokeLineCap(StrokeLineCap.ROUND);
+ con11.setStroke(Color.MIDNIGHTBLUE);
+ con11.setStrokeWidth(2.0);
+ con11.startXProperty().bind(content.layoutXProperty().add(bindLineStartx));
+ con11.startYProperty().bind(content.layoutYProperty().add(bindLineStarty));
+ startNode = ((Integer) content.hashCode()).toString();
+ con11.endXProperty().bind(node.layoutXProperty().add(bindLineEndx));
+ con11.endYProperty().bind(node.layoutYProperty().add(bindLineEndy));
+ endNode = ((Integer) node.hashCode()).toString();
+ con11.setId(startNode + "," + endNode);
+ hbox.setStyle("-fx-border-color: Transparent");
+ con.setVisible(false);
+ anchor.setVisible(false);
+ hb.getChildren().add(con11);
+ flag = true;
+
+ Map<Node, String> map = anchorNodeHash;
+ Iterator<Map.Entry<Node, String>> entries = map.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry<Node, String> entry = entries.next();
+ entry.getKey();
+ hb.getChildren().remove(entry.getKey());
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+
+ }
+ if (flag == false) {
+ Map<Node, String> map = anchorNodeHash;
+ Iterator<Map.Entry<Node, String>> entries = map.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry<Node, String> entry = entries.next();
+ entry.getKey();
+ hb.getChildren().remove(entry.getKey());
+ anchorFlag = false;
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ });
+ con11.setOnMouseEntered(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ con11.setStroke(Color.GOLD);
+ }
+ });
+ con11.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ con11.setStroke(Color.MIDNIGHTBLUE);
+ }
+ });
+ final DraggableNode contentLine = new DraggableNode();
+ con11.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ topologyLink.start(new Stage());
+ if (arrayOfLinkTopologyHash.isEmpty()) {
+ for (HashMap<String, String> linkHash : arrayOfLinkTopologyHash) {
+ Set linkSet = linkHash.entrySet();
+ Iterator linkHashDetailIterator = linkSet.iterator();
+ while (linkHashDetailIterator.hasNext()) {
+
+ Map.Entry linkMap = (Map.Entry) linkHashDetailIterator.next();
+ if (linkMap.getKey().toString().equals(con11.getId())) {
+ String[] linkValues = linkMap.getValue().toString().split("_");
+ topologyLink.nameText.setText(linkValues[0]);
+ topologyLink.typeText.setText(linkValues[1]);
+ topologyLink.devicesInTopoEditor.setEditable(true);
+ topologyLink.devicesInTopoEditor.getSelectionModel().select(linkValues[2]);
+ topologyLink.interfaceList2.setEditable(true);
+ topologyLink.interfaceList2.getSelectionModel().select(linkValues[3]);
+ topologyLink.destDevicesInTopoEditor.setEditable(true);
+ topologyLink.destDevicesInTopoEditor.getSelectionModel().select(linkValues[4]);
+ topologyLink.interfaceList4.setEditable(true);
+ topologyLink.interfaceList4.getSelectionModel().select(linkValues[5]);
+ }
+ }
+
+ }
+ }
+
+ for (String string : draggedImagesName) {
+ topologyLink.devicesInTopoEditor.getItems().add(string);
+ topologyLink.destDevicesInTopoEditor.getItems().add(string);
+ }
+ topologyLink.devicesInTopoEditor.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ topologyLink.interfaceList2.getItems().clear();
+ try {
+ for (HashMap<String, String> interFaceDetail : arrayOfInterFaceHash) {
+ Set set = interFaceDetail.entrySet();
+ Iterator interFaceHashDetailIterator = set.iterator();
+ while (interFaceHashDetailIterator.hasNext()) {
+ Map.Entry me = (Map.Entry) interFaceHashDetailIterator.next();
+ String[] deviceNameAndiniterFaceValue = me.getValue().toString().split("\\_");
+ if (deviceNameAndiniterFaceValue[1].equals(topologyLink.devicesInTopoEditor.getSelectionModel().getSelectedItem())) {
+ if (!me.getKey().toString().equals("")) {
+ topologyLink.interfaceList2.getItems().add(me.getKey().toString());
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ });
+
+ topologyLink.destDevicesInTopoEditor.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+
+ topologyLink.interfaceList4.getItems().clear();
+ try {
+ for (HashMap<String, String> interFaceDetail : arrayOfInterFaceHash) {
+ Set set = interFaceDetail.entrySet();
+ Iterator interFaceHashDetailIterator = set.iterator();
+ while (interFaceHashDetailIterator.hasNext()) {
+ Map.Entry me = (Map.Entry) interFaceHashDetailIterator.next();
+ String[] deviceNameAndiniterFaceValue = me.getValue().toString().split("\\_");
+ if (deviceNameAndiniterFaceValue[1].equals(topologyLink.destDevicesInTopoEditor.getSelectionModel().getSelectedItem())) {
+ if (!me.getKey().toString().equals("")) {
+ topologyLink.interfaceList4.getItems().add(me.getKey().toString());
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ });
+ topologyLink.finishSelectedLink.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ con11.setId(topologyLink.nameText.getText() + "_" + con11.getStartX() + "_" + con11.getStartY() + "_" + con11.getEndX() + "_" + con11.getEndY());
+ String detailedString = topologyLink.nameText.getText() + "_" + topologyLink.typeText.getText() + "_" + topologyLink.devicesInTopoEditor.getSelectionModel().getSelectedItem() + "_" + topologyLink.interfaceList2.getSelectionModel().getSelectedItem() + "_" + topologyLink.destDevicesInTopoEditor.getSelectionModel().getSelectedItem() + "_" + topologyLink.interfaceList4.getSelectionModel().getSelectedItem() + "_";
+ linkTopologyHash.put(con11.getId(), detailedString);
+ arrayOfLinkTopologyHash = new ArrayList<HashMap<String, String>>();
+ arrayOfLinkTopologyHash.add(linkTopologyHash);
+ topologyLink.copyStage.close();
+ }
+ });
+ } else if (arg0.getButton() == MouseButton.SECONDARY) {
+ }
+ }
+ });
+ }
+
+ public void closeNodeOnCanvas(final Button closeButton, final VBox hbox, final Pane hb, final DraggableNode content) {
+ final ArrayList<Node> removeNodes = new ArrayList<Node>();
+
+ closeButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ Node parent = hbox.getParent();
+ ObservableList<Node> allCurrentNode = hb.getChildren();
+ for (Node node : allCurrentNode) {
+ if (node.toString().contains("Line")) {
+ if (!node.toString().matches("Line[id=Line[id=null,null]]")) {
+ if (node.getId() != null) {
+ String[] startLineNode = node.getId().split(",");
+ Integer nodeHash = content.hashCode();
+ if (nodeHash.toString().equals(startLineNode[0])) {
+ removeNodes.add(node);
+ }
+ if (startLineNode.length == 2) {
+ if (nodeHash.toString().equals(startLineNode[1])) {
+ removeNodes.add(node);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (Node removenode : removeNodes) {
+ hb.getChildren().remove(removenode);
+ }
+
+ hb.getChildren().remove(content);
+ }
+ });
+ }
+
+ private void enableDrag(final Circle circle) {
+ final OFAAnchorInsideImageNode.Delta dragDelta = new OFAAnchorInsideImageNode.Delta();
+
+ circle.setOnMousePressed(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ dragDelta.x = circle.getCenterX() - mouseEvent.getX();
+ dragDelta.y = circle.getCenterY() - mouseEvent.getY();
+ circle.getScene().setCursor(Cursor.MOVE);
+ }
+ });
+
+ circle.setOnMouseReleased(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ }
+ });
+
+ circle.setOnMouseDragged(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ circle.setCenterX(mouseEvent.getX() + dragDelta.x);
+ circle.setCenterY(mouseEvent.getY() + dragDelta.y);
+ }
+ });
+
+ circle.setOnMouseEntered(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ if (!mouseEvent.isPrimaryButtonDown()) {
+ circle.getScene().setCursor(Cursor.HAND);
+ }
+ }
+ });
+
+ circle.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ if (!mouseEvent.isPrimaryButtonDown()) {
+ }
+ }
+ });
+ }
+
+ class Anchor extends Circle {
+
+ Anchor(String id, DoubleProperty x, DoubleProperty y) {
+ super(x.get(), y.get(), 7);
+ setId(id);
+ setFill(Color.ANTIQUEWHITE.deriveColor(1, 1, 1, 0.75));
+ setStroke(Color.GREY);
+ x.bind(centerXProperty());
+ y.bind(centerYProperty());
+ }
+ }
+
+ class Delta {
+
+ double x, y;
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFAContentHelp.java b/TestON/TAI/src/tai_ofa/OFAContentHelp.java
new file mode 100644
index 0000000..083daf5
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFAContentHelp.java
@@ -0,0 +1,705 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Side;
+import javafx.scene.Group;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.Label;
+import javafx.scene.control.ListView;
+import javafx.scene.control.MenuItem;
+import javafx.scene.control.TextField;
+import javafx.scene.input.KeyCode;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.StackPane;
+
+/**
+ *
+ * @author Raghav kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class OFAContentHelp {
+
+ ContextMenu assertContext;
+ ArrayList<MenuItem> assertNameList;
+ CodeEditor Content;
+ TAI_OFA OFAReference;
+ String ospkCommand;
+ boolean keyPressed = false;
+ ArrayList<String> checkBuffer;
+ ContextMenu contextMenu, driverFunctionContextMenu;
+ ArrayList<String> myDevices;
+ ArrayList<MenuItem> myMenuItems;
+ ArrayList<String> driverFunctionName;
+ ArrayList<MenuItem> functionMenuItem;
+ OFAParamDeviceName paramFile;
+ String deviceTypePath;
+ ContextMenu commandNameContextMenu, withContextMenu, runDriverContextMenu;
+ ArrayList<MenuItem> bdtFunction;
+ String selectedDeviceName;
+ String selectedFunctionName;
+ TextField paraMeterListText;
+ ArrayList<String> parameterArrayList = new ArrayList<String>();
+ ArrayList<TextField> parameterTextFieldList = new ArrayList<TextField>();
+ String matchedCase;
+ ArrayList<Label> parameterLabel = new ArrayList<Label>();
+ OFAFileOperations fileOperation = new OFAFileOperations();
+ ObservableList<String> data;
+ Group popupRoot;
+ ListView<String> seleniumFunctionListView, cliFunctionListView;
+ String baseDeviceDriver, cliFunctionStr;
+ ArrayList<String> cliFunctionList = new ArrayList<String>();
+ HashMap<String, String> cliFunctionWithArgumentMap = new HashMap<String, String>();
+ String selectedCLiFunction;
+ String selectedSeleniumFunction;
+ TAILocale label = new TAILocale(new Locale("en", "EN"));
+ String OFAHarnessPath = label.hierarchyTestON;
+ String bdrPath;
+ String selectedDeviceType;
+
+ public OFAContentHelp() {
+ }
+
+ public OFAContentHelp(CodeEditor editor, TAI_OFA reference) {
+ this.Content = editor;
+ OFAReference = reference;
+ }
+
+ public void assertContextMenu() {
+ assertContext = new ContextMenu();
+ MenuItem equal = new MenuItem("EQUALS");
+ MenuItem match = new MenuItem("MATCHES");
+ MenuItem greater = new MenuItem("GREATER");
+ MenuItem lesser = new MenuItem("LESSER");
+ assertNameList = new ArrayList<MenuItem>();
+ assertNameList.add(equal);
+ assertNameList.add(match);
+ assertNameList.add(greater);
+ assertNameList.add(lesser);
+ assertContext.getItems().addAll(equal, match, greater, lesser);
+ }
+
+ public void ospkHelp() {
+
+ Content.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
+ @Override
+ public void handle(KeyEvent keyEvent) {
+ if (keyEvent.getCode() == KeyCode.SPACE) {
+ ArrayList<Integer> existingCaseNumber = new ArrayList<Integer>();
+ existingCaseNumber.add(0);
+ String[] content = Content.getCodeAndSnapshot().split("\n");
+ for (int i = 0; i < content.length; i++) {
+ Pattern pattern = Pattern.compile("CASE\\s+(\\d+)\\s*");
+ Matcher matchCase = pattern.matcher(content[i]);
+
+ while (matchCase.find()) {
+ try {
+ int number = Integer.parseInt(matchCase.group(1));
+ existingCaseNumber.add(number);
+ } catch (Exception e) {
+ }
+ }
+ }
+
+ int max = Collections.max(existingCaseNumber);
+ max = max + 1;
+ String caseNumbers = String.valueOf(max);
+ Content.setLine(Integer.parseInt(Content.getCurrentLineNumber()), Content.getCurrentLine().replace("CASE", "CASE" + " " + caseNumbers));
+ }
+
+ Pattern namePattern = Pattern.compile("\\s*NAME\\s+(.*)");
+ Pattern descPattern = Pattern.compile("DESC\\s+(.*)");
+ Pattern stepPattern = Pattern.compile("STEP\\s+(.*)");
+ Pattern onPattern = Pattern.compile("ON\\s+(.*)");
+ Pattern cmdPattern = Pattern.compile("ON\\s+(\\w+\\s+(.*))");
+ Pattern runPattern = Pattern.compile("" + ospkCommand + "\\s+(.*)");
+ Pattern assertPattern = Pattern.compile("ASSERT\\s+(.*)");
+ Pattern usingPattern = Pattern.compile("(.*)\\s+USING\\s+");
+ String[] OFAEditorLine = Content.getCodeAndSnapshot().split("\n");
+
+ final Matcher onMatch = onPattern.matcher(Content.getCurrentLine());
+ final Matcher cmdMatch = cmdPattern.matcher(Content.getCurrentLine());
+ final Matcher runMatch = runPattern.matcher(Content.getCurrentLine());
+ final Matcher asertMatch = assertPattern.matcher(Content.getCurrentLine());
+ final Matcher usingMatch = usingPattern.matcher(Content.getCurrentLine());
+ Matcher nameMatch = namePattern.matcher(Content.getCurrentLine());
+ Matcher descMatch = descPattern.matcher(Content.getCurrentLine());
+ Matcher stepMatch = stepPattern.matcher(Content.getCurrentLine());
+ while (nameMatch.find()) {
+ if (nameMatch.group(1).isEmpty()) {
+ if (keyEvent.getCode() == KeyCode.SPACE) {
+ Content.setLine(Integer.parseInt(Content.getCurrentLineNumber()), Content.getCurrentLine().replace("NAME", "NAME" + " " + "\"\""));
+ }
+
+ }
+ }
+
+ while (descMatch.find()) {
+ if (descMatch.group(1).isEmpty()) {
+ if (keyEvent.getCode() == KeyCode.SPACE) {
+ Content.setLine(Integer.parseInt(Content.getCurrentLineNumber()), Content.getCurrentLine().replace("DESC", "DESC" + " " + "\"\""));
+ }
+
+ }
+ }
+
+ while (stepMatch.find()) {
+ if (stepMatch.group(1).isEmpty()) {
+ if (keyEvent.getCode() == KeyCode.SPACE) {
+ Content.setLine(Integer.parseInt(Content.getCurrentLineNumber()), Content.getCurrentLine().replace("STEP", "STEP" + " " + "\"\""));
+ }
+
+ }
+ }
+
+
+ while (onMatch.find()) {
+ if (onMatch.group(1).isEmpty()) {
+ if (keyEvent.getCode() == KeyCode.getKeyCode("Ctrl")) {
+ keyPressed = true;
+ }
+
+ if (keyPressed == true) {
+ if (keyEvent.getCode() == KeyCode.SPACE) {
+ keyPressed = false;
+ onMatch.group();
+ onDeviceContextMenu();
+ contextMenu.show(OFAReference.editorTabPane, Side.TOP, Content.cursorPosfromLeft(), Content.cursorPosfromTop() + 65);
+ for (final MenuItem myMenuItem : myMenuItems) {
+ myMenuItem.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ HashMap<String, String> deviceNameAndType = paramFile.getdeviceNameAndType();
+ Iterator paramIterator = deviceNameAndType.entrySet().iterator();
+ while (paramIterator.hasNext()) {
+ Map.Entry mEntry = (Map.Entry) paramIterator.next();
+ if (myMenuItem.getText().equals(mEntry.getKey())) {
+ selectedDeviceType = mEntry.getValue().toString();
+ selectedDeviceType = selectedDeviceType.replaceAll("\\s+", "");
+ String driverTypePath = OFAHarnessPath + "/drivers/common/";
+ File aFile = new File(driverTypePath);
+ fileOperation.Process(aFile);
+ for (String path : fileOperation.filePath) {
+ String[] splitPath = path.split("\\/");
+ String[] fileName = splitPath[splitPath.length - 1].split("\\.");
+ for (int p = 0; p < fileName.length; p++) {
+ if ((selectedDeviceType).equals(fileName[p])) {
+ deviceTypePath = path;
+ bdrPath = deviceTypePath.replaceAll("py", "ospk");
+ }
+ }
+ }
+ }
+ }
+ selectedDeviceName = myMenuItem.getText();
+ Content.setLine(Integer.parseInt(Content.getCurrentLineNumber()), Content.getCurrentLine().replace("ON", "ON" + " " + myMenuItem.getText()));
+ }
+ });
+ }
+ }
+ }
+
+ }
+ }
+ while (cmdMatch.find()) {
+ if (cmdMatch.group(2).isEmpty()) {
+ if (keyEvent.getCode() == KeyCode.getKeyCode("Ctrl")) {
+ keyPressed = true;
+ }
+
+ if (keyPressed == true) {
+ if (keyEvent.getCode() == KeyCode.SPACE) {
+ runContextMenu();
+ commandNameContextMenu.show(OFAReference.editorTabPane, Side.TOP, Content.cursorPosfromLeft(), Content.cursorPosfromTop() + 115);
+ for (final MenuItem bdtCmd : bdtFunction) {
+ bdtCmd.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ ospkCommand = bdtCmd.getText();
+ Content.setLine(Integer.parseInt(Content.getCurrentLineNumber()), Content.getCurrentLine().replace(selectedDeviceName, selectedDeviceName + " " + bdtCmd.getText()));
+ }
+ });
+ }
+ }
+ }
+ }
+ }
+
+ while (runMatch.find()) {
+
+ if (runMatch.group(1).isEmpty()) {
+ if (keyEvent.getCode() == KeyCode.getKeyCode("Ctrl")) {
+ keyPressed = true;
+ }
+ if (keyPressed == true) {
+ if (keyEvent.getCode() == KeyCode.SPACE) {
+ keyPressed = false;
+
+ onDriverContextMenu();
+ driverFunctionContextMenu.show(OFAReference.editorTabPane, Side.TOP, Content.cursorPosfromLeft(), Content.cursorPosfromTop() + 65);
+
+ Group popupRoot = (Group) driverFunctionContextMenu.getScene().getRoot();
+ final ListView<String> driverFunctionListView = new ListView<String>();
+ data = FXCollections.observableArrayList();
+ for (String function : driverFunctionName) {
+ data.add(function);
+ }
+ driverFunctionListView.setItems(data);
+ driverFunctionListView.setMaxHeight(100);
+ driverFunctionListView.setMaxWidth(150);
+ driverFunctionListView.getSelectionModel().selectFirst();
+
+ driverFunctionListView.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
+ @Override
+ public void handle(KeyEvent arg0) {
+ if (arg0.getCode() == KeyCode.ENTER || arg0.getCode() == KeyCode.SPACE) {
+ selectedFunctionName = driverFunctionListView.getSelectionModel().getSelectedItem().toString();
+ Content.setLine(Integer.parseInt(Content.getCurrentLineNumber()), Content.getCurrentLine().replace("RUN", "RUN" + " " + selectedFunctionName));
+ driverFunctionContextMenu.hide();
+ }
+ }
+ });
+ popupRoot.getChildren().add(driverFunctionListView);
+ driverFunctionListView.requestFocus();
+ }
+ }
+ }
+ }
+
+ while (asertMatch.find()) {
+ if (asertMatch.group(1).isEmpty()) {
+ if (keyEvent.getCode() == KeyCode.getKeyCode("Ctrl")) {
+ keyPressed = true;
+ }
+
+ if (keyPressed == true) {
+ if (keyEvent.getCode() == KeyCode.SPACE) {
+ OFAContentHelp contentHelp = new OFAContentHelp();
+ contentHelp.assertContextMenu();
+ contentHelp.assertContext.show(OFAReference.editorTabPane, Side.TOP, Content.cursorPosfromLeft(), Content.cursorPosfromTop() + 65);
+ for (final MenuItem assertCommand : contentHelp.assertNameList) {
+ assertCommand.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ Content.setLine(Integer.parseInt(Content.getCurrentLineNumber()), Content.getCurrentLine().replace("ASSERT", "ASSERT " + assertCommand.getText()));
+ }
+ });
+ }
+ }
+ }
+ }
+
+ }
+
+ while (usingMatch.find()) {
+ if (!usingMatch.group(1).isEmpty()) {
+ if (keyEvent.getCode() == KeyCode.CONTROL) {
+ keyPressed = true;
+ }
+
+ if (keyPressed == true) {
+ if (keyEvent.getCode() == KeyCode.SPACE) {
+ OFAParamDeviceName paramDeice = new OFAParamDeviceName();
+ if (selectedDeviceType.equals("poxclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/emulator/poxclidriver.py");
+ paramDeice.driverFunctionName(baseCliDevice);
+ for (String functionName : paramDeice.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ } else if (selectedDeviceType.equals("mininetclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/emulator/mininetclidriver.py");
+ paramDeice.driverFunctionName(baseCliDevice);
+ for (String functionName : paramDeice.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ } else if (selectedDeviceType.equals("hpswitchclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotetestbed/hpswitchclidriver.py");
+ paramDeice.driverFunctionName(baseCliDevice);
+ for (String functionName : paramDeice.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("flowvisorclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotesys/flowvisorclidriver.py");
+ paramDeice.driverFunctionName(baseCliDevice);
+ for (String functionName : paramDeice.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("floodlightclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotesys/floodlightclidriver.py");
+ paramDeice.driverFunctionName(baseCliDevice);
+ for (String functionName : paramDeice.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("remotepoxdriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotesys/remotepoxdriver.py");
+ paramDeice.driverFunctionName(baseCliDevice);
+ for (String functionName : paramDeice.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("remotevmdriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotesys/remotevmdriver.py");
+ paramDeice.driverFunctionName(baseCliDevice);
+ for (String functionName : paramDeice.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("dpctlclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/tool/dpctlclidriver.py");
+ paramDeice.driverFunctionName(baseCliDevice);
+ for (String functionName : paramDeice.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("fvtapidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/api/fvtapidriver.py");
+ paramDeice.driverFunctionName(baseCliDevice);
+ for (String functionName : paramDeice.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ HashMap<String, String> functionAndParameter = paramDeice.functionWithParameter;
+ Set set = functionAndParameter.entrySet();
+ // Get an iterator
+ Iterator functionAndParameterIterator = set.iterator();
+ // Display elements
+ final GridPane paramPanel = new GridPane();
+ paramPanel.setStyle("-fx-background-color: DAE6F3;");
+ String caseParameter = "";
+ parameterLabel.clear();
+ parameterTextFieldList.clear();
+ while (functionAndParameterIterator.hasNext()) {
+ Map.Entry functionInfo = (Map.Entry) functionAndParameterIterator.next();
+ if (selectedFunctionName.equals(functionInfo.getKey().toString())) {
+ String[] splitParameter = functionInfo.getValue().toString().split("\\,");
+ if (splitParameter.length > 0) {
+ for (int j = 0; j < splitParameter.length; j++) {
+ Label parameterList = new Label();
+ parameterLabel.add(parameterList);
+ paraMeterListText = new TextField();
+ parameterList.setText(splitParameter[j]);
+ paramPanel.add(parameterList, 0, j);
+ paramPanel.add(paraMeterListText, 1, j);
+ parameterTextFieldList.add(paraMeterListText);
+ caseParameter += splitParameter[j].toLowerCase() + "AS " + "CASE" + "[" + splitParameter[j].toLowerCase() + "]" + ",";
+ }
+ }
+ }
+ }
+ withContextMenu();
+ withContextMenu.show(OFAReference.editorTabPane, Side.TOP, Content.cursorPosfromLeft(), Content.cursorPosfromTop() + 65);
+ Group popupRoot = (Group) withContextMenu.getScene().getRoot();
+ Group popupCSSBridge = (Group) popupRoot.getChildren().get(0);
+ StackPane popupContent = (StackPane) popupCSSBridge.getChildren().get(0);
+ popupRoot.getChildren().add(paramPanel);
+ if (!caseParameter.equals("")) {
+ try {
+ caseParameter = caseParameter.substring(0, caseParameter.length() - 1);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+ }
+ popupContent.setMaxHeight(OFAReference.editorTabPane.getHeight() - 400);
+ Content.setLine(Integer.parseInt(Content.getCurrentLineNumber()), Content.getCurrentLine().replace("USING", "USING" + " " + caseParameter));
+ for (int k = Integer.parseInt(Content.getCurrentLineNumber()); k > 0; k--) {
+ Pattern firstUpperCasePattern = Pattern.compile("CASE\\s+(\\d)");
+ Matcher firstUpperCaseMatch = firstUpperCasePattern.matcher(Content.getCurrentLine(k));
+ if (firstUpperCaseMatch.find()) {
+ matchedCase = firstUpperCaseMatch.group();
+ break;
+ }
+ }
+ try {
+ paraMeterListText.setOnKeyPressed(new EventHandler<KeyEvent>() {
+ @Override
+ public void handle(KeyEvent keyEvent) {
+ if (keyEvent.getCode() == KeyCode.ENTER) {
+ String paramCaseContent = "";
+ String matchCaseWithoutSpace = matchedCase.replaceAll("\\s+", "");
+ String currentTabPath = OFAReference.editorTabPane.getSelectionModel().getSelectedItem().getId();
+ String paramFile = currentTabPath.replace(fileOperation.getExtension(currentTabPath), ".params");
+ Pattern matchCasePattern = Pattern.compile("^\\s*\\<" + matchCaseWithoutSpace + "\\>");
+ String fileContent[] = fileOperation.getContents(new File(paramFile)).split("\n");
+ String myCase = "";
+ Boolean caseFlag = false;
+ int k;
+ for (k = 0; k < fileContent.length; k++) {
+ Matcher caseMatch = matchCasePattern.matcher(fileContent[k]);
+ if (caseMatch.find()) {
+ myCase = caseMatch.group();
+ caseFlag = true;
+ break;
+ }
+ }
+ if (caseFlag == true) {
+ String remainingConetent = "";
+ int caseVarible = k;
+ k++;
+ for (; k < fileContent.length; k++) {
+ remainingConetent += "\n" + fileContent[k];
+ }
+ String allContent = "";
+ allContent += fileContent[0];
+ for (int p = 1; p < caseVarible; p++) {
+ allContent += "\n" + fileContent[p];
+ }
+ allContent += "\n\t<" + matchCaseWithoutSpace + ">";
+
+ for (int i = 0; i < parameterTextFieldList.size(); i++) {
+ String parameterLabels = parameterLabel.get(i).getText().replaceAll("\"", "");
+ paramCaseContent += "\n\t\t<" + parameterLabels.toLowerCase() + ">" + parameterTextFieldList.get(i).getText() + "</" + parameterLabels.toLowerCase() + ">";
+ }
+
+ allContent += paramCaseContent;
+ allContent += remainingConetent;
+ String paramFilePath = OFAReference.editorTabPane.getSelectionModel().getSelectedItem().getId().replace(fileOperation.getExtension(OFAReference.editorTabPane.getSelectionModel().getSelectedItem().getId()), ".params");
+ String paramFileContent = fileOperation.getContents(new File(paramFilePath));
+ try {
+ fileOperation.setContents(new File(paramFilePath), allContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(OFAContentHelp.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(OFAContentHelp.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ withContextMenu.hide();
+ paramPanel.setVisible(false);
+ } else {
+ paramCaseContent += "<" + matchCaseWithoutSpace + ">";
+ for (int i = 0; i < parameterTextFieldList.size(); i++) {
+ paramCaseContent += "\n\t\t<" + parameterLabel.get(i).getText().toLowerCase() + ">" + parameterTextFieldList.get(i).getText() + "</" + parameterLabel.get(i).getText().toLowerCase() + ">";
+ }
+
+ paramCaseContent += "\n\t" + "</" + matchCaseWithoutSpace + ">";
+ String paramFilePath = OFAReference.editorTabPane.getSelectionModel().getSelectedItem().getId().replace(fileOperation.getExtension(OFAReference.editorTabPane.getSelectionModel().getSelectedItem().getId()), ".params");
+ String paramFileContent = fileOperation.getContents(new File(paramFilePath));
+ String removeTestParam = paramFileContent.replace("</TEST_PARAMS>", " ");
+ removeTestParam += "\t" + paramCaseContent + "\n\n" + "</TEST_PARAMS>";
+ try {
+ fileOperation.setContents(new File(paramFilePath), removeTestParam);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(OFAContentHelp.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(OFAContentHelp.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ withContextMenu.hide();
+ paramPanel.setVisible(false);
+ }
+ }
+ }
+ });
+ } catch (Exception e) {
+ }
+
+ }
+ }
+ }
+
+ }
+
+ checkBuffer = new ArrayList<String>();
+
+ if (keyEvent.getCode() == KeyCode.ENTER) {
+ String bufferedString = "";
+ for (String s : checkBuffer) {
+ bufferedString += s;
+ }
+ Pattern pattern = Pattern.compile("CASE\\s+(\\d+)");
+ Matcher match = pattern.matcher(bufferedString);
+ while (match.find()) {
+ Content.setCode(Content.getCodeAndSnapshot().replaceAll(bufferedString, bufferedString + "\n\n" + "END CASE"));
+ }
+ checkBuffer.clear();
+ }
+
+ }
+ });
+
+ Content.setOnKeyPressed(new EventHandler<KeyEvent>() {
+ @Override
+ public void handle(KeyEvent arg0) {
+ String text = arg0.getText();
+ if (arg0.getCode() == KeyCode.ENTER) {
+ } else if (arg0.getCode() == KeyCode.BACK_SPACE) {
+ } else {
+ checkBuffer.add(text);
+ }
+ }
+ });
+ }
+
+ public void onDeviceContextMenu() {
+ contextMenu = new ContextMenu();
+ myDevices = new ArrayList<String>();
+ ArrayList<String> paramDeviceType = new ArrayList<String>();
+ myMenuItems = new ArrayList<MenuItem>();
+
+ String selectedTabPath = OFAReference.editorTabPane.getSelectionModel().getSelectedItem().getId();
+ String[] splitSelectedPath = selectedTabPath.split("\\/");
+ String[] ospkFileName = splitSelectedPath[splitSelectedPath.length - 1].toString().split("\\.");
+ String paramFileName = ospkFileName[0] + ".topo";
+ String paramFilePath = selectedTabPath.replace(splitSelectedPath[splitSelectedPath.length - 1].toString(), paramFileName);
+ paramFile = new OFAParamDeviceName(paramFilePath, "");
+ paramFile.parseParamFile();
+
+ for (String deviceName : paramFile.getParamDeviceName()) {
+ myDevices.add(deviceName);
+ }
+
+ for (String myDevice : myDevices) {
+ final MenuItem myMenuItem = new MenuItem(myDevice);
+ myMenuItem.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ }
+ });
+ myMenuItems.add(myMenuItem);
+ }
+
+ for (MenuItem myMenuItem : myMenuItems) {
+ contextMenu.getItems().addAll(myMenuItem);
+
+ }
+
+ OFAReference.editorTabPane.setContextMenu(contextMenu);
+ }
+
+ public void onDriverContextMenu() {
+ driverFunctionContextMenu = new ContextMenu();
+ driverFunctionName = new ArrayList<String>();
+ driverFunctionName.clear();
+ OFAParamDeviceName driverFile = new OFAParamDeviceName();
+
+ if (selectedDeviceType.equals("poxclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/emulator/poxclidriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ } else if (selectedDeviceType.equals("mininetclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/emulator/mininetclidriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("hpswitchdriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotesys/hpswitchdriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("dpctlclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/tool/dpctlclidriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("fvtapidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/api/fvtapidriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ } else if (selectedDeviceType.equals("hpswitchclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotetestbed/hpswitchclidriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("flowvisorclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotetestbed/flowvisorclidriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("floodlightclidriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotetestbed/floodlightclidriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("remotepoxdriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotetestbed/remotepoxdriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ if (selectedDeviceType.equals("remotevmdriver")) {
+ String baseCliDevice = bdrPath.replace(bdrPath, label.hierarchyTestON + "/drivers/common/cli/remotetestbed/remotevmdriver.py");
+ driverFile.driverFunctionName(baseCliDevice);
+ for (String functionName : driverFile.driverFunctionName) {
+ driverFunctionName.add(functionName);
+ }
+ }
+ driverFunctionContextMenu.getItems().add(new MenuItem());
+ }
+
+ public void runContextMenu() {
+ commandNameContextMenu = new ContextMenu();
+ MenuItem run = new MenuItem("RUN");
+ MenuItem exec = new MenuItem("EXEC");
+ MenuItem config = new MenuItem("CONFIG");
+ bdtFunction = new ArrayList<MenuItem>();
+ bdtFunction.add(run);
+ bdtFunction.add(exec);
+ bdtFunction.add(config);
+ commandNameContextMenu.getItems().addAll(run, exec, config);
+ }
+
+ public void withContextMenu() {
+ withContextMenu = new ContextMenu();
+ MenuItem item = new MenuItem();
+ withContextMenu.getItems().add(item);
+ item.setDisable(true);
+ }
+
+ // drivers context menu
+ public void runDriverContextMenu() {
+ runDriverContextMenu = new ContextMenu();
+ MenuItem runDriverMenuItem = new MenuItem("");
+ runDriverContextMenu.getItems().add(runDriverMenuItem);
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFAFileOperations.java b/TestON/TAI/src/tai_ofa/OFAFileOperations.java
new file mode 100644
index 0000000..9296502
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFAFileOperations.java
@@ -0,0 +1,168 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class OFAFileOperations {
+
+ BufferedReader input;
+ ArrayList list = new ArrayList();
+ ArrayList<String> filePath = new ArrayList<String>();
+
+ public OFAFileOperations() {
+ }
+
+ public void writeInFile(String path, String demoFile) {
+ try {
+ FileWriter fstream = new FileWriter(path);
+ BufferedWriter out = new BufferedWriter(fstream);
+ out.write(demoFile);
+ out.close();
+ } catch (Exception e) {
+ }
+ }
+
+ public String getContents(File aFile) {
+ StringBuilder contents = new StringBuilder();
+
+ try {
+ //use buffering, reading one line at a time
+ //FileReader always assumes default encoding is OK!
+ try {
+ input = new BufferedReader(new FileReader(aFile));
+ } catch (Exception e) {
+ }
+
+ try {
+ String line = null; //not declared within while loop
+
+ while ((line = input.readLine()) != null) {
+ contents.append(line);
+ contents.append(System.getProperty("line.separator"));
+ }
+ } finally {
+ try {
+ input.close();
+ } catch (Exception e) {
+ }
+
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ return contents.toString();
+ }
+
+ public String getExtension(String name) {
+ String extension = null;
+ try {
+
+ if (name.contains(".")) {
+ int dotPos = name.lastIndexOf(".");
+ extension = name.substring(dotPos);
+ }
+ } catch (Exception e) {
+ }
+
+ return extension;
+ }
+
+ public String getFileName(String name) {
+ String fileName = null;
+ try {
+
+ if (name.contains(".")) {
+ int dotPos = name.lastIndexOf(".");
+ fileName = name.substring(0, dotPos);
+ }
+ } catch (Exception e) {
+ }
+
+ return fileName;
+ }
+
+ public void setContents(File aFile, String aContents) throws FileNotFoundException, IOException {
+ if (aFile == null) {
+ throw new IllegalArgumentException("File should not be null.");
+ }
+ if (!aFile.exists()) {
+ throw new FileNotFoundException("File does not exist: " + aFile);
+ }
+ if (!aFile.isFile()) {
+ throw new IllegalArgumentException("Should not be a directory: " + aFile);
+ }
+ if (!aFile.canWrite()) {
+ throw new IllegalArgumentException("File cannot be written: " + aFile);
+ }
+
+ //use buffering
+ Writer output = new BufferedWriter(new FileWriter(aFile));
+ try {
+ //FileWriter always assumes default encoding is OK!
+ output.write(aContents);
+ } finally {
+ output.close();
+ }
+ }
+
+ public void saveFile(File saveToDisk, String content) throws FileNotFoundException, IOException {
+ setContents(saveToDisk, content);
+ }
+ static int spc_count = -1;
+
+ void Process(File aFile) {
+
+ spc_count++;
+ String spcs = "";
+ for (int i = 0; i < spc_count; i++) {
+ spcs += " ";
+ }
+ if (aFile.isFile()) {
+ list.add(aFile.getName());
+ filePath.add(aFile.getPath());
+
+ } else if (aFile.isDirectory()) {
+ File[] listOfFiles = aFile.listFiles();
+
+
+ if (listOfFiles != null) {
+ for (int i = 0; i < listOfFiles.length; i++) {
+ Process(listOfFiles[i]);
+ }
+ } else {
+ }
+ }
+ spc_count--;
+
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFALoadTree.java b/TestON/TAI/src/tai_ofa/OFALoadTree.java
new file mode 100644
index 0000000..8d1981c
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFALoadTree.java
@@ -0,0 +1,178 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
+import javafx.event.Event;
+import javafx.event.EventHandler;
+import javafx.scene.Node;
+import javafx.scene.control.TreeItem;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class OFALoadTree extends TreeItem<String> {
+
+ OFAFileOperations fileOperation = new OFAFileOperations();
+ public static Image folderCollapseImage = new Image("images/folder.jpg", 30.0, 30.0, true, true);
+ public static Image folderExpandImage = new Image("images/folder.jpg", 10.0, 10.0, true, true);
+ public static Image fileImage = new Image("images/File.png", 30.0, 30.0, true, true);
+ //this stores the full path to the file or directory
+ private String fullPath;
+
+ public String getFullPath() {
+ return (this.fullPath);
+ }
+ private boolean isDirectory;
+
+ public boolean isDirectory() {
+ return (this.isDirectory);
+ }
+
+ public OFALoadTree(Path file) {
+ super(file.toString());
+ this.fullPath = file.toString();
+ //test if this is a directory and set the icon
+ if (Files.isDirectory(file)) {
+ this.isDirectory = true;
+ if ("common".equals(file.getFileName().toString())) {
+ Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("/images/project.jpeg"), 20, 20, true, true));
+ this.setGraphic(rootIcon);
+ } else if ("cli".equals(file.getFileName().toString())) {
+ Node rootIcon2 = new ImageView(new Image(getClass().getResourceAsStream("/images/terminal.png"), 20, 20, true, true));
+ rootIcon2.setId("/images/terminal.png");
+ this.setGraphic(rootIcon2);
+ } else if ("api".equals(file.getFileName().toString())) {
+ Node rootIcon3 = new ImageView(new Image(getClass().getResourceAsStream("/images/www2.jpg"), 20, 20, true, true));
+ this.setGraphic(rootIcon3);
+ } else if ("emulator".equals(file.getFileName().toString())) {
+ Node rootIcon4 = new ImageView(new Image(getClass().getResourceAsStream("/images/mobile.png"), 20, 20, true, true));
+ this.setGraphic(rootIcon4);
+ } else if ("tool".equals(file.getFileName().toString())) {
+ Node rootIcon5 = new ImageView(new Image(getClass().getResourceAsStream("/images/automatorui.png"), 20, 20, true, true));
+ this.setGraphic(rootIcon5);
+ } else if ("contoller".equals(file.getFileName().toString())) {
+ Node rootIcon6 = new ImageView(new Image(getClass().getResourceAsStream("/images/windows.jpg"), 20, 20, true, true));
+ this.setGraphic(rootIcon6);
+ } else {
+ Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("/images/project.jpeg"), 20, 20, true, true));
+ rootIcon.setId("/images/project.jpeg");
+ this.setGraphic(rootIcon);
+ }
+ } else {
+ this.isDirectory = false;
+ String fileName = file.getFileName().toString();
+ String ext = fileOperation.getExtension(fileName);
+ if (".ospk".equals(ext)) {
+ Node rootIcon5 = new ImageView(fileImage);
+ rootIcon5.setId(".ospk");
+ this.setGraphic(rootIcon5);
+
+ } else if (".params".equals(ext)) {
+ Node rootIcon1 = new ImageView(new Image(getClass().getResourceAsStream("/images/params.jpeg"), 30, 30, true, true));
+ rootIcon1.setId(".params");
+ setGraphic(rootIcon1);
+
+ } else if (".topo".equals(ext)) {
+ Node rootIcon3 = new ImageView(new Image(getClass().getResourceAsStream("/images/tpl.png"), 30, 30, true, true));
+ rootIcon3.setId(".topo");
+ setGraphic(rootIcon3);
+ } else if (".log".equals(ext)) {
+ Node rootIcon3 = new ImageView(new Image(getClass().getResourceAsStream("/images/log.jpg"), 20, 20, true, true));
+ rootIcon3.setId(".log");
+ setGraphic(rootIcon3);
+ } else if (".rpt".equals(ext)) {
+ Node rootIcon3 = new ImageView(new Image(getClass().getResourceAsStream("/images/report.jpeg"), 20, 20, true, true));
+ rootIcon3.setId(".rpt");
+ setGraphic(rootIcon3);
+ } else if (".session".equals(ext)) {
+ Node rootIcon3 = new ImageView(new Image(getClass().getResourceAsStream("/images/session.png"), 20, 20, true, true));
+ rootIcon3.setId(".session");
+ setGraphic(rootIcon3);
+ } else if (".py".equals(ext)) {
+ Node rootIcon3 = new ImageView(new Image(getClass().getResourceAsStream("/images/py.jpg"), 20, 20, true, true));
+ rootIcon3.setId(".py");
+ setGraphic(rootIcon3);
+ }
+
+ //if you want different icons for different file types this is where you'd do it
+ }
+
+ //set the value
+ if (!fullPath.endsWith(File.separator)) {
+ //set the value (which is what is displayed in the tree)
+ String value = file.toString();
+ int indexOf = value.lastIndexOf(File.separator);
+ if (indexOf > 0) {
+ this.setValue(value.substring(indexOf + 1));
+ } else {
+ this.setValue(value);
+ }
+ }
+
+
+ this.addEventHandler(TreeItem.branchExpandedEvent(), new EventHandler() {
+ @Override
+ public void handle(Event e) {
+ OFALoadTree source = (OFALoadTree) e.getSource();
+ if (source.isDirectory() && source.isExpanded()) {
+ }
+ try {
+ if (source.getChildren().isEmpty()) {
+ Path path = Paths.get(source.getFullPath());
+ BasicFileAttributes attribs = Files.readAttributes(path, BasicFileAttributes.class);
+ if (attribs.isDirectory()) {
+ DirectoryStream<Path> dir = Files.newDirectoryStream(path);
+ for (Path file : dir) {
+ OFALoadTree treeNode = new OFALoadTree(file);
+ String fileExtension = fileOperation.getExtension(treeNode.getValue());
+ String fileName = fileOperation.getFileName(treeNode.getValue());
+ if (fileExtension == null || fileExtension.equals(".py") || fileExtension.equals(".ospk") || fileExtension.equals(".topo") || fileExtension.equals(".params") || fileExtension.equals(".log") || fileExtension.equals(".rpt") || fileExtension.equals(".session")) {
+ if (fileExtension == null) {
+ treeNode.setExpanded(true);
+ source.getChildren().add(treeNode);
+ } else {
+ if (fileExtension.matches(".(ospk|params|topo|py|log|rpt|session)")) {
+ String finalValue = treeNode.getValue().replace(fileExtension, "");
+ treeNode.setValue(finalValue);
+ if (!treeNode.getValue().equals("__init__")) {
+ source.getChildren().add(treeNode);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ } catch (Exception ex) {
+ }
+ }
+ });
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFAParamDeviceName.java b/TestON/TAI/src/tai_ofa/OFAParamDeviceName.java
new file mode 100644
index 0000000..a8146df
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFAParamDeviceName.java
@@ -0,0 +1,336 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+class OFAParamDeviceName {
+
+ String paramFilePath;
+ ArrayList<String> paramDeviceName;
+ ArrayList<String> driverFunctionName;
+ ArrayList<String> paramDeviceType;
+ ArrayList<String> paramDeviceCoordinate;
+ ArrayList<String> paramDeviceHost;
+ ArrayList<String> paramDeviceUser;
+ ArrayList<String> paramDevicePassword;
+ ArrayList<String> paramDeviceTransport;
+ ArrayList<String> paramDevicePort;
+ ArrayList<String> paramDeviceBrowser;
+ ArrayList<String> paramDeviceUrl;
+ HashMap<String, String> deviceInfo = new HashMap();
+ HashMap<String, String> urlInfo = new HashMap();
+ HashMap<String, String> browserInfo = new HashMap();
+ HashMap<String, String> coordinateInfo = new HashMap();
+ HashMap<String, String> hostInfo = new HashMap();
+ HashMap<String, String> userInfo = new HashMap();
+ HashMap<String, String> passwordInfo = new HashMap();
+ HashMap<String, String> portInfo = new HashMap();
+ HashMap<String, String> transportInfo = new HashMap();
+ String cliFunction;
+ HashMap deviceFunctionAndParameter = new HashMap();
+ HashMap<String, String> functionWithParameter;
+ String functionName;
+ String functionParameter;
+ HashMap<String, String> webFunctionHashFirstParameter = new HashMap<String, String>();
+ HashMap<String, String> webFunctionHashSecondParameter = new HashMap<String, String>();
+ ArrayList<String> seleniumFunctionList = new ArrayList<String>();
+ String bdrAction;
+ TAILocale label = new TAILocale(new Locale("en", "EN"));
+ String autoMateHarnessPath = label.OFAHarnessPath;
+ ArrayList<String> bdrFunctionName;
+
+ public OFAParamDeviceName() {
+ }
+
+ public OFAParamDeviceName(String filePath, String driverFilePath) {
+ paramDeviceName = new ArrayList<String>();
+ paramDeviceType = new ArrayList<String>();
+ paramDeviceCoordinate = new ArrayList<String>();
+ paramDeviceHost = new ArrayList<String>();
+ paramDeviceUser = new ArrayList<String>();
+ paramDevicePassword = new ArrayList<String>();
+ paramDeviceTransport = new ArrayList<String>();
+ paramDevicePort = new ArrayList<String>();
+ paramDeviceBrowser = new ArrayList<String>();
+ paramDeviceUrl = new ArrayList<String>();
+ this.paramFilePath = filePath;
+ }
+
+ public void parseParamFile() {
+ try {
+
+ FileInputStream fstream = new FileInputStream(paramFilePath);
+ ArrayList<String> paramFileName = new ArrayList<String>();
+ ArrayList<String> nameBetweenTags = new ArrayList<String>();
+ DataInputStream in = new DataInputStream(fstream);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+ while ((strLine = br.readLine()) != null) {
+ paramFileName.add(strLine);
+
+ }
+
+ for (int i = 0; i < paramFileName.size(); i++) {
+ String dName = "";
+ String dType = "";
+ String dCoordinate = "";
+ String dHost = "";
+ String dUser = "";
+ String dPassword = "";
+ String dTransport = "";
+ String dPort = "";
+ String dBrowser = "";
+ String dUrl = "";
+ Pattern devicePatternMatch = Pattern.compile("<COMPONENT>");
+ Matcher deviceNameMatch = devicePatternMatch.matcher(paramFileName.get(i));
+ if (deviceNameMatch.find()) {
+ int j = i + 1;
+ while (!paramFileName.get(j).equals("</COMPONENT>")) {
+ Pattern newTag = Pattern.compile("<(.+)(\\d+)>");
+ Matcher tagMatch = newTag.matcher(paramFileName.get(j));
+ if (tagMatch.find()) {
+ String temp = tagMatch.group(1);
+ Pattern slashCheck = Pattern.compile("^\\w+");
+ Matcher slashMatch = slashCheck.matcher(temp);
+ if (slashMatch.find()) {
+ paramDeviceName.add(slashMatch.group() + tagMatch.group(2));
+ dName = slashMatch.group() + tagMatch.group(2);
+ }
+
+ }
+
+
+ Pattern deviceTypePattern = Pattern.compile("<type>\\s*(.+)\\s*</type>");
+ Matcher deviceTypeMatch = deviceTypePattern.matcher(paramFileName.get(j));
+
+ while (deviceTypeMatch.find()) {
+ paramDeviceType.add(deviceTypeMatch.group(1));
+ dType = deviceTypeMatch.group(1).toLowerCase();
+
+ }
+ Pattern deviceCoordinatePattern = Pattern.compile("<coordinate(x,y)>\\s*(.+)\\s*</coordinate(x,y)>");
+ Matcher deviceCoordinateMatch = deviceCoordinatePattern.matcher(paramFileName.get(j));
+ while (deviceCoordinateMatch.find()) {
+ paramDeviceCoordinate.add(deviceCoordinateMatch.group(1));
+ dCoordinate = deviceCoordinateMatch.group(1);
+
+ }
+ Pattern devicehostNamePattern = Pattern.compile("<host>\\s*(.+)\\s*</host>");
+ Matcher deviceHostMatch = devicehostNamePattern.matcher(paramFileName.get(j));
+
+ while (deviceHostMatch.find()) {
+ paramDeviceHost.add(deviceHostMatch.group(1));
+ dHost = deviceHostMatch.group(1);
+ }
+ Pattern deviceUserPattern = Pattern.compile("<user>\\s*(.+)\\s*</user>");
+ Matcher deviceUserMatch = deviceUserPattern.matcher(paramFileName.get(j));
+ while (deviceUserMatch.find()) {
+ paramDeviceUser.add(deviceUserMatch.group(1));
+ dUser = deviceUserMatch.group(1);
+ }
+
+ Pattern devicePasswordPattern = Pattern.compile("<password>\\s*(.+)\\s*</password>");
+ Matcher devicePasswordMatch = devicePasswordPattern.matcher(paramFileName.get(j));
+ while (devicePasswordMatch.find()) {
+ paramDevicePassword.add(devicePasswordMatch.group(1));
+ dPassword = devicePasswordMatch.group(1);
+ }
+
+ Pattern devicePortPattern = Pattern.compile("<test_target>\\s*(.+)\\s*</test_target>");
+ Matcher devicePortMatch = devicePortPattern.matcher(paramFileName.get(j));
+ while (devicePortMatch.find()) {
+ paramDevicePort.add(devicePortMatch.group(1));
+ dPort = devicePortMatch.group(1);
+ }
+
+ deviceInfo.put(dName, dType);
+ coordinateInfo.put(dName, dCoordinate);
+ hostInfo.put(dName, dHost);
+ userInfo.put(dName, dUser);
+ passwordInfo.put(dName, dPassword);
+ portInfo.put(dName, dPort);
+ j++;
+ }
+ }
+ }
+ //Close the input stream
+ in.close();
+ } catch (Exception e) {//Catch exception if any
+ System.err.println("Error: " + e.getMessage());
+ }
+ }
+
+ public void parseDevice(String devicePath) {
+ try {
+ FileInputStream fstream = new FileInputStream(devicePath);
+ DataInputStream in = new DataInputStream(fstream);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+ while ((strLine = br.readLine()) != null) {
+ Pattern cliFunctionPattern = Pattern.compile("sub\\s+(\\w+)");
+ Matcher cliFunctionMatch = cliFunctionPattern.matcher(strLine);
+ Pattern cliFunctionArgumentPattern = Pattern.compile("utilities.parse_args\\(\\[\\s+qw\\((.*)\\)\\s*\\]\\,(.*)");
+ Matcher argumentMatch = cliFunctionArgumentPattern.matcher(strLine);
+ while (cliFunctionMatch.find()) {
+ cliFunction = cliFunctionMatch.group(1);
+ Pattern rm = Pattern.compile("_(.*)");
+ Matcher str2 = rm.matcher(cliFunction);
+ if (!str2.find()) {
+ }
+ }
+ while (argumentMatch.find()) {
+ deviceFunctionAndParameter.put(cliFunction, argumentMatch.group(1));
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ public void driverFunctionName(String driverPath) {
+ try {
+ functionWithParameter = new HashMap<String, String>();
+ FileInputStream fstream = new FileInputStream(driverPath);
+ driverFunctionName = new ArrayList<String>();
+ DataInputStream in = new DataInputStream(fstream);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+ while ((strLine = br.readLine()) != null) {
+ Pattern functionParameterPattern = Pattern.compile("(.*)\\s*=\\s*utilities.parse_args\\(\\s*\\[\\s*(.*)\\s*\\]\\s*\\,(.*)");
+ Matcher functionParaMeterMatch = functionParameterPattern.matcher(strLine);
+ Pattern pattern = Pattern.compile("^\\s*def\\s+(\\w+)");
+ Matcher match = pattern.matcher(strLine);
+ while (match.find()) {
+ functionName = match.group(1);
+ Pattern cliFunctionWithOut_ = Pattern.compile("_(.*)");
+ Matcher cliFunctionWithOut_Match = cliFunctionWithOut_.matcher(functionName);
+ if (!cliFunctionWithOut_Match.find()) {
+ driverFunctionName.add(match.group(1));
+ }
+
+
+ }
+ while (functionParaMeterMatch.find()) {
+ functionParameter = functionParaMeterMatch.group(2);
+ functionWithParameter.put(functionName, functionParameter);
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ public ArrayList<String> getParamDeviceName() {
+ return paramDeviceName;
+ }
+
+ public ArrayList<String> getParamDeviceType() {
+ return paramDeviceType;
+ }
+
+ public ArrayList<String> getDriverFunctionName() {
+ return driverFunctionName;
+ }
+
+ public ArrayList<String> getCoordinateName() {
+ return paramDeviceCoordinate;
+ }
+
+ public ArrayList<String> getBrowserName() {
+ return paramDeviceBrowser;
+ }
+
+ public ArrayList<String> getHostName() {
+ return paramDeviceHost;
+ }
+
+ public ArrayList<String> getUserName() {
+ return paramDeviceUser;
+ }
+
+ public ArrayList<String> getPassword() {
+ return paramDevicePassword;
+ }
+
+ public ArrayList<String> getTransport() {
+ return paramDeviceTransport;
+ }
+
+ public ArrayList<String> getPort() {
+ return paramDevicePort;
+ }
+
+ public ArrayList<String> getUrl() {
+ return paramDeviceUrl;
+ }
+
+ public HashMap<String, String> getdeviceNameAndType() {
+ return deviceInfo;
+ }
+
+ public HashMap<String, String> getdeviceNameAndBrowser() {
+ return browserInfo;
+ }
+
+ public HashMap<String, String> getdeviceNameAndUrl() {
+ return urlInfo;
+ }
+
+ public HashMap<String, String> getdeviceNameAndCoordinate() {
+ return coordinateInfo;
+ }
+
+ public HashMap<String, String> getdeviceNameAndHost() {
+ return hostInfo;
+ }
+
+ public HashMap<String, String> getdeviceNameAndUser() {
+ return userInfo;
+ }
+
+ public HashMap<String, String> getdeviceNameAndPassword() {
+ return passwordInfo;
+ }
+
+ public HashMap<String, String> getdeviceNameAndTransport() {
+ return transportInfo;
+ }
+
+ public HashMap<String, String> getdeviceNameAndPort() {
+ return portInfo;
+ }
+
+ public HashMap<String, String> getDeviceFunctionAndArgument() {
+ return deviceFunctionAndParameter;
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFATestCaseSelection.java b/TestON/TAI/src/tai_ofa/OFATestCaseSelection.java
new file mode 100644
index 0000000..d7824d0
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFATestCaseSelection.java
@@ -0,0 +1,429 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javafx.application.Application;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.Label;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableView;
+import javafx.scene.control.cell.PropertyValueFactory;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.StackPane;
+import javafx.scene.text.Text;
+import javafx.stage.Stage;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class OFATestCaseSelection extends Application {
+
+ String driverFile;
+ String paramFileName;
+ String pythonFile;
+ TAILocale label = new TAILocale(Locale.ENGLISH);
+
+ OFATestCaseSelection(String fileName, String paramsFileName) {
+ driverFile = label.hierarchyTestON + "/tests/" + fileName + "/" + fileName + ".ospk";
+ pythonFile = label.hierarchyTestON + "/tests/" + fileName + "/" + fileName + ".py";
+ paramFileName = label.hierarchyTestON + "/tests/" + fileName + "/" + fileName + ".params";
+ }
+ ObservableList<TestCaseSelectionTable> data;
+ ObservableList<String> testSelected;
+ TableView<TestCaseSelectionTable> deviceTable;
+ TableColumn selectCaseColumn;
+ TableColumn testCaseIdColumn;
+ TableColumn testCaseNameColumn;
+ TreeMap<String, String> testCaseIdAndName = new TreeMap<String, String>();
+ String caseId, caseName;
+ GridPane testCaseSelectionGrid = new GridPane();
+ TreeMap<String, String> stepHash = new TreeMap<String, String>();
+ TableColumn stepId, stepName;
+ TableView<TestSelectStepTable> stepTable;
+ ObservableList<TestSelectStepTable> stepData;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+ @Override
+ public void start(final Stage primaryStage) {
+ primaryStage.setTitle("TestCase Selection");
+ primaryStage.setResizable(false);
+ testSelected = FXCollections.observableArrayList();
+ stepData = FXCollections.observableArrayList();
+
+ testCaseSelectionGrid.setPadding(new Insets(0, 0, 0, 15));
+ testCaseSelectionGrid.setVgap(10);
+ testCaseSelectionGrid.setHgap(20);
+ final CheckBox selectTestCase = new CheckBox();
+ Label testCaseId = new Label("");
+ Label testCaseName = new Label("");
+
+ stepTable = new TableView<TestSelectStepTable>();
+ deviceTable = new TableView<TestCaseSelectionTable>();
+ data = FXCollections.observableArrayList(new TestCaseSelectionTable(selectTestCase, testCaseId, testCaseName));
+ deviceTable.setMinWidth(430);
+ deviceTable.setMaxHeight(300);
+ testCaseIdColumn = new TableColumn();
+
+ testCaseIdColumn.setCellValueFactory(new PropertyValueFactory<TestCaseSelectionTable, CheckBox>("testCaseCheckBox"));
+ testCaseIdColumn.setMinWidth(90);
+ testCaseIdColumn.setResizable(false);
+ selectCaseColumn = new TableColumn("TestCase Id");
+ selectCaseColumn.setSortable(true);
+ selectCaseColumn.setCellValueFactory(new PropertyValueFactory<TestCaseSelectionTable, Label>("testCaseId"));
+ selectCaseColumn.setMinWidth(130);
+ selectCaseColumn.setResizable(false);
+ testCaseNameColumn = new TableColumn("TestCase Name");
+ testCaseNameColumn.setCellValueFactory(new PropertyValueFactory<TestCaseSelectionTable, Label>("testCaseName"));
+ testCaseNameColumn.setMinWidth(130);
+ testCaseNameColumn.setResizable(false);
+ deviceTable.setItems(data);
+ deviceTable.getColumns().addAll(testCaseIdColumn, selectCaseColumn, testCaseNameColumn);
+ stepTable.setMinWidth(620);
+ stepTable.setMaxHeight(330);
+
+ stepId = new TableColumn("ID");
+ stepId.setCellValueFactory(new PropertyValueFactory<TestSelectStepTable, Label>("testStepId"));
+ stepId.setMinWidth(10);
+ stepId.setResizable(true);
+
+ stepName = new TableColumn("Name");
+ stepName.setCellValueFactory(new PropertyValueFactory<TestSelectStepTable, Label>("testStepName"));
+ stepName.setMinWidth(400);
+ stepName.setResizable(true);
+
+
+ stepTable.getColumns().addAll(stepId, stepName);
+ stepTable.setItems(stepData);
+ driverFunctionName();
+
+ Iterator driverFileIterator = testCaseIdAndName.entrySet().iterator();
+ while (driverFileIterator.hasNext()) {
+ Map.Entry testCaseDetail = (Map.Entry) driverFileIterator.next();
+ final CheckBox selectcase = new CheckBox();
+ final Label id = new Label((String) testCaseDetail.getKey());
+ Label name = new Label((String) testCaseDetail.getValue());
+ selectTestCase.selectedProperty().addListener(new ChangeListener<Boolean>() {
+ @Override
+ public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
+ selectcase.setSelected(true);
+ if (selectTestCase.isSelected() == false) {
+ selectcase.setSelected(false);
+ }
+ }
+ });
+
+ selectcase.selectedProperty().addListener(new ChangeListener<Boolean>() {
+ @Override
+ public void changed(ObservableValue<? extends Boolean> arg0, Boolean arg1, Boolean arg2) {
+ if (selectcase.isSelected() == true) {
+ stepData.clear();
+ for (int i = 0; i < deviceTable.getItems().size(); i++) {
+ if (deviceTable.getItems().get(i).testCaseId.getText().equals(id.getText())) {
+ deviceTable.getSelectionModel().select(i);
+ Pattern caseNumberPattern = Pattern.compile("CASE\\s*(\\d+)");
+ Matcher caseNumberMatcher = caseNumberPattern.matcher(deviceTable.getItems().get(i).testCaseId.getText());
+ String caseNumber = "";
+ if (caseNumberMatcher.find()) {
+ caseNumber = caseNumberMatcher.group(1);
+ }
+
+ getTestSteps(caseNumber);
+ testSelected.add(caseNumber);
+
+ Iterator entries = stepHash.entrySet().iterator();
+ while (entries.hasNext()) {
+ Map.Entry entry = (Map.Entry) entries.next();
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+ stepData.add(new TestSelectStepTable(new Label(key), new Label(value)));
+ }
+
+ stepTable.setItems(stepData);
+ stepTable.setVisible(true);
+ try {
+ testCaseSelectionGrid.add(new Text("Test Steps :"), 0, 3);
+ testCaseSelectionGrid.add(stepTable, 0, 4);
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ if (deviceTable.getSelectionModel().getSelectedItem().getTestCaseCheckBox().isSelected() == true) {
+ }
+ }
+ });
+
+ data.add(new TestCaseSelectionTable(selectcase, id, name));
+ testCaseIdColumn.setCellValueFactory(new PropertyValueFactory<TestCaseSelectionTable, CheckBox>("testCaseCheckBox"));
+ testCaseIdColumn.setMinWidth(50);
+ testCaseIdColumn.setResizable(false);
+
+ selectCaseColumn.setCellValueFactory(new PropertyValueFactory<TestCaseSelectionTable, Label>("testCaseId"));
+ selectCaseColumn.setMinWidth(100);
+ selectCaseColumn.setResizable(false);
+
+ testCaseNameColumn.setCellValueFactory(new PropertyValueFactory<TestCaseSelectionTable, Label>("testCaseName"));
+ testCaseNameColumn.setMinWidth(292);
+ testCaseNameColumn.setResizable(false);
+ deviceTable.setItems(data);
+ }
+
+ testCaseSelectionGrid.add(deviceTable, 0, 1);
+
+ HBox optionButton = new HBox(5);
+ optionButton.setPadding(new Insets(0, 0, 0, 0));
+
+ Button startTest = new Button("Save");
+
+ startTest.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ for (int i = 0; i < deviceTable.getItems().size(); i++) {
+
+ if (deviceTable.getItems().get(i).testCaseIdCheck.isSelected()) {
+ deviceTable.getSelectionModel().select(i);
+ }
+
+ if (deviceTable.getSelectionModel().getSelectedItem().getTestCaseCheckBox().isSelected() == true) {
+ }
+ }
+
+ StringBuilder testcases = new StringBuilder();
+ for (String s : testSelected) {
+ testcases.append(s).append(',');
+ }
+ primaryStage.close();
+ }
+ });
+
+ Button modifyParams = new Button("Modify Params");
+ Button cancelButton = new Button("Cancel");
+ optionButton.getChildren().addAll(new Label(" "), startTest, modifyParams, cancelButton);
+ testCaseSelectionGrid.add(optionButton, 0, 5);
+
+ StackPane root = new StackPane();
+ root.getChildren().add(testCaseSelectionGrid);
+ primaryStage.setScene(new Scene(root, 650, 400));
+ primaryStage.show();
+ }
+
+ public void driverFunctionName() {
+ try {
+ FileInputStream fstream = new FileInputStream(driverFile);
+ ArrayList<String> driverFunctionName = new ArrayList<String>();
+ DataInputStream in = new DataInputStream(fstream);
+ BufferedReader br = new BufferedReader(new InputStreamReader(in));
+ String strLine;
+ while ((strLine = br.readLine()) != null) {
+ Pattern casePattern = Pattern.compile("^CASE\\s+(\\d+)");
+ Matcher match = casePattern.matcher(strLine);
+ while (match.find()) {
+ driverFunctionName.add(match.group());
+ caseId = match.group();
+ strLine = br.readLine();
+ casePattern = Pattern.compile("NAME\\s+(\\\"+(.*)\\\")");
+ match = casePattern.matcher(strLine);
+ if (match.find()) {
+ caseName = match.group(2);
+ }
+ testCaseIdAndName.put(caseId, caseName);
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ public void getParamsUpdate(String testcases) {
+ try {
+ File file = new File(paramFileName);
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ String line = "", oldtext = "";
+ while ((line = reader.readLine()) != null) {
+ oldtext += line + "\r\n";
+ }
+ reader.close();
+ String newtext = oldtext.replaceAll("<testcases>\\s*(\\d+)</testcases>", "<testcases>" + testcases + "</testcases>");
+ FileWriter writer = new FileWriter(paramFileName);
+ writer.write(newtext);
+ writer.close();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ }
+ }
+
+ public TreeMap getCaseIdAndName() {
+ return testCaseIdAndName;
+ }
+
+ public void getTestSteps(String caseNumber) {
+ OFAFileOperations fileOperation = new OFAFileOperations();
+ int stepCount = 0;
+ String stepCounter = "";
+ BufferedReader input = null;
+ ArrayList<String> contents = new ArrayList<String>();
+ File scriptName = new File(driverFile);
+ if (scriptName.exists()) {
+ try {
+ //use buffering, reading one line at a time
+ //FileReader always assumes default encoding is OK!
+ try {
+ input = new BufferedReader(new FileReader(scriptName));
+ } catch (Exception e) {
+ }
+
+ try {
+ String line = null; //not declared within while loop
+ while ((line = input.readLine()) != null) {
+ contents.add(line);
+ }
+ } finally {
+ try {
+ input.close();
+ } catch (Exception e) {
+ }
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ for (int i = 0; i < contents.size(); i++) {
+ Pattern casePattern = Pattern.compile("\\s*CASE\\s*(\\d+)\\s*");
+ Matcher caseMatcher = casePattern.matcher(contents.get(i));
+ if (caseMatcher.find()) {
+ if (caseMatcher.group(1).equals(caseNumber)) {
+ i++;
+ Pattern casePatterns = Pattern.compile("\\s*CASE\\s*(\\d+)\\s*");
+ Matcher caseMatchers = casePatterns.matcher(contents.get(i));
+ while (!caseMatchers.find() && i < contents.size()) {
+ Pattern casesPatterns = Pattern.compile("\\s*CASE\\s*(\\d+)\\s*");
+ Matcher casesMatchers = casesPatterns.matcher(contents.get(i));
+ if (casesMatchers.find()) {
+ break;
+ } else {
+ Pattern stepPattern = Pattern.compile("\\s*STEP\\s+\"\\s*(.*)\\s*\"\\s*");
+ Matcher stepMatcher = stepPattern.matcher(contents.get(i));
+ try {
+ if (stepMatcher.find()) {
+ stepCount++;
+ stepCounter = caseNumber + "." + String.valueOf(stepCount);
+ stepHash.put(stepCounter, stepMatcher.group(1));
+ }
+ } catch (Exception e) {
+ break;
+ }
+ i++;
+ }
+ }
+ i--;
+ }
+ }
+ }
+ } else {
+ try {
+ //use buffering, reading one line at a time
+ //FileReader always assumes default encoding is OK!
+ try {
+ input = new BufferedReader(new FileReader(pythonFile));
+ } catch (Exception e) {
+ }
+
+ try {
+ String line = null; //not declared within while loop
+ while ((line = input.readLine()) != null) {
+ contents.add(line);
+ }
+ } finally {
+ try {
+ input.close();
+ } catch (Exception e) {
+ }
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+
+ for (int i = 0; i < contents.size(); i++) {
+ Pattern casePattern = Pattern.compile("\\s*def\\s+CASE(\\d+)\\s*\\(\\s*(.*)\\s*\\)\\s*:\\s*");
+ Matcher caseMatcher = casePattern.matcher(contents.get(i));
+ if (caseMatcher.find()) {
+ if (caseMatcher.group(1).equals(caseNumber)) {
+ i++;
+ Pattern casePatterns = Pattern.compile("\\s*def\\s+CASE(\\d+)\\s*\\(\\s*(.*)\\s*\\)\\s*:\\s*");
+ Matcher caseMatchers = casePatterns.matcher(contents.get(i));
+ while (!caseMatchers.find() && i < contents.size()) {
+ Pattern casesPatterns = Pattern.compile("\\s*def\\s+CASE(\\d+)\\s*\\(\\s*(.*)\\s*\\)\\s*:\\s*");
+ Matcher casesMatchers = casesPatterns.matcher(contents.get(i));
+ if (casesMatchers.find()) {
+ break;
+ } else {
+ Pattern stepPattern = Pattern.compile("\\s*main.step\\(\\s*\"\\s*(.*)\\s*\"\\s*\\)\\s*");
+ Matcher stepMatcher = stepPattern.matcher(contents.get(i));
+ try {
+ if (stepMatcher.find()) {
+ stepCount++;
+ stepCounter = caseNumber + "." + String.valueOf(stepCount);
+ stepHash.put(stepCounter, stepMatcher.group(1));
+ }
+ } catch (Exception e) {
+ break;
+ }
+ i++;
+ }
+ }
+ i--;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFATestParameters.java b/TestON/TAI/src/tai_ofa/OFATestParameters.java
new file mode 100644
index 0000000..91d3193
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFATestParameters.java
@@ -0,0 +1,221 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.util.Iterator;
+import javafx.application.Application;
+import javafx.application.Platform;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
+import javafx.scene.control.TreeItem;
+import javafx.scene.control.TreeView;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.StackPane;
+import javafx.stage.Stage;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class OFATestParameters extends Application {
+
+ Stage stage;
+ TAI_OFA ofaReferernce;
+ TreeView<String> projectExplorerTreeView;
+ OFATestSummary testSummaryPop;
+ TreeItem<String> selectetdTest;
+ ObservableList<TreeItem<String>> listProject;
+ ObservableList<TreeItem<String>> paramFile;
+ ComboBox<String> paramList;
+ ComboBox<String> topologyList;
+ String projectToRun;
+ /**
+ * @param args the command line arguments
+ */
+ Button selectTestCase = new Button("Select TestCases");
+ Button startTest = new Button("Start Test");
+ Button cancelButton = new Button("Cancel");
+
+ public void setProjectView(TreeView<String> tree) {
+ projectExplorerTreeView = tree;
+ }
+
+ public OFATestParameters(TAI_OFA ofaReference) {
+ this.ofaReferernce = ofaReference;
+ }
+
+ public void setProjectList(ObservableList<TreeItem<String>> list) {
+ listProject = list;
+ }
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+ @Override
+ public void start(Stage primaryStage) {
+ testSummaryPop = new OFATestSummary(ofaReferernce, stage);
+ stage = primaryStage;
+ primaryStage.setTitle("Test ParaMeter");
+ primaryStage.setResizable(false);
+ GridPane testParameterGrid = new GridPane();
+ testParameterGrid.setPadding(new Insets(100, 0, 0, 60));
+ testParameterGrid.setVgap(8);
+ testParameterGrid.setHgap(2);
+
+ selectTestCase.setDisable(true);
+ startTest.setDisable(true);
+ Label projectName = new Label("Test Name :");;
+ testParameterGrid.add(projectName, 0, 1);
+ final ComboBox<String> projectNameList = new ComboBox<String>();
+ projectNameList.setMinWidth(170);
+
+ ObservableList<String> dataForProject = projectNameList.getItems();
+ final Iterator<TreeItem<String>> projectIterator = listProject.iterator();
+ while (projectIterator.hasNext()) {
+ final TreeItem<String> treeItem = projectIterator.next();
+ dataForProject.add(treeItem.getValue());
+ ObservableList<TreeItem<String>> list = treeItem.getChildren();
+ Iterator<TreeItem<String>> it = list.iterator();
+ }
+ projectNameList.setItems(dataForProject);
+ testParameterGrid.add(projectNameList, 1, 1);
+ projectNameList.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ final Iterator<TreeItem<String>> projectIterator = listProject.iterator();
+ while (projectIterator.hasNext()) {
+ final TreeItem<String> treeItem = projectIterator.next();
+ ObservableList<TreeItem<String>> list = treeItem.getChildren();
+ if (treeItem.getValue().equalsIgnoreCase(projectNameList.getSelectionModel().getSelectedItem())) {
+ ObservableList<TreeItem<String>> children = treeItem.getChildren();
+ final Iterator<TreeItem<String>> testListIterator = children.iterator();
+ while (testListIterator.hasNext()) {
+ selectetdTest = testListIterator.next();
+ paramFile = selectetdTest.getChildren();
+ if (selectetdTest.getGraphic().getId().equals(".params")) {
+ paramList.getItems().add(selectetdTest.getValue());
+ }
+
+ if (selectetdTest.getGraphic().getId().equals(".topo")) {
+ topologyList.getItems().add(selectetdTest.getValue());
+ }
+ selectTestCase.setDisable(false);
+ startTest.setDisable(false);
+ }
+ }
+ }
+ }
+ });
+
+ Label params = new Label("Params");
+ testParameterGrid.add(params, 0, 3);
+ paramList = new ComboBox<String>();
+ paramList.setMinWidth(170);
+ testParameterGrid.add(paramList, 1, 3);
+
+ Label topology = new Label("Topology");
+ testParameterGrid.add(topology, 0, 4);
+ topologyList = new ComboBox<String>();
+ topologyList.setMinWidth(170);
+ testParameterGrid.add(topologyList, 1, 4);
+
+ Label logFolder = new Label("Log Folder");
+ testParameterGrid.add(logFolder, 0, 5);
+ TextField logFolderPath = new TextField();
+ logFolderPath.setMaxWidth(170);
+ testParameterGrid.add(logFolderPath, 1, 5);
+ Label cliOption = new Label("CLI Options:");
+ testParameterGrid.add(cliOption, 0, 6);
+
+ HBox testDirBox = new HBox(5);
+ CheckBox testDirCheck = new CheckBox("Test Directory");
+ TextField testDirPath = new TextField();
+ testDirPath.setMaxWidth(140);
+ testDirBox.getChildren().addAll(testDirCheck, testDirPath);
+ testParameterGrid.add(testDirBox, 1, 7);
+
+ HBox emailBox = new HBox(5);
+ CheckBox emailIdCheck = new CheckBox("Email Id ");
+ TextField emailText = new TextField();
+ emailText.setMaxWidth(140);
+ emailBox.getChildren().addAll(emailIdCheck, emailText);
+ testParameterGrid.add(emailBox, 1, 8);
+
+ HBox optionButton = new HBox(5);
+ optionButton.setPadding(new Insets(0, 0, 0, 0));
+ optionButton.getChildren().addAll(selectTestCase, startTest, cancelButton);
+ testParameterGrid.add(optionButton, 1, 11);
+
+ selectTestCase.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ String testName = projectNameList.getSelectionModel().getSelectedItem();
+ String paramsFileName = paramList.getSelectionModel().getSelectedItem();
+ OFATestCaseSelection testCasePop = new OFATestCaseSelection(testName, paramsFileName);
+ testCasePop.start(new Stage());
+ }
+ });
+
+ startTest.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ testSummaryPop.start(new Stage());
+ Runnable firstRunnable = new Runnable() {
+ public void run() {
+ try {
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ Runnable secondRunnable = new Runnable() {
+ public void run() {
+ try {
+ ExecuteTest tail = new ExecuteTest(testSummaryPop.getTable(), testSummaryPop.getData(), testSummaryPop.getChart(),
+ testSummaryPop.getFinalSummaryTable(), testSummaryPop.getFinalSummaryData(),
+ testSummaryPop.getVieLogsButton(), testSummaryPop.getpieChartData(),
+ testSummaryPop.getPassData(), testSummaryPop.getFailData(), testSummaryPop.getAbortData(),
+ testSummaryPop.getNoResultData(), projectNameList.getSelectionModel().getSelectedItem().toString(), testSummaryPop.getTextArea("log"), testSummaryPop.getStepTable(), testSummaryPop.getStepData(), testSummaryPop.getTextArea("pox"), testSummaryPop.getTextArea("mininet"), testSummaryPop.getTextArea("flowvisor"));
+ tail.runTest();
+ } catch (Exception iex) {
+ }
+ }
+ };
+ Platform.runLater(firstRunnable);
+ Platform.runLater(secondRunnable);
+ stage.close();
+ }
+ });
+ StackPane root = new StackPane();
+ root.getChildren().add(testParameterGrid);
+ primaryStage.setScene(new Scene(root, 460, 360));
+ primaryStage.show();
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFATestSummary.java b/TestON/TAI/src/tai_ofa/OFATestSummary.java
new file mode 100644
index 0000000..3a1dc15
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFATestSummary.java
@@ -0,0 +1,663 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import com.sun.org.apache.xalan.internal.xsltc.compiler.util.StringStack;
+import java.awt.Color;
+import java.awt.TextArea;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javafx.application.Application;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.geometry.Orientation;
+import javafx.scene.Group;
+import javafx.scene.Scene;
+import javafx.scene.chart.PieChart;
+import javafx.scene.control.Button;
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.ComboBoxBuilder;
+import javafx.scene.control.Label;
+import javafx.scene.control.Separator;
+import javafx.scene.control.SplitPane;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableView;
+import javafx.scene.control.TextAreaBuilder;
+import javafx.scene.control.TextField;
+import javafx.scene.control.TextFieldBuilder;
+import javafx.scene.control.ToolBar;
+import javafx.scene.control.Tooltip;
+import javafx.scene.control.cell.PropertyValueFactory;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.layout.FlowPane;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.StackPane;
+import javafx.scene.layout.VBox;
+import javafx.scene.text.Text;
+import javafx.stage.Stage;
+import javafx.stage.WindowEvent;
+import org.apache.xmlrpc.XmlRpcClient;
+import org.apache.xmlrpc.XmlRpcException;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class OFATestSummary extends Application {
+
+ ObservableList<SummaryTable> data;
+ ObservableList<FinalSummaryTable> summaryData;
+ ObservableList<StepTable> stepData;
+ TableView<SummaryTable> summaryTable;
+ TableView<StepTable> stepTable;
+ PieChart.Data passData = new PieChart.Data("Pass", 0);
+ PieChart.Data failData = new PieChart.Data("Fail", 0);
+ PieChart.Data abortData = new PieChart.Data("Abort", 0);
+ PieChart.Data noResult = new PieChart.Data("No Result", 0);
+ ObservableList<PieChart.Data> pieChartData;
+ TableView<FinalSummaryTable> finalSummaryTable = new TableView<FinalSummaryTable>();
+ TableColumn testCaseIdColumn, testCaseNameColumn;
+ TableColumn testCaseStatusColumn, testCaseStartTimeColumn, testCaseEndTimeColumn;
+ Button viewLogs = new Button("Debug & Console");
+ GridPane buttonPane = new GridPane();
+ TableColumn stepId, stepName, stepStatus;
+ TableColumn summaryItem, information;
+ HashMap<String, String> testCaseIdAndName = new HashMap<String, String>();
+ String caseId, caseName;
+ Stage copyStage;
+ PieChart chart;
+ StackPane rootStack;
+ TAI_OFA ofaReference;
+ Stage paramaterWindow;
+ ComboBox LogBox;
+ TabPane execWindow = new TabPane();
+ Tab debugLog = new Tab("Debug Logs");
+ Tab componentLog = new Tab("Test Log");
+ Tab testSummaryTab = new Tab("Test Summary");
+ Tab dpctlSessionTab = new Tab("FlowVisor1.session");
+ Tab mininetSessionTab = new Tab("Mininet1.session");
+ Tab poxSessionTab = new Tab("POX2.session");
+ TabPane baseTabPane = new TabPane();
+ javafx.scene.control.TextArea debugLogText = TextAreaBuilder.create().build();
+ javafx.scene.control.TextArea compononetLogText = TextAreaBuilder.create().build();
+ javafx.scene.control.TextArea flowVisorSessionText = TextAreaBuilder.create().build();
+ javafx.scene.control.TextArea poxSessionText = TextAreaBuilder.create().build();
+ javafx.scene.control.TextArea mininetSessionText = TextAreaBuilder.create().build();
+ String variableName = "";
+ String command = "";
+ ToolBar quickLauchBar = new ToolBar();
+ Double toolBarHeight;
+ Scene scene;
+ SplitPane baseSplitPane = new SplitPane();
+ TabPane consoleTabPane;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+ public OFATestSummary(TAI_OFA ofaReference, Stage paramaterWindow) {
+ this.ofaReference = ofaReference;
+ this.paramaterWindow = paramaterWindow;
+ }
+
+ public void start(Stage primaryStage) {
+ copyStage = primaryStage;
+ primaryStage.setTitle("Test Execution Status");
+ primaryStage.setResizable(false);
+ Group rootGroup = new Group();
+ scene = new Scene(rootGroup, 1020, 920);
+ Pane basePanel = new Pane();
+ HBox baseBox = new HBox();
+ VBox consoleBox = new VBox();
+ VBox buttonBox = new VBox();
+
+ getDebugTab();
+ getToolBar();
+ buttonBox.getChildren().addAll(buttonPane);
+ consoleBox.getChildren().addAll(quickLauchBar, baseTabPane);
+ baseBox.getChildren().addAll(consoleBox);
+ basePanel.getChildren().addAll(baseBox);
+ SplitPane sp = getTestSummary();
+ testSummaryTab.setContent(sp);
+ testSummaryTab.setClosable(false);
+ baseTabPane.getTabs().addAll(testSummaryTab);
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = baseTabPane.getSelectionModel();
+ selectionModel.select(testSummaryTab);
+ baseTabPane.prefWidthProperty().bind(scene.widthProperty().subtract(200));
+ baseTabPane.prefHeightProperty().bind(scene.heightProperty().subtract(10));
+ primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
+ @Override
+ public void handle(WindowEvent t) {
+ XmlRpcClient server;
+ try {
+ server = new XmlRpcClient("http://localhost:9000");
+ Vector params = new Vector();
+ params.add(new String("main"));
+ try {
+ server.execute("stop", new Vector());
+ } catch (XmlRpcException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ } catch (MalformedURLException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ basePanel.prefHeightProperty().bind(scene.heightProperty());
+ quickLauchBar.prefWidthProperty().bind(scene.widthProperty());
+ quickLauchBar.setMinHeight(scene.heightProperty().get() / 20);
+ toolBarHeight = quickLauchBar.getMinHeight();
+ baseTabPane.prefHeightProperty().bind(scene.heightProperty());
+ baseBox.prefHeightProperty().bind(scene.heightProperty());
+ consoleBox.prefHeightProperty().bind(scene.heightProperty());
+ rootGroup.getChildren().addAll(basePanel);
+ primaryStage.setScene(scene);
+ primaryStage.show();
+
+ }
+
+ public TableView getTable() {
+ return summaryTable;
+ }
+
+ public SplitPane getTestSummary() {
+ GridPane testCaseSummaryTable = new GridPane();
+ testCaseSummaryTable.setPadding(new Insets(10, 0, 0, 10));
+ GridPane finalSummaryPane = new GridPane();
+ finalSummaryPane.setPadding(new Insets(300, 0, 0, 20));
+ GridPane stepSummaryPane = new GridPane();
+ stepSummaryPane.setPadding(new Insets(300, 0, 0, 20));
+
+ CheckBox selectTestCase = new CheckBox();
+ summaryTable = new TableView<SummaryTable>();
+ stepTable = new TableView<StepTable>();
+ summaryTable.setMinWidth(580);
+ summaryTable.setMaxHeight(250);
+ testCaseIdColumn = new TableColumn(ofaReference.label.testSummaryTestCaseId);
+ testCaseIdColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseId"));
+ testCaseIdColumn.setMaxWidth(30);
+ testCaseIdColumn.setResizable(true);
+
+ testCaseNameColumn = new TableColumn(ofaReference.label.testSummaryTestCaseName);
+ testCaseNameColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseName"));
+ testCaseNameColumn.setMinWidth(303);
+ testCaseNameColumn.setResizable(true);
+
+ testCaseStatusColumn = new TableColumn(ofaReference.label.testSummaryExecutionStatus);
+ testCaseStatusColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseStatus"));
+ testCaseStatusColumn.setMinWidth(85);
+ testCaseStatusColumn.setResizable(true);
+
+ testCaseStartTimeColumn = new TableColumn(ofaReference.label.testSummaryStartTest);
+ testCaseStartTimeColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseStartTime"));
+ testCaseStartTimeColumn.setMinWidth(195);
+ testCaseStartTimeColumn.setResizable(true);
+
+ testCaseEndTimeColumn = new TableColumn(ofaReference.label.testSummaryEndTest);
+ testCaseEndTimeColumn.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("testCaseEndTime"));
+ testCaseEndTimeColumn.setMinWidth(195);
+ testCaseEndTimeColumn.setResizable(true);
+
+ summaryTable.setItems(data);
+ summaryTable.getColumns().addAll(testCaseIdColumn, testCaseNameColumn, testCaseStatusColumn, testCaseStartTimeColumn, testCaseEndTimeColumn);
+
+ summaryItem = new TableColumn(ofaReference.label.summary);
+ summaryItem.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("summaryItem"));
+ summaryItem.setMinWidth(140);
+ summaryItem.setResizable(true);
+
+ information = new TableColumn(ofaReference.label.information);
+ information.setCellValueFactory(new PropertyValueFactory<SummaryTable, Label>("information"));
+ information.setMinWidth(210);
+ information.setResizable(true);
+
+ finalSummaryTable.setMinWidth(350);
+ finalSummaryTable.setMaxHeight(300);
+ SplitPane leftPane = new SplitPane();
+ SplitPane rightPane = new SplitPane();
+ leftPane.setOrientation(Orientation.HORIZONTAL);
+ rightPane.setOrientation(Orientation.VERTICAL);
+ finalSummaryTable.setItems(summaryData);
+ finalSummaryTable.setVisible(false);
+ finalSummaryTable.getColumns().addAll(summaryItem, information);
+ HBox pieChart = new HBox(10);
+ pieChart.setPadding(new Insets(300, 0, 0, 300));
+ ArrayList<PieChart.Data> dataList = new ArrayList<PieChart.Data>();
+
+ dataList.add(passData);
+ dataList.add(failData);
+ dataList.add(abortData);
+ dataList.add(noResult);
+ pieChartData = FXCollections.observableArrayList(dataList);
+ chart = new PieChart(pieChartData);
+ chart.setTitle(ofaReference.label.testSummaryTestSummary);
+ pieChart.getChildren().add(chart);
+ chart.setVisible(false);
+ summaryTable.setVisible(false);
+ stepTable.setVisible(true);
+ stepTable.setMinWidth(450);
+ stepTable.setMaxHeight(300);
+
+ stepId = new TableColumn("ID");
+ stepId.setCellValueFactory(new PropertyValueFactory<StepTable, Label>("testStepId"));
+ stepId.setMinWidth(10);
+ stepId.setResizable(true);
+
+ stepName = new TableColumn("Name");
+ stepName.setCellValueFactory(new PropertyValueFactory<StepTable, Label>("testStepName"));
+ stepName.setMinWidth(470);
+ stepName.setResizable(true);
+
+ stepStatus = new TableColumn("Status");
+ stepStatus.setCellValueFactory(new PropertyValueFactory<StepTable, Label>("testStepStatus"));
+ stepStatus.setMinWidth(40);
+ stepStatus.setResizable(true);
+ stepTable.getColumns().addAll(stepId, stepName, stepStatus);
+ stepTable.setItems(stepData);
+ stepSummaryPane.add(stepTable, 0, 2);
+
+ finalSummaryPane.add(finalSummaryTable, 0, 2);
+ rootStack = new StackPane();
+ testCaseSummaryTable.add(summaryTable, 0, 1);
+ rootStack.getChildren().addAll(testCaseSummaryTable, pieChart, stepSummaryPane, finalSummaryPane);
+ leftPane.getItems().addAll(rootStack);
+ consoleTabPane = new TabPane();
+ consoleTabPane.setPrefWidth(700);
+ consoleTabPane.getTabs().addAll(componentLog, debugLog, dpctlSessionTab, mininetSessionTab, poxSessionTab);
+
+ Image topoImage = new Image("images/topo.png", 400, 200, true, true);
+ ImageView topo = new ImageView(topoImage);
+ TabPane imageTabPane = new TabPane();
+ Tab imageTab = new Tab("Test Topology");
+ imageTab.setContent(topo);
+ imageTabPane.getTabs().add(imageTab);
+ imageTabPane.setMinWidth(300);
+ rightPane.getItems().addAll(imageTabPane, consoleTabPane);
+ rightPane.setDividerPosition(1, 400);
+ baseSplitPane.setDividerPosition(1, 10);
+ baseSplitPane.getItems().addAll(leftPane, rightPane);
+ return baseSplitPane;
+ }
+
+ public void getDebugTab() {
+ poxSessionText.prefWidth(450);
+ poxSessionText.prefHeight(620);
+ poxSessionText.setStyle(
+ "-fx-text-fill: #0A0A2A;"
+ + "-fx-background-color: #EFFBFB;");
+ poxSessionText.setEditable(false);
+ poxSessionTab.setContent(poxSessionText);
+ flowVisorSessionText.prefWidth(450);
+ flowVisorSessionText.prefHeight(620);
+ flowVisorSessionText.setStyle(
+ "-fx-text-fill: #0A0A2A;"
+ + "-fx-background-color: #EFFBFB;");
+ flowVisorSessionText.setEditable(false);
+ dpctlSessionTab.setContent(flowVisorSessionText);
+ mininetSessionText.prefWidth(450);
+ mininetSessionText.prefHeight(620);
+ mininetSessionText.setStyle(
+ "-fx-text-fill: #0A0A2A;"
+ + "-fx-background-color: #EFFBFB;");
+ mininetSessionText.setEditable(false);
+ mininetSessionTab.setContent(mininetSessionText);
+ debugLogText.prefWidth(450);
+ debugLogText.prefHeight(620);
+ debugLogText.setStyle(
+ "-fx-text-fill: #0A0A2A;"
+ + "-fx-background-color: #EFFBFB;");
+ debugLogText.setEditable(false);
+ componentLog.setClosable(false);
+ compononetLogText.prefWidth(350);
+ compononetLogText.prefHeight(620);
+ compononetLogText.setStyle(
+ "-fx-text-fill: #0A0A2A;"
+ + "-fx-background-color: #EFFBFB;");
+ compononetLogText.setEditable(false);
+ componentLog.setContent(compononetLogText);
+ debugLog.setClosable(false);
+ debugLog.setContent(debugLogText);
+ debugLog.setContent(debugLogText);
+ }
+
+ public void getToolBar() {
+ Image pauseImage = new Image("images/Pause.png", 20.0, 20.0, true, true);
+ Button pause = new Button("", new ImageView(pauseImage));
+ Image stopImage = new Image("images/Stop.png", 20.0, 20.0, true, true);
+ Button stop = new Button("", new ImageView(stopImage));
+ stop.setTooltip(new Tooltip("Stop"));
+
+ Image resumeImage = new Image("images/Resume_1.png", 20.0, 20.0, true, true);
+ Button resume = new Button("", new ImageView(resumeImage));
+ resume.setTooltip(new Tooltip("Resume"));
+
+ Image dumpVarImage = new Image("images/dumpvar.png", 20.0, 20.0, true, true);
+ Button dumpVar = new Button("", new ImageView(dumpVarImage));
+ dumpVar.setTooltip(new Tooltip("Dump Var"));
+
+ Image showlogImage = new Image("images/showlog.jpg", 20.0, 20.0, true, true);
+ Button showlog = new Button("", new ImageView(showlogImage));
+ showlog.setTooltip(new Tooltip("Show Log"));
+
+ Image currentCaseImage = new Image("images/currentcase.jpg", 20.0, 20.0, true, true);
+ Button currentcase = new Button("", new ImageView(currentCaseImage));
+ currentcase.setTooltip(new Tooltip("Current Case"));
+
+ Image currentStepImage = new Image("images/currentstep.png", 20.0, 20.0, true, true);
+ Button currentStep = new Button("", new ImageView(currentStepImage));
+ currentStep.setTooltip(new Tooltip("Current Step"));
+
+ Image nextStepImage = new Image("images/nextStep.jpg", 20.0, 20.0, true, true);
+ Button nextStep = new Button("", new ImageView(nextStepImage));
+ nextStep.setTooltip(new Tooltip("Next Step"));
+
+ Image compileImage = new Image("images/compile.jpg", 20.0, 20.0, true, true);
+ Button compile = new Button("", new ImageView(compileImage));
+ compile.setTooltip(new Tooltip("Compile"));
+
+ Image getTestImage = new Image("images/testname.jpg", 20.0, 20.0, true, true);
+ Button getTest = new Button("", new ImageView(getTestImage));
+ getTest.setTooltip(new Tooltip("Get Test"));
+
+ Image interpretImage = new Image("images/interpreter.jpg", 20.0, 20.0, true, true);
+ Button interpret = new Button("", new ImageView(interpretImage));
+ interpret.setTooltip(new Tooltip("Interpret"));
+
+ Image doImage = new Image("images/do.jpg", 20.0, 20.0, true, true);
+ Button doCommand = new Button("", new ImageView(doImage));
+ doCommand.setTooltip(new Tooltip("Do"));
+
+ Image redoImage = new Image("images/redo.png", 20.0, 20.0, true, true);
+ Button redoCommand = new Button("", new ImageView(redoImage));
+ redoCommand.setTooltip(new Tooltip("Re-execute"));
+
+ final Button submit = new Button("Enter");
+ final TextField value = TextFieldBuilder.create().build();
+ value.setMinWidth(480);
+ final ExecutionConsole execConsole = new ExecutionConsole(command, submit, value);
+
+ redoCommand.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ requestServer("redo", new Vector());
+ requestServer("resume", new Vector());
+ }
+ });
+
+ getTest.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ requestServer("getTest", new Vector());
+ }
+ });
+
+ doCommand.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ try {
+ command = "doCommand";
+ execConsole.start(new Stage());
+ execConsole.setTitles("do Command");
+ } catch (Exception ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ interpret.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ try {
+ value.setEditable(true);
+ command = "interpret";
+ execConsole.start(new Stage());
+ execConsole.setTitles("interpret Command");
+ } catch (Exception ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ compile.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ try {
+ command = "doCompile";
+ execConsole.start(new Stage());
+ execConsole.setTitles("compile Command");
+ } catch (Exception ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ resume.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ requestServer("resume", new Vector());
+ }
+ });
+
+ nextStep.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ requestServer("nextStep", new Vector());
+ }
+ });
+
+ currentStep.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ requestServer("currentStep", new Vector());
+ }
+ });
+
+ currentcase.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ requestServer("currentCase", new Vector());
+ }
+ });
+
+ showlog.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ requestServer("showLog", new Vector());
+ }
+ });
+
+ submit.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ variableName = value.getText();
+ execConsole.closeWindow();
+ Vector params = new Vector();
+ params.add(variableName);
+ requestServer(command, params);
+ }
+ });
+ dumpVar.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ try {
+ command = "dumpVar";
+ execConsole.start(new Stage());
+ execConsole.setTitles("dumpvar Command");
+ } catch (Exception ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+
+ }
+ });
+
+ pause.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ XmlRpcClient server;
+ try {
+ server = new XmlRpcClient("http://localhost:9000");
+ try {
+ Object response = server.execute("pauseTest", new Vector());
+ compononetLogText.appendText("\n Will pause the test's execution, after completion of this step.....\n\n");
+ } catch (XmlRpcException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ } catch (MalformedURLException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ stop.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ XmlRpcClient server;
+ try {
+ server = new XmlRpcClient("http://localhost:9000");
+ Vector params = new Vector();
+ try {
+ server.execute("stop", new Vector());
+ } catch (XmlRpcException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ } catch (MalformedURLException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ quickLauchBar.getItems().addAll(pause, resume, stop, new Separator(Orientation.VERTICAL), dumpVar, currentcase, currentStep, showlog, nextStep,
+ new Separator(Orientation.VERTICAL), getTest, compile, doCommand, interpret, redoCommand);
+ }
+
+ public void requestServer(String request, Vector params) {
+
+ XmlRpcClient server;
+ try {
+ server = new XmlRpcClient("http://localhost:9000");
+ try {
+ Object response = server.execute(request, params);
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = consoleTabPane.getSelectionModel();
+ selectionModel.select(debugLog);
+ debugLogText.appendText(request + " Ouput \n =====================================================================\n");
+ debugLogText.appendText(response.toString());
+ debugLogText.appendText("\n ======================================================================\n");
+ } catch (XmlRpcException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ } catch (MalformedURLException ex) {
+ Logger.getLogger(OFATestSummary.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+
+ public Button getVieLogsButton() {
+ return viewLogs;
+ }
+
+ public StackPane getRoot() {
+ return rootStack;
+ }
+
+ public ObservableList<SummaryTable> getData() {
+ return data;
+ }
+
+ public PieChart getChart() {
+ return chart;
+ }
+
+ public TableView getFinalSummaryTable() {
+ return finalSummaryTable;
+ }
+
+ public ObservableList<FinalSummaryTable> getFinalSummaryData() {
+ return summaryData;
+ }
+
+ public ObservableList<PieChart.Data> getpieChartData() {
+ return pieChartData;
+ }
+
+ public javafx.scene.control.TextArea getTextArea(String name) {
+ if (name.equals("log")) {
+ return compononetLogText;
+ } else if (name.equals("pox")) {
+ return poxSessionText;
+ } else if (name.equals("flowvisor")) {
+ return flowVisorSessionText;
+ } else if (name.equals("mininet")) {
+ return mininetSessionText;
+ }
+ return new javafx.scene.control.TextArea();
+ }
+
+ public PieChart.Data getPassData() {
+ return passData;
+ }
+
+ public PieChart.Data getFailData() {
+ return failData;
+ }
+
+ public PieChart.Data getAbortData() {
+ return abortData;
+ }
+
+ public PieChart.Data getNoResultData() {
+ return noResult;
+ }
+
+ ///Step TABLE
+ public TableView getStepTable() {
+ return stepTable;
+ }
+
+ public ObservableList<StepTable> getStepData() {
+ return stepData;
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFATopology.java b/TestON/TAI/src/tai_ofa/OFATopology.java
new file mode 100644
index 0000000..b2e6830
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFATopology.java
@@ -0,0 +1,278 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Locale;
+import javafx.application.Application;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.Event;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.Label;
+import javafx.scene.control.PasswordField;
+import javafx.scene.control.RadioButton;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.control.TableColumn;
+import javafx.scene.control.TableColumn.CellEditEvent;
+import javafx.scene.control.TableView;
+import javafx.scene.control.TextField;
+import javafx.scene.control.TextFieldBuilder;
+import javafx.scene.control.cell.PropertyValueFactory;
+import javafx.scene.control.cell.TextFieldTableCell;
+import javafx.scene.input.KeyCode;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+import javafx.stage.Stage;
+import sun.misc.Cleaner;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class OFATopology extends Application {
+
+ public OFATopology() {
+ }
+ ObservableList<OFATopologyInterface> data;
+ TableView<OFATopologyInterface> deviceTable;
+ TableColumn device;
+ TableColumn number;
+ TableColumn type;
+ int count = 1;
+ String getHostName, getUserName, getPassword, getTranportProtocol, getPort;
+ ArrayList<String> getAttribute = new ArrayList<String>();
+ ArrayList<String> getValue = new ArrayList<String>();
+ ArrayList<TextField> attributeList = new ArrayList<TextField>();
+ ArrayList<TextField> valueList = new ArrayList<TextField>();
+ TextField attributeText;
+ Button interFacesave;
+ TextField valueText;
+ Button save;
+ TextField hostNameText;
+ TextField userNameText;
+ PasswordField passwordText;
+ TextField portText;
+ TextField deviceText;
+ ComboBox<String> transportList;
+ Stage copyStage;
+ ArrayList<String> propertyDetail = new ArrayList<String>();
+ HashMap<TextField, TextField> hashProperty = new HashMap<TextField, TextField>();
+ Button defaultButton;
+ Button cancelButton;
+ RadioButton testTargetRadioButton;
+ TAILocale label = new TAILocale(new Locale("en", "EN"));
+
+ /**
+ * @param args the command line arguments
+ */
+ OFATopology(TextField text) {
+ deviceText = text;
+ }
+
+ @Override
+ public void start(final Stage primaryStage) {
+ copyStage = primaryStage;
+ primaryStage.setTitle(label.topoTitle);
+ primaryStage.setResizable(false);
+ TabPane toplogyTabPane = new TabPane();
+ toplogyTabPane.setMaxHeight(280);
+ Tab propertyTab = new Tab(label.topoProperties);
+ Tab interfaceTab = new Tab("Component");
+ propertyTab.setClosable(false);
+ interfaceTab.setClosable(false);
+ toplogyTabPane.getTabs().addAll(propertyTab, interfaceTab);
+
+ GridPane propertyGrid = new GridPane();
+ propertyGrid.setVgap(8);
+ propertyGrid.setHgap(10);
+ propertyGrid.setPadding(new Insets(10, 0, 0, 50));
+
+ Label attribute = new Label(label.topoAttribute);
+ attribute.setStyle("-fx-padding: 0; -fx-background-color: lightgray; -fx-border-width: 2;-fx-border-color: gray;");
+ propertyGrid.add(attribute, 0, 1);
+
+ Label value = new Label(label.topoValue);
+ value.setStyle("-fx-padding: 0; -fx-background-color: lightgray; -fx-border-width: 2;-fx-border-color: gray;");
+ propertyGrid.add(value, 1, 1);
+
+ Label hostName = new Label(label.topoHost);
+ propertyGrid.add(hostName, 0, 2);
+ hostNameText = new TextField();
+ propertyGrid.add(hostNameText, 1, 2);
+ Label userName = new Label(label.topoUserName);
+ propertyGrid.add(userName, 0, 3);
+ userNameText = new TextField();
+ propertyGrid.add(userNameText, 1, 3);
+ Label password = new Label(label.topoPassword);
+ propertyGrid.add(password, 0, 4);
+ passwordText = new PasswordField();
+ propertyGrid.add(passwordText, 1, 4);
+ Label transport = new Label(label.topoTransport);
+ transportList = new ComboBox<String>();
+ transportList.setMinWidth(200);
+ transportList.getItems().addAll(label.topoSSH, label.topoTELNET, label.topoFTP, label.topoRLOGIN);
+ Label testTargetLabel = new Label("Test Target");
+ propertyGrid.add(testTargetLabel, 0, 5);
+ testTargetRadioButton = new RadioButton("True");
+ propertyGrid.add(testTargetRadioButton, 1, 5);
+ HBox propertyButton = new HBox(5);
+
+ propertyButton.setPadding(new Insets(280, 0, 0, 140));
+ save = new Button(label.topoSave);
+ defaultButton = new Button(label.topoDefault);
+ cancelButton = new Button(label.topoCancel);
+ propertyButton.getChildren().addAll(save, defaultButton, cancelButton);
+ propertyTab.setContent(propertyGrid);
+
+ // interface tab code
+ GridPane interfaceGridPane = new GridPane();
+ interfaceGridPane.setVgap(20);
+ interfaceGridPane.setHgap(20);
+ interfaceGridPane.setPadding(new Insets(10, 0, 0, 10));
+ Label interFaceNumber = new Label("" + count);
+ attributeText = new TextField();
+ valueText = new TextField();
+
+ valueText.setOnKeyPressed(new EventHandler<KeyEvent>() {
+ @Override
+ public void handle(KeyEvent keyEvent) {
+ if (keyEvent.getCode() == KeyCode.ENTER) {
+ deviceTable.getSelectionModel().select(deviceTable.getItems().size() - 1);
+ if (deviceTable.getSelectionModel().isSelected(deviceTable.getItems().size() - 1)) {
+ if (!deviceTable.getSelectionModel().getSelectedItem().getDeviceName().getText().equals("") && !deviceTable.getSelectionModel().getSelectedItem().getDeviceType().getText().equals("")) {
+ addInterFace();
+ }
+ }
+ }
+ }
+ });
+
+ deviceTable = new TableView<OFATopologyInterface>();
+ data = FXCollections.observableArrayList(new OFATopologyInterface(interFaceNumber, attributeText, valueText));
+ deviceTable.setMinWidth(330);
+ deviceTable.setMaxHeight(200);
+ number = new TableColumn(label.topoInterfaces);
+ number.setCellValueFactory(new PropertyValueFactory<OFATopologyInterface, Label>("interFaceNumber"));
+ number.setMinWidth(90);
+ number.setResizable(false);
+ device = new TableColumn(label.topoAttribute);
+ device.setCellValueFactory(new PropertyValueFactory<OFATopologyInterface, TextField>("deviceName"));
+ device.setMaxWidth(119);
+ device.setResizable(false);
+ type = new TableColumn(label.topoValues);
+ type.setCellValueFactory(new PropertyValueFactory<OFATopologyInterface, TextField>("deviceType"));
+ type.setMaxWidth(119);
+ type.setResizable(false);
+ deviceTable.setItems(data);
+ deviceTable.getColumns().addAll(number, device, type);
+ interfaceGridPane.add(deviceTable, 0, 1);
+ interfaceTab.setContent(interfaceGridPane);
+ HBox interFaceButton = new HBox(5);
+ interFaceButton.setPadding(new Insets(0, 0, 0, 2));
+ attributeList.add(attributeText);
+ valueList.add(valueText);
+ hashProperty.put(attributeText, valueText);
+
+ interfaceGridPane.add(interFaceButton, 0, 2);
+ Pane root = new Pane();
+ root.getChildren().addAll(propertyButton, toplogyTabPane);
+ primaryStage.setScene(new Scene(root, 350, 300));
+ primaryStage.show();
+ }
+
+ public void addInterFace() {
+ int intNumber = ++count;
+ Label interFaceNumber = new Label("" + intNumber);
+ attributeText = new TextField();
+ attributeList.add(attributeText);
+ valueText = new TextField();
+ attributeText.setMaxWidth(120);
+ valueText.setMinWidth(120);
+ hashProperty.put(attributeText, valueText);
+ for (int i = 0; i < deviceTable.getItems().size(); i++) {
+ deviceTable.getSelectionModel().select(deviceTable.getItems().size() - 1);
+ }
+
+ deviceTable.getSelectionModel().select(deviceTable.getItems().size());
+ valueText.setOnKeyPressed(new EventHandler<KeyEvent>() {
+ @Override
+ public void handle(KeyEvent keyEvent) {
+ if (keyEvent.getCode() == KeyCode.ENTER) {
+ deviceTable.getSelectionModel().select(deviceTable.getItems().size() - 1);
+ if (deviceTable.getSelectionModel().isSelected(deviceTable.getItems().size() - 1)) {
+ if (!deviceTable.getSelectionModel().getSelectedItem().getDeviceName().getText().equals("") && !deviceTable.getSelectionModel().getSelectedItem().getDeviceType().getText().equals("")) {
+ addInterFace();
+ }
+ }
+
+ }
+ }
+ });
+ valueList.add(valueText);
+ data.add(new OFATopologyInterface(interFaceNumber, attributeText, valueText));
+ number.setCellValueFactory(new PropertyValueFactory<OFATopologyInterface, Label>("interFaceNumber"));
+ number.setMinWidth(90);
+ number.setResizable(false);
+ device.setCellValueFactory(new PropertyValueFactory<OFATopologyInterface, TextField>("deviceName"));
+ device.setMaxWidth(120);
+ device.setResizable(false);
+ type.setCellValueFactory(new PropertyValueFactory<OFATopologyInterface, TextField>("deviceType"));
+ type.setMaxWidth(120);
+ type.setResizable(false);
+ deviceTable.setItems(data);
+ deviceTable.setEditable(true);
+ }
+
+ public String getHostName() {
+ return getHostName;
+ }
+
+ public String getUserName() {
+ return getUserName;
+ }
+
+ public String getPassword() {
+ return getPassword;
+ }
+
+ public String getTransportProtocool() {
+ return getTranportProtocol;
+ }
+
+ public String getPort() {
+ return getPort;
+ }
+
+ public ArrayList getAtttribute() {
+ return getAttribute;
+ }
+
+ public ArrayList getValue() {
+ return getValue;
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFATopologyInterface.java b/TestON/TAI/src/tai_ofa/OFATopologyInterface.java
new file mode 100644
index 0000000..085a64f
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFATopologyInterface.java
@@ -0,0 +1,64 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class OFATopologyInterface {
+ public Label interFaceNumber;
+ private TextField deviceName;
+ private TextField deviceType;
+
+
+
+ public OFATopologyInterface(Label emailtext,TextField deviceNameText,TextField deviceTypeText){
+ this.deviceName = deviceNameText;
+ this.deviceType = deviceTypeText;
+ this.interFaceNumber = emailtext;
+ }
+
+ public TextField getDeviceName() {
+ return deviceName;
+ }
+ public void setDeviceName(TextField fName) {
+ deviceName = fName;
+ }
+
+ public TextField getDeviceType() {
+ return deviceType;
+ }
+ public void setDeviceType(TextField fName) {
+ deviceType = fName;
+ }
+
+ public Label getInterFaceNumber() {
+ return interFaceNumber;
+ }
+ public void setInterFaceNumber(Label fName) {
+ interFaceNumber = fName;
+ }
+}
+
+
+
diff --git a/TestON/TAI/src/tai_ofa/OFATopologyLink.java b/TestON/TAI/src/tai_ofa/OFATopologyLink.java
new file mode 100644
index 0000000..8efe264
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFATopologyLink.java
@@ -0,0 +1,128 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import javafx.application.Application;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.StackPane;
+import javafx.stage.Stage;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+class OFATopologyLink extends Application {
+
+ Label device1;
+ ComboBox<String> devicesInTopoEditor;
+ ComboBox<String> destDevicesInTopoEditor;
+ ComboBox<String> interfaceList2;
+ ComboBox<String> interfaceList4;
+ GridPane propertyGrid = new GridPane();
+ Button finishSelectedLink;
+ Button cancelButton;
+ TextField nameText;
+ TextField typeText;
+ Stage copyStage;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+ @Override
+ public void start(final Stage primaryStage) {
+ copyStage = primaryStage;
+ primaryStage.setTitle("Selected Link Popup");
+ propertyGrid.setVgap(8);
+ propertyGrid.setHgap(30);
+ primaryStage.setResizable(false);
+ propertyGrid.setPadding(new Insets(10, 0, 0, 50));
+ devicesInTopoEditor = new ComboBox<String>();
+ interfaceList2 = new ComboBox<String>();
+ Label attribute = new Label("Attribute");
+ attribute.setStyle("-fx-padding: 0; -fx-background-color: lightgray; -fx-border-width: 2;-fx-border-color: gray;");
+ propertyGrid.add(attribute, 0, 1);
+
+ Label value = new Label("Value");
+ value.setStyle("-fx-padding: 0; -fx-background-color: lightgray; -fx-border-width: 2;-fx-border-color: gray;");
+ propertyGrid.add(value, 1, 1);
+ Label name = new Label("Name");
+ propertyGrid.add(name, 0, 2);
+ nameText = new TextField();
+ propertyGrid.add(nameText, 1, 2);
+
+ Label type = new Label("Type");
+ propertyGrid.add(type, 0, 3);
+ typeText = new TextField();
+ propertyGrid.add(typeText, 1, 3);
+ device1 = new Label("Source Device");
+ propertyGrid.add(device1, 0, 4);
+ devicesInTopoEditor.setMinWidth(170);
+ propertyGrid.add(devicesInTopoEditor, 1, 4);
+
+ Label interface1 = new Label("Interface");
+ propertyGrid.add(interface1, 0, 5);
+ interfaceList2 = new ComboBox<String>();
+ interfaceList2.setMinWidth(170);
+ propertyGrid.add(interfaceList2, 1, 5);
+
+ Label device2 = new Label("Destination Device");
+ propertyGrid.add(device2, 0, 6);
+ destDevicesInTopoEditor = new ComboBox<String>();
+ destDevicesInTopoEditor.setMinWidth(170);
+ propertyGrid.add(destDevicesInTopoEditor, 1, 6);
+
+ Label device3 = new Label("Interface");
+ propertyGrid.add(device3, 0, 7);
+ interfaceList4 = new ComboBox<String>();
+ interfaceList4.setMinWidth(170);
+ propertyGrid.add(interfaceList4, 1, 7);
+
+ HBox propertyButton = new HBox(5);
+ propertyButton.setPadding(new Insets(0, 0, 0, 0));
+ finishSelectedLink = new Button("Save");
+
+ cancelButton = new Button("Cancel");
+ propertyButton.getChildren().addAll(new Label(" "), finishSelectedLink, cancelButton);
+ propertyGrid.add(propertyButton, 1, 8);
+
+ cancelButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ primaryStage.close();
+ }
+ });
+ StackPane root = new StackPane();
+ root.getChildren().add(propertyGrid);
+ primaryStage.setScene(new Scene(root, 450, 320));
+ primaryStage.show();
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/OFAWizard.java b/TestON/TAI/src/tai_ofa/OFAWizard.java
new file mode 100644
index 0000000..d046989
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/OFAWizard.java
@@ -0,0 +1,2204 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.security.acl.Owner;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Observable;
+import java.util.Set;
+import java.util.Stack;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javafx.application.Application;
+import javafx.beans.property.DoubleProperty;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.geometry.Orientation;
+import javafx.geometry.Side;
+import javafx.scene.Cursor;
+import javafx.scene.Node;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.ComboBoxBuilder;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.Label;
+import javafx.scene.control.MenuItem;
+import javafx.scene.control.MultipleSelectionModel;
+import javafx.scene.control.Separator;
+import javafx.scene.control.SingleSelectionModel;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.control.TextField;
+import javafx.scene.control.TextFieldBuilder;
+import javafx.scene.control.ToolBar;
+import javafx.scene.control.Tooltip;
+import javafx.scene.control.TreeItem;
+import javafx.scene.control.TreeView;
+import javafx.scene.effect.DropShadow;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.input.ClipboardContent;
+import javafx.scene.input.DragEvent;
+import javafx.scene.input.Dragboard;
+import javafx.scene.input.KeyEvent;
+import javafx.scene.input.MouseButton;
+import javafx.scene.input.MouseDragEvent;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.input.TransferMode;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.BorderPaneBuilder;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.GridPaneBuilder;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.Priority;
+import javafx.scene.layout.Region;
+import javafx.scene.layout.StackPane;
+import javafx.scene.layout.VBox;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Circle;
+import javafx.scene.shape.Line;
+import javafx.scene.shape.StrokeLineCap;
+import javafx.scene.text.Font;
+import javafx.scene.text.FontWeight;
+import javafx.scene.text.Text;
+import javafx.stage.Stage;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class OFAWizard extends Application {
+
+ NewWizard wizard;
+ TAI_OFA referenceOFA;
+
+ public OFAWizard() {
+ }
+ TreeItem<String> rootItem;
+ TreeItem<String> testTree;
+ ObservableList<TreeItem<String>> listProject;
+ TreeView<String> projectTree;
+ int caseNumber;
+ String paramsFileName;
+
+ public OFAWizard(TreeItem<String> root, int i, ObservableList<TreeItem<String>> listProject1, TreeView<String> projectTree1) {
+ rootItem = root;
+ caseNumber = i;
+ listProject = listProject1;
+ projectTree = projectTree1;
+ }
+
+ public void setOFA(TAI_OFA ofa) {
+ this.referenceOFA = ofa;
+ }
+
+ @Override
+ public void start(Stage stage) throws Exception {
+ wizard = new NewWizard(stage, rootItem, referenceOFA, caseNumber, listProject, projectTree);
+ stage.setTitle("TestON - Automation is O{pe}N ");
+ Scene scene = new Scene(wizard, 700, 400);
+ stage.setScene(scene);
+ stage.setResizable(false);
+ scene.getStylesheets().addAll(this.getClass().getResource("wizard.css").toExternalForm());
+ paramsFileName = wizard.paramsFileName;
+ stage.show();
+ }
+
+ public void setProjectList(ObservableList<TreeItem<String>> list) {
+ listProject = list;
+ }
+
+ public void setProjectView(TreeView<String> tree) {
+ projectTree = tree;
+ }
+}
+
+/**
+ * basic wizard infrastructure class
+ */
+class Wizard extends StackPane {
+
+ private static final int UNDEFINED = -1;
+ private ObservableList<WizardPage> pages = FXCollections.observableArrayList();
+ private Stack<Integer> history = new Stack();
+ private int curPageIdx = UNDEFINED;
+ NewWizard newWizardObjct;
+
+ public Wizard() {
+ }
+
+ void setAllData(WizardPage... nodes) {
+ for (WizardPage wizardPage : nodes) {
+ wizardPage.setNewWizard(newWizardObjct);
+ pages.add(wizardPage);
+ }
+ navTo(0);
+ setStyle("-fx-padding: 0; -fx-background-color: cornsilk;");
+ }
+
+ Wizard(WizardPage... nodes) {
+ for (WizardPage wizardPage : nodes) {
+ wizardPage.setNewWizard(newWizardObjct);
+ pages.add(wizardPage);
+ }
+ navTo(0);
+ setStyle("-fx-padding: 0; -fx-background-color: cornsilk;");
+ }
+
+ ObservableList<WizardPage> getAllChildrens() {
+ return pages;
+ }
+
+ void nextPage() {
+ if (hasNextPage()) {
+ navTo(curPageIdx + 1);
+ }
+ }
+
+ void priorPage() {
+ if (hasPriorPage()) {
+ navTo(history.pop(), false);
+ }
+ }
+
+ boolean hasNextPage() {
+ return (curPageIdx < pages.size() - 1);
+ }
+
+ boolean hasPriorPage() {
+ return !history.isEmpty();
+ }
+
+ void navTo(int nextPageIdx, boolean pushHistory) {
+ if (nextPageIdx < 0 || nextPageIdx >= pages.size()) {
+ return;
+ }
+ if (curPageIdx != UNDEFINED) {
+ if (pushHistory) {
+ history.push(curPageIdx);
+ }
+ }
+
+ WizardPage nextPage = pages.get(nextPageIdx);
+ curPageIdx = nextPageIdx;
+ getChildren().clear();
+ getChildren().add(nextPage);
+ nextPage.manageButtons();
+ }
+
+ void navTo(int nextPageIdx) {
+ navTo(nextPageIdx, true);
+ }
+
+ void navTo(String id) {
+ Node page = lookup("#" + id);
+ if (page != null) {
+ int nextPageIdx = pages.indexOf(page);
+ if (nextPageIdx != UNDEFINED) {
+ navTo(nextPageIdx);
+ }
+ }
+ }
+
+ public void finish() {
+ }
+
+ public void cancel() {
+ }
+
+ public void setNewWizard(NewWizard newWizardObj) {
+ newWizardObjct = newWizardObj;
+ }
+}
+
+/**
+ * basic wizard page class
+ */
+abstract class WizardPage extends VBox {
+
+ TAILocale label = new TAILocale(new Locale("en", "EN"));
+ Button priorButton = new Button("<< Previous");
+ Button nextButton = new Button("Next >>");
+ Button cancelButton = new Button("Cancel");
+ Button finishButton = new Button("Finish");
+ NewWizard newWizardReference;
+
+ WizardPage(String title) {
+ //getChildren().add(der.create().text(title).build());
+ setId(title);
+ setSpacing(0);
+ setStyle("-fx-padding:0; -fx-background-color: white; ");
+ Region spring = new Region();
+ VBox.setVgrow(spring, Priority.ALWAYS);
+ getChildren().addAll(getContent(), spring, getButtons());
+
+ priorButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent actionEvent) {
+ priorPage();
+ }
+ });
+
+ nextButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ nextPage();
+ }
+ });
+
+ cancelButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ getWizard().cancel();
+ }
+ });
+
+ finishButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ getWizard().finish();
+ }
+ });
+ }
+
+ HBox getButtons() {
+ Region spring = new Region();
+ HBox.setHgrow(spring, Priority.ALWAYS);
+ HBox buttonBar = new HBox(5);
+ cancelButton.setCancelButton(true);
+ // finishButton.setDefaultButton(true);
+ buttonBar.getChildren().addAll(spring, priorButton, nextButton, cancelButton, finishButton);
+ return buttonBar;
+ }
+
+ abstract Parent getContent();
+
+ boolean hasNextPage() {
+ return getWizard().hasNextPage();
+ }
+
+ boolean hasPriorPage() {
+ return getWizard().hasPriorPage();
+ }
+
+ void nextPage() {
+ getWizard().nextPage();
+ }
+
+ void priorPage() {
+ getWizard().priorPage();
+ }
+
+ void navTo(String id) {
+ getWizard().navTo(id);
+ }
+
+ Wizard getWizard() {
+ return (Wizard) getParent();
+ }
+
+ public void manageButtons() {
+ if (!hasPriorPage()) {
+ priorButton.setDisable(true);
+ }
+
+ if (!hasNextPage()) {
+ nextButton.setDisable(true);
+ }
+ }
+
+ public void setNewWizard(NewWizard refWizard) {
+ newWizardReference = refWizard;
+ }
+}
+
+/*
+ * this Class shows the OFA wizard
+ */
+class NewWizard extends Wizard {
+
+ String[] splitDeviceDetails;
+ TestWizard testWizard;
+ Stage owner;
+ String topologyDemo, paramFileDemo, ospkFileDemo;
+ TreeItem<String> projectExplorerTreeItem;
+ OFALoadTree projectNameTree;
+ TAI_OFA referenceOFA;
+ TAILocale label = new TAILocale(new Locale("en", "EN"));
+ String OFAUiPath = label.hierarchyTestON + "/tests/";
+ TreeItem<String> treeItem1;
+ String paramsFileName, topoFileName;
+ boolean flag = false;
+ String topologyFileDemo;
+ String[] splitDeviceDetail;
+
+ public NewWizard(Stage owner, TreeItem<String> treeItem, TAI_OFA reference, int caseNumber, final ObservableList<TreeItem<String>> listProject1, TreeView<String> projectTree1) {
+ super();
+
+ super.setNewWizard(this);
+
+ this.owner = owner;
+ testWizard = new TestWizard();
+
+ switch (caseNumber) {
+ /*
+ * cases ---
+ * 1. New Project
+ * 2. New Params file
+ * 3. New Topology file
+ * 4. New Driver
+ *
+ */
+ case 1:
+ final ProjectWizard projectWizard = new ProjectWizard();
+ ParamsWizard paramsWizard = new ParamsWizard();
+ super.setAllData(projectWizard, paramsWizard, new TopologyWizard());
+ projectWizard.projectName.textProperty().addListener(new ChangeListener<String>() {
+ @Override
+ public void changed(ObservableValue<? extends String> arg0, String arg1, String arg2) {
+ String message = "\nYour projectName must be\n" + "started with alphabate and \nshould not have special symbol";
+ textValidation("([a-zA-Z]\\d*[a-zA_Z])+|([a-zA-Z]\\d*)+|", arg2, projectWizard.error, projectWizard.nextButton, message, projectWizard.projectName);
+ }
+ });
+ projectExplorerTreeItem = treeItem;
+ referenceOFA = reference;
+ paramsWizard.gridPane.add(testWizard.testParams, 0, 0);
+ paramsWizard.gridPane.add(new Label(label.wizEmailId), 0, 2);
+ paramsWizard.gridPane.add(testWizard.emailId, 1, 2);
+ paramsWizard.gridPane.add(new Label("Log Directory "), 0, 3);
+ paramsWizard.gridPane.add(testWizard.log_dir, 1, 3);
+ paramsWizard.gridPane.add(new Label(label.wizNumberofTestCases), 0, 4);
+ paramsWizard.gridPane.add(testWizard.testCases, 1, 4);
+ paramsWizard.gridPane.add(testWizard.imageHouse, 60, 0);
+ paramsWizard.nextButton.setDisable(false);
+ break;
+
+ case 2:
+
+ super.setAllData(testWizard);
+ projectExplorerTreeItem = treeItem;
+ referenceOFA = reference;
+ testWizard.gridPane.add(new Label(label.wizProject), 0, 1);
+ testWizard.gridPane.add(testWizard.projectNameList, 1, 1);
+ testWizard.gridPane.add(new Label(label.wizParamName), 0, 3);
+
+ testWizard.gridPane.add(testWizard.paramName, 1, 3);
+
+ testWizard.nextButton.setDisable(true);
+
+ testWizard.paramName.textProperty().addListener(new ChangeListener<String>() {
+ @Override
+ public void changed(ObservableValue<? extends String> arg0, String arg1, String arg2) {
+ if (!arg2.isEmpty()) {
+ testWizard.projectNameList.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue arg0, Object arg1, Object arg2) {
+ if (!arg2.toString().isEmpty()) {
+ testWizard.testNameList.valueProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue arg0, Object arg1, Object arg2) {
+ testWizard.finishButton.setDisable(arg2.toString().isEmpty());
+ }
+ });
+ }
+ }
+ });
+ }
+ }
+ });
+ Iterator<TreeItem<String>> projectList1 = listProject1.iterator();
+ testWizard.projectNameList.getItems().clear();
+ while (projectList1.hasNext()) {
+ TreeItem<String> projectComb = projectList1.next();
+ projectComb.getValue();
+ testWizard.projectNameList.getItems().add(projectComb.getValue());
+ }
+
+ testWizard.projectNameList.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+
+ final Iterator<TreeItem<String>> projectIterator = listProject1.iterator();
+ while (projectIterator.hasNext()) {
+ final TreeItem<String> treeItem = projectIterator.next();
+ ObservableList<TreeItem<String>> list = treeItem.getChildren();
+ if (treeItem.getValue().equalsIgnoreCase(testWizard.projectNameList.getSelectionModel().getSelectedItem().toString())) {
+ ObservableList<TreeItem<String>> children = treeItem.getChildren();
+ final Iterator<TreeItem<String>> testListIterator = children.iterator();
+ while (testListIterator.hasNext()) {
+ TreeItem<String> testComb = testListIterator.next();
+ testComb.getValue();
+ }
+ }
+ }
+ }
+ });
+ break;
+
+ case 3:
+ final ParamsWizard paramWizard = new ParamsWizard();
+ super.setAllData(paramWizard, new TopologyWizard());
+ projectExplorerTreeItem = treeItem;
+ referenceOFA = reference;
+ paramWizard.gridPane.add(testWizard.testParams, 0, 0);
+ paramWizard.gridPane.add(new Label("Test Name :"), 0, 2);
+ paramWizard.gridPane.add(testWizard.projectNameList, 1, 2);
+ paramWizard.gridPane.add(new Label("Topology Name"), 0, 3);
+ paramWizard.gridPane.add(testWizard.topologyName, 1, 3);
+ paramWizard.gridPane.add(testWizard.imageHouse, 60, 0);
+ paramWizard.nextButton.setDisable(true);
+ Iterator<TreeItem<String>> projectList2 = listProject1.iterator();
+ testWizard.projectNameList.getItems().clear();
+ while (projectList2.hasNext()) {
+ TreeItem<String> projectComb = projectList2.next();
+ projectComb.getValue();
+ testWizard.projectNameList.getItems().add(projectComb.getValue());
+ }
+
+ testWizard.projectNameList.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+
+ final Iterator<TreeItem<String>> projectIterator = listProject1.iterator();
+ while (projectIterator.hasNext()) {
+ final TreeItem<String> treeItem = projectIterator.next();
+ ObservableList<TreeItem<String>> list = treeItem.getChildren();
+ if (treeItem.getValue().equalsIgnoreCase(testWizard.projectNameList.getSelectionModel().getSelectedItem().toString())) {
+ ObservableList<TreeItem<String>> children = treeItem.getChildren();
+ final Iterator<TreeItem<String>> testListIterator = children.iterator();
+ while (testListIterator.hasNext()) {
+ TreeItem<String> testComb = testListIterator.next();
+ testComb.getValue();
+ }
+ }
+ }
+ }
+ });
+
+ testWizard.topologyName.setOnKeyReleased(new EventHandler<KeyEvent>() {
+ @Override
+ public void handle(KeyEvent t) {
+ if (!testWizard.topologyName.getText().isEmpty()) {
+ paramWizard.nextButton.setDisable(false);
+ } else {
+ paramWizard.nextButton.setDisable(true);
+ }
+ }
+ });
+ break;
+ }
+ }
+
+ @Override
+ public void finish() {
+ String projectName = null;
+ String testName = null;
+ String testParamsName = null;
+ String testTopologyName = null;
+ ObservableList<WizardPage> nodeList = super.getAllChildrens();
+ int i = 0;
+
+ while (i < nodeList.size()) {
+ WizardPage node = nodeList.get(i);
+ if (node.getId().equals(label.wizProjectWizardId)) {
+ ProjectWizard projectWizard = (ProjectWizard) node;
+ projectName = projectWizard.getName();
+ new File(OFAUiPath + projectName).mkdir();
+ String projectWorkSpacePath = OFAUiPath + projectName;
+ File[] file = File.listRoots();
+ Path name = new File(projectWorkSpacePath).toPath();
+ projectNameTree = new OFALoadTree(name);
+
+ projectExplorerTreeItem.getChildren().add(projectNameTree);
+ String pathToFiles = projectNameTree.getFullPath() + "/";
+
+
+ Path ospkName = new File(projectNameTree.getFullPath() + "/" + projectName + ".ospk").toPath();
+ Path paramsName = new File(projectNameTree.getFullPath() + "/" + projectName + ".params").toPath();
+ Path topologyName = new File(projectNameTree.getFullPath() + "/" + projectName + ".topo").toPath();
+
+ OFALoadTree topologyTestTree = new OFALoadTree(topologyName);
+ topologyTestTree.setValue(topologyName.toString().replace(topologyName.toString(), projectName));
+
+ OFALoadTree ospkTestTree = new OFALoadTree(ospkName);
+ ospkTestTree.setValue(ospkName.toString().replace(ospkName.toString(), projectName));
+
+ OFALoadTree paramTestTree = new OFALoadTree(paramsName);
+ paramTestTree.setValue(paramsName.toString().replace(paramsName.toString(), projectName));
+ projectNameTree.getChildren().addAll(topologyTestTree, paramTestTree, ospkTestTree);
+
+ paramFileDemo = "<PARAMS>" + "\n\t" + "<testcases> \"1\" </testcases>" + "\n\t"
+ + "<mail> " + testWizard.emailId.getText() + "</mail>\n\t" + "<log_dir>" + testWizard.log_dir.getText() + "</log_dir>" + "\n\n\t"
+ + "<CASE1>" + "\n\t\t" + "#Enter your CASE parameter here in the form" + "\n\t\t" + "#param = value"
+ + "\n\t\t" + "<STEP1>" + "\n\t\t\t" + "#Enter your STEP parameter here in the form" + "\n\t\t\t" + "#param = value" + "\n\t\t" + "</STEP1>" + "\n\t" + "</CASE1>"
+ + "\n" + "\n</PARAMS>";
+
+ ospkFileDemo = "CASE 1" + "\n" + "\t" + "NAME" + " " + "\"Give test case name \"" + "\n" + "\t"
+ + "DESC \"Give test case description\"" + "\n" + "END CASE";
+
+ testTopologyName = projectName + ".topo";
+ String topoFileDemo = "<TOPOLOGY>" + "\n\t<COMPONENT>" + "\n\t\t# put components here as given below" + "\n\t\t<component1>" + "\n\t\t\t# put component parameters here"
+ + "\n\t\t <host> 192.168.56.101 </host>" + "\n\t\t</component1>" + "\n\t</COMPONENT>" + "</TOPOLOGY>";
+
+ try {
+ new File(pathToFiles + "/" + projectName + ".ospk").createNewFile();
+ new File(pathToFiles + "/" + projectName + ".params").createNewFile();
+ new File(pathToFiles + "/" + projectName + ".topo").createNewFile();
+ new File(pathToFiles + "/" + "__init__.py").createNewFile();
+ } catch (IOException ex) {
+
+ }
+ writeInFile(pathToFiles + "/" + projectName + ".params", paramFileDemo);
+ writeInFile(pathToFiles + "/" + projectName + ".ospk", ospkFileDemo);
+
+ referenceOFA.checkEditor();
+
+ } else if (node.getId().equals(label.wizTestWizardId)) {
+
+ testWizard = (TestWizard) node;
+ String selectedProject = testWizard.projectNameList.getSelectionModel().getSelectedItem().toString();
+ String paramName = testWizard.paramName.getText();
+ String pathParams = "";
+ for (int index = 0; index < referenceOFA.projectExplorerTree.getChildren().size(); index++) {
+
+ if (referenceOFA.projectExplorerTree.getChildren().get(index).getValue().equals(selectedProject)) {
+
+ pathParams = OFAUiPath + selectedProject;
+ Path name = new File(OFAUiPath + selectedProject + "/" + paramName).toPath();
+ OFALoadTree testSelection = new OFALoadTree(name);
+
+ Path paramsName = new File(name + ".params").toPath();
+ paramsFileName = paramsName.toString();
+ OFALoadTree paramsTestTree = new OFALoadTree(paramsName);
+ paramsTestTree.setValue(paramName);
+ referenceOFA.projectExplorerTree.getChildren().get(index).getChildren().addAll(paramsTestTree);
+ try {
+ new File(paramsFileName).createNewFile();
+ } catch (IOException ex) {
+ Logger.getLogger(NewWizard.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ writeInFile(paramsFileName, referenceOFA.paramsFileContent);
+ }
+ }
+
+
+ } else if (node.getId().equals(label.wizTopologyWizardId)) {
+ TopologyWizard topoWizard = (TopologyWizard) node;
+
+ ArrayList<String> deviceName = new ArrayList<String>();
+ Iterator<TextField> attributeIterator = topoWizard.getDeviceNameList().iterator();
+ while (attributeIterator.hasNext()) {
+ TextField iteratorAttributeText = attributeIterator.next();
+ deviceName.add(iteratorAttributeText.getText());
+ }
+ topologyFileDemo = "<TOPOLOGY>" + "\n\t" + "<COMPONENT>" + "\n\t";
+
+ for (String device : topoWizard.getPropertyDetail()) {
+ splitDeviceDetail = device.split("\n");
+ topologyFileDemo += "\n\t\t" + "<" + splitDeviceDetail[0] + ">";
+ splitDeviceDetail = device.split("\n");
+ try {
+ topologyFileDemo += "\n\t\t\t" + "<hostname> " + splitDeviceDetail[1] + "</hostname>\n\t\t\t" + "<user>" + splitDeviceDetail[2]
+ + "</user>\n\t\t\t" + "<password>" + splitDeviceDetail[3] + "</password>\n\t\t\t" + "<type>" + splitDeviceDetail[5] + "</type>\n\t\t\t" + "<coordinate(x,y)>"
+ + splitDeviceDetail[7] + "</coordinate(x,y)>\n\t\t\t";
+
+ if (topoWizard.topoplogy.testTargetRadioButton.isSelected()) {
+ topologyFileDemo += "<test_target> 1 </test_target>\n\t\t\t" + "<COMPONENTS>";
+ } else {
+ topologyFileDemo += "<COMPONENTS>";
+ }
+ String[] deviceDetailsArray = topoWizard.interFaceValue.toArray(new String[topoWizard.interFaceValue.size()]);
+ int noOfDevices = 0;
+ for (String name : topoWizard.interFaceName) {
+ String propertyDetail = deviceDetailsArray[noOfDevices++];
+ String[] details = propertyDetail.split("\\_");
+ String[] splitInterFace = name.split("\\_");
+ if (splitInterFace[1].equals(splitDeviceDetail[0]) && details[1].equals(splitDeviceDetail[0])) {
+ // topologyFileDemo += "\n\t\t\t"+splitInterFace[0]+"="+details[0];
+ }
+ }
+ for (HashMap<String, String> interFaceDetail : topoWizard.arrayOfInterFaceHash) {
+ Set set = interFaceDetail.entrySet();
+ Iterator interFaceHashDetailIterator = set.iterator();
+ while (interFaceHashDetailIterator.hasNext()) {
+ Map.Entry me = (Map.Entry) interFaceHashDetailIterator.next();
+ String[] deviceNameAndiniterFaceValue = me.getValue().toString().split("\\_");
+ if (deviceNameAndiniterFaceValue[1].equals(splitDeviceDetail[0])) {
+ if (!me.getKey().toString().isEmpty()) {
+ if (!me.getKey().toString().equals("//s+")) {
+ topologyFileDemo += "\n\t\t\t\t" + "<" + me.getKey().toString() + ">" + deviceNameAndiniterFaceValue[0].toString() + "</" + me.getKey().toString() + ">";
+
+ }
+ }
+ }
+
+ }
+ topologyFileDemo += "\n\t\t\t</COMPONENTS>";
+ }
+
+ topologyFileDemo += "\n\t\t" + "</" + splitDeviceDetail[0] + ">";
+
+ } catch (Exception e) {
+ }
+ }
+ Set set = topoWizard.linkTopologyHash.entrySet();
+ Iterator linkHashDetailIterator = set.iterator();
+ while (linkHashDetailIterator.hasNext()) {
+ Map.Entry me = (Map.Entry) linkHashDetailIterator.next();
+
+ String[] linkValue = me.getValue().toString().split("_");
+ String[] linkCoordinates = me.getKey().toString().split("_");
+
+ topologyFileDemo += "\n\t\t" + "<" + linkValue[0] + ">";
+ topologyFileDemo += "\n\t\t\t" + "<" + linkValue[2].toString() + ">" + linkValue[3].toString() + "</" + linkValue[2].toString() + ">";
+ topologyFileDemo += "\n\t\t\t" + "<" + linkValue[4].toString() + ">" + linkValue[5].toString() + "</" + linkValue[4].toString() + ">";
+ topologyFileDemo += "\n\t\t\t" + "<linkCoordinates(startx,starty,endx,endy)" + ">" + linkCoordinates[1].toString() + "," + linkCoordinates[2] + "," + linkCoordinates[3] + "," + linkCoordinates[4] + "</linkCoordinates(startx,starty,endx,endy)" + ">";
+ topologyFileDemo += "\n\t\t" + "</" + linkValue[0] + ">";
+
+ }
+
+ topologyFileDemo += "\n\t" + "</COMPONENT>" + "\n" + "</TOPOLOGY>";
+ String pathTopo = "";
+ if (testTopologyName != null) {
+ writeInFile(label.hierarchyTestON + "/tests/" + projectName + "/" + testTopologyName, topologyFileDemo);
+ } else {
+ String projectNames = testWizard.projectNameList.getSelectionModel().getSelectedItem().toString();
+ for (int index = 0; index < referenceOFA.projectExplorerTree.getChildren().size(); index++) {
+
+ if (referenceOFA.projectExplorerTree.getChildren().get(index).getValue().equals(projectNames)) {
+ pathTopo = OFAUiPath + projectNames;
+ Path name = new File(OFAUiPath + projectNames + "/" + testWizard.topologyName.getText()).toPath();
+ OFALoadTree testSelection = new OFALoadTree(name);
+
+ Path topoName = new File(name + ".topo").toPath();
+ topoFileName = topoName.toString();
+ OFALoadTree topoTestTree = new OFALoadTree(topoName);
+ topoTestTree.setValue(topoFileName);
+ topoTestTree.setValue(topoFileName.toString().replace(topoFileName.toString(), testWizard.topologyName.getText()));
+
+ referenceOFA.projectExplorerTree.getChildren().get(index).getChildren().addAll(topoTestTree);
+ try {
+ new File(topoFileName).createNewFile();
+ } catch (IOException ex) {
+ Logger.getLogger(NewWizard.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ writeInFile(topoFileName, topologyFileDemo);
+ }
+ }
+
+ }
+
+ }
+
+ i++;
+ }
+ owner.close();
+ }
+
+ public String getParamsFileName() {
+ return paramsFileName;
+ }
+
+ public void writeInFile(String path, String demoFile) {
+ try {
+ // Create file
+ FileWriter fstream = new FileWriter(path);
+ BufferedWriter out = new BufferedWriter(fstream);
+ out.write(demoFile);
+ out.close();
+ } catch (Exception e) {
+
+ }
+ }
+
+ public void cancel() {
+
+ owner.close();
+ }
+
+ public void textValidation(String regExp, String arg2, Label error, Button nextButton, String text, TextField name) {
+ Tooltip tooltip = new Tooltip();
+ if (arg2.matches(regExp)) {
+ error.setVisible(false);
+ nextButton.setDisable(false);
+ } else {
+ error.setVisible(true);
+ nextButton.setDisable(true);
+ flag = true;
+ String errorImage = "/images/error.png";
+ Image saveImage = new Image(getClass().getResourceAsStream(errorImage), 18.0, 18.0, true, true);
+ ImageView imageSave = new ImageView(saveImage);
+ error.setGraphic(imageSave);
+
+ tooltip.autoFixProperty();
+ tooltip.setText(text);
+ tooltip.setStyle("-fx-background-color:white");
+ error.setTooltip(tooltip);
+ Image image = new Image(getClass().getResourceAsStream("/images/error.png"), 24.0, 24.0, true, true);
+ tooltip.setGraphic(new ImageView(image));
+ }
+ if (arg2.isEmpty() || flag == true) {
+ nextButton.setDisable(true);
+ flag = false;
+ }
+ }
+}
+
+/**
+ * This page gathers more information about the new Test
+ */
+class ProjectWizard extends WizardPage {
+
+ TextField projectName;
+ String newProjectName;
+ String name;
+ boolean flag = false;
+ Label error;
+ ImageView imageHouse;
+
+ public ProjectWizard() {
+ super("Project");
+
+ nextButton.setDisable(true);
+
+ finishButton.setDisable(true);
+ this.setId("projectWizard");
+
+ }
+
+ @Override
+ Parent getContent() {
+ projectName = TextFieldBuilder.create().build();
+
+ projectName.setMinWidth(170);
+ nextButton.setDisable(true);
+ error = new Label();
+ error.setVisible(false);
+
+ error.setTextFill(Color.RED);
+ imageHouse = new ImageView(new Image("images/paxterra_logo.jpg", 100, 100, true, true));
+
+ HBox image = new HBox();
+ image.setPadding(new Insets(0, 0, 0, 470));
+ Button Open = new Button();
+ String openImgPath = "/images/TestON.png";
+ Open.setStyle("-fx-background-color:white");
+ Open.setLayoutX(0);
+ Open.setLayoutY(0);
+ GridPane gridPane = new GridPane();
+ gridPane.setPadding(new Insets(70, 0, 0, 200));
+ gridPane.setHgap(10);
+ gridPane.setVgap(8);
+ Label project = new Label("Project Name");
+
+
+ gridPane.setId("pane");
+ gridPane.add(project, 0, 11);
+ gridPane.add(projectName, 1, 11);
+ gridPane.add(error, 2, 10);
+ gridPane.add(imageHouse, 10, 0);
+
+ return GridPaneBuilder.create().children(gridPane).build();
+
+ }
+
+ void nextPage() {
+ // If they have complaints, go to the normal next page
+
+ if (!projectName.getText().equals("")) {
+ super.nextPage();
+ newProjectName = projectName.getText();
+
+ } else {
+
+ // No complaints? Short-circuit the rest of the pages
+ navTo("ParamsWizard");
+ }
+ }
+
+ public String getName() {
+ return newProjectName;
+ }
+}
+
+/**
+ * This page gathers more information about the Test Script
+ */
+class TestWizard extends WizardPage {
+
+ TextField emailIds;
+ TextField numberOfTestCase;
+ TextField paramName;
+ TextField topologyName;
+ String getTestName, getEmailId;
+ String getNumberOfTestCases;
+ ObservableList<TreeItem<String>> listProject;
+ TreeView<String> projectTree;
+ ComboBox projectNameList;
+ ComboBox testNameList;
+ GridPane gridPane;
+ Label projectError, testError, emailIdError;
+ ImageView imageHouse;
+ Text testParams;
+ TextField testCases;
+ TextField emailId;
+ TextField log_dir;
+ Text caseParameter;
+ Button addParams;
+
+ public TestWizard() {
+ super("More Info");
+ this.setId("testWizard");
+ nextButton.setDisable(true);
+ finishButton.setDisable(false);
+ }
+
+ @Override
+ Parent getContent() {
+
+ HBox image = new HBox();
+ image.setPadding(new Insets(0, 0, 0, 470));
+
+ topologyName = TextFieldBuilder.create().build();
+ testParams = new Text("Test Params :");
+ testParams.setFont(Font.font("Arial", FontWeight.BOLD, 15));
+ testParams.setFill(Color.BLUE);
+ testCases = TextFieldBuilder.create().build();
+ emailId = TextFieldBuilder.create().build();
+ log_dir = TextFieldBuilder.create().build();
+ caseParameter = new Text("Case Params");
+ caseParameter.setFont(Font.font("Arial", FontWeight.BOLD, 10));
+ addParams = new Button("Add Case Params");
+ projectNameList = ComboBoxBuilder.create().build();
+ projectError = new Label();
+ projectError.setDisable(true);
+ paramName = TextFieldBuilder.create().build();
+ imageHouse = new ImageView(new Image("images/TestON.png", 200, 200, true, true));
+
+ testCases.lengthProperty().addListener(new ChangeListener<Number>() {
+ @Override
+ public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
+ if (newValue.intValue() > oldValue.intValue()) {
+ char ch = testCases.getText().charAt(oldValue.intValue());
+ //Check if the new character is the number or other's
+ if (!(ch >= '0' && ch <= '9')) {
+ testCases.setText(testCases.getText().substring(0, testCases.getText().length() - 1));
+ }
+ }
+ }
+ });
+
+ nextButton.setDisable(false);
+ finishButton.setDisable(false);
+ gridPane = new GridPane();
+ gridPane.setPadding(new Insets(30, 0, 0, 40));
+ gridPane.setHgap(0);
+ gridPane.setVgap(5);
+ return GridPaneBuilder.create().children(gridPane).build();
+ }
+
+ void nextPage() {
+
+ if (!emailId.getText().equals("") || numberOfTestCase.getText().equals("") || log_dir.getText().equals("")) {
+ super.nextPage();
+
+ getEmailId = emailId.getText();
+ getNumberOfTestCases = numberOfTestCase.getText();
+ } else {
+
+ navTo("topologyWizards");
+ }
+ }
+
+ public String getTestName() {
+ return getTestName;
+ }
+
+ public String getEmailId() {
+ return getEmailId;
+ }
+
+ public String getNumberOfTestCase() {
+ return getNumberOfTestCases;
+ }
+}
+
+/**
+ * This page gathers more information about the new Params File
+ */
+class ParamsWizard extends WizardPage {
+
+ TextField emailIds;
+ TextField numberOfTestCase;
+ TextField paramName;
+ TextField topologyName;
+ String getTestName, getEmailId;
+ String getNumberOfTestCases;
+ ObservableList<TreeItem<String>> listProject;
+ TreeView<String> projectTree;
+ ComboBox projectNameList;
+ ComboBox testNameList;
+ GridPane gridPane;
+ Label projectError, testError, emailIdError;
+ ImageView imageHouse;
+ // here is new list
+ Text testParams;
+ TextField testCases;
+ TextField emailId;
+ TextField log_dir;
+ Text caseParameter;
+ Button addParams;
+ TextField testTopology;
+
+ public ParamsWizard() {
+ super("More Info");
+ this.setId("paramsWizard");
+ nextButton.setDisable(true);
+ finishButton.setDisable(false);
+ }
+
+ @Override
+ Parent getContent() {
+
+ HBox image = new HBox();
+ image.setPadding(new Insets(0, 0, 0, 470));
+
+ testTopology = emailId = TextFieldBuilder.create().build();
+ testParams = new Text("Test Params :");
+ testParams.setId("testParamsTitle");
+ testParams.setFont(Font.font("Arial", FontWeight.BOLD, 15));
+ testParams.setFill(Color.BLUE);
+
+ DropShadow dropShadow = new DropShadow();
+ dropShadow.setColor(Color.BLACK);
+ dropShadow.setRadius(25);
+ dropShadow.setSpread(0.25);
+ testParams.setEffect(dropShadow);
+
+ testCases = TextFieldBuilder.create().build();
+ emailId = TextFieldBuilder.create().build();
+ log_dir = TextFieldBuilder.create().build();
+ caseParameter = new Text("Case Params");
+ caseParameter.setFont(Font.font("Arial", FontWeight.BOLD, 10));
+ addParams = new Button("Add Case Params");
+ projectNameList = ComboBoxBuilder.create().build();
+ projectError = new Label();
+ projectError.setDisable(true);
+ paramName = TextFieldBuilder.create().build();
+ imageHouse = new ImageView(new Image("images/paxterra_logo.jpg", 100, 100, true, true));
+
+ testCases.lengthProperty().addListener(new ChangeListener<Number>() {
+ @Override
+ public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
+ if (newValue.intValue() > oldValue.intValue()) {
+ char ch = testCases.getText().charAt(oldValue.intValue());
+ //Check if the new character is the number or other's
+ if (!(ch >= '0' && ch <= '9')) {
+ testCases.setText(testCases.getText().substring(0, testCases.getText().length() - 1));
+ }
+ }
+ }
+ });
+ nextButton.setDisable(false);
+ finishButton.setDisable(false);
+
+ gridPane = new GridPane();
+ gridPane.setPadding(new Insets(30, 0, 0, 40));
+ gridPane.setHgap(0);
+ gridPane.setVgap(5);
+
+ return GridPaneBuilder.create().children(gridPane).build();
+
+ }
+
+ void nextPage() {
+
+ if (!emailId.getText().equals("") || testCases.getText().equals("") || log_dir.getText().equals("")) {
+ super.nextPage();
+
+ getEmailId = emailId.getText();
+ getNumberOfTestCases = testCases.getText();
+ } else {
+
+ navTo("topologyWizards");
+ }
+ }
+
+ public String getTestName() {
+ return getTestName;
+ }
+
+ public String getEmailId() {
+ return getEmailId;
+ }
+
+ public String getNumberOfTestCase() {
+ return getNumberOfTestCases;
+ }
+}
+
+/**
+ * This page gathers more information about the Test Topology
+ */
+class TopologyWizard extends WizardPage {
+
+ ArrayList<TextField> deviceNameList = new ArrayList<TextField>();
+ ArrayList<String> draggedImagesName = new ArrayList<String>();
+ OFATopology topoplogy;
+ ArrayList<String> propertyValue = new ArrayList<String>();
+ ArrayList<String> interFaceName = new ArrayList<String>();
+ ArrayList<String> interFaceValue = new ArrayList<String>();
+ TreeView<String> driverExplorerTreeView;
+ ArrayList<String> webInfoList = new ArrayList<String>();
+ ArrayList<String> webCisco = new ArrayList<String>();
+ HashMap<String, String> interFaceHashDetail = new HashMap<String, String>();
+ ArrayList<HashMap<String, String>> arrayOfInterFaceHash;
+ HashMap<String, String> webToplogyHash = new HashMap<String, String>();
+ ArrayList<HashMap<String, String>> arrayOfwebTopologyHash;
+ OFATopologyLink topologyLink = new OFATopologyLink();
+ HashMap<String, String> linkTopologyHash = new HashMap<String, String>();
+ ArrayList<HashMap<String, String>> arrayOfLinkTopologyHash = new ArrayList<HashMap<String, String>>();
+ ArrayList<String> topoEditorDeviceInfo = new ArrayList<String>();
+ Button lineButtonHorizontal;
+ TAILocale label = new TAILocale(new Locale("en", "EN"));
+ boolean anchorFlag = false;
+ boolean selectFlag = false;
+
+ public TopologyWizard() {
+ super("");
+ this.setId(label.wizTopologyWizardId);
+ }
+
+ Parent getContent() {
+ TAILocale label = new TAILocale(Locale.ENGLISH);
+ VBox parentTopologyBox = new VBox();
+ ToolBar canvasToolBar = new ToolBar();
+ lineButtonHorizontal = new Button();
+
+ Tooltip horizontal = new Tooltip("Click to add horizontal line in canvas");
+ lineButtonHorizontal.setTooltip(horizontal);
+ Image image = new Image(getClass().getResourceAsStream("/images/Link1.png"), 28.0, 28.0, true, true);
+ ImageView imageNew = new ImageView(image);
+ lineButtonHorizontal.setGraphic(imageNew);
+
+ Button lineButtonVertical = new Button();
+ Tooltip vertical = new Tooltip("Click to add vertical line in canvas");
+ lineButtonVertical.setTooltip(vertical);
+
+ final Button deleteAllButton = new Button();
+ Tooltip delete = new Tooltip("Click to reset or clear canvas");
+ deleteAllButton.setTooltip(delete);
+ Image image2 = new Image(getClass().getResourceAsStream("/images/Refresh.png"), 24.0, 24.0, true, true);
+ ImageView imageNew2 = new ImageView(image2);
+ deleteAllButton.setGraphic(imageNew2);
+
+ Image image1 = new Image(getClass().getResourceAsStream("/images/verticalLine.jpg"), 24.0, 24.0, true, true);
+ ImageView imageNew1 = new ImageView(image1);
+ lineButtonVertical.setGraphic(imageNew1);
+
+ canvasToolBar.getItems().addAll(lineButtonHorizontal, deleteAllButton);
+ HBox topologyBox = new HBox();
+ TabPane topologyPane = new TabPane();
+ topologyPane.setSide(Side.LEFT);
+ final Tab topologyModifiedDriverExplorerTab = new Tab("DEVICES");
+ topologyPane.setMaxWidth(250);
+
+ String hostName = label.hierarchyTestON + "/drivers/common";
+ final Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("/images/project.jpeg"), 16, 16, true, true));
+ TreeItem<String> driverExplorerTree = new TreeItem<String>("Drivers");
+ File[] file = File.listRoots();
+ Path name = new File(hostName).toPath();
+ LoadDirectory treeNode = new LoadDirectory(name);
+ driverExplorerTree = treeNode;
+ driverExplorerTree.setExpanded(true);
+ driverExplorerTreeView = new TreeView<String>(driverExplorerTree);
+ topologyModifiedDriverExplorerTab.setContent(driverExplorerTreeView);
+ driverExplorerTreeView.setShowRoot(false);
+ topologyPane.getTabs().add(topologyModifiedDriverExplorerTab);
+ topologyModifiedDriverExplorerTab.setClosable(false);
+
+ final TabPane topologyNewCanvas = new TabPane();
+ topologyNewCanvas.setSide(Side.BOTTOM);
+ final Tab canvasTab = new Tab("Canvas");
+ canvasTab.setClosable(false);
+ Button mew = new Button("CLICK");
+ mew.setGraphic(rootIcon);
+ HBox hBox1 = new HBox();
+ hBox1.setPrefWidth(345);
+ hBox1.setPrefHeight(200);
+ hBox1.setStyle("-fx-border-color: blue;"
+ + "-fx-border-width: 1;"
+ + "-fx-border-style: solid;");
+ Pane box1 = new Pane();
+ box1.setPrefWidth(500);
+ box1.setPrefHeight(200);
+ canvasTab.setContent(box1);
+ topologyNewCanvas.getTabs().add(canvasTab);
+ deleteAllButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ Pane pane = (Pane) canvasTab.getContent();
+ ObservableList<Node> list = pane.getChildren();
+ pane.getChildren().removeAll(list);
+
+ }
+ });
+ lineButtonVertical.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ final Line connecting = new Line();
+ connecting.setStrokeWidth(3);
+ connecting.setEndY(90);
+ connecting.setLayoutX(33);
+ connecting.setLayoutY(33);
+
+ final DraggableNode contentLine = new DraggableNode();
+ contentLine.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+ OFATopologyLink topologyLink = new OFATopologyLink();
+ topologyLink.start(new Stage());
+ } else if (arg0.getButton() == MouseButton.SECONDARY) {
+ deleteLineContextMenu(contentLine, connecting, arg0);
+ }
+ }
+ });
+
+ contentLine.getChildren().add(connecting);
+
+ Pane created = (Pane) canvasTab.getContent();
+
+ created.getChildren().addAll(contentLine);
+ }
+ });
+
+ driverExplorerTreeView.setOnDragDetected(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ final MultipleSelectionModel<TreeItem<String>> selectedItem = driverExplorerTreeView.getSelectionModel();
+ try {
+ Image i = new Image(selectedItem.getSelectedItem().getGraphic().getId(), 60, 60, true, true);
+ Dragboard db = driverExplorerTreeView.startDragAndDrop(TransferMode.COPY);
+
+ ClipboardContent content = new ClipboardContent();
+ content.putImage(i);
+ db.setContent(content);
+
+ arg0.consume();
+ } catch (Exception e) {
+ }
+
+ }
+ });
+
+ final Pane pane = (Pane) canvasTab.getContent();
+ pane.setOnDragOver(new EventHandler<DragEvent>() {
+ @Override
+ public void handle(DragEvent t) {
+
+ Dragboard db = t.getDragboard();
+
+ if (db.hasImage()) {
+ t.acceptTransferModes(TransferMode.COPY);
+ }
+ t.consume();
+ }
+ });
+
+ pane.setOnDragDropped(new EventHandler<DragEvent>() {
+ @Override
+ public void handle(DragEvent event) {
+
+ Dragboard db = event.getDragboard();
+
+ if (db.hasImage()) {
+
+ insertImage(db.getImage(), pane, event.getX(), event.getY());
+
+ event.setDropCompleted(true);
+ } else {
+ event.setDropCompleted(false);
+ }
+ event.consume();
+ }
+ });
+
+ SingleSelectionModel<Tab> tab = topologyNewCanvas.getSelectionModel();
+ tab.getSelectedItem().getContent().setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ SingleSelectionModel<Tab> tab1 = topologyNewCanvas.getSelectionModel();
+ }
+ });
+
+ topologyBox.getChildren().addAll(topologyPane, topologyNewCanvas);
+ parentTopologyBox.getChildren().addAll(canvasToolBar, topologyBox);
+ return parentTopologyBox;
+ }
+
+ void insertImage(Image i, final Pane hb, double x, double y) {
+ final TextField text = new TextField();
+ final String[] deviceInfo;;
+ text.setId(driverExplorerTreeView.getSelectionModel().getSelectedItem().getValue().toString() + "_" + driverExplorerTreeView.getSelectionModel().getSelectedItem().getParent().getValue());
+ deviceInfo = text.getId().split("\\_");
+ deviceNameList.add(text);
+ text.setPrefWidth(100);
+ ImageView iv = new ImageView();
+ iv.setImage(i);
+
+ final DraggableNode content = new DraggableNode();
+ final VBox hbox = new VBox();
+ hbox.setPrefWidth(80);
+ hbox.setPrefHeight(100);
+ lineButtonHorizontal.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ final Line connecting = new Line(33, 43, 33, 43);
+ connecting.setId("Line");
+ connecting.setStrokeLineCap(StrokeLineCap.ROUND);
+ connecting.setStroke(Color.MIDNIGHTBLUE);
+ connecting.setStrokeWidth(2.5);
+ final TopologyWizard.Anchor anchor1 = new TopologyWizard.Anchor("Anchor 1", connecting.startXProperty(), connecting.startYProperty());
+ final TopologyWizard.Anchor anchor2 = new TopologyWizard.Anchor("Anchor 2", connecting.endXProperty(), connecting.endYProperty());
+ anchor1.setFill(Color.TRANSPARENT.deriveColor(1, 1, 1, 0.5));
+ anchor2.setFill(Color.TRANSPARENT.deriveColor(1, 1, 1, 0.5));
+ Circle[] circles = {anchor1, anchor2};
+ for (Circle circle : circles) {
+ enableDrag(circle);
+ }
+ enableDragLineWithAnchors(connecting, anchor1, anchor2);
+
+ anchor1.setOnMouseEntered(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ anchor1.setFill(Color.GOLD.deriveColor(1, 1, 1, 0.5));
+ anchor1.setVisible(true);
+ anchor2.setVisible(true);
+ }
+ });
+
+ anchor1.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ anchor1.setFill(Color.TRANSPARENT.deriveColor(1, 1, 1, 0.5));
+ anchor1.setVisible(false);
+ anchor2.setVisible(false);
+ }
+ });
+
+ anchor2.setOnMouseEntered(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ anchor2.setFill(Color.GOLD.deriveColor(1, 1, 1, 0.5));
+ anchor1.setVisible(true);
+ anchor2.setVisible(true);
+ }
+ });
+
+ anchor2.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ anchor2.setFill(Color.TRANSPARENT.deriveColor(1, 1, 1, 0.5));
+ anchor1.setVisible(false);
+ anchor2.setVisible(false);
+ }
+ });
+
+ connecting.setOnMouseEntered(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ connecting.setStroke(Color.GOLD);
+ anchor1.setVisible(true);
+ anchor2.setVisible(true);
+ }
+ });
+ connecting.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ connecting.setStroke(Color.MIDNIGHTBLUE);
+ anchor1.setVisible(false);
+ anchor2.setVisible(false);
+
+ }
+ });
+
+ final DraggableNode contentLine = new DraggableNode();
+
+ connecting.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+
+ topologyLink.start(new Stage());
+
+ if (arrayOfLinkTopologyHash.isEmpty()) {
+ for (HashMap<String, String> linkHash : arrayOfLinkTopologyHash) {
+ Set linkSet = linkHash.entrySet();
+ Iterator linkHashDetailIterator = linkSet.iterator();
+ while (linkHashDetailIterator.hasNext()) {
+
+ Map.Entry linkMap = (Map.Entry) linkHashDetailIterator.next();
+
+ if (linkMap.getKey().toString().equals(connecting.getId())) {
+ String[] linkValues = linkMap.getValue().toString().split("_");
+
+ topologyLink.nameText.setText(linkValues[0]);
+ topologyLink.typeText.setText(linkValues[1]);
+ topologyLink.devicesInTopoEditor.setEditable(true);
+ topologyLink.devicesInTopoEditor.getSelectionModel().select(linkValues[2]);
+ topologyLink.interfaceList2.setEditable(true);
+ topologyLink.interfaceList2.getSelectionModel().select(linkValues[3]);
+ topologyLink.destDevicesInTopoEditor.setEditable(true);
+ topologyLink.destDevicesInTopoEditor.getSelectionModel().select(linkValues[4]);
+ topologyLink.interfaceList4.setEditable(true);
+ topologyLink.interfaceList4.getSelectionModel().select(linkValues[5]);
+
+ }
+ }
+ }
+ }
+
+ for (String string : draggedImagesName) {
+ topologyLink.devicesInTopoEditor.getItems().add(string);
+ topologyLink.destDevicesInTopoEditor.getItems().add(string);
+ }
+
+ topologyLink.devicesInTopoEditor.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ topologyLink.interfaceList2.getItems().clear();
+ try {
+ for (HashMap<String, String> interFaceDetail : arrayOfInterFaceHash) {
+ Set set = interFaceDetail.entrySet();
+ Iterator interFaceHashDetailIterator = set.iterator();
+ while (interFaceHashDetailIterator.hasNext()) {
+ Map.Entry me = (Map.Entry) interFaceHashDetailIterator.next();
+
+ String[] deviceNameAndiniterFaceValue = me.getValue().toString().split("\\_");
+
+ if (deviceNameAndiniterFaceValue[1].equals(topologyLink.devicesInTopoEditor.getSelectionModel().getSelectedItem())) {
+ if (!me.getKey().toString().equals("")) {
+ topologyLink.interfaceList2.getItems().add(me.getKey().toString());
+
+ }
+ }
+
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ });
+
+ topologyLink.destDevicesInTopoEditor.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ topologyLink.interfaceList4.getItems().clear();
+ try {
+ for (HashMap<String, String> interFaceDetail : arrayOfInterFaceHash) {
+ Set set = interFaceDetail.entrySet();
+ Iterator interFaceHashDetailIterator = set.iterator();
+ while (interFaceHashDetailIterator.hasNext()) {
+ Map.Entry me = (Map.Entry) interFaceHashDetailIterator.next();
+ String[] deviceNameAndiniterFaceValue = me.getValue().toString().split("\\_");
+ if (deviceNameAndiniterFaceValue[1].equals(topologyLink.destDevicesInTopoEditor.getSelectionModel().getSelectedItem())) {
+ if (!me.getKey().toString().equals("")) {
+ topologyLink.interfaceList4.getItems().add(me.getKey().toString());
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ });
+
+ topologyLink.finishSelectedLink.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ connecting.setId(topologyLink.nameText.getText() + "_" + connecting.getStartX() + "_" + connecting.getStartY() + "_" + connecting.getEndX() + "_" + connecting.getEndY());
+ String detailedString = topologyLink.nameText.getText() + "_" + topologyLink.typeText.getText() + "_" + topologyLink.devicesInTopoEditor.getSelectionModel().getSelectedItem() + "_" + topologyLink.interfaceList2.getSelectionModel().getSelectedItem() + "_" + topologyLink.destDevicesInTopoEditor.getSelectionModel().getSelectedItem() + "_" + topologyLink.interfaceList4.getSelectionModel().getSelectedItem() + "_";
+ linkTopologyHash.put(connecting.getId(), detailedString);
+ arrayOfLinkTopologyHash = new ArrayList<HashMap<String, String>>();
+ arrayOfLinkTopologyHash.add(linkTopologyHash);
+ topologyLink.copyStage.close();
+ }
+ });
+ } else if (arg0.getButton() == MouseButton.SECONDARY) {
+ deleteLineContextMenu(contentLine, connecting, arg0);
+ }
+ }
+ });
+ hb.getChildren().addAll(connecting, anchor1, anchor2);
+ }
+ });
+
+ content.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ if (anchorFlag == false) {
+ if (arg0.getClickCount() == 1) {
+ final Line con = new Line();
+ con.setStrokeLineCap(StrokeLineCap.ROUND);
+ con.setStroke(Color.MIDNIGHTBLUE);
+ con.setStrokeWidth(2.0);
+
+ final Line con1 = new Line();
+ con1.setStrokeLineCap(StrokeLineCap.ROUND);
+ con1.setStroke(Color.MIDNIGHTBLUE);
+ con1.setStrokeWidth(2.0);
+
+ final Line con2 = new Line();
+ con2.setStrokeLineCap(StrokeLineCap.ROUND);
+ con2.setStroke(Color.MIDNIGHTBLUE);
+ con2.setStrokeWidth(2.0);
+
+ final Line con3 = new Line();
+ con3.setStrokeLineCap(StrokeLineCap.ROUND);
+ con3.setStroke(Color.MIDNIGHTBLUE);
+ con3.setStrokeWidth(2.0);
+
+ OFAAnchorInsideImageNode mainAnchor = new OFAAnchorInsideImageNode(226.0, 41.0);
+ final Anchor anchor3 = new Anchor("anchor3", con.startXProperty(), con.startYProperty());
+ final Anchor anchor4 = new Anchor("anchor4", con.endXProperty(), con.endYProperty());
+ final Anchor anchor5 = new Anchor("anchor5", con1.startXProperty(), con1.startYProperty());
+ final Anchor anchor6 = new Anchor("anchor6", con1.endXProperty(), con1.endYProperty());
+ final Anchor anchor7 = new Anchor("anchor7", con2.startXProperty(), con2.startYProperty());
+ final Anchor anchor8 = new Anchor("anchor8", con2.endXProperty(), con2.endYProperty());
+ final Anchor anchor9 = new Anchor("anchor9", con3.startXProperty(), con3.startYProperty());
+ final Anchor anchor10 = new Anchor("anchor10", con3.endXProperty(), con3.endYProperty());
+ anchor3.setLayoutX(content.getLayoutX());
+ anchor3.setLayoutY(content.getLayoutY());
+ anchor3.setVisible(false);
+ anchor4.setLayoutX(content.getLayoutX() + 40);
+ anchor4.setLayoutY(content.getLayoutY());
+ anchor5.setLayoutX(content.getLayoutX());
+ anchor5.setLayoutY(content.getLayoutY());
+ anchor5.setVisible(false);
+ anchor6.setLayoutX(content.getLayoutX() + 40);
+ anchor6.setLayoutY(content.getLayoutY() + 100);
+ anchor7.setLayoutX(content.getLayoutX());
+ anchor7.setLayoutY(content.getLayoutY());
+ anchor7.setVisible(false);
+ anchor8.setLayoutX(content.getLayoutX());
+ anchor8.setLayoutY(content.getLayoutY() + 50);
+ anchor9.setLayoutX(content.getLayoutX());
+ anchor9.setLayoutY(content.getLayoutY());
+ anchor9.setVisible(false);
+ anchor10.setLayoutX(content.getLayoutX() + 80);
+ anchor10.setLayoutY(content.getLayoutY() + 50);
+
+ con1.setLayoutX(anchor6.getLayoutX());
+ con1.setLayoutY(anchor6.getLayoutY());
+ con.setLayoutX(anchor4.getLayoutX());
+ con.setLayoutY(anchor4.getLayoutY());
+ con2.setLayoutX(anchor8.getLayoutX());
+ con2.setLayoutY(anchor8.getLayoutY());
+ con3.setLayoutX(anchor10.getLayoutX());
+ con3.setLayoutY(anchor10.getLayoutY());
+
+ con.setId("connectingLine");
+ con.setLayoutX(anchor4.getLayoutX());
+ con.setLayoutY(anchor4.getLayoutY());
+
+ anchorFlag = true;
+ hb.getChildren().addAll(con, anchor3, anchor4, con1, anchor5, anchor6, con2, anchor7, anchor8, con3, anchor9, anchor10);
+ HashMap<Node, String> anchorNodeHash = new HashMap();
+
+ anchorNodeHash.put(anchor4, anchor4.getId());
+ anchorNodeHash.put(anchor6, anchor6.getId());
+ anchorNodeHash.put(anchor8, anchor8.getId());
+ anchorNodeHash.put(anchor10, anchor10.getId());
+ anchorNodeHash.put(con1, con1.getId());
+ anchorNodeHash.put(con2, con2.getId());
+ anchorNodeHash.put(con3, con3.getId());
+ anchorNodeHash.put(con, con.getId());
+
+ final ObservableList<Node> allNodeInCanvas = hb.getChildren();
+ mainAnchor.anchorsInsideImage(anchor4, 40, 0, 40, 100, hb, content, hbox, con, draggedImagesName, arrayOfInterFaceHash, linkTopologyHash, anchorNodeHash);
+ mainAnchor.anchorsInsideImage(anchor6, 40, 100, 40, 0, hb, content, hbox, con, draggedImagesName, arrayOfInterFaceHash, linkTopologyHash, anchorNodeHash);
+ mainAnchor.anchorsInsideImage(anchor8, 0, 50, 80, 50, hb, content, hbox, con, draggedImagesName, arrayOfInterFaceHash, linkTopologyHash, anchorNodeHash);
+ mainAnchor.anchorsInsideImage(anchor10, 80, 50, 0, 50, hb, content, hbox, con, draggedImagesName, arrayOfInterFaceHash, linkTopologyHash, anchorNodeHash);
+
+ hbox.setOnDragDetected(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent t) {
+ hbox.startFullDrag();
+ }
+ });
+
+ hbox.setOnMouseDragged(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent t) {
+ anchorFlag = false;
+ hb.getChildren().removeAll(con, con1, con2, con3, anchor4, anchor6, anchor8, anchor10);
+ }
+ });
+
+ content.setOnMouseMoved(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ Double x13 = content.getScene().getX() + 482.0 + 53.0;
+ Double x14 = content.getLayoutX() + 482.0;
+ Double y13 = content.getScene().getY() + 142.0 + 92.0;
+ Double y14 = content.getLayoutY() + 142.0;
+ boolean exitFlag = false;
+ for (int i = 0; i <= 80; i++) {
+ for (int j = 0; j <= 100; j++) {
+ Double x1 = content.getScene().getX();
+ Double y1 = content.getScene().getX();
+ Double x11 = x1 + i;
+ Double y11 = y1 + j;
+ if (x11 == arg0.getSceneX()) {
+ if (y11 == arg0.getSceneY()) {
+ exitFlag = true;
+ }
+ }
+ }
+ }
+
+ if (exitFlag == false) {
+ anchorFlag = false;
+ hb.getChildren().removeAll(con, con1, con2, con3, anchor4, anchor5, anchor6, anchor7, anchor8, anchor9, anchor10);
+ }
+ }
+ });
+
+ }
+ }
+
+ if (arg0.getClickCount() == 2) {
+ if (deviceInfo[0].equals("fvtapidriver") || deviceInfo[0].equals("poxclidriver") || deviceInfo[0].equals("mininetclidriver") || deviceInfo[0].equals("dpctlclidriver")
+ || deviceInfo[0].equals("floodlightclidriver") || deviceInfo[0].equals("flowvisorclidriver") || deviceInfo[0].equals("hpswitchclidriver")
+ || deviceInfo[0].equals("remotevmdriver") || deviceInfo[0].equals("remotepoxdriver") || deviceInfo[0].equals("flowvisordriver") || deviceInfo[0].equals("switchclidriver")) {
+ try {
+ topoplogy = new OFATopology();
+ topoplogy.start(new Stage());
+ } catch (Exception ex) {
+ Logger.getLogger(TopologyWizard.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ if (topoplogy.testTargetRadioButton.isSelected()) {
+ selectFlag = true;
+ }
+
+ topoplogy.cancelButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ topoplogy.copyStage.close();
+ }
+ });
+
+ topoplogy.save.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ topoplogy.getHostName = topoplogy.hostNameText.getText();
+ topoplogy.getUserName = topoplogy.userNameText.getText();
+ topoplogy.getPassword = topoplogy.passwordText.getText();
+
+ for (int i = 0; i < topoplogy.deviceTable.getItems().size(); i++) {
+ topoplogy.deviceTable.getSelectionModel().select(i);
+ interFaceHashDetail.put(topoplogy.deviceTable.getSelectionModel().getSelectedItem().getDeviceName().getText(), topoplogy.deviceTable.getSelectionModel().getSelectedItem().getDeviceType().getText() + "_" + text.getText());
+ arrayOfInterFaceHash = new ArrayList<HashMap<String, String>>();
+ arrayOfInterFaceHash.add(interFaceHashDetail);
+ }
+
+ draggedImagesName.add(text.getText());
+ propertyValue.add(text.getText() + "\n" + topoplogy.getHostName + "\n" + topoplogy.getUserName + "\n" + topoplogy.getPassword + "\n" + topoplogy.getTranportProtocol + "\n" + deviceInfo[0] + "\n" + topoplogy.getPort + "\n" + content.getId());
+ topoplogy.copyStage.close();
+ }
+ });
+ }
+ if (deviceInfo[1].equals("cli") || deviceInfo[1].equals("poxclidriver") || deviceInfo[1].equals("mininetclidriver") || deviceInfo[1].equals("dpctlclidriver")
+ || deviceInfo[1].equals("floodlightclidriver") || deviceInfo[1].equals("flowvisorclidriver") || deviceInfo[1].equals("hpswitchclidriver")
+ || deviceInfo[1].equals("remotevmdriver") || deviceInfo[1].equals("remotepoxdriver") || deviceInfo[1].equals("flowvisordriver") || deviceInfo[1].equals("switchclidriver")) {
+ try {
+ topoplogy = new OFATopology();
+ topoplogy.start(new Stage());
+ } catch (Exception ex) {
+ Logger.getLogger(TopologyWizard.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ topoplogy.cancelButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ topoplogy.copyStage.close();
+ }
+ });
+
+ try {
+ topoplogy.save.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ topoplogy.getHostName = topoplogy.hostNameText.getText();
+ topoplogy.getUserName = topoplogy.userNameText.getText();
+ topoplogy.getPassword = topoplogy.passwordText.getText();
+ for (int i = 0; i < topoplogy.deviceTable.getItems().size(); i++) {
+ topoplogy.deviceTable.getSelectionModel().select(i);
+ interFaceHashDetail.put(topoplogy.deviceTable.getSelectionModel().getSelectedItem().getDeviceName().getText(), topoplogy.deviceTable.getSelectionModel().getSelectedItem().getDeviceType().getText() + "_" + text.getText());
+ arrayOfInterFaceHash = new ArrayList<HashMap<String, String>>();
+ arrayOfInterFaceHash.add(interFaceHashDetail);
+ }
+ draggedImagesName.add(text.getText());
+ propertyValue.add(text.getText() + "\n" + topoplogy.getHostName + "\n" + topoplogy.getUserName + "\n" + topoplogy.getPassword + "\n" + topoplogy.getTranportProtocol + "\n" + deviceInfo[0] + "\n" + topoplogy.getPort + "\n" + content.getId());
+ topoplogy.copyStage.close();
+ }
+ });
+ } catch (Exception e) {
+ }
+ }
+
+ }
+ }
+ });
+
+ final Button closeButton = new Button();
+ Tooltip close = new Tooltip();
+ close.setText("Delete this device");
+ closeButton.setTooltip(close);
+ Image image = new Image(getClass().getResourceAsStream("/images/close_icon2.jpg"), 12, 12, true, true);
+ ImageView imageNew3 = new ImageView(image);
+ closeButton.setGraphic(imageNew3);
+ closeButton.setStyle("-fx-background-color: white;");
+
+ final ArrayList<Node> removeNodes = new ArrayList<Node>();
+ closeButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ OFAAnchorInsideImageNode node = new OFAAnchorInsideImageNode(224.0, 41.0);
+ node.closeNodeOnCanvas(closeButton, hbox, hb, content);
+ Node parent = hbox.getParent();
+ ObservableList<Node> allCurrentNode = hb.getChildren();
+ for (Node node1 : allCurrentNode) {
+ if (node1.toString().contains("Line")) {
+ if (!node1.toString().matches("Line[id=Line[id=null,null]]")) {
+ if (node1.getId() != null) {
+ String[] startLineNode = node1.getId().split(",");
+ Integer nodeHash = content.hashCode();
+
+ if (nodeHash.toString().equals(startLineNode[0])) {
+ removeNodes.add(node1);
+ }
+
+ if (startLineNode.length == 2) {
+ if (nodeHash.toString().equals(startLineNode[1])) {
+ removeNodes.add(node1);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (Node removenode : removeNodes) {
+ hb.getChildren().remove(removenode);
+ }
+
+ hb.getChildren().remove(content);
+
+ }
+ });
+
+ hbox.getChildren().addAll(closeButton, iv, text);
+ hbox.setId(iv.toString());
+
+ text.setPromptText("Device Name");
+ content.getChildren().add(hbox);
+
+ content.setOnMouseEntered(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ hbox.setStyle("-fx-border-color: Gold");
+ }
+ });
+
+ content.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ hbox.setStyle("-fx-border-color: Transparent");
+ Double xcoordinate = content.getLayoutX();
+ Double ycoordinate = content.getLayoutY();
+ OFATopology device = new OFATopology();
+
+ content.setId(xcoordinate.toString() + "," + ycoordinate.toString());
+ }
+ });
+
+ content.setLayoutX(x - 40);
+ content.setLayoutY(y - 30);
+ hb.getChildren().add(content);
+ }
+
+ void anchorsInsideImageNode(final Anchor anchor, final double bindLinex, final double bindLiney, final Pane hb, final DraggableNode content, final VBox hbox, final Line con) {
+
+
+ final Line con11 = new Line();
+
+ anchor.setOnDragDetected(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ anchor.startFullDrag();
+ enableDrag(anchor);
+ }
+ });
+
+ anchor.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+
+ boolean exitFlag = false;
+ for (int i = 0; i <= 80; i++) {
+ for (int j = 0; j <= 100; j++) {
+ Double x1 = anchor.getLayoutX() + 482.0;
+ Double y1 = anchor.getLayoutY() + 142.0;
+ Double x11 = x1 + i;
+ Double y11 = y1 + j;
+ if (x11 == arg0.getSceneX()) {
+ if (y11 == arg0.getSceneY()) {
+ exitFlag = true;
+
+ }
+ }
+ }
+ }
+ if (exitFlag == false) {
+ hbox.setStyle("-fx-border-color: Transparent");
+ anchor.setVisible(false);
+ con.setVisible(false);
+
+ }
+ }
+ });
+
+ hbox.setOnMouseDragged(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ try {
+ con.setVisible(false);
+ anchor.setVisible(false);
+ hb.getChildren().removeAll(con, anchor);
+ } catch (Exception e) {
+ }
+
+ }
+ });
+
+ anchor.setOnMouseDragReleased(new EventHandler<MouseDragEvent>() {
+ @Override
+ public void handle(MouseDragEvent arg0) {
+
+ ObservableList<Node> allNodesCanvas = hb.getChildren();
+ boolean flag = false;
+ try {
+ for (Node node : allNodesCanvas) {
+
+ Double x = node.getLayoutX() + 226.0;
+ Double y = node.getLayoutY() + 41.0;
+
+ if (node.toString().startsWith("DraggableNode")) {
+ for (int i = 0; i <= 80; i++) {
+ for (int j = 0; j <= 100; j++) {
+ Double x1 = node.getLayoutX() + 226.0;
+ Double y1 = node.getLayoutY() + 41.0;
+ Double x11 = x1 + i;
+ Double y11 = y1 + j;
+ if (x11 == arg0.getSceneX()) {
+ if (y11 == arg0.getSceneY()) {
+ con11.setStrokeLineCap(StrokeLineCap.ROUND);
+ con11.setStroke(Color.MIDNIGHTBLUE);
+ con11.setStrokeWidth(2.0);
+ con11.startXProperty().bind(content.layoutXProperty().add(bindLinex));
+ con11.startYProperty().bind(content.layoutYProperty().add(bindLiney));
+ con11.endXProperty().bind(node.layoutXProperty().add(bindLinex));
+ con11.endYProperty().bind(node.layoutYProperty().add(bindLiney));
+
+ hbox.setStyle("-fx-border-color: Transparent");
+
+ hb.getChildren().add(con11);
+ con.setVisible(false);
+ anchor.setVisible(false);
+ flag = true;
+
+ }
+
+ }
+ }
+ }
+
+ }
+
+ }
+ if (flag == false) {
+ con.setVisible(false);
+ anchor.setVisible(false);
+ }
+ } catch (Exception e) {
+
+ }
+
+ }
+ });
+
+ con11.setOnMouseEntered(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+
+ con11.setStroke(Color.GOLD);
+
+ }
+ });
+ con11.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+
+ con11.setStroke(Color.MIDNIGHTBLUE);
+ }
+ });
+
+ final DraggableNode contentLine = new DraggableNode();
+ con11.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+ if (arg0.getClickCount() == 2) {
+
+ topologyLink.start(new Stage());
+
+ if (arrayOfLinkTopologyHash.isEmpty()) {
+ for (HashMap<String, String> linkHash : arrayOfLinkTopologyHash) {
+ Set linkSet = linkHash.entrySet();
+ Iterator linkHashDetailIterator = linkSet.iterator();
+ while (linkHashDetailIterator.hasNext()) {
+
+ Map.Entry linkMap = (Map.Entry) linkHashDetailIterator.next();
+ if (linkMap.getKey().toString().equals(con11.getId())) {
+ String[] linkValues = linkMap.getValue().toString().split("_");
+ topologyLink.nameText.setText(linkValues[0]);
+ topologyLink.typeText.setText(linkValues[1]);
+ topologyLink.devicesInTopoEditor.setEditable(true);
+ topologyLink.devicesInTopoEditor.getSelectionModel().select(linkValues[2]);
+ topologyLink.interfaceList2.setEditable(true);
+ topologyLink.interfaceList2.getSelectionModel().select(linkValues[3]);
+ topologyLink.destDevicesInTopoEditor.setEditable(true);
+ topologyLink.destDevicesInTopoEditor.getSelectionModel().select(linkValues[4]);
+ topologyLink.interfaceList4.setEditable(true);
+ topologyLink.interfaceList4.getSelectionModel().select(linkValues[5]);
+ }
+ }
+ }
+ }
+
+ for (String string : draggedImagesName) {
+ topologyLink.devicesInTopoEditor.getItems().add(string);
+ topologyLink.destDevicesInTopoEditor.getItems().add(string);
+ }
+
+ topologyLink.devicesInTopoEditor.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ topologyLink.interfaceList2.getItems().clear();
+ try {
+ for (HashMap<String, String> interFaceDetail : arrayOfInterFaceHash) {
+ Set set = interFaceDetail.entrySet();
+ Iterator interFaceHashDetailIterator = set.iterator();
+ while (interFaceHashDetailIterator.hasNext()) {
+ Map.Entry me = (Map.Entry) interFaceHashDetailIterator.next();
+ String[] deviceNameAndiniterFaceValue = me.getValue().toString().split("\\_");
+ if (deviceNameAndiniterFaceValue[1].equals(topologyLink.devicesInTopoEditor.getSelectionModel().getSelectedItem())) {
+ if (!me.getKey().toString().equals("")) {
+ topologyLink.interfaceList2.getItems().add(me.getKey().toString());
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ });
+
+ topologyLink.destDevicesInTopoEditor.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+
+ topologyLink.interfaceList4.getItems().clear();
+ try {
+ for (HashMap<String, String> interFaceDetail : arrayOfInterFaceHash) {
+ Set set = interFaceDetail.entrySet();
+ Iterator interFaceHashDetailIterator = set.iterator();
+ while (interFaceHashDetailIterator.hasNext()) {
+ Map.Entry me = (Map.Entry) interFaceHashDetailIterator.next();
+ String[] deviceNameAndiniterFaceValue = me.getValue().toString().split("\\_");
+
+ if (deviceNameAndiniterFaceValue[1].equals(topologyLink.destDevicesInTopoEditor.getSelectionModel().getSelectedItem())) {
+ if (!me.getKey().toString().equals("")) {
+ topologyLink.interfaceList4.getItems().add(me.getKey().toString());
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ });
+
+ topologyLink.finishSelectedLink.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ con11.setId(topologyLink.nameText.getText() + "_" + con11.getStartX() + "_" + con11.getStartY() + "_" + con11.getEndX() + "_" + con11.getEndY());
+ String detailedString = topologyLink.nameText.getText() + "_" + topologyLink.typeText.getText() + "_" + topologyLink.devicesInTopoEditor.getSelectionModel().getSelectedItem() + "_" + topologyLink.interfaceList2.getSelectionModel().getSelectedItem() + "_" + topologyLink.destDevicesInTopoEditor.getSelectionModel().getSelectedItem() + "_" + topologyLink.interfaceList4.getSelectionModel().getSelectedItem() + "_";
+ linkTopologyHash.put(con11.getId(), detailedString);
+ arrayOfLinkTopologyHash = new ArrayList<HashMap<String, String>>();
+ arrayOfLinkTopologyHash.add(linkTopologyHash);
+ topologyLink.copyStage.close();
+ }
+ });
+
+
+ }
+ if (arg0.getButton() == MouseButton.SECONDARY) {
+ deleteLineContextMenu(contentLine, con11, arg0);
+
+ }
+ }
+ });
+
+ }
+
+ void insertImage1(Image i, Tab hb) {
+ ImageView iv = new ImageView();
+ iv.setImage(i);
+ setupGestureSource(iv);
+ }
+
+ void setupGestureTarget(final HBox targetBox) {
+ targetBox.setOnDragOver(new EventHandler<DragEvent>() {
+ @Override
+ public void handle(DragEvent event) {
+ Dragboard db = event.getDragboard();
+ if (db.hasImage()) {
+ event.acceptTransferModes(TransferMode.COPY);
+ }
+ event.consume();
+ }
+ });
+
+ targetBox.setOnDragDropped(new EventHandler<DragEvent>() {
+ @Override
+ public void handle(DragEvent event) {
+ Dragboard db = event.getDragboard();
+ if (db.hasImage()) {
+ event.setDropCompleted(true);
+ } else {
+ event.setDropCompleted(false);
+ }
+ event.consume();
+ }
+ });
+ }
+
+ void setupGestureSource(final ImageView source) {
+ source.setOnDragDetected(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent event) {
+
+ /*
+ * allow any transfer mode
+ */
+ Dragboard db = source.startDragAndDrop(TransferMode.COPY);
+
+ /*
+ * put a image on dragboard
+ */
+ ClipboardContent content = new ClipboardContent();
+
+ Image sourceImage = source.getImage();
+ content.putImage(sourceImage);
+ db.setContent(content);
+
+ event.consume();
+ }
+ });
+
+ }
+
+ void deleteLineContextMenu(final DraggableNode contentLine, final Line connecting, MouseEvent arg0) {
+
+ ContextMenu menu = new ContextMenu();
+ MenuItem item = new MenuItem("Delete Line");
+ item.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ contentLine.setVisible(false);
+ contentLine.getChildren().remove(connecting);
+ }
+ });
+
+ menu.getItems().add(item);
+ menu.show(contentLine, arg0.getScreenX(), arg0.getScreenY());
+
+ }
+
+ public ArrayList<TextField> getDeviceNameList() {
+ return deviceNameList;
+ }
+
+ public ArrayList<String> getPropertyDetail() {
+ return propertyValue;
+ }
+
+ class Anchor extends Circle {
+
+ Anchor(String id, DoubleProperty x, DoubleProperty y) {
+ super(x.get(), y.get(), 7);
+ setId(id);
+ setFill(Color.ANTIQUEWHITE.deriveColor(1, 1, 1, 0.75));
+ setStroke(Color.GREY);
+ x.bind(centerXProperty());
+ y.bind(centerYProperty());
+ }
+ }
+
+ class Anchor2 extends DraggableNode {
+
+ Anchor2(String id, DoubleProperty x, DoubleProperty y) {
+ super();
+ setId(id);
+
+ x.bind(layoutXProperty());
+ y.bind(layoutYProperty());
+ }
+ }
+
+ private void enableDragLineWithAnchors(final Line connecting, final Circle anchor1, final Circle anchor2) {
+ final Delta dragDelta = new Delta();
+
+ connecting.setOnMousePressed(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ // record a delta distance for the drag and drop operation.
+ dragDelta.x = connecting.getLayoutX() - mouseEvent.getX();
+ dragDelta.y = connecting.getLayoutY() - mouseEvent.getY();
+ dragDelta.x = anchor1.getLayoutX() - mouseEvent.getX();
+ dragDelta.y = anchor1.getLayoutY() - mouseEvent.getY();
+ dragDelta.x = anchor2.getLayoutX() - mouseEvent.getX();
+ dragDelta.y = anchor2.getLayoutY() - mouseEvent.getY();
+ connecting.getScene().setCursor(Cursor.MOVE);
+ }
+ });
+ connecting.setOnMouseReleased(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ connecting.getScene().setCursor(Cursor.HAND);
+ }
+ });
+ connecting.setOnMouseDragged(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ connecting.setLayoutX(mouseEvent.getX() + dragDelta.x);
+ connecting.setLayoutY(mouseEvent.getY() + dragDelta.y);
+ anchor1.setLayoutX(mouseEvent.getX() + dragDelta.x);
+ anchor1.setLayoutY(mouseEvent.getY() + dragDelta.y);
+ anchor2.setLayoutX(mouseEvent.getX() + dragDelta.x);
+ anchor2.setLayoutY(mouseEvent.getY() + dragDelta.y);
+
+ }
+ });
+ connecting.setOnMouseEntered(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ if (!mouseEvent.isPrimaryButtonDown()) {
+ connecting.getScene().setCursor(Cursor.HAND);
+ }
+ }
+ });
+
+ connecting.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ if (!mouseEvent.isPrimaryButtonDown()) {
+ connecting.getScene().setCursor(Cursor.DEFAULT);
+ }
+ }
+ });
+ }
+
+ private void enableDrag(final Circle circle) {
+ final TopologyWizard.Delta dragDelta = new TopologyWizard.Delta();
+ circle.setOnMousePressed(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ // record a delta distance for the drag and drop operation.
+ dragDelta.x = circle.getCenterX() - mouseEvent.getX();
+ dragDelta.y = circle.getCenterY() - mouseEvent.getY();
+ circle.getScene().setCursor(Cursor.MOVE);
+ }
+ });
+ circle.setOnMouseReleased(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ circle.getScene().setCursor(Cursor.HAND);
+ }
+ });
+ circle.setOnMouseDragged(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ circle.setCenterX(mouseEvent.getX() + dragDelta.x);
+ circle.setCenterY(mouseEvent.getY() + dragDelta.y);
+ }
+ });
+ circle.setOnMouseEntered(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ if (!mouseEvent.isPrimaryButtonDown()) {
+ circle.getScene().setCursor(Cursor.HAND);
+ }
+ }
+ });
+ circle.setOnMouseExited(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent mouseEvent) {
+ if (!mouseEvent.isPrimaryButtonDown()) {
+ circle.getScene().setCursor(Cursor.DEFAULT);
+ }
+ }
+ });
+ }
+
+ class Delta {
+
+ double x, y;
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/StepTable.java b/TestON/TAI/src/tai_ofa/StepTable.java
new file mode 100644
index 0000000..ead5d85
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/StepTable.java
@@ -0,0 +1,63 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import javafx.scene.control.Label;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class StepTable {
+ public Label testStepId;
+ public Label testStepName;
+ public Label testStepStatus;
+
+ public StepTable() {
+
+ }
+ public StepTable(Label stepId, Label stepName,Label status) {
+
+ this.testStepId = stepId;
+ this.testStepName = stepName;
+ this.testStepStatus = status;
+
+ }
+
+
+ public Label getTestStepId() {
+ return testStepId;
+ }
+ public void setTestStepId(Label newStepId) {
+ testStepId = newStepId;
+ }
+ public Label getTestStepName() {
+ return testStepName;
+ }
+ public void setTestCaseName(Label newStepName) {
+ testStepName = newStepName;
+ }
+ public Label getTestStepStatus() {
+ return testStepStatus;
+ }
+ public void setTestCaseStatus(Label newStepStatus) {
+ testStepStatus = newStepStatus;
+ }
+
+}
diff --git a/TestON/TAI/src/tai_ofa/SummaryTable.java b/TestON/TAI/src/tai_ofa/SummaryTable.java
new file mode 100644
index 0000000..5c1b1a8
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/SummaryTable.java
@@ -0,0 +1,80 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.Label;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class SummaryTable {
+ public Label testCaseId;
+ public Label testCaseName;
+ public Label testCaseStatus;
+ public Label testCaseStartTime;
+ public Label testCaseEndTime;
+ public SummaryTable() {
+
+ }
+ public SummaryTable(Label caseId, Label caseName,Label status,Label startTime, Label endTime) {
+
+ this.testCaseId = caseId;
+ this.testCaseName = caseName;
+ this.testCaseStatus = status;
+ this.testCaseStartTime =startTime;
+ this.testCaseEndTime = endTime;
+ }
+
+
+ public Label getTestCaseId() {
+ return testCaseId;
+ }
+ public void setTestCaseId(Label newCaseId) {
+ testCaseId = newCaseId;
+ }
+ public Label getTestCaseName() {
+ return testCaseName;
+ }
+ public void setTestCaseName(Label newCaseName) {
+ testCaseName = newCaseName;
+ }
+ public Label getTestCaseStatus() {
+ return testCaseStatus;
+ }
+ public void setTestCaseStatus(Label newCaseStatus) {
+ testCaseStatus = newCaseStatus;
+ }
+
+ public Label getTestCaseStartTime() {
+ return testCaseStartTime;
+ }
+ public void setTestCaseStartTime(Label newCaseStartTime) {
+ testCaseStartTime = newCaseStartTime;
+ }
+ public Label getTestCaseEndTime() {
+ return testCaseEndTime;
+ }
+ public void setTestCaseEndTime(Label newCaseEndTime) {
+ testCaseEndTime = newCaseEndTime;
+ }
+
+
+}
diff --git a/TestON/TAI/src/tai_ofa/TAILocale.java b/TestON/TAI/src/tai_ofa/TAILocale.java
new file mode 100644
index 0000000..8f002f2
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/TAILocale.java
@@ -0,0 +1,160 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+
+import java.text.MessageFormat;
+import java.util.*;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class TAILocale {
+
+ String fileMenu, viewMenu, editMenu, helpMenu, runMenu,OFAHarnessPath,hierarchyTestON;
+ String New, newTestScript, newParams, newTopology,newDriver;
+ String open, save, saveAs, saveAll, close, closeAll, exit;
+ String copy, cut, paste, select, selectAll, pauseTest, resumeTest, stopTest,aboutHelp;
+ String driverExplorer, logExplorer, ProjectExplorer;
+ String contextNew, contextTest, contextTpl, contextParam, contextOpen, contextCut, contextCopy, contextPaste, contextDelete, contextRefresh;
+ String wizTitle, wiz_Previous, wizN_ext, wizCancel, wiz_Finish, wizTestName, wizTestParams, wizEmailId, wizNumberofTestCases, wizEstimatedTime, wizProject, wizParamName, wizTopologyName;
+ String wizProjectWizardId, wizTestWizardId, wizTopologyWizardId;
+ String topoTitle, topoProperties, topoInterfaces, topoAttribute, topoValue, topoHost, topoUserName, topoPassword, topoTransport;
+ String topoSSH, topoTELNET, topoFTP, topoRLOGIN, topoPrompt, topoSave, topoDefault, topoCancel, topoAttribue, topoValues;
+ String testSummaryEndTest, testSummaryTestSummary, testSummaryEnterComment, testSummaryConsoleOutput, summary, information;
+ String testSummaryViewLog, testSummaryExecutionStatus, testSummaryTestCaseId, testSummaryTestCaseName, testSummaryTestCaseTitle, testSummaryStartTest;
+ String testParameterTestDirctory, testParameteremailId, testParameterSelectTestCase, testParameterStartTest, testParameterCancel;
+
+ public TAILocale(Locale currentLocale){
+ TAIProperties resource = new TAIProperties();
+ MessageFormat messageFormat = new MessageFormat("");
+ messageFormat.setLocale(currentLocale);
+
+ hierarchyTestON = (String) resource.handleObject("hierarchyTestON");
+ OFAHarnessPath = (String) resource.handleObject("OFAHarnessPath");
+ fileMenu = (String) resource.handleObject("File");
+ viewMenu = (String) resource.handleObject("View");
+ editMenu = (String) resource.handleObject("Edit");
+ helpMenu= (String) resource.handleObject("Help");
+ runMenu = (String) resource.handleObject("Run");
+ pauseTest = (String) resource.handleObject("Pause");
+ resumeTest = (String) resource.handleObject("Resume");
+ stopTest = (String) resource.handleObject("Stop");
+ aboutHelp = (String) resource.handleObject("About");
+ driverExplorer = (String) resource.handleObject("DriverExplorer");
+ logExplorer= (String) resource.handleObject("LogExplorer");
+ ProjectExplorer = (String) resource.handleObject("ProjectExplorer");
+ copy = (String) resource.handleObject("Copy");
+ cut = (String) resource.handleObject("Cut");
+ paste = (String) resource.handleObject("Paste");
+ select = (String) resource.handleObject("Select");
+ selectAll = (String) resource.handleObject("Select All");
+ New = (String) resource.handleObject("New");
+ open = (String) resource.handleObject("Open");
+ save = (String) resource.handleObject("Save");
+ saveAs = (String) resource.handleObject("SaveAs");
+ saveAll = (String) resource.handleObject("Save All");
+ close = (String) resource.handleObject("Close");
+ closeAll = (String) resource.handleObject("CloseAll");
+ exit = (String) resource.handleObject("Exit");
+ newDriver = (String) resource.handleObject("Driver");
+ newTestScript = (String) resource.handleObject("newTestScript");
+ newParams = (String) resource.handleObject("Params");
+ newTopology = (String) resource.handleObject("Topology");
+
+ // project explorer context menu
+
+ contextNew = (String) resource.handleObject("New");
+ contextTest = (String) resource.handleObject("Test");
+
+ contextParam = (String) resource.handleObject("Params");
+ contextTpl = (String) resource.handleObject("Tpl");
+
+ contextOpen = (String) resource.handleObject("Open");
+ contextCut = (String) resource.handleObject("Cut");
+
+ contextCopy = (String) resource.handleObject("Copy");;
+ contextPaste = (String) resource.handleObject("Paste");
+
+ contextRefresh = (String) resource.handleObject("Refresh");
+ contextDelete = (String) resource.handleObject("Delete");
+
+ //OFA Wizards
+ wizTitle = (String) resource.handleObject("wizTitle");
+ wiz_Previous = (String) resource.handleObject("wiz_Previous");
+ wizN_ext = (String) resource.handleObject("wizN_ext");
+ wizCancel = (String) resource.handleObject("wizCancel");
+ wiz_Finish = (String) resource.handleObject("wiz_Finish");
+
+ wizTestName = (String) resource.handleObject("wizTestName");
+ wizTestParams = (String) resource.handleObject("wizTestParams");
+ wizEmailId = (String) resource.handleObject("wizEmailId");
+ wizNumberofTestCases = (String) resource.handleObject("wizNumberofTestCases");
+ wizEstimatedTime = (String) resource.handleObject("wizEstimatedTime");
+ wizProject = (String) resource.handleObject("wizProject");
+ wizParamName = (String) resource.handleObject("wizParamName");
+ wizTopologyName = (String) resource.handleObject("wizTopologyName");
+
+
+ wizProjectWizardId = (String) resource.handleObject("wizProjectWizardId");
+ wizTestWizardId = (String) resource.handleObject("wizTestWizardId");
+ wizTopologyWizardId = (String) resource.handleObject("wizTopologyWizardId");
+
+ // OFA Topology
+
+ topoTitle = (String) resource.handleObject("topoTitle");
+ topoProperties = (String) resource.handleObject("topoProperties");
+ topoInterfaces = (String) resource.handleObject("topoInterfaces");
+ topoAttribute = (String) resource.handleObject("topoAttribute");
+ topoValue = (String) resource.handleObject("topoValue");
+ topoHost = (String) resource.handleObject("topoHost");
+ topoUserName = (String) resource.handleObject("topoUserName");
+ topoPassword = (String) resource.handleObject("topoPassword");
+ topoTransport = (String) resource.handleObject("topoTransport");
+ topoSSH = (String) resource.handleObject("topoSSH");
+ topoTELNET = (String) resource.handleObject("topoTELNET");
+ topoFTP = (String) resource.handleObject("topoFTP");
+ topoRLOGIN = (String) resource.handleObject("topoRLOGIN");
+ topoPrompt = (String) resource.handleObject("topoPrompt");
+ topoSave = (String) resource.handleObject("topoSave");
+ topoDefault = (String) resource.handleObject("topoDefault");
+ topoCancel = (String) resource.handleObject("topoCancel");
+ topoValues = (String) resource.handleObject("topoValues");
+
+ // OFA Test Summary
+
+ testSummaryViewLog = (String) resource.handleObject("testSummaryViewLog");
+ testSummaryTestCaseTitle = (String) resource.handleObject("testSummaryExecutionStatus");
+ testSummaryTestCaseId = (String) resource.handleObject("testSummaryTestCaseId");
+ testSummaryTestCaseName = (String) resource.handleObject("testSummaryTestCaseName");
+ testSummaryExecutionStatus = (String) resource.handleObject("testSummaryTestCaseStatus");
+ testSummaryStartTest = (String) resource.handleObject("testSummaryStartTest");
+ testSummaryEndTest = (String) resource.handleObject("testSummaryEndTest");
+ testSummaryTestSummary = (String) resource.handleObject("testSummaryTestSummary");
+ summary = (String) resource.handleObject("summary");
+ information = (String) resource.handleObject("information");
+ testSummaryEnterComment = (String) resource.handleObject("testSummaryEnterComment");
+ testSummaryConsoleOutput = (String) resource.handleObject("testSummaryConsoleOutput");
+ testParameterCancel = (String) resource.handleObject("testParameterCancel");
+
+
+
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/TAIProperties.java b/TestON/TAI/src/tai_ofa/TAIProperties.java
new file mode 100644
index 0000000..8810c8b
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/TAIProperties.java
@@ -0,0 +1,386 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+import java.util.*;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class TAIProperties extends ResourceBundle {
+
+ public Object handleObject(String key){
+ //Set TestON Hierarchy path here
+ if (key.equals("hierarchyTestON")){
+ return "/home/paxterra/Desktop/TestON/";
+ }
+
+
+ if (key.equals("OFAHarnessPath")){
+ return "/home/paxterra/Music/TAI_OFA/src/";
+ }
+
+ if (key.equals("File")){
+ return "File";
+ }
+
+ if (key.equals("View")) {
+ return "View";
+ }
+
+ if (key.equals("Run")){
+ return "Run";
+ }
+
+ if (key.equals("Edit")){
+ return "Edit";
+ }
+
+ if (key.equals("Help")){
+ return "Help";
+ }
+
+ if (key.equals("New")){
+ return "New";
+ }
+
+ if (key.equals("Open")){
+ return "Open";
+ }
+
+ if(key.equals("Pause")) {
+ return "Pause";
+ }
+ if(key.equals("Resume")) {
+ return "Resume";
+ }
+ if(key.equals("Stop")) {
+ return "Stop";
+ }
+ if(key.equals("About")) {
+ return "About";
+ }
+
+ if(key.equals("DriverExplorer")) {
+ return "Driver Explorer";
+ }
+
+ if(key.equals("ProjectExplorer")) {
+ return "Project Explorer";
+ }
+
+ if(key.equals("LogExplorer")) {
+ return "Log Explorer";
+ }
+
+ if(key.equals("Cut")) {
+ return "Cut";
+ }
+ if(key.equals("Copy")) {
+ return "Copy";
+ }
+
+ if(key.equals("Paste")) {
+ return "Paste";
+ }
+
+ if(key.equals("Select")) {
+ return "Select";
+ }
+ if(key.equals("Select All")) {
+ return "Select All";
+ }
+ if(key.equals("Save")) {
+ return "Save";
+ }
+ if(key.equals("SaveAs")) {
+ return "Save As";
+ }
+
+ if(key.equals("Save All")) {
+ return "SaveAll";
+ }
+
+ if(key.equals("Close")) {
+ return "Close";
+ }
+ if(key.equals("CloseAll")) {
+ return "CloseAll";
+ }
+ if(key.equals("Exit")) {
+ return "Exit";
+ }
+
+ if(key.equals("Exit")) {
+ return "Exit";
+ }
+
+ if(key.equals("Driver")) {
+ return "Component Driver";
+ }
+ if(key.equals("Params")) {
+ return "Params";
+ }
+ if(key.equals("Topology")) {
+ return "Topology";
+ }
+ if(key.equals("newTestScript")) {
+ return "Test Script";
+ }
+
+ //Context Menu
+ if (key.equals("New")) {
+ return "New";
+ }
+
+ if (key.equals("Test")) {
+ return "Test";
+ }
+ if (key.equals("Param")) {
+ return "Params";
+ }
+ if (key.equals("Tpl")) {
+ return "TPL";
+ }
+
+ if (key.equals("Open")) {
+ return "Open";
+ }
+
+ if (key.equals("Cut")) {
+ return "Cut";
+ }
+
+ if (key.equals("Copy")) {
+ return "Copy";
+ }
+
+ if (key.equals("Paste")) {
+ return "Paste";
+ }
+ if (key.equals("Refresh")) {
+ return "Refresh";
+ }
+
+ if (key.equals("Delete")) {
+ return "Delete";
+ }
+
+ //OFA WIZARDS
+ if (key.equals("wizTitle")) {
+ return "AutoMate";
+ }
+ if (key.equals("wiz_Previous")) {
+ return "_Previous";
+ }
+
+ if (key.equals("wizN_ext")) {
+ return "N_ext";
+ }
+ if (key.equals("wizCancel")) {
+ return "Cancel";
+ }
+
+ if (key.equals("wiz_Finish")) {
+ return "_Finish";
+ }
+ if (key.equals("wizTestName")) {
+ return "Test Name";
+ }
+
+ if (key.equals("wizTestParams")) {
+ return "TEST PARAMS:";
+ }
+ if (key.equals("wizEmailId")) {
+ return "Email Id";
+ }
+
+ if (key.equals("wizNumberofTestCases")) {
+ return "Number of TestCases";
+ }
+ if (key.equals("wizEstimatedTime")) {
+ return "Estimated Time";
+ }
+
+ if (key.equals("wizProject")) {
+ return "Project";
+ }
+ if (key.equals("wizParamName")) {
+ return "Param Name";
+ }
+
+ if (key.equals("wizTopologyName")) {
+ return "Topology Name";
+ }
+ if (key.equals("wizProjectWizardId")) {
+ return "projectWizard";
+ }
+
+ if (key.equals("wizTestWizardId")) {
+ return "testWizard";
+ }
+ if (key.equals("wizTopologyWizardId")) {
+ return "topologyWizard";
+ }
+
+ if (key.equals("wiz")) {
+ return "Attribue";
+ }
+ if (key.equals("wiz")) {
+ return "Values";
+ }
+
+ // OFA Topology
+
+ if (key.equals("topoTitle")) {
+ return "Topology";
+ }
+ if (key.equals("topoProperties")) {
+ return "Properties";
+ }
+
+ if (key.equals("topoInterfaces")) {
+ return "Interfaces";
+ }
+ if (key.equals("topoAttribute")) {
+ return "Attribute";
+ }
+
+ if (key.equals("topoValue")) {
+ return "Value";
+ }
+
+ if (key.equals("topoHost")) {
+ return "Host";
+ }
+ if (key.equals("topoUserName")) {
+ return "User Name";
+ }
+ if (key.equals("topoPassword")) {
+ return "Password";
+ }
+ if (key.equals("topoTransport")) {
+ return "Transport";
+ }
+
+ if (key.equals("topoSSH")) {
+ return "SSH";
+ }
+
+ if (key.equals("topoTELNET")) {
+ return "TELNET";
+ }
+ if (key.equals("topoFTP")) {
+ return "FTP";
+ }
+ if (key.equals("topoRLOGIN")) {
+ return "RLOGIN";
+ }
+
+
+
+ if (key.equals("topoPrompt")) {
+ return "Prompt";
+ }
+
+ if (key.equals("topoSave")) {
+ return "Save";
+ }
+ if (key.equals("topoDefault")) {
+ return "Default";
+ }
+ if (key.equals("topoCancel")) {
+ return "Cancel";
+ }
+
+
+ if (key.equals("topoInterfaces")) {
+ return "Interfaces";
+ }
+ if (key.equals("topoAttribue")) {
+ return "Attribue";
+ }
+ if (key.equals("topoValues")) {
+ return "Values";
+ }
+
+
+
+
+
+ // OFA TestSummary
+
+
+ if (key.equals("testSummaryViewLog")) {
+ return "View Logs";
+ }
+ if (key.equals("testSummaryExecutionStatus")) {
+ return "Execution Status";
+ }
+
+ if (key.equals("testSummaryTestCaseId")) {
+ return "ID";
+ }
+ if (key.equals("testSummaryTestCaseName")) {
+ return "Name";
+ }
+
+ if (key.equals("testSummaryTestCaseStatus")) {
+ return "Status";
+ }
+
+ if (key.equals("testSummaryStartTest")) {
+ return "Start Test";
+ }
+ if (key.equals("testSummaryEndTest")) {
+ return "End Test";
+ }
+ if (key.equals("summary")) {
+ return "Summary";
+ }
+ if (key.equals("information")) {
+ return "Information";
+ }
+
+ if (key.equals("testSummaryTestSummary")) {
+ return "Test Summary";
+ }
+
+ if (key.equals("testSummaryEnterComment")) {
+ return "Test Summary Console";
+ }
+ if (key.equals("testSummaryConsoleOutput")) {
+ return "Console output";
+ }
+
+ return null;
+ }
+
+ @Override
+ protected Set<String> handleGetObject(String key) {
+
+ return new HashSet<String>(Arrays.asList("okKey", "cancelKey"));
+ }
+
+ @Override
+ public Enumeration<String> getKeys() {
+ return Collections.enumeration(keySet());
+ }
+
+}
diff --git a/TestON/TAI/src/tai_ofa/TAI_OFA.java b/TestON/TAI/src/tai_ofa/TAI_OFA.java
new file mode 100644
index 0000000..fc47b5b
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/TAI_OFA.java
@@ -0,0 +1,1326 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javafx.application.Application;
+import javafx.application.Platform;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+import javafx.collections.ObservableList;
+import javafx.event.ActionEvent;
+import javafx.event.Event;
+import javafx.event.EventHandler;
+import javafx.geometry.Insets;
+import javafx.geometry.Orientation;
+import javafx.geometry.Pos;
+import javafx.scene.Group;
+import javafx.scene.Node;
+import javafx.scene.Scene;
+import javafx.scene.control.Accordion;
+import javafx.scene.control.Button;
+import javafx.scene.control.ComboBox;
+import javafx.scene.control.ComboBoxBuilder;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.Label;
+import javafx.scene.control.Menu;
+import javafx.scene.control.MenuBar;
+import javafx.scene.control.MenuButton;
+import javafx.scene.control.MenuItem;
+import javafx.scene.control.Separator;
+import javafx.scene.control.SeparatorMenuItem;
+import javafx.scene.control.SplitPane;
+import javafx.scene.control.Tab;
+import javafx.scene.control.TabPane;
+import javafx.scene.control.TextArea;
+import javafx.scene.control.TextField;
+import javafx.scene.control.TextFieldBuilder;
+import javafx.scene.control.TitledPane;
+import javafx.scene.control.ToolBar;
+import javafx.scene.control.Tooltip;
+import javafx.scene.control.TreeCell;
+import javafx.scene.control.TreeItem;
+import javafx.scene.control.TreeView;
+import javafx.scene.effect.Effect;
+import javafx.scene.image.Image;
+import javafx.scene.image.ImageView;
+import javafx.scene.input.InputEvent;
+import javafx.scene.input.MouseButton;
+import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+import javafx.scene.layout.VBox;
+import javafx.scene.layout.VBoxBuilder;
+import javafx.scene.paint.Color;
+import javafx.scene.text.Font;
+import javafx.scene.text.FontWeight;
+import javafx.scene.text.Text;
+import javafx.stage.FileChooser;
+import javafx.stage.FileChooser.ExtensionFilter;
+import javafx.stage.Modality;
+import javafx.stage.Screen;
+import javafx.stage.Stage;
+import javafx.util.Callback;
+import javax.swing.JOptionPane;
+import javax.swing.SingleSelectionModel;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ *
+ */
+public class TAI_OFA extends Application {
+
+ MenuBar OFA_MenuBar = new MenuBar();
+ Scene scene;
+ TAILocale label = new TAILocale(new Locale("en", "EN"));
+ Stage copyStage;
+ double toolBarHeight, menuBarHeight;
+ ToolBar toolbar = new ToolBar();
+ TitledPane projectExplorer;
+ TitledPane logExlorer;
+ TitledPane driverExplorer;
+ TreeView<String> projectExplorerTreeView, logExplorerTreeView, driverExplorerTreeView;
+ TreeItem<String> driverExplorerTree;
+ static double OFAContainerWidth, OFAContainerHeight;
+ boolean projectExplorerFlag, editorFlag;
+ ContextMenu contextMenu;
+ TAI_OFA OFAReference;
+ TabPane explorerTabPane, editorTabPane;
+ FileChooser openParams;
+ OFAFileOperations fileOperation = new OFAFileOperations();
+ Tab explorerTab;
+ Accordion explorer;
+ TreeItem<String> projectExplorerTree, logExplorerTree;
+ OFAWizard wizard;
+ AddParams addParams;
+ String paramsFileContent, projectWorkSpacePath;
+ OFATestSummary testSummaryPop;
+ Button Save;
+ MenuItem saveAll;
+ MenuItem closeAll;
+
+ public TAI_OFA() {
+ OFAReference = this;
+
+ }
+
+ public TAI_OFA(TabPane pane, Scene sc, TabPane pane1) {
+ editorTabPane = pane;
+ scene = sc;
+ explorerTabPane = pane1;
+ OFAReference = this;
+ }
+
+ @Override
+ public void start(Stage primaryStage) {
+ copyStage = primaryStage;
+ Group root = new Group();
+
+ projectWorkSpacePath = label.hierarchyTestON;
+ scene = new Scene(root, 800, 600, Color.DARKGRAY);
+ VBox baseBox = new VBox();
+ getFileMenu();
+ getEditMenu();
+ getViewMenu();
+ getRunMenu();
+ getHelpMenu();
+ getToolBar();
+ OFA_MenuBar.setPrefWidth(scene.widthProperty().get());
+ toolbar.prefWidthProperty().bind(scene.widthProperty());
+ toolbar.setMinHeight(scene.heightProperty().get() / 20);;
+ toolBarHeight = toolbar.getMinHeight();
+ OFA_MenuBar.setPrefHeight(scene.heightProperty().get() / 20);
+ menuBarHeight = OFA_MenuBar.getPrefHeight();
+ explorerTabPane = new TabPane();
+ editorTabPane = new TabPane();
+ explorer = new Accordion();
+ explorerTab = new Tab("Explorer");
+ explorerTabPane.setLayoutX(0);
+ projectExplorerFlag = true;
+
+ getProjectExplorer();
+ getLogExplorer();
+ getDriverExplorer();
+ explorer.setMinSize(200, scene.getHeight() - 40);
+ explorer.getPanes().addAll(projectExplorer, logExlorer, driverExplorer);
+ explorerTabPane.prefHeightProperty().bind(scene.heightProperty());
+ explorerTabPane.setMinWidth(200);
+ explorerTab.setContent(explorer);
+ explorerTabPane.getTabs().addAll(explorerTab);
+ editorTabPane.setLayoutX(270);
+ final Pane basePane = new Pane();
+ explorerTabPane.prefHeightProperty().bind(scene.heightProperty().subtract(toolBarHeight + menuBarHeight + 1));
+ basePane.getChildren().addAll(explorerTabPane, new Separator(Orientation.VERTICAL), editorTabPane);
+ basePane.autosize();
+ baseBox.getChildren().addAll(OFA_MenuBar, toolbar, basePane);
+ baseBox.prefHeightProperty().bind(primaryStage.heightProperty());
+ OFAContainerWidth = scene.getWidth();
+ OFAContainerHeight = scene.getHeight();
+ root.getChildren().addAll(baseBox);
+ primaryStage.setTitle("TestON - Automation is O{pe}N");
+ primaryStage.setScene(scene);
+ primaryStage.setResizable(true);
+ primaryStage.sizeToScene();
+ primaryStage.show();
+ }
+
+ public void getFileMenu() {
+
+
+ //adding Menus
+ Menu fileMenu = new Menu(label.fileMenu);
+
+ //adding File Menu
+ Image newImage = new Image("images/newIcon.jpg", 20.0, 20.0, true, true);
+ Image saveAllImage = new Image("images/saveAll.jpg", 20.0, 20.0, true, true);
+
+ Menu newFileMenu = new Menu("New", new ImageView(newImage));
+ MenuItem newTest = new MenuItem("New Test");
+ MenuItem componentDriver = new MenuItem(label.newDriver);
+ MenuItem newParams = new MenuItem(label.newParams);
+ MenuItem newTopology = new MenuItem(label.newTopology);
+ MenuItem testScript = new MenuItem(label.newTestScript);
+ newFileMenu.getItems().addAll(newTest, componentDriver, newParams, newTopology, testScript);
+
+
+ newTopology.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ try {
+ wizard = new OFAWizard(projectExplorerTree, 3, projectExplorerTree.getChildren(), projectExplorerTreeView);
+ wizard.setOFA(OFAReference);
+ wizard.start(new Stage());
+
+ } catch (Exception ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ newTest.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ wizard = new OFAWizard(projectExplorerTree, 1, projectExplorerTree.getChildren(), projectExplorerTreeView);
+ wizard.setOFA(OFAReference);
+ try {
+ wizard.start(new Stage());
+ } catch (Exception ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ newParams.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ addParams = new AddParams();
+ addParams.setOFA(OFAReference);
+ addParams.getNewParams();
+ }
+ });
+
+
+ Image openImage = new Image("images/open.png", 15.0, 15.0, true, true);
+ Menu open = new Menu(label.open, new ImageView(openImage));
+ MenuItem openParams = new MenuItem("Params");
+ Menu openTestScript = new Menu("Test Script");
+ MenuItem pyTest = new MenuItem("Python TestScript");
+ MenuItem ospkTest = new MenuItem("OpenSpeak TestScript");
+ openTestScript.getItems().addAll(pyTest, ospkTest);
+
+ MenuItem openTopology = new MenuItem("Topology");
+ MenuItem openDriver = new MenuItem("Driver");
+
+ open.getItems().addAll(openParams, openTopology, openTestScript, openDriver);
+
+ openParams.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ openFile("params", "");
+ }
+ });
+
+ ospkTest.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ openFile("ospk", "");
+ }
+ });
+
+
+ Image saveImage = new Image("images/Save_24x24.png", 15.0, 15.0, true, true);
+ MenuItem save = new MenuItem(label.save, new ImageView(saveImage));
+
+ MenuItem saveAs = new MenuItem(label.saveAs);
+ saveAll = new MenuItem(label.saveAll, new ImageView(saveAllImage));
+
+ Image exitImage = new Image("images/exit.gif", 15.0, 15.0, true, true);
+ MenuItem exit = new MenuItem(label.exit, new ImageView(exitImage));
+ exit.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ copyStage.close();
+ }
+ });
+ Image closeImage = new Image("images/close_icon2.jpg", 15.0, 15.0, true, true);
+ MenuItem close = new MenuItem(label.close, new ImageView(closeImage));
+ closeAll = new MenuItem(label.closeAll);
+ fileMenu.getItems().addAll(newFileMenu, open, save, saveAll, saveAs, new SeparatorMenuItem(), close, closeAll, new SeparatorMenuItem(), exit);
+
+ OFA_MenuBar.getMenus().addAll(fileMenu);
+ }
+
+ public void getProjectExplorer() {
+
+ projectWorkSpacePath = label.hierarchyTestON + "/tests/";
+ File[] file = File.listRoots();
+ Path name = new File(projectWorkSpacePath).toPath();
+ OFALoadTree treeNode = new OFALoadTree(name);
+
+ treeNode.setExpanded(true);
+ projectExplorerTree = treeNode;
+ for (int i = 0; i < treeNode.getChildren().size(); i++) {
+ if (treeNode.getChildren().get(i).getValue().equals("__init__")) {
+ treeNode.getChildren().remove(treeNode.getChildren().get(i));
+ }
+ }
+ projectExplorerTreeView = new TreeView<String>(treeNode);
+ VBox projectExpl = new VBox();
+ Button newTest = new Button("New Test");
+ projectExplorerTreeView.setMinHeight(scene.getHeight() - (40 + toolBarHeight + menuBarHeight));
+ projectExpl.getChildren().addAll(newTest, projectExplorerTreeView);
+ projectExplorer = new TitledPane("Project Explorer", projectExpl);
+ projectExplorer.setContent(projectExpl);
+
+ newTest.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ wizard = new OFAWizard(projectExplorerTree, 1, projectExplorerTree.getChildren(), projectExplorerTreeView);
+ wizard.setOFA(OFAReference);
+ try {
+ wizard.start(new Stage());
+ } catch (Exception ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ projectExplorerTreeView.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent arg0) {
+
+ if (arg0.getButton() == MouseButton.SECONDARY) {
+ contextMenu();
+ contextMenu.show(projectExplorerTreeView, arg0.getScreenX(), arg0.getScreenY());
+
+ } else if (arg0.getClickCount() == 2) {
+ String path = "";
+ TreeItem<String> selectedTreeItem = projectExplorerTreeView.getSelectionModel().getSelectedItem();
+ try {
+
+ path = label.hierarchyTestON + "/tests/" + selectedTreeItem.getParent().getValue().toString() + "/" + selectedTreeItem.getValue();
+ if (selectedTreeItem.isLeaf()) {
+ if (selectedTreeItem.getGraphic().getId().equals(".params")) {
+ path = path + ".params";
+ } else if (selectedTreeItem.getGraphic().getId().equals(".topo")) {
+ path = path + ".topo";
+ } else if (selectedTreeItem.getGraphic().getId().equals(".py")) {
+ path = path + ".py";
+ } else if (selectedTreeItem.getGraphic().getId().equals(".ospk")) {
+ path = path + ".ospk";
+ }
+ String fileContent = fileOperation.getContents(new File(path));
+ editorFlag = true;
+ checkEditor();
+ OFATabEditor(new CodeEditor(fileContent), new CodeEditorParams(fileContent), new File(path).getAbsolutePath(), "");
+ } else if (!selectedTreeItem.isLeaf()) {
+ }
+
+
+
+ } catch (Exception e) {
+ }
+ }
+ }
+ });
+
+ projectExplorerTreeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue observable, Object oldValus, Object newValue) {
+ ObservableList<TreeItem<String>> tata = projectExplorerTreeView.getSelectionModel().getSelectedItems();
+
+ TreeItem treeItem = (TreeItem) newValue;
+ }
+ });
+
+
+ explorerTab.setOnClosed(new EventHandler<Event>() {
+ @Override
+ public void handle(Event closeEvent) {
+ explorerTabPane.setVisible(false);
+ projectExplorerFlag = false;
+ checkEditor();
+
+ }
+ });
+
+
+ }
+
+ public void loadLogExlporer() {
+ String projectWorkSpacePaths = label.hierarchyTestON + "/logs/";
+ File[] file = File.listRoots();
+ Path name = new File(projectWorkSpacePaths).toPath();
+ OFALoadTree treeNode = new OFALoadTree(name);
+ treeNode.setExpanded(true);
+ logExplorerTreeView = new TreeView<String>(treeNode);
+ }
+
+ public void getLogExplorer() {
+
+ loadLogExlporer();
+ VBox logExpl = new VBox();
+ logExplorerTreeView.setMinHeight(scene.getHeight() - (toolBarHeight + menuBarHeight + 20));
+ logExpl.getChildren().addAll(logExplorerTreeView);
+ logExlorer = new TitledPane("Log Explorer", logExpl);
+
+ VBox logExplore = new VBox();
+ Button refresh = new Button("refresh");
+ logExplorerTreeView.setMinHeight(scene.getHeight() - (40 + toolBarHeight + menuBarHeight));
+ logExplore.getChildren().addAll(refresh, logExplorerTreeView);
+ logExlorer.setContent(logExplore);
+
+ refresh.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ String projectWorkSpacePaths = label.hierarchyTestON + "/logs/";
+ File[] file = File.listRoots();
+ Path name = new File(projectWorkSpacePaths).toPath();
+ OFALoadTree treeNode = new OFALoadTree(name);
+ treeNode.setExpanded(true);
+
+ logExplorerTreeView.setRoot(treeNode);
+ }
+ });
+
+
+ logExplorerTreeView.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent click) {
+ if (click.getClickCount() == 2 && click.getButton() == MouseButton.PRIMARY) {
+ TreeItem<String> selectedItem = logExplorerTreeView.getSelectionModel().getSelectedItem();
+ String fileExtentsion = selectedItem.getGraphic().getId();
+ String selectedFilePath = label.hierarchyTestON + "/logs/" + selectedItem.getParent().getValue() + "/" + selectedItem.getValue() + fileExtentsion;
+ String fileContent = fileOperation.getContents(new File(selectedFilePath));
+ editorFlag = true;
+
+ checkEditor();
+ OFATabEditor(new CodeEditor(fileContent), new CodeEditorParams(""), new File(selectedFilePath).getAbsolutePath(), "");
+ }
+ }
+ });
+ }
+
+ public void getDriverExplorer() {
+
+ projectWorkSpacePath = label.hierarchyTestON + "/drivers/common";
+
+ final Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("/images/project.jpeg"), 16, 16, true, true));
+ driverExplorerTree = new TreeItem<String>("Drivers");
+ File[] file = File.listRoots();
+
+ Path name = new File(projectWorkSpacePath).toPath();
+ OFALoadTree treeNode = new OFALoadTree(name);
+
+ driverExplorerTree.setExpanded(true);
+ //create the tree view
+ driverExplorerTreeView = new TreeView<String>(treeNode);
+ driverExplorer = new TitledPane("Driver Explorer", driverExplorerTreeView);
+
+ driverExplorer.prefHeight(scene.heightProperty().get());
+
+ VBox driverExpl = new VBox();
+ driverExpl.getChildren().addAll(new Button("New Driver"), driverExplorerTreeView);
+ driverExplorerTreeView.setShowRoot(false);
+ driverExplorerTreeView.setMinHeight(scene.getHeight() - (toolBarHeight + menuBarHeight + 50));
+
+ driverExplorer.setContent(driverExpl);
+ driverExplorer.prefHeight(scene.heightProperty().get());
+
+
+ ObservableList<TreeItem<String>> children = driverExplorerTree.getChildren();
+ Iterator<TreeItem<String>> tree = children.iterator();
+ while (tree.hasNext()) {
+ TreeItem<String> value = tree.next();
+ if (value.getValue().equals("common")) {
+ driverExplorerTreeView.setShowRoot(false);
+ }
+ }
+
+ driverExplorerTreeView.setOnMouseClicked(new EventHandler<MouseEvent>() {
+ @Override
+ public void handle(MouseEvent event) {
+
+ if (event.getClickCount() == 1 && event.getButton() == MouseButton.PRIMARY) {
+ //final Node rootIcon = new ImageView(new Image(getClass().getResourceAsStream("/images/project.jpeg")));
+ TreeItem<String> driverSelectedItem = driverExplorerTreeView.getSelectionModel().getSelectedItem();
+
+ try {
+ String[] splitSelectedDriver = driverSelectedItem.getValue().split("\\.");
+
+ String path = null;
+ TreeItem selectedTreeItem = driverSelectedItem.getParent();
+ TreeItem selectedParentItem = selectedTreeItem.getParent();
+
+ path = projectWorkSpacePath + "/" + driverSelectedItem.getParent().getParent().getValue() + "/" + driverSelectedItem.getParent().getValue()
+ + "/" + driverSelectedItem.getValue() + ".py";
+
+ if (driverSelectedItem.getParent().getValue().equals("emulator")) {
+ path = projectWorkSpacePath + "/" + driverSelectedItem.getParent().getParent().getValue() + "/" + driverSelectedItem.getParent().getValue()
+ + "/" + driverSelectedItem.getValue() + ".py";
+ } else if (driverSelectedItem.getParent().getValue().equals("api")) {
+ path = projectWorkSpacePath + "/" + driverSelectedItem.getParent().getValue() + "/" + driverSelectedItem.getValue() + ".py";
+ } else if (driverSelectedItem.getParent().getValue().equals("tool")) {
+ path = projectWorkSpacePath + "/" + driverSelectedItem.getParent().getParent().getValue() + "/" + driverSelectedItem.getParent().getValue()
+ + "/" + driverSelectedItem.getValue() + ".py";
+ } else if (driverSelectedItem.getParent().getValue().equals("cli")) {
+ path = projectWorkSpacePath + "/" + driverSelectedItem.getParent().getValue() + "/" + driverSelectedItem.getValue() + ".py";
+ }
+ String fileContent = fileOperation.getContents(new File(path));
+ projectExplorerFlag = true;
+ checkEditor();
+ OFATabEditor(new CodeEditor(fileContent), new CodeEditorParams(""), path, driverSelectedItem.getValue());
+
+
+ } catch (Exception e) {
+ }
+
+ }
+ }
+ });
+
+
+
+ driverExplorerTreeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
+ @Override
+ public void changed(ObservableValue observable, Object oldValus, Object newValue) {
+ ObservableList<TreeItem<String>> tata = projectExplorerTreeView.getSelectionModel().getSelectedItems();
+
+ TreeItem treeItem = (TreeItem) newValue;
+ }
+ });
+
+ driverExplorerTree.setExpanded(true);
+
+ }
+
+ public void contextMenu() {
+ contextMenu = new ContextMenu();
+ Image copyImage = new Image("images/Copy.png", 20.0, 20.0, true, true);
+ Image cutImage = new Image("images/Cut.png", 20.0, 20.0, true, true);
+ Image pasteImage = new Image("images/Paste.jpg", 20.0, 20.0, true, true);
+ Image deleteImage = new Image("images/delete.png", 20.0, 20.0, true, true);
+
+ Menu newContextMenu = new Menu(label.contextNew);
+ MenuItem scriptContextMenu = new MenuItem(label.contextTest);
+ newContextMenu.getItems().add(scriptContextMenu);
+ MenuItem openContextMenu = new MenuItem(label.contextOpen);
+ MenuItem cutContextMenu = new MenuItem(label.contextCut, new ImageView(cutImage));
+ MenuItem copyContextMenu = new MenuItem(label.contextCopy, new ImageView(copyImage));
+ MenuItem pasteContextMenu = new MenuItem(label.contextPaste, new ImageView(pasteImage));
+ MenuItem refreshContextMenu = new MenuItem(label.contextRefresh);
+ MenuItem deleteContextMenu = new MenuItem(label.contextDelete, new ImageView(deleteImage));
+
+ refreshContextMenu.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ refreshLogExplorer();
+ }
+ });
+
+ openContextMenu.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent args0) {
+ TreeItem<String> selectedTreeItem = projectExplorerTreeView.getSelectionModel().getSelectedItem();
+
+ }
+ });
+
+ contextMenu.getItems().addAll(newContextMenu, openContextMenu, cutContextMenu, copyContextMenu, pasteContextMenu, refreshContextMenu, deleteContextMenu);
+ projectExplorerTreeView.contextMenuProperty().setValue(contextMenu);
+ scriptContextMenu.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ }
+ });
+ }
+
+ public void getEditMenu() {
+ //adding Edit Menu
+ Image copyImage = new Image("images/Copy.png", 20.0, 20.0, true, true);
+ Image cutImage = new Image("images/Cut.png", 20.0, 20.0, true, true);
+ Image pasteImage = new Image("images/Paste.jpg", 20.0, 20.0, true, true);
+
+
+ Menu editMenu = new Menu(label.editMenu);
+ MenuItem cut = new MenuItem(label.cut, new ImageView(cutImage));
+ MenuItem copy = new MenuItem(label.copy, new ImageView(copyImage));
+ MenuItem paste = new MenuItem(label.paste, new ImageView(pasteImage));
+ MenuItem select = new MenuItem(label.select);
+ MenuItem selectAll = new MenuItem(label.selectAll);
+
+ editMenu.getItems().addAll(cut, copy, paste, select, selectAll);
+ OFA_MenuBar.getMenus().addAll(editMenu);
+
+
+ }
+
+ public void getViewMenu() {
+ //add View Menu
+ Menu viewMenu = new Menu(label.viewMenu);
+ MenuItem Explorer = new MenuItem("Explorer");
+ MenuItem commandOptions = new MenuItem("CommandLine Explorer");
+
+
+ viewMenu.getItems().addAll(Explorer, commandOptions);
+ OFA_MenuBar.getMenus().addAll(viewMenu);
+
+ Explorer.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+
+ explorerTab = new Tab("Explorer");
+ explorerTabPane.setLayoutX(0);
+ projectExplorerFlag = true;
+
+ explorerTab.setContent(explorer);
+
+ explorerTabPane.getTabs().addAll(explorerTab);
+ editorTabPane.setLayoutX(270);
+ explorerTabPane.setVisible(true);
+ projectExplorerFlag = true;
+
+
+ checkEditor();
+
+
+ }
+ });
+
+
+ }
+
+ public void getToolBar() {
+ Image newImage = new Image("images/newIcon.jpg", 20.0, 20.0, true, true);
+ MenuButton New = new MenuButton("", new ImageView(newImage));
+ New.setTooltip(new Tooltip("New"));
+ MenuItem newTest = new MenuItem("New Test");
+ MenuItem componentDriver = new MenuItem(label.newDriver);
+ MenuItem newParams = new MenuItem(label.newParams);
+ MenuItem newTopology = new MenuItem(label.newTopology);
+ MenuItem testScript = new MenuItem(label.newTestScript);
+
+ New.getItems().addAll(newTest, componentDriver, newParams, newTopology, testScript);
+ New.setMinWidth(2);
+
+ newTest.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ wizard = new OFAWizard(projectExplorerTree, 1, projectExplorerTree.getChildren(), projectExplorerTreeView);
+ wizard.setOFA(OFAReference);
+ try {
+ wizard.start(new Stage());
+ } catch (Exception ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+
+ newParams.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ try {
+ wizard = new OFAWizard(projectExplorerTree, 2, projectExplorerTree.getChildren(), projectExplorerTreeView);
+ wizard.setOFA(OFAReference);
+ wizard.start(new Stage());
+
+ } catch (Exception ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ });
+
+ //Open Icon on Tool Bar
+ Image openImage = new Image("images/open.png", 20.0, 20.0, true, true);
+ MenuButton Open = new MenuButton("", new ImageView(openImage));
+ Open.setTooltip(new Tooltip("Open"));
+ MenuItem openComponentDriver = new MenuItem(label.newDriver);
+ MenuItem openParams = new MenuItem(label.newParams);
+ MenuItem openTopology = new MenuItem(label.newTopology);
+ MenuItem openTestScript = new MenuItem(label.newTestScript);
+
+ Open.getItems().addAll(openComponentDriver, openParams, openTopology, openTestScript);
+ Image saveImage = new Image("images/Save_24x24.png", 20.0, 20.0, true, true);
+ Save = new Button("", new ImageView(saveImage));
+ Save.setTooltip(new Tooltip("Save"));
+
+ Image configImage = new Image("images/project_1.jpeg", 20.0, 20.0, true, true);
+ Button configuration = new Button("", new ImageView(configImage));
+ configuration.setTooltip(new Tooltip("Run With ..."));
+
+ Image playImage = new Image("images/Play.png", 20.0, 20.0, true, true);
+ MenuButton play = new MenuButton("", new ImageView(playImage));
+ play.setTooltip(new Tooltip("Run"));
+
+ MenuItem run = new MenuItem("Run");
+ MenuItem runWithOptionButton = new MenuItem("Run With ...");
+
+ play.getItems().addAll(run, runWithOptionButton);
+ Image pauseImage = new Image("images/Pause.png", 20.0, 20.0, true, true);
+ Button pause = new Button("", new ImageView(pauseImage));
+ pause.setTooltip(new Tooltip("Pause"));
+
+ run.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ testSummaryPop = new OFATestSummary(OFAReference, copyStage);
+ testSummaryPop.start(new Stage());
+ Runnable firstRunnable = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+ Runnable secondRunnable = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ ExecuteTest testExecute = new ExecuteTest(testSummaryPop.getTable(), testSummaryPop.getData(), testSummaryPop.getChart(),
+ testSummaryPop.getFinalSummaryTable(), testSummaryPop.getFinalSummaryData(),
+ testSummaryPop.getVieLogsButton(), testSummaryPop.getpieChartData(),
+ testSummaryPop.getPassData(), testSummaryPop.getFailData(), testSummaryPop.getAbortData(),
+ testSummaryPop.getNoResultData(), editorTabPane.getSelectionModel().getSelectedItem().getText().substring(0, editorTabPane.getSelectionModel().getSelectedItem().getText().lastIndexOf('.')), testSummaryPop.getTextArea("log"), testSummaryPop.getStepTable(), testSummaryPop.getStepData(), testSummaryPop.getTextArea("pox"), testSummaryPop.getTextArea("mininet"), testSummaryPop.getTextArea("flowvisor"));
+
+ testExecute.runTest();
+ } catch (Exception iex) {
+ }
+ }
+ };
+
+ Platform.runLater(firstRunnable);
+ Platform.runLater(secondRunnable);
+ }
+ });
+
+
+ runWithOptionButton.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent t) {
+ OFATestParameters testParameter = new OFATestParameters(OFAReference);
+ testParameter.setProjectView(projectExplorerTreeView);
+ testParameter.setProjectList(projectExplorerTree.getChildren());
+ testParameter.start(new Stage());
+ }
+ });
+
+ Image stopImage = new Image("images/Stop.png", 20.0, 20.0, true, true);
+ Button stop = new Button("", new ImageView(stopImage));
+ stop.setTooltip(new Tooltip("Stop"));
+
+ Image resumeImage = new Image("images/Resume_1.png", 20.0, 20.0, true, true);
+ Button resume = new Button("", new ImageView(resumeImage));
+ resume.setTooltip(new Tooltip("Resume"));
+
+ Image copyImage = new Image("images/Copy.png", 20.0, 20.0, true, true);
+ Button copy = new Button("", new ImageView(copyImage));
+ copy.setTooltip(new Tooltip("Copy"));
+
+ Image cutImage = new Image("images/Cut.png", 20.0, 20.0, true, true);
+ Button cut = new Button("", new ImageView(cutImage));
+ cut.setTooltip(new Tooltip("Cut"));
+
+ Image pasteImage = new Image("images/Paste.jpg", 20.0, 20.0, true, true);
+ Button paste = new Button("", new ImageView(pasteImage));
+ paste.setTooltip(new Tooltip("Paste"));
+
+ Image exitImage = new Image("images/exit.gif", 20.0, 20.0, true, true);
+ Button exit = new Button("", new ImageView(exitImage));
+ exit.setTooltip(new Tooltip("Exit"));
+
+
+
+
+ toolbar.getItems().addAll(New, Open, Save, new Separator(Orientation.VERTICAL), cut, copy, paste, new Separator(Orientation.VERTICAL), configuration, play, pause, stop, resume, new Separator(Orientation.VERTICAL), exit);
+
+ }
+
+ public void getRunMenu() {
+ //adding Run Menu
+ Menu runMenu = new Menu(label.runMenu);
+ Image pauseImage = new Image("images/Pause.png", 20.0, 20.0, true, true);
+ Image playImage = new Image("images/Play.png", 20.0, 20.0, true, true);
+ Image stopImage = new Image("images/Stop.png", 20.0, 20.0, true, true);
+ Image configImage = new Image("images/Settings.jpg", 20.0, 20.0, true, true);
+ Image resumeImage = new Image("images/Resume_1.png", 20.0, 20.0, true, true);
+
+
+ MenuItem run = new MenuItem(label.runMenu, new ImageView(playImage));
+ MenuItem pause = new MenuItem(label.pauseTest, new ImageView(pauseImage));
+ MenuItem resume = new MenuItem(label.resumeTest, new ImageView(resumeImage));
+ MenuItem stop = new MenuItem(label.stopTest, new ImageView(stopImage));
+ MenuItem config = new MenuItem("Settings", new ImageView(configImage));
+
+ runMenu.getItems().addAll(run, pause, resume, stop, new SeparatorMenuItem(), config);
+ OFA_MenuBar.getMenus().addAll(runMenu);
+ }
+
+ public void getHelpMenu() {
+ //adding Help Menu
+ Menu helpMenu = new Menu(label.helpMenu);
+ MenuItem about = new MenuItem(label.aboutHelp);
+ MenuItem help = new MenuItem(label.helpMenu);
+
+ helpMenu.getItems().addAll(about, help);
+ OFA_MenuBar.getMenus().addAll(helpMenu);
+ }
+
+ public void OFATabEditor(final CodeEditor Content, final CodeEditorParams ContentParams, final String title, String str) {
+ //saveFileItem.setDisable(false);
+ ContentParams.setOFA(OFAReference);
+
+ final Tab editorTab = new Tab();
+ final File fileName;
+ ObservableList<Tab> allTab = editorTabPane.getTabs();
+ if (allTab.isEmpty()) {
+ String fname = "";
+ String ext = "";
+ int mid = title.lastIndexOf(".");
+ fname = title.substring(0, mid);
+ ext = title.substring(mid + 1, title.length());
+
+ if ("params".equals(ext) || "topo".equals(ext)) {
+
+ ContentParams.prefWidthProperty().bind(scene.widthProperty().subtract(270));
+
+ fileName = new File(title);
+ editorTab.setText(fileName.getName());
+ editorTab.setContent(ContentParams);
+ editorTab.setId(title);
+ String currentTab1 = editorTab.getId();
+
+ editorTabPane.getTabs().add(editorTab);
+
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ selectionModel.select(editorTab);
+ ContentParams.setOnKeyReleased(new EventHandler<InputEvent>() {
+ @Override
+ public void handle(InputEvent arg0) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab1 = selectionModel.getSelectedItem().getId();
+ String currentTabTitle = selectionModel.getSelectedItem().getText();
+ if (fileName.getName().equals(currentTabTitle)) {
+ selectionModel.getSelectedItem().setText("* " + currentTabTitle);
+ Save.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab1 = selectionModel.getSelectedItem().getId();
+ selectionModel.getSelectedItem().setText(fileName.getName());
+ String currentFileContent = ContentParams.getCodeAndSnapshot();
+
+ try {
+
+ ArrayList<String> textContent = new ArrayList<String>();
+ String textAreaCon = ContentParams.getCodeAndSnapshot();
+
+ String[] textAreaContent = textAreaCon.split("\n");
+
+ for (String string : textAreaContent) {
+ textContent.add(string);
+ }
+
+ HashMap errorHash = new HashMap();
+ fileOperation.saveFile(fileName, currentFileContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+ });
+ } else {
+ }
+ }
+ });
+
+ } else {
+ fileName = new File(title);
+
+ editorTab.setText(fileName.getName());
+ editorTab.setId(title);
+ Content.prefWidthProperty().bind(scene.widthProperty());
+ editorTab.setContent(Content);
+ String currentTab = editorTab.getId();
+
+ editorTabPane.getTabs().addAll(editorTab);
+
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ selectionModel.select(editorTab);
+ Content.setOnKeyReleased(new EventHandler<InputEvent>() {
+ @Override
+ public void handle(InputEvent arg0) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab = selectionModel.getSelectedItem().getId();
+ File file = new File(currentTab);
+
+ String currentTabTitle = selectionModel.getSelectedItem().getText();
+
+
+ if (file.getName().equals(currentTabTitle)) {
+ selectionModel.getSelectedItem().setText("* " + currentTabTitle);
+ Save.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab = selectionModel.getSelectedItem().getId();
+ File file = new File(currentTab);
+ selectionModel.getSelectedItem().setText(file.getName());
+ File fileName = new File(currentTab);
+ String currentFileContent = Content.getCodeAndSnapshot();
+ try {
+ fileOperation.saveFile(fileName, currentFileContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+ });
+ } else {
+ }
+
+ }
+ });
+
+ File path = new File(OFAReference.editorTabPane.getSelectionModel().getSelectedItem().getId());
+ String[] currentFileExtintion = path.getName().split("\\.");
+ if (currentFileExtintion[1].equals("ospk")) {
+ OFAContentHelp contentHelp = new OFAContentHelp(Content, OFAReference);
+ contentHelp.ospkHelp();
+ }
+ }
+ } else {
+ boolean tabexistsFlag = false;
+ for (Tab tab : allTab) {
+ if (tab.getId().equals(title)) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ selectionModel.select(tab);
+ tabexistsFlag = true;
+ break;
+ } else {
+ }
+ }
+ if (tabexistsFlag == false) {
+
+ String fname = "";
+ String ext = "";
+ int mid = title.lastIndexOf(".");
+ fname = title.substring(0, mid);
+ ext = title.substring(mid + 1, title.length());
+
+ if ("params".equals(ext) || "topo".equals(ext)) {
+
+ ContentParams.prefWidthProperty().bind(scene.widthProperty().subtract(500));
+
+ fileName = new File(title);
+ editorTab.setText(fileName.getName());
+ editorTab.setContent(ContentParams);
+ editorTab.setId(title);
+ String currentTab1 = editorTab.getId();
+ editorTabPane.getTabs().add(editorTab);
+
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ selectionModel.select(editorTab);
+
+ ContentParams.setOnKeyReleased(new EventHandler<InputEvent>() {
+ @Override
+ public void handle(InputEvent arg0) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab1 = selectionModel.getSelectedItem().getId();
+
+ String currentTabTitle = selectionModel.getSelectedItem().getText();
+
+ if (fileName.getName().equals(currentTabTitle)) {
+ selectionModel.getSelectedItem().setText("* " + currentTabTitle);
+ Save.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab1 = selectionModel.getSelectedItem().getId();
+
+ selectionModel.getSelectedItem().setText(fileName.getName());
+ String currentFileContent = ContentParams.getCodeAndSnapshot();
+ try {
+ fileOperation.saveFile(fileName, currentFileContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+ });
+ } else {
+ }
+ }
+ });
+ } else {
+ fileName = new File(title);
+
+ editorTab.setText(fileName.getName());
+ editorTab.setId(title);
+ Content.prefWidthProperty().bind(scene.widthProperty());
+ editorTab.setContent(Content);
+ String currentTab = editorTab.getId();
+
+ editorTabPane.getTabs().addAll(editorTab);
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ selectionModel.select(editorTab);
+
+ Content.setOnKeyReleased(new EventHandler<InputEvent>() {
+ @Override
+ public void handle(InputEvent arg0) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab = selectionModel.getSelectedItem().getId();
+ File file = new File(currentTab);
+
+ String currentTabTitle = selectionModel.getSelectedItem().getText();
+
+
+ if (file.getName().equals(currentTabTitle)) {
+ selectionModel.getSelectedItem().setText("* " + currentTabTitle);
+ Save.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab = selectionModel.getSelectedItem().getId();
+ File file = new File(currentTab);
+ selectionModel.getSelectedItem().setText(file.getName());
+ File fileName = new File(currentTab);
+ String currentFileContent = Content.getCodeAndSnapshot();
+ try {
+ fileOperation.saveFile(fileName, currentFileContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+ });
+ } else {
+ }
+
+ }
+ });
+
+ File path = new File(OFAReference.editorTabPane.getSelectionModel().getSelectedItem().getId());
+ String[] currentFileExtintion = path.getName().split("\\.");
+ if (currentFileExtintion[1].equals("ospk")) {
+ OFAContentHelp contentHelp = new OFAContentHelp(Content, OFAReference);
+ contentHelp.ospkHelp();
+ }
+ }
+ }
+ }
+
+ editorTab.setOnSelectionChanged(new EventHandler<Event>() {
+ @Override
+ public void handle(Event arg0) {
+
+ String currentTab = editorTab.getId();
+ String fname = "";
+ String ext = "";
+ int mid = currentTab.lastIndexOf(".");
+ fname = currentTab.substring(0, mid);
+ try {
+ } catch (ArrayIndexOutOfBoundsException e) {
+ }
+
+
+
+ final File fileName;
+ if ("params".equals(ext) || "topo".equals(ext)) {
+
+
+ Save.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab = selectionModel.getSelectedItem().getId();
+ File file = new File(currentTab);
+ selectionModel.getSelectedItem().setText(file.getName());
+ File fileName = new File(currentTab);
+ String currentFileContent = ContentParams.getCodeAndSnapshot();
+ try {
+ fileOperation.saveFile(fileName, currentFileContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+ });
+
+ } else {
+
+ Save.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+
+ javafx.scene.control.SingleSelectionModel<Tab> selectionModel = editorTabPane.getSelectionModel();
+ String currentTab = selectionModel.getSelectedItem().getId();
+ File file = new File(currentTab);
+ selectionModel.getSelectedItem().setText(file.getName());
+ File fileName = new File(currentTab);
+ String currentFileContent = Content.getCodeAndSnapshot();
+ try {
+ fileOperation.saveFile(fileName, currentFileContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+ });
+ }
+ }
+ });
+
+ //SaveAll Option in file menu click event
+
+ saveAll.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+
+ ObservableList<Tab> allTab = editorTabPane.getTabs();
+ javafx.scene.control.SingleSelectionModel<Tab> selectedItemToGetBack = editorTabPane.getSelectionModel();
+ Tab selectedTabBeforeSaveAll = selectedItemToGetBack.getSelectedItem();
+ for (Tab tab : allTab) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectedItem = editorTabPane.getSelectionModel();
+
+ selectedItem.select(tab);
+ String currentTab = tab.getId();
+ String fname = "";
+ String ext = "";
+ int mid = currentTab.lastIndexOf(".");
+ fname = currentTab.substring(0, mid);
+ ext = currentTab.substring(mid + 1, currentTab.length());
+ final File fileName;
+ String checkModifier = selectedItem.getSelectedItem().getText();
+ File exactPath = new File(currentTab);
+ String properName = exactPath.getName();
+ if (!checkModifier.equals(properName)) {
+
+ if ("params".equals(ext) || "topo".equals(ext)) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectedItem1 = editorTabPane.getSelectionModel();
+ String currentTab1 = tab.getId();
+ File file = new File(currentTab1);
+
+ File fileName1 = new File(currentTab1);
+ selectedItem1.getSelectedItem().setText(fileName1.getName());
+ String currentFileContent = ((CodeEditorParams) tab.getContent()).getCodeAndSnapshot();
+ try {
+ fileOperation.saveFile(fileName1, currentFileContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+
+ } else {
+ javafx.scene.control.SingleSelectionModel<Tab> selectedItem1 = editorTabPane.getSelectionModel();
+ String currentTab2 = tab.getId();
+
+ File fileName2 = new File(currentTab2);
+ selectedItem1.getSelectedItem().setText(fileName2.getName());
+ String currentFileContent = ((CodeEditor) tab.getContent()).getCodeAndSnapshot();
+ try {
+ fileOperation.saveFile(fileName2, currentFileContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ }
+
+ }
+ }
+ selectedItemToGetBack.select(selectedTabBeforeSaveAll);
+ }
+ });
+
+ editorTab.setOnClosed(new EventHandler<Event>() {
+ @Override
+ public void handle(Event arg0) {
+ javafx.scene.control.SingleSelectionModel<Tab> selectedItem1 = editorTabPane.getSelectionModel();
+ String fileName = editorTab.getId();
+ String tabName = editorTab.getText();
+ File tabIdentity = new File(fileName);
+ String properName = tabIdentity.getName();
+ if (!properName.equals(tabName)) {
+ int optionPressed = JOptionPane.showConfirmDialog(null, "Would you like to save the content of this tab\n");
+ if (optionPressed == 0) {
+ String extension = fileOperation.getExtension(editorTab.getText());
+ if ("params".equals(extension) || "topo".equals(extension)) {
+ try {
+ String tabContent = ((CodeEditorParams) editorTab.getContent()).getCodeAndSnapshot();
+ fileOperation.saveFile(tabIdentity, tabContent);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ } else {
+ try {
+ String tabContent1 = ((CodeEditor) editorTab.getContent()).getCodeAndSnapshot();
+ fileOperation.saveFile(tabIdentity, tabContent1);
+ } catch (FileNotFoundException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ } catch (IOException ex) {
+ Logger.getLogger(TAI_OFA.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+ }
+
+ }
+ });
+
+ closeAll.setOnAction(new EventHandler<ActionEvent>() {
+ @Override
+ public void handle(ActionEvent arg0) {
+ Stage dialogStage = new Stage();
+ dialogStage.initModality(Modality.NONE);
+ dialogStage.setScene(new Scene(VBoxBuilder.create().
+ children(new Text("Yes"), new Button("No")).
+ alignment(Pos.CENTER).padding(new Insets(5)).build()));
+ dialogStage.show();
+
+
+ }
+ });
+
+ }
+
+ public void openFile(String extension, String extension2) {
+ File selected;
+ String fileContent = "";
+ openParams = new FileChooser();
+ if ("".equals(extension2)) {
+ openParams.getExtensionFilters().add(new ExtensionFilter("Display only (*." + extension + ") files", "*." + extension));
+ } else {
+ openParams.getExtensionFilters().add(new ExtensionFilter("Display only (*." + extension + ")" + "files", "*." + extension));
+ openParams.getExtensionFilters().add(new ExtensionFilter("Display only (*." + extension2 + ") files", "*." + extension2));
+ }
+ selected = openParams.showOpenDialog(contextMenu);
+ try {
+ fileContent = fileOperation.getContents(selected);
+ checkEditor();
+ String filename = selected.getName();
+ checkEditor();
+ OFATabEditor(new CodeEditor(fileContent), new CodeEditorParams(fileContent), selected.getAbsolutePath(), "");
+ } catch (Exception e) {
+ }
+
+ editorTabPane.prefWidthProperty().bind(scene.widthProperty().subtract(200));
+ }
+
+ public void checkEditor() {
+ if (projectExplorerFlag == false && editorFlag == false) {
+ editorFlag = true;
+ editorTabPane.prefHeightProperty().bind(scene.heightProperty().subtract(40));
+ editorTabPane.setLayoutX(explorerTabPane.getLayoutX());
+ editorTabPane.setMaxWidth(OFAContainerWidth);
+ } else if (projectExplorerFlag == true && editorFlag == false) {
+ editorFlag = true;
+ editorTabPane.setLayoutX(explorerTabPane.getLayoutX() + explorerTabPane.getWidth());
+ editorTabPane.prefHeightProperty().bind(scene.heightProperty().subtract(65));
+ editorTabPane.prefWidthProperty().bind(scene.widthProperty().subtract(250));
+
+ } else if (editorFlag == true && projectExplorerFlag == false) {
+ editorTabPane.setLayoutX(explorerTabPane.getLayoutX());
+ editorTabPane.prefHeightProperty().bind(scene.heightProperty().subtract(65));
+ editorTabPane.prefWidthProperty().bind(scene.widthProperty());
+ } else if (editorFlag == true && projectExplorerFlag == true) {
+ editorTabPane.prefHeightProperty().bind(scene.heightProperty().subtract(65));
+ editorTabPane.prefWidthProperty().bind(scene.widthProperty().subtract(explorerTabPane.getWidth()));
+ editorTabPane.setLayoutX(explorerTabPane.getLayoutX() + explorerTabPane.getWidth());
+ }
+
+ }
+
+ public void refreshLogExplorer() {
+
+
+ String projectWorkSpacePaths = label.hierarchyTestON + "/logs/";
+ File[] file = File.listRoots();
+ Path name = new File(projectWorkSpacePaths).toPath();
+ OFALoadTree treeNode = new OFALoadTree(name);
+ treeNode.setExpanded(true);
+
+
+ }
+
+ /**
+ *
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ launch(args);
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/TestCaseSelectionTable.java b/TestON/TAI/src/tai_ofa/TestCaseSelectionTable.java
new file mode 100644
index 0000000..11a6f49
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/TestCaseSelectionTable.java
@@ -0,0 +1,61 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import javafx.scene.control.CheckBox;
+import javafx.scene.control.Label;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+ */
+public class TestCaseSelectionTable {
+
+ public CheckBox testCaseIdCheck;
+ public Label testCaseId;
+ public Label testCaseName;
+ public TestCaseSelectionTable() {
+
+ }
+ public TestCaseSelectionTable(CheckBox idCheck, Label caseId, Label caseName) {
+ this.testCaseIdCheck = idCheck;
+ this.testCaseId = caseId;
+ this.testCaseName = caseName;
+ }
+
+ public CheckBox getTestCaseCheckBox() {
+ return testCaseIdCheck;
+ }
+ public void setTestCaseCheckBox(CheckBox newCheck) {
+ testCaseIdCheck = newCheck;
+ }
+
+ public Label getTestCaseId() {
+ return testCaseId;
+ }
+ public void setTestCaseId(Label newCaseId) {
+ testCaseId = newCaseId;
+ }
+ public Label getTestCaseName() {
+ return testCaseName;
+ }
+ public void setTestCaseName(Label newCaseName) {
+ testCaseName = newCaseName;
+ }
+}
diff --git a/TestON/TAI/src/tai_ofa/TestSelectStepTable.java b/TestON/TAI/src/tai_ofa/TestSelectStepTable.java
new file mode 100644
index 0000000..420dc76
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/TestSelectStepTable.java
@@ -0,0 +1,58 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package tai_ofa;
+
+import javafx.scene.control.Label;
+
+/**
+ *
+ * @author Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+
+ */
+public class TestSelectStepTable {
+ public Label testStepId;
+ public Label testStepName;
+ public Label testStepStatus;
+
+ public TestSelectStepTable() {
+
+ }
+ public TestSelectStepTable(Label stepId, Label stepName) {
+
+ this.testStepId = stepId;
+ this.testStepName = stepName;
+
+
+ }
+
+
+ public Label getTestStepId() {
+ return testStepId;
+ }
+ public void setTestStepId(Label newStepId) {
+ testStepId = newStepId;
+ }
+ public Label getTestStepName() {
+ return testStepName;
+ }
+ public void setTestStepName(Label newStepName) {
+ testStepName = newStepName;
+ }
+
+}
diff --git a/TestON/TAI/src/tai_ofa/gui.css b/TestON/TAI/src/tai_ofa/gui.css
new file mode 100644
index 0000000..55cebba
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/gui.css
@@ -0,0 +1,26 @@
+/*
+
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+
+ Document : gui
+ Created on : 02 Feb, 2013, 6:30:28 PM
+ Author : Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+ Description:
+ Purpose of the stylesheet follows.
+*/
+.error{
+ -fx-background-color: red,linear-gradient(to bottom, derive(red,60%) 5%,derive(red,90%) 40%);
+}
diff --git a/TestON/TAI/src/tai_ofa/test.css b/TestON/TAI/src/tai_ofa/test.css
new file mode 100644
index 0000000..69d1a31
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/test.css
@@ -0,0 +1,19 @@
+.default-color0.chart-pie { -fx-pie-color: blue; }
+.default-color1.chart-pie { -fx-pie-color: yellow; }
+.default-color2.chart-pie { -fx-pie-color: pink; }
+.default-color3.chart-pie { -fx-pie-color: blue; }
+.default-color4.chart-pie { -fx-pie-color: green; }
+.default-color5.chart-pie { -fx-pie-color: red; }
+.chart-pie-label-line {
+ -fx-stroke: #8b4513;
+ -fx-fill: #8b4513;
+}
+
+.chart-pie-label {
+ -fx-fill: #8b4513;
+ -fx-font-size: 1em;
+}
+.chart-legend {
+ -fx-background-color: sienna;
+ -fx-stroke: #daa520;
+}
diff --git a/TestON/TAI/src/tai_ofa/wizard.css b/TestON/TAI/src/tai_ofa/wizard.css
new file mode 100644
index 0000000..5c2dbfb
--- /dev/null
+++ b/TestON/TAI/src/tai_ofa/wizard.css
@@ -0,0 +1,51 @@
+/*
+
+ * TestON is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+
+ * TestON is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with TestON. If not, see <http://www.gnu.org/licenses/>.
+
+
+ Document : wizard
+ Created on : 22 Mar, 2013, 11:32:44 AM
+ Author : Raghav Kashyap (raghavkashyap@paxterrasolutions.com)
+ Description:
+ Purpose of the stylesheet follows.
+*/
+
+#pane{
+ -fx-background-image: url("/images/TestON.png");
+ -fx-background-repeat: stretch;
+ -fx-background-size: 300 200;
+
+
+}
+.label {
+ -fx-font-size: 15px;
+ -fx-font-weight: bold;
+ -fx-text-fill: #333333;
+ -fx-effect: dropshadow( gaussian , rgba(255,255,255,0.5) , 0,0,0,1 );
+}
+
+.button {
+ -fx-text-fill: black;
+ -fx-font-family: "Arial Narrow";
+
+
+ -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );
+}
+
+#testParamsTitle {
+ -fx-font-size: 32px;
+ -fx-font-family: "Arial Black";
+ -fx-fill: #818181;
+ -fx-effect: innershadow( three-pass-box , rgba(0,0,0,0.7) , 6, 0.0 , 0 , 2 );
+}