Skip to content
Snippets Groups Projects
Verified Commit 1c8296e6 authored by Théo Pirkl's avatar Théo Pirkl :nail_care:
Browse files

Upgrades user-friendliness

parent f0bab20a
Branches
No related tags found
1 merge request!21*poof* final version
...@@ -12,6 +12,7 @@ import javafx.scene.Scene; ...@@ -12,6 +12,7 @@ import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.input.KeyCode;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.WindowEvent; import javafx.stage.WindowEvent;
import javafx.application.Platform; import javafx.application.Platform;
...@@ -73,10 +74,10 @@ public class ConnectionController implements Initializable { ...@@ -73,10 +74,10 @@ public class ConnectionController implements Initializable {
// Faire les initialisations avant affichage ici. // Faire les initialisations avant affichage ici.
appNameLabel.setText(AppConfig.APP_NAME); appNameLabel.setText(AppConfig.APP_NAME);
appConnectionStatusLabel.setText("Merci de rentrer votre nom. Il permettra de vous identifier."); appConnectionStatusLabel.setText("Merci de rentrer votre nom. Il permettra de vous identifier.");
Platform.runLater(new Runnable() { Platform.runLater(() -> usernameSelectionTextField.requestFocus());
@Override usernameSelectionTextField.setOnKeyPressed(event -> {
public void run() { if (event.getCode().equals(KeyCode.ENTER)){
usernameSelectionTextField.requestFocus(); handleConfirmButton.fire();
} }
}); });
} }
......
...@@ -7,8 +7,10 @@ import javafx.fxml.FXML; ...@@ -7,8 +7,10 @@ import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.canvas.Canvas; import javafx.scene.canvas.Canvas;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.shape.Line; import javafx.scene.shape.Line;
import javafx.stage.Stage; import javafx.stage.Stage;
import org.json.JSONArray; import org.json.JSONArray;
...@@ -38,6 +40,15 @@ public class MainWindowController implements Initializable { ...@@ -38,6 +40,15 @@ public class MainWindowController implements Initializable {
@FXML @FXML
private Canvas connectionCanvas; private Canvas connectionCanvas;
@FXML
private Button searchOriginButton;
@FXML
private Button searchDestinationButton;
@FXML
private Button launchItinaryButton;
/** /**
* Shows a sad message when the API crashes. * Shows a sad message when the API crashes.
*/ */
...@@ -95,16 +106,25 @@ public class MainWindowController implements Initializable { ...@@ -95,16 +106,25 @@ public class MainWindowController implements Initializable {
startStopLabel.setText(""); // No text should be visible when no journey has been selected. startStopLabel.setText(""); // No text should be visible when no journey has been selected.
LinkAPI transportApi = new LinkAPI(); LinkAPI transportApi = new LinkAPI();
originComboBox.valueProperty().addListener( originComboBox.setOnKeyPressed(event -> {
(observable, oldValue, newValue) -> searchStops(newValue, transportApi, originComboBox) if (event.getCode().equals(KeyCode.ENTER)){
); searchOriginButton.fire();
}
});
destinationComboBox.valueProperty().addListener( destinationComboBox.setOnKeyPressed(event -> {
(observable, oldValue, newValue) -> { if (event.getCode().equals(KeyCode.ENTER)){
searchStops(newValue, transportApi, destinationComboBox); searchDestinationButton.fire();
if (destinationComboBox.getItems().contains(newValue) && }
originComboBox.getItems().contains(originComboBox.getValue())){ });
// Both are autofilled, plotting route
searchOriginButton.
setOnAction(event -> searchStops(originComboBox.getValue(), transportApi, originComboBox));
searchDestinationButton.
setOnAction(event -> searchStops(destinationComboBox.getValue(), transportApi, destinationComboBox));
launchItinaryButton.setOnAction(event -> {
try { try {
JSONArray connections = transportApi.getConnections( JSONArray connections = transportApi.getConnections(
originComboBox.getValue(), destinationComboBox.getValue()); originComboBox.getValue(), destinationComboBox.getValue());
...@@ -118,8 +138,6 @@ public class MainWindowController implements Initializable { ...@@ -118,8 +138,6 @@ public class MainWindowController implements Initializable {
} catch (IOException | ParseException e) { } catch (IOException | ParseException e) {
showSadMessage(); showSadMessage();
} }
} });
}
);
} }
} }
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<Pane maxHeight="48.0" maxWidth="1000.0" minHeight="48.0" minWidth="32.0" prefHeight="48.0" prefWidth="32.0" style="-fx-background-color: #35B1EE;" BorderPane.alignment="CENTER"> <Pane maxHeight="48.0" maxWidth="1000.0" minHeight="48.0" minWidth="32.0" prefHeight="48.0" prefWidth="32.0" style="-fx-background-color: #35B1EE;" BorderPane.alignment="CENTER">
<children> <children>
<ComboBox id="originComboBox" fx:id="originComboBox" editable="true" layoutX="12.0" layoutY="10.0" prefHeight="27.0" prefWidth="275.0" promptText="Tapez le nom d'un arrêt..." /> <ComboBox id="originComboBox" fx:id="originComboBox" editable="true" layoutX="12.0" layoutY="10.0" prefHeight="27.0" prefWidth="275.0" promptText="Tapez le nom d'un arrêt..." />
<Line endY="48.0" layoutX="300.0" startY="1.0"> <Line endY="48.0" layoutX="411.0" layoutY="-1.0" startY="1.0">
<stroke> <stroke>
<LinearGradient> <LinearGradient>
<stops> <stops>
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
</LinearGradient> </LinearGradient>
</stroke> </stroke>
</Line> </Line>
<ComboBox id="destinationComboBox" fx:id="destinationComboBox" editable="true" layoutX="310.0" layoutY="10.0" prefHeight="27.0" prefWidth="282.0" promptText="Choisissez votre destination..." /> <ComboBox id="destinationComboBox" fx:id="destinationComboBox" editable="true" layoutX="421.0" layoutY="9.0" prefHeight="27.0" prefWidth="282.0" promptText="Choisissez votre destination..." />
<Line endY="48.0" layoutX="603.0" layoutY="-1.0" startY="1.0"> <Line endY="48.0" layoutX="827.0" layoutY="-1.0" startY="1.0">
<stroke> <stroke>
<LinearGradient> <LinearGradient>
<stops> <stops>
...@@ -35,12 +35,14 @@ ...@@ -35,12 +35,14 @@
</LinearGradient> </LinearGradient>
</stroke> </stroke>
</Line> </Line>
<Label id="currentJourneyLabel" fx:id="currentJourneyLabel" layoutX="612.0" layoutY="16.0" text="CHANGEZ-MOI" textFill="WHITE" /> <Button id="searchOriginButton" fx:id="searchOriginButton" layoutX="293.0" layoutY="10.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="107.0" text="Chercher" />
<Button fx:id="searchDestinationButton" layoutX="711.0" layoutY="9.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="107.0" text="Chercher" />
<Button id="launchItinaryButton" fx:id="launchItinaryButton" layoutX="836.0" layoutY="9.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="156.0" text="Itinéraire..." />
</children> </children>
</Pane> </Pane>
</top> </top>
<right> <right>
<Pane prefHeight="517.0" prefWidth="326.0" BorderPane.alignment="CENTER" /> <Pane prefHeight="517.0" prefWidth="326.0" style="-fx-background-color: #dadada;" BorderPane.alignment="CENTER" />
</right> </right>
<center> <center>
<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER"> <Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
...@@ -52,6 +54,7 @@ ...@@ -52,6 +54,7 @@
</Label> </Label>
<Line endX="100.0" layoutX="115.0" layoutY="49.0" startX="-100.0" stroke="#4c7ba8" /> <Line endX="100.0" layoutX="115.0" layoutY="49.0" startX="-100.0" stroke="#4c7ba8" />
<Canvas id="connectionCanvas" fx:id="connectionCanvas" height="451.0" layoutX="15.0" layoutY="59.0" width="652.0" /> <Canvas id="connectionCanvas" fx:id="connectionCanvas" height="451.0" layoutX="15.0" layoutY="59.0" width="652.0" />
<Label id="currentJourneyLabel" fx:id="currentJourneyLabel" layoutX="15.0" layoutY="59.0" text="CHANGEZ-MOI" textFill="#2600ff" />
</children> </children>
</Pane> </Pane>
</center> </center>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment