Archived
0

add included stations to route search screen

This commit is contained in:
Mo
2016-06-04 10:58:55 +03:00
parent 5b0833d8a6
commit 2a69c43bd1
4 changed files with 70 additions and 12 deletions

View File

@@ -4,14 +4,18 @@ import javafx.fxml.FXML;
import javafx.scene.control.*;
import ru.trader.analysis.CrawlerSpecificator;
import ru.trader.core.Profile;
import ru.trader.core.Vendor;
import ru.trader.model.*;
import ru.trader.view.support.autocomplete.AutoCompletion;
import ru.trader.view.support.autocomplete.CachedSuggestionProvider;
import ru.trader.view.support.autocomplete.StationsProvider;
import ru.trader.view.support.autocomplete.SystemsProvider;
import ru.trader.view.support.cells.CustomListCell;
import java.util.Collection;
import java.util.Iterator;
import java.util.Optional;
import java.util.stream.Collectors;
public class RouteSearchController {
@@ -33,6 +37,11 @@ public class RouteSearchController {
private ListView<MissionModel> missionsList;
@FXML
private MissionsController missionsController;
@FXML
private TextField includeStarportText;
private AutoCompletion<StationModel> includeStarport;
@FXML
private ListView<StationModel> includesStations;
private MarketModel market;
private ProfileModel profile;
@@ -42,6 +51,7 @@ public class RouteSearchController {
init();
profile = MainController.getProfile();
missionsList.setItems(missionsController.getMissions());
includesStations.setCellFactory(new CustomListCell<>(StationModel::getFullName));
initListeners();
}
@@ -62,6 +72,14 @@ public class RouteSearchController {
}
fromStation.setValue(ModelFabric.NONE_STATION.getName());
toStation.setValue(ModelFabric.NONE_STATION.getName());
StationsProvider stationsProvider = market.getStationsProvider();
if (includeStarport == null){
includeStarport = new AutoCompletion<>(includeStarportText, new CachedSuggestionProvider<>(stationsProvider), ModelFabric.NONE_STATION, stationsProvider.getConverter());
} else {
includeStarport.setSuggestions(stationsProvider.getPossibleSuggestions());
includeStarport.setConverter(stationsProvider.getConverter());
}
}
private void initListeners(){
@@ -105,6 +123,8 @@ public class RouteSearchController {
CrawlerSpecificator specificator = new CrawlerSpecificator();
specificator.setByTime(rbByTime.isSelected());
specificator.setFullScan(cbFullScan.isSelected());
Collection<Vendor> starports = includesStations.getItems().stream().map(ModelFabric::get).collect(Collectors.toList());
specificator.all(starports);
missionsList.getItems().forEach(m -> m.toSpecification(specificator));
market.getRoutes(f, fS, t, tS, profile.getBalance(), specificator, routes -> {
for (Iterator<RouteModel> iterator = routes.iterator(); iterator.hasNext(); ) {
@@ -173,6 +193,26 @@ public class RouteSearchController {
@FXML
private void clearMissions(){
missionsController.clear();
}
@FXML
private void addStarport(){
StationModel station = includeStarport.getValue();
if (!ModelFabric.isFake(station)){
includesStations.getItems().add(station);
}
}
@FXML
private void removeStarport(){
int index = includesStations.getSelectionModel().getSelectedIndex();
if (index >= 0){
includesStations.getItems().remove(index);
}
}
@FXML
private void clearStarports(){
includesStations.getItems().clear();
}
}

View File

@@ -175,6 +175,7 @@ router.search.type=Search type:
router.search.byTime=Best time, hours
router.search.byProfit=Best profit, Cr/h
router.search.full=Full scan
router.pane.includeStations=Included stations
# settings.fxml
settings.title=Settings

View File

@@ -174,6 +174,7 @@ router.search.type=\u0422\u0438\u043F \u043F\u043E\u0438\u0441\u043A\u0430:
router.search.byTime=\u041D\u0430\u0438\u043C\u0435\u043D\u044C\u0448\u0435\u0435 \u0432\u0440\u0435\u043C\u044F, \u0447
router.search.byProfit=\u041D\u0430\u0438\u0431\u043E\u043B\u044C\u0448\u0430\u044F \u043F\u0440\u0438\u0431\u044B\u043B\u044C, \u041A\u0440/\u0447
router.search.full=\u0413\u043B\u0443\u0431\u043E\u043A\u0438\u0439 \u043F\u043E\u0438\u0441\u043A
router.pane.includeStations=\u041F\u0440\u043E\u043C\u0435\u0436\u0443\u0442\u043E\u0447\u043D\u044B\u0435 \u0441\u0442\u0430\u043D\u0446\u0438\u0438
# settings.fxml
settings.title=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B

View File

@@ -37,17 +37,33 @@
</VBox>
</HBox>
</TitledPane>
<TitledPane text="%router.pane.missions" collapsible="false">
<HBox spacing="10">
<fx:include fx:id="missions" source="missions.fxml"/>
<HBox spacing="4" maxHeight="200">
<VBox spacing="4" alignment="TOP_RIGHT">
<Button prefWidth="30" onAction="#addMission"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
<Button prefWidth="30" onAction="#removeMission"><graphic><Glyph text="FontAwesome|MINUS"/></graphic></Button>
<Button prefWidth="30" onAction="#clearMissions"><graphic><Glyph text="FontAwesome|TRASH"/></graphic></Button>
</VBox>
<ListView fx:id="missionsList" />
<HBox>
<TitledPane text="%router.pane.missions" collapsible="false">
<HBox spacing="10" minHeight="210" maxHeight="210">
<fx:include fx:id="missions" source="missions.fxml"/>
<HBox spacing="4" maxHeight="200">
<VBox spacing="4" alignment="TOP_RIGHT">
<Button prefWidth="30" onAction="#addMission"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
<Button prefWidth="30" onAction="#removeMission"><graphic><Glyph text="FontAwesome|MINUS"/></graphic></Button>
<Button prefWidth="30" onAction="#clearMissions"><graphic><Glyph text="FontAwesome|TRASH"/></graphic></Button>
</VBox>
<ListView fx:id="missionsList" />
</HBox>
</HBox>
</HBox>
</TitledPane>
</TitledPane>
<TitledPane text="%router.pane.includeStations" collapsible="false">
<VBox minHeight="210" maxHeight="210" spacing="4">
<TextField fx:id="includeStarportText" prefWidth="150"/>
<HBox spacing="4" alignment="CENTER" VBox.vgrow="ALWAYS">
<ListView fx:id="includesStations" HBox.hgrow="ALWAYS"/>
<VBox spacing="4">
<Button prefWidth="30" onAction="#addStarport"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
<Button prefWidth="30" onAction="#removeStarport"><graphic><Glyph text="FontAwesome|MINUS"/></graphic></Button>
<Button prefWidth="30" onAction="#clearStarports"><graphic><Glyph text="FontAwesome|TRASH"/></graphic></Button>
</VBox>
</HBox>
</VBox>
</TitledPane>
</HBox>
</VBox>