From afa2d06b56fec1b81288e9522e4b7887d6c974c0 Mon Sep 17 00:00:00 2001 From: iMoHax Date: Thu, 14 Apr 2016 13:37:17 +0300 Subject: [PATCH] implement single land search --- .../controllers/RouteSearchController.java | 25 ++++++++++++++++++- .../java/ru/trader/model/MarketModel.java | 7 +++++- .../resources/lang/locale_en_US.properties | 1 + .../resources/lang/locale_ru_RU.properties | 1 + .../src/main/resources/view/routeSearch.fxml | 1 + 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/ru/trader/controllers/RouteSearchController.java b/client/src/main/java/ru/trader/controllers/RouteSearchController.java index d292096..a94c9b5 100644 --- a/client/src/main/java/ru/trader/controllers/RouteSearchController.java +++ b/client/src/main/java/ru/trader/controllers/RouteSearchController.java @@ -3,6 +3,7 @@ package ru.trader.controllers; import javafx.fxml.FXML; import javafx.scene.control.*; import ru.trader.analysis.CrawlerSpecificator; +import ru.trader.core.Profile; import ru.trader.model.*; import ru.trader.view.support.autocomplete.AutoCompletion; import ru.trader.view.support.autocomplete.CachedSuggestionProvider; @@ -109,7 +110,7 @@ public class RouteSearchController { for (Iterator iterator = routes.iterator(); iterator.hasNext(); ) { RouteModel route = iterator.next(); Collection notAdded = route.addAll(0, missionsList.getItems()); - if (!notAdded.isEmpty()){ + if (!notAdded.isEmpty()) { iterator.remove(); } } @@ -133,6 +134,28 @@ public class RouteSearchController { }); } + @FXML + private void searchSingled(){ + SystemModel f = fromSystem.getValue(); + SystemModel t = toSystem.getValue(); + StationModel fS = f != null ? f.get(fromStation.getValue()) : ModelFabric.NONE_STATION; + StationModel tS = t != null ? t.get(toStation.getValue()) : ModelFabric.NONE_STATION; + + CrawlerSpecificator specificator = new CrawlerSpecificator(); + specificator.setByTime(rbByTime.isSelected()); + specificator.setFullScan(cbFullScan.isSelected()); + + Profile profile = Profile.clone(ModelFabric.get(this.profile)); + profile.setLands(fS.equals(tS) ? 2 : 1); + market.getRoutes(f, fS, t, tS, profile, specificator, routes -> { + Optional path = Screeners.showRouters(routes); + if (path.isPresent()) { + this.profile.setRoute(path.get()); + Screeners.showTrackTab(); + } + }); + } + @FXML private void addMission(){ diff --git a/client/src/main/java/ru/trader/model/MarketModel.java b/client/src/main/java/ru/trader/model/MarketModel.java index 622c1f3..307c451 100644 --- a/client/src/main/java/ru/trader/model/MarketModel.java +++ b/client/src/main/java/ru/trader/model/MarketModel.java @@ -240,10 +240,15 @@ public class MarketModel { getRoutes(stationFrom.getSystem(), stationFrom, stationTo.getSystem(), stationTo, balance, specificator, result); } + public void getRoutes(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, double balance, CrawlerSpecificator specificator, Consumer> result) { - ProgressController progress = new ProgressController(Screeners.getMainScreen(), Localization.getString("analyzer.routes.title")); Profile profile = Profile.clone(ModelFabric.get(MainController.getProfile())); profile.setBalance(balance); + getRoutes(from, stationFrom, to, stationTo, profile, specificator, result); + } + + public void getRoutes(SystemModel from, StationModel stationFrom, SystemModel to, StationModel stationTo, Profile profile, CrawlerSpecificator specificator, Consumer> result) { + ProgressController progress = new ProgressController(Screeners.getMainScreen(), Localization.getString("analyzer.routes.title")); RoutesSearchTask task = new RoutesSearchTask(this, ModelFabric.get(from), ModelFabric.get(stationFrom), ModelFabric.get(to), ModelFabric.get(stationTo), profile, specificator diff --git a/client/src/main/resources/lang/locale_en_US.properties b/client/src/main/resources/lang/locale_en_US.properties index 45b8443..ea2ab3f 100644 --- a/client/src/main/resources/lang/locale_en_US.properties +++ b/client/src/main/resources/lang/locale_en_US.properties @@ -157,6 +157,7 @@ router.pane.route.from=From: router.pane.route.to=To: router.pane.route.fast=Fasted router.button.search=Find +router.button.singledSearch=A -> B router.pane.route.jumps=Jumps: router.button.recompute=Recompute router.button.rebuild=Rebuild diff --git a/client/src/main/resources/lang/locale_ru_RU.properties b/client/src/main/resources/lang/locale_ru_RU.properties index 6ed73f9..64013e9 100644 --- a/client/src/main/resources/lang/locale_ru_RU.properties +++ b/client/src/main/resources/lang/locale_ru_RU.properties @@ -157,6 +157,7 @@ router.pane.route.from=\u041E\u0442: router.pane.route.to=\u0414\u043E: router.pane.route.fast=\u0411\u044B\u0441\u0442\u0440\u044B\u0439 router.button.search=\u041D\u0430\u0439\u0442\u0438 +router.button.singledSearch=\u0410 -> \u0411 router.pane.route.jumps=\u041F\u0440\u044B\u0436\u043A\u043E\u0432: router.button.recompute=\u041F\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0442\u044C router.button.rebuild=\u041F\u0435\u0440\u0435\u0441\u0442\u0440\u043E\u0438\u0442\u044C diff --git a/client/src/main/resources/view/routeSearch.fxml b/client/src/main/resources/view/routeSearch.fxml index 72f88e4..e3ea953 100644 --- a/client/src/main/resources/view/routeSearch.fxml +++ b/client/src/main/resources/view/routeSearch.fxml @@ -24,6 +24,7 @@