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;
}
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());
}
}
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());
}
}
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());
}
Aggregations