Skip to content
Snippets Groups Projects
Select Git revision
  • 5c1d6fef90d5b4e831f72f042fed9f0aa1035438
  • main default protected
  • jw_sonar
  • v6.0.0 protected
  • interactive-mode-preference
  • bedran_exercise-list
  • add_route_user
  • Jw_sonar_backup
  • exercise_list_filter
  • assignment_filter
  • add_route_assignments
  • move-to-esm-only
  • 6.0.0-dev
  • Pre-alpha
  • 5.0.0
  • Latest
  • 4.2.0
  • 4.1.1
  • 4.1.0
  • 4.0.1
  • 4.0.0
  • 3.5.0
  • 3.4.2
  • 3.4.1
  • 3.3.0
  • 3.2.3
  • 3.2.2
  • 3.2.0
  • 3.1.2
  • 3.1.1
  • 3.1.0
  • 3.0.1
32 results

DojoBackendManager.ts

Blame
  • MainWindowController.java 1.97 KiB
    package ch.hepia.ui;
    
    import ch.hepia.api.transport.LinkAPI;
    import javafx.fxml.FXML;
    import javafx.fxml.Initializable;
    import javafx.scene.control.Alert;
    import javafx.scene.control.ComboBox;
    import javafx.scene.control.Label;
    import org.json.JSONArray;
    
    import java.net.URL;
    import java.util.ResourceBundle;
    
    public class MainWindowController implements Initializable {
    
        @FXML
        private Label currentJourneyLabel;
    
        @FXML
        private Label startStopLabel;
    
        @FXML
        private ComboBox<String> originComboBox;
    
        @FXML
        private ComboBox<String> destinationComboBox;
    
        @Override
        public void initialize(URL url, ResourceBundle resourceBundle) {
            currentJourneyLabel.setText("Vous n'avez prévu aucun voyage pour le moment.");
            startStopLabel.setText(""); // No text should be visible when no journey has been selected.
            LinkAPI transportApi = new LinkAPI();
    
            originComboBox.valueProperty().addListener(
                (observable, oldValue, newValue) -> {
                    if (!newValue.isEmpty() && newValue.length() > 3){
                        originComboBox.getItems().clear();
                        try {
                            JSONArray a = transportApi.getStations(newValue);
                            for (int i = 0; i < a.length(); i++){
                                originComboBox.getItems().add(a.getJSONObject(i).getString("name"));
                            }
                        } catch (Exception e) {
                            AlertUtils.dialog(
                                    Alert.AlertType.ERROR, "Erreur",
                                    "Une erreur est survenue.",
                                    "Impossible de contacter les services de transport Suisses.");
                        }
                    }
                });
    
            destinationComboBox.valueProperty().addListener(
                (observable, oldValue, newValue) -> {
                    if (!newValue.isEmpty() && !originComboBox.getValue().isEmpty()){
    
                    }
                }
            );
        }
    }