Search in sources :

Example 1 with CommandTest

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;
}
Also used : TestGroup(fvarrui.sysadmin.challenger.test.TestGroup) Challenge(fvarrui.sysadmin.challenger.Challenge) Test(fvarrui.sysadmin.challenger.test.Test) Goal(fvarrui.sysadmin.challenger.Goal) ListChangeListener(javafx.collections.ListChangeListener) TreeItem(javafx.scene.control.TreeItem) CommandTest(fvarrui.sysadmin.challenger.test.CommandTest) Command(fvarrui.sysadmin.challenger.command.Command) TreeItem(javafx.scene.control.TreeItem) Test(fvarrui.sysadmin.challenger.test.Test) CommandTest(fvarrui.sysadmin.challenger.test.CommandTest) TestGroup(fvarrui.sysadmin.challenger.test.TestGroup) CommandTest(fvarrui.sysadmin.challenger.test.CommandTest)

Example 2 with CommandTest

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());
}
Also used : CommandTest(fvarrui.sysadmin.challenger.test.CommandTest)

Aggregations

CommandTest (fvarrui.sysadmin.challenger.test.CommandTest)2 Challenge (fvarrui.sysadmin.challenger.Challenge)1 Goal (fvarrui.sysadmin.challenger.Goal)1 Command (fvarrui.sysadmin.challenger.command.Command)1 Test (fvarrui.sysadmin.challenger.test.Test)1 TestGroup (fvarrui.sysadmin.challenger.test.TestGroup)1 ListChangeListener (javafx.collections.ListChangeListener)1 TreeItem (javafx.scene.control.TreeItem)1