Fixed up missing acceptance criteria of story 7

main
Fan-Wu Yang 9 years ago
parent 434017c558
commit cb50ea176c

@ -147,7 +147,7 @@ public class AddTripController extends Controller{
} }
}); });
String[] dir = {"University","Home"}; String[] dir = {Trip.TO_UNI, Trip.TO_HOME};
ObservableList<String> dirArr = FXCollections.observableArrayList(dir); ObservableList<String> dirArr = FXCollections.observableArrayList(dir);
direction.setItems(dirArr); direction.setItems(dirArr);
direction.getSelectionModel().selectFirst(); direction.getSelectionModel().selectFirst();

@ -10,6 +10,7 @@ import javafx.scene.control.TableView;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import model.SharedTrip; import model.SharedTrip;
import model.Stop; import model.Stop;
import model.Trip;
import model.TripStop; import model.TripStop;
import java.net.URL; import java.net.URL;
@ -36,6 +37,12 @@ public class SharedTripsController extends Controller{
private ObservableList<SharedTrip> sharedTrips; private ObservableList<SharedTrip> sharedTrips;
@FXML @FXML
private TextField stopName; private TextField stopName;
@FXML
private ComboBox<String> directionBox;
public void showDetails(){
}
public void resetSearch(){ public void resetSearch(){
stopsFilter.getSelectionModel().select(0); stopsFilter.getSelectionModel().select(0);
@ -43,26 +50,35 @@ public class SharedTripsController extends Controller{
public void search(){ public void search(){
sharedTrips.remove(0, sharedTrips.size()); sharedTrips.remove(0, sharedTrips.size());
//ignore stop
boolean ignoreStopFilter = stopsFilter.getSelectionModel().getSelectedIndex() == 0; boolean ignoreStopFilter = stopsFilter.getSelectionModel().getSelectedIndex() == 0;
boolean ignoreStopNameSearch = stopName.getText().equals("") || stopName.getText() == null; boolean ignoreStopNameSearch = stopName.getText().equals("") || stopName.getText() == null;
boolean ignoreStopSearch = ignoreStopFilter && ignoreStopNameSearch;
Pattern stopNamePattern = Pattern.compile(".*"+stopName.getText()+".*", Pattern.CASE_INSENSITIVE); Pattern stopNamePattern = Pattern.compile(".*"+stopName.getText()+".*", Pattern.CASE_INSENSITIVE);
//ignore direction
boolean ignoreDirection = directionBox.getSelectionModel().isSelected(0);
for(SharedTrip sharedTrip: parent.getSession().getDataManager().getSharedTrips()){ for(SharedTrip sharedTrip: parent.getSession().getDataManager().getSharedTrips()){
//stops are equal //stops are equal
boolean added = false; boolean add = false;
for (TripStop stop : sharedTrip.route) { for (TripStop stop : sharedTrip.route) {
if (stop.equals(stopsFilter.getValue()) || ignoreStopFilter) { if (ignoreStopSearch){
sharedTrips.add(sharedTrip); add = true;
added = true; break;
}
if (stop.equals(stopsFilter.getValue())) {
add = true;
break; break;
} }
if (stopNamePattern.matcher(stop.getName()).matches()){ if (stopNamePattern.matcher(stop.getName()).matches()){
sharedTrips.add(sharedTrip); add = true;
added = true;
break; break;
} }
} }
if (added){ if (!ignoreDirection) {
continue;//for other filters later add = sharedTrip.direction.equals(directionBox.getValue());
}
if (add){
sharedTrips.add(sharedTrip);//for other filters later
} }
} }
} }
@ -76,7 +92,7 @@ public class SharedTripsController extends Controller{
daysColumn.setCellValueFactory(p -> new SimpleStringProperty(p.getValue().getDays())); daysColumn.setCellValueFactory(p -> new SimpleStringProperty(p.getValue().getDays()));
//add all stops that have shared trips with them. TODO only display visible ones. //add all stops that have shared trips with them. TODO only display visible ones.
ObservableList<TripStop> stops = FXCollections.observableArrayList(); ObservableList<TripStop> stops = FXCollections.observableArrayList();
stops.add(new TripStop("None", "")); stops.add(new TripStop("Any", ""));
HashMap<TripStop, Boolean> stopAdded = new HashMap<>(); HashMap<TripStop, Boolean> stopAdded = new HashMap<>();
for (SharedTrip trip:sharedTrips){ for (SharedTrip trip:sharedTrips){
for(TripStop stop: trip.route){ for(TripStop stop: trip.route){
@ -91,10 +107,13 @@ public class SharedTripsController extends Controller{
search(); search();
}); });
stopName.textProperty().addListener(e-> search()); stopName.textProperty().addListener(e-> search());
directionBox.valueProperty().addListener(e->search());
} }
@Override @Override
public void initialize(URL location, ResourceBundle resources) { public void initialize(URL location, ResourceBundle resources) {
ObservableList<String> directions = FXCollections.observableArrayList();
directions.addAll("Any", Trip.TO_UNI, Trip.TO_HOME);
directionBox.setItems(directions);
} }
} }

@ -28,6 +28,9 @@ public class Trip {
public static int SATURDAY = 5; public static int SATURDAY = 5;
public static int SUNDAY = 6; public static int SUNDAY = 6;
public static String TO_UNI = "University";
public static String TO_HOME = "Home";
public enum Days{ public enum Days{
MONDAY("Monday", 0), TUESDAY("Tuesday", 1), WEDNESDAY("Wednesday", 2), THURSDAY("THURSDAY", 3), FRIDAY("Friday", 4), MONDAY("Monday", 0), TUESDAY("Tuesday", 1), WEDNESDAY("Wednesday", 2), THURSDAY("THURSDAY", 3), FRIDAY("Friday", 4),
SATURDAY("SATURDAY", 5), SUNDAY("SUNDAY", 6); SATURDAY("SATURDAY", 5), SUNDAY("SUNDAY", 6);

@ -24,6 +24,7 @@
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="348.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="348.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label text="Shared Trips" GridPane.columnSpan="6" GridPane.halignment="CENTER"> <Label text="Shared Trips" GridPane.columnSpan="6" GridPane.halignment="CENTER">
@ -49,6 +50,13 @@
<Button fx:id="resetSearch" mnemonicParsing="false" text="Reset Search" AnchorPane.bottomAnchor="8.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="7.0" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowIndex="4" GridPane.valignment="CENTER" /> <Button fx:id="resetSearch" mnemonicParsing="false" text="Reset Search" AnchorPane.bottomAnchor="8.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="7.0" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowIndex="4" GridPane.valignment="CENTER" />
</children> </children>
</AnchorPane> </AnchorPane>
<Label text="Direction:" GridPane.columnIndex="4" GridPane.rowIndex="3" />
<AnchorPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowIndex="6">
<children>
<Button layoutX="60.0" layoutY="2.0" mnemonicParsing="false" onAction="#showDetails" text="Details/Book" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" />
</children>
</AnchorPane>
<ComboBox fx:id="directionBox" prefWidth="150.0" GridPane.columnIndex="5" GridPane.rowIndex="3" />
</children> </children>
</GridPane> </GridPane>
</children> </children>

Binary file not shown.

@ -24,6 +24,7 @@
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" /> <RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="348.0" vgrow="SOMETIMES" /> <RowConstraints minHeight="10.0" prefHeight="348.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.0" vgrow="SOMETIMES" />
</rowConstraints> </rowConstraints>
<children> <children>
<Label text="Shared Trips" GridPane.columnSpan="6" GridPane.halignment="CENTER"> <Label text="Shared Trips" GridPane.columnSpan="6" GridPane.halignment="CENTER">
@ -49,6 +50,13 @@
<Button fx:id="resetSearch" mnemonicParsing="false" text="Reset Search" AnchorPane.bottomAnchor="8.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="7.0" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowIndex="4" GridPane.valignment="CENTER" /> <Button fx:id="resetSearch" mnemonicParsing="false" text="Reset Search" AnchorPane.bottomAnchor="8.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="7.0" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowIndex="4" GridPane.valignment="CENTER" />
</children> </children>
</AnchorPane> </AnchorPane>
<Label text="Direction:" GridPane.columnIndex="4" GridPane.rowIndex="3" />
<AnchorPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.columnSpan="2" GridPane.rowIndex="6">
<children>
<Button layoutX="60.0" layoutY="2.0" mnemonicParsing="false" onAction="#showDetails" text="Details/Book" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" />
</children>
</AnchorPane>
<ComboBox fx:id="directionBox" prefWidth="150.0" GridPane.columnIndex="5" GridPane.rowIndex="3" />
</children> </children>
</GridPane> </GridPane>
</children> </children>

Loading…
Cancel
Save