use of fvarrui.sysadmin.challenger.test.CommandTest in project Challenger4SysAdmins by fvarrui.
the class TreeItemFactory method createTestTreeItem.
/**
* @param test un test
* @return un item de tipo test
*/
public static TreeItem<Object> createTestTreeItem(Test test) {
TreeItem<Object> testItem = new TreeItem<Object>();
testItem.setExpanded(true);
testItem.setValue(test);
if (test instanceof TestGroup) {
TestGroup ct = (TestGroup) test;
for (Test t : ct.getTests()) {
testItem.getChildren().add(createTestTreeItem(t));
}
ct.testsProperty().addListener(new ListChangeListener<Test>() {
public void onChanged(Change<? extends Test> c) {
while (c.next()) {
c.getAddedSubList().stream().forEach(g -> testItem.getChildren().add(createTestTreeItem(g)));
c.getRemoved().stream().forEach(g -> {
TreeItem<Object> item = testItem.getChildren().stream().filter(i -> i.getValue().equals(g)).findFirst().get();
testItem.getChildren().remove(item);
});
}
}
});
} else if (test instanceof CommandTest) {
CommandTest ct = (CommandTest) test;
if (ct.getCommand() != null) {
testItem.getChildren().add(createCommandTreeItem(ct.getCommand()));
}
ct.commandProperty().addListener((o, ov, nv) -> {
if (nv != null) {
testItem.getChildren().add(createCommandTreeItem(ct.getCommand()));
} else {
testItem.getChildren().clear();
}
});
}
return testItem;
}
use of fvarrui.sysadmin.challenger.test.CommandTest in project Challenger4SysAdmins by fvarrui.
the class TreeEditorController method removeCommand.
private void removeCommand(Command command) {
CommandTest parent = (CommandTest) selectedItem.get().getParent().getValue();
parent.setCommand(null);
System.out.println("comando " + command.getCommand() + " eliminado del test " + parent.getName());
}
Aggregations