diff --git a/polling-station-gui/src/main/java/polling_station_dashboard/EventHandlerMapper.java b/polling-station-gui/src/main/java/polling_station_dashboard/EventHandlerMapper.java index 16a54a8..74b632b 100644 --- a/polling-station-gui/src/main/java/polling_station_dashboard/EventHandlerMapper.java +++ b/polling-station-gui/src/main/java/polling_station_dashboard/EventHandlerMapper.java @@ -2,6 +2,8 @@ package polling_station_dashboard; import javafx.stage.Stage; import polling_station_dashboard.search.SearchHandler; +import polling_station_dashboard.search.advancedSearch.AdvancedSearchHandler; +import polling_station_dashboard.search.advancedSearch.AdvancedSearchLoader; import polling_station_dashboard.search.submitVoter.lodgeAppeal.LodgeAppealLoader; import polling_station_dashboard.search.submitVoter.lodgeAppeal.LodgeAppealVisualUpdater; import polling_station_dashboard.search.votersFetcher.DummyVotersFetcher; @@ -39,6 +41,12 @@ public class EventHandlerMapper { map.Add("StatusLogButton", statusLogVisualUpdater); map.Add("StatusLog", statusLogVisualUpdater); + // map advanced search object to its handler + AdvancedSearchLoader advancedSearchLoader = new AdvancedSearchLoader(primaryStage); + AdvancedSearchHandler advancedSearchHandler = new AdvancedSearchHandler( + advancedSearchLoader.GetSettingsInstance(), primaryStage); + map.Add("ExpandAdvanceSearch", advancedSearchHandler); + // map add voter to search button triggered SearchHandler searchHandler = new SearchHandler(primaryStage, new DummyVotersFetcher()); map.Add("SearchButton", searchHandler); diff --git a/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchController.java b/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchController.java index b543f9f..ea41bad 100644 --- a/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchController.java +++ b/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchController.java @@ -1,9 +1,26 @@ package polling_station_dashboard.search.advancedSearch; +import javafx.fxml.FXML; +import javafx.scene.layout.GridPane; +import javafx.stage.Stage; + /** * Created by dasha on 7/9/2016. * AdvancedSearchController controls the behavior of the adnvaced search panel * for example searching by tag type */ public class AdvancedSearchController { + + private Stage currentStage; + + private GridPane regularSearch; + + public void SetStage(Stage stage){ + this.currentStage = stage; + } + + public void SetRegulartSearch(GridPane regularSearch) { this.regularSearch = regularSearch; } + + @FXML + private void AdvancedSearch(){} } diff --git a/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchHandler.java b/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchHandler.java index 6a8f7ad..433c7bf 100644 --- a/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchHandler.java +++ b/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchHandler.java @@ -2,6 +2,10 @@ package polling_station_dashboard.search.advancedSearch; import javafx.event.Event; import javafx.event.EventHandler; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Pane; +import javafx.stage.Stage; /** * Created by dasha on 7/9/2016. @@ -9,8 +13,33 @@ import javafx.event.EventHandler; */ public class AdvancedSearchHandler implements EventHandler { + private GridPane advancedSearch; + private Stage currentStage; + + public AdvancedSearchHandler(GridPane advancedSearch, Stage primalStage) + { + this.advancedSearch = advancedSearch; + this.currentStage = primalStage; + } + + private void UpdateAdvancedSearch() { + RemoveRegularSearch(); + AddAdvancedSearch(); + } + + private void AddAdvancedSearch() { + Pane searchContainer = (Pane) currentStage.getScene().lookup("#SearchContainer"); + searchContainer.getChildren().add(advancedSearch); + } + + private void RemoveRegularSearch() { + // the only element that is in this container is the regular search + Pane searchContainer = (Pane) currentStage.getScene().lookup("#SearchContainer"); + searchContainer.getChildren().remove(0); + } + @Override public void handle(Event event) { - + UpdateAdvancedSearch(); } } diff --git a/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchLoader.java b/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchLoader.java index 686c902..6a11919 100644 --- a/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchLoader.java +++ b/polling-station-gui/src/main/java/polling_station_dashboard/search/advancedSearch/AdvancedSearchLoader.java @@ -1,8 +1,33 @@ package polling_station_dashboard.search.advancedSearch; +import javafx.fxml.FXMLLoader; +import javafx.scene.layout.GridPane; +import javafx.stage.Stage; +import polling_station_dashboard.settings.settingsController; + +import java.io.IOException; + /** * Created by dasha on 7/9/2016. * AdvancedSearchLoader loads the advanced search panel */ public class AdvancedSearchLoader { + private static final String ADVANCED_SEARCH_FXML_PATH = "/view/dashboard/advanced_search.fxml"; + + private Stage currentStage; + private FXMLLoader fxmlLoader; + + public AdvancedSearchLoader(Stage primaryStage) throws IOException + { + currentStage = primaryStage; + fxmlLoader = new FXMLLoader(getClass().getResource(ADVANCED_SEARCH_FXML_PATH)); + } + + public GridPane GetSettingsInstance() throws IOException { + GridPane settings = fxmlLoader.load(); + AdvancedSearchController controller = fxmlLoader.getController(); + controller.SetStage(currentStage); + + return settings; + } } diff --git a/polling-station-gui/src/main/resources/view/dashboard/advanced_search.fxml b/polling-station-gui/src/main/resources/view/dashboard/advanced_search.fxml index 9e77e9a..4fced60 100644 --- a/polling-station-gui/src/main/resources/view/dashboard/advanced_search.fxml +++ b/polling-station-gui/src/main/resources/view/dashboard/advanced_search.fxml @@ -7,7 +7,7 @@ - + @@ -29,7 +29,7 @@
- +
diff --git a/polling-station-gui/src/main/resources/view/dashboard/polling_station_dashboard.fxml b/polling-station-gui/src/main/resources/view/dashboard/polling_station_dashboard.fxml index 6d539e5..1cb0e98 100644 --- a/polling-station-gui/src/main/resources/view/dashboard/polling_station_dashboard.fxml +++ b/polling-station-gui/src/main/resources/view/dashboard/polling_station_dashboard.fxml @@ -29,21 +29,25 @@
- -
- -
- - - - - - - - -
@@ -83,7 +87,7 @@ -