|
|
|
@ -28,8 +28,13 @@ public class TreeViewCtrl extends FXMLView {
|
|
|
|
|
@FXML
|
|
|
|
|
private Label nameLabel;
|
|
|
|
|
@FXML
|
|
|
|
|
private TextField nameTextField;
|
|
|
|
|
@FXML
|
|
|
|
|
private Label temperatureLabel;
|
|
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
|
private ComboBox strategyOptions;
|
|
|
|
|
|
|
|
|
|
private ArrayList<CapteurAbstrait> capteurAbstraits;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -61,6 +66,8 @@ public class TreeViewCtrl extends FXMLView {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void initializeCapteur() {
|
|
|
|
|
strategyOptions.getItems().addAll("CPU", "Random");
|
|
|
|
|
|
|
|
|
|
treeView.setCellFactory(param -> new TreeCell<CapteurAbstrait>() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void updateItem(CapteurAbstrait capteur, boolean empty) {
|
|
|
|
@ -69,7 +76,7 @@ public class TreeViewCtrl extends FXMLView {
|
|
|
|
|
textProperty().unbind();
|
|
|
|
|
setText("");
|
|
|
|
|
} else {
|
|
|
|
|
textProperty().bind(capteur.getNom());
|
|
|
|
|
setText(capteur.getNom().getValue());
|
|
|
|
|
String image = "/images/random.png";
|
|
|
|
|
if (capteur.getClass() == CapteurVirtuel.class) {
|
|
|
|
|
image = "/images/virtual.png";
|
|
|
|
@ -86,13 +93,38 @@ public class TreeViewCtrl extends FXMLView {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
strategyOptions.setVisible(false);
|
|
|
|
|
treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
|
|
|
|
if (oldValue != null) {
|
|
|
|
|
CapteurAbstrait capteur = oldValue.getValue();
|
|
|
|
|
idLabel.textProperty().unbindBidirectional(capteur.getId());
|
|
|
|
|
nameLabel.textProperty().unbindBidirectional(capteur.getNom());
|
|
|
|
|
temperatureLabel.textProperty().unbind();
|
|
|
|
|
if(capteur instanceof UnitCapteur){
|
|
|
|
|
strategyOptions.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (newValue != null) {
|
|
|
|
|
CapteurAbstrait capteur = newValue.getValue();
|
|
|
|
|
if (capteur instanceof UnitCapteur) {
|
|
|
|
|
strategyOptions.setVisible(true);
|
|
|
|
|
} else {
|
|
|
|
|
strategyOptions.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
idLabel.textProperty().bindBidirectional(capteur.getId());
|
|
|
|
|
nameLabel.textProperty().bindBidirectional(capteur.getNom());
|
|
|
|
|
temperatureLabel.textProperty().bind(Bindings.format("%.2f",capteur.getTemp()));
|
|
|
|
|
nameTextField.setOnAction(event -> {
|
|
|
|
|
capteur.setNom(nameTextField.getText());
|
|
|
|
|
});
|
|
|
|
|
nameTextField.setText(capteur.getNom().getValue());
|
|
|
|
|
capteur.getNom().addListener((obs, oldName, newName) -> {
|
|
|
|
|
capteur.setNom(newName);
|
|
|
|
|
newValue.setValue(capteur);
|
|
|
|
|
});
|
|
|
|
|
if(capteur instanceof UnitCapteur){
|
|
|
|
|
strategyOptions.setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|