Search in sources :

Example 1 with Goal

use of fvarrui.sysadmin.challenger.Goal in project Challenger4SysAdmins by fvarrui.

the class TreeItemFactory method createChallengeTreeItem.

/**
 * @param challenge un chellenge
 * @return un item
 */
public static TreeItem<Object> createChallengeTreeItem(Challenge challenge) {
    TreeItem<Object> challengeItem = new TreeItem<Object>();
    challengeItem.setExpanded(true);
    challengeItem.setValue(challenge);
    for (Goal goal : challenge.getGoals()) {
        challengeItem.getChildren().add(createGoalTreeItem(goal));
    }
    challenge.goalsProperty().addListener(new ListChangeListener<Goal>() {

        public void onChanged(Change<? extends Goal> c) {
            while (c.next()) {
                c.getAddedSubList().stream().forEach(g -> challengeItem.getChildren().add(createGoalTreeItem(g)));
                c.getRemoved().stream().forEach(g -> {
                    TreeItem<Object> item = challengeItem.getChildren().stream().filter(i -> i.getValue().equals(g)).findFirst().get();
                    challengeItem.getChildren().remove(item);
                });
            }
        }
    });
    return challengeItem;
}
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) Goal(fvarrui.sysadmin.challenger.Goal) TreeItem(javafx.scene.control.TreeItem)

Example 2 with Goal

use of fvarrui.sysadmin.challenger.Goal in project Challenger4SysAdmins by fvarrui.

the class RootController method onSeleccionadoChanged.

/**
 * Listener para ser notificado de cambios y bindear el modelo.
 * @param o valor observable
 * @param ov viejo goal
 * @param nv goal nuevo
 * @throws IOException si no puede cargar la vista
 */
private void onSeleccionadoChanged(ObservableValue<? extends Object> o, Object ov, Object nv) {
    centerPane.setCenter(emptyView);
    // desbindea del panel el elemento anterior
    if (ov instanceof Challenge) {
        challengeController.challengeProperty().unbind();
    } else if (ov instanceof Goal) {
        goalController.goalProperty().unbind();
    } else if (ov instanceof Test) {
        testController.testProperty().unbind();
    } else if (ov instanceof ShellCommand) {
        comandController.shellCommandProperty().unbind();
    }
    // bindea el elemento al panel adecuado y lo muestra
    if (nv instanceof Challenge) {
        Challenge challenge = (Challenge) nv;
        challengeController.challengeProperty().bind(new SimpleObjectProperty<>(challenge));
        centerPane.setCenter(challengeController.getView());
    } else if (nv instanceof Goal) {
        Goal goal = (Goal) nv;
        goalController.goalProperty().bind(new SimpleObjectProperty<Goal>(goal));
        centerPane.setCenter(goalController.getView());
    } else if (nv instanceof Test) {
        Test test = (Test) nv;
        testController.testProperty().bind(new SimpleObjectProperty<>(test));
        centerPane.setCenter(testController.getView());
    } else if (nv instanceof ShellCommand) {
        ShellCommand comand = (ShellCommand) nv;
        comandController.shellCommandProperty().bind(new SimpleObjectProperty<>(comand));
        centerPane.setCenter(comandController.getView());
    }
}
Also used : SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Goal(fvarrui.sysadmin.challenger.Goal) Test(fvarrui.sysadmin.challenger.test.Test) ShellCommand(fvarrui.sysadmin.challenger.command.ShellCommand) Challenge(fvarrui.sysadmin.challenger.Challenge)

Example 3 with Goal

use of fvarrui.sysadmin.challenger.Goal in project Challenger4SysAdmins by fvarrui.

the class TreeEditorController method removeTest.

private void removeTest(Test test) {
    Object parent = selectedItem.get().getParent().getValue();
    if (parent instanceof Goal) {
        Goal goal = (Goal) parent;
        goal.setTest(null);
        System.out.println("test " + test.getName() + " eliminado del objetivo " + goal.getName());
    } else if (parent instanceof TestGroup) {
        TestGroup compoundTest = (TestGroup) parent;
        compoundTest.getTests().remove(test);
        System.out.println("test " + test.getName() + " eliminado del test " + compoundTest.getName());
    } else if (parent instanceof NotTest) {
        NotTest notTest = (NotTest) parent;
        notTest.setTest(null);
        System.out.println("test " + test.getName() + " eliminado del test de negaci�n " + notTest.getName());
    }
}
Also used : Goal(fvarrui.sysadmin.challenger.Goal) TestGroup(fvarrui.sysadmin.challenger.test.TestGroup) NotTest(fvarrui.sysadmin.challenger.test.NotTest)

Example 4 with Goal

use of fvarrui.sysadmin.challenger.Goal in project Challenger4SysAdmins by fvarrui.

the class TreeEditorController method addGoal.

private void addGoal(Challenge challenge) {
    Goal goal = new Goal("Nuevo objetivo");
    challenge.getGoals().add(goal);
    System.out.println("objetivo " + goal.getName() + " a�adido al reto " + challenge.getName());
}
Also used : Goal(fvarrui.sysadmin.challenger.Goal)

Aggregations

Goal (fvarrui.sysadmin.challenger.Goal)4 Challenge (fvarrui.sysadmin.challenger.Challenge)2 Test (fvarrui.sysadmin.challenger.test.Test)2 TestGroup (fvarrui.sysadmin.challenger.test.TestGroup)2 Command (fvarrui.sysadmin.challenger.command.Command)1 ShellCommand (fvarrui.sysadmin.challenger.command.ShellCommand)1 CommandTest (fvarrui.sysadmin.challenger.test.CommandTest)1 NotTest (fvarrui.sysadmin.challenger.test.NotTest)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ListChangeListener (javafx.collections.ListChangeListener)1 TreeItem (javafx.scene.control.TreeItem)1