- modify station editor
- add system editor - show services in station tab
This commit is contained in:
@@ -92,6 +92,7 @@ public class Main extends Application {
|
||||
Screeners.loadTopOrdersStage(getUrl(("topOrders.fxml")));
|
||||
Screeners.loadPathsStage(getUrl(("paths.fxml")));
|
||||
Screeners.loadSettingsStage(getUrl(("settings.fxml")));
|
||||
Screeners.loadSEditorStage(getUrl(("sEditor.fxml")));
|
||||
}
|
||||
|
||||
private static URL getUrl(String filename) throws MalformedURLException {
|
||||
|
||||
@@ -17,6 +17,7 @@ import ru.trader.World;
|
||||
import ru.trader.model.ItemModel;
|
||||
import ru.trader.model.MarketModel;
|
||||
import ru.trader.model.StationModel;
|
||||
import ru.trader.model.SystemModel;
|
||||
import ru.trader.view.support.Localization;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
@@ -141,11 +142,12 @@ public class MainController {
|
||||
|
||||
|
||||
public void addSystem(ActionEvent actionEvent){
|
||||
//TODO: implement
|
||||
Screeners.showSystemsEditor(null);
|
||||
}
|
||||
|
||||
public void editSystem(ActionEvent actionEvent){
|
||||
//TODO: implement
|
||||
SystemModel system = offersController.getSystem();
|
||||
Screeners.showSystemsEditor(system);
|
||||
}
|
||||
|
||||
public void removeSystem(ActionEvent actionEvent){
|
||||
@@ -153,8 +155,11 @@ public class MainController {
|
||||
}
|
||||
|
||||
public void addStation(ActionEvent actionEvent) {
|
||||
SystemModel system = offersController.getSystem();
|
||||
if (system != null){
|
||||
Screeners.showAddStation(offersController.getSystem());
|
||||
}
|
||||
}
|
||||
|
||||
public void editStation(ActionEvent actionEvent) {
|
||||
//TODO: disable edit station, if station is null
|
||||
|
||||
@@ -14,9 +14,11 @@ import org.controlsfx.control.SegmentedButton;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import javafx.fxml.FXML;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.model.*;
|
||||
import ru.trader.model.support.BindingsHelper;
|
||||
import ru.trader.model.support.ChangeMarketListener;
|
||||
import ru.trader.view.support.NumberField;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,18 +31,28 @@ public class OffersController {
|
||||
|
||||
@FXML
|
||||
private Insets stationsMargin;
|
||||
|
||||
@FXML
|
||||
private ListView<SystemModel> systems;
|
||||
|
||||
@FXML
|
||||
private SegmentedButton stationsBar;
|
||||
|
||||
@FXML
|
||||
private TableView<OfferModel> tblSell;
|
||||
|
||||
@FXML
|
||||
private TableView<OfferModel> tblBuy;
|
||||
@FXML
|
||||
private Label distance;
|
||||
@FXML
|
||||
private CheckBox cbMarket;
|
||||
@FXML
|
||||
private CheckBox cbBlackMarket;
|
||||
@FXML
|
||||
private CheckBox cbRepair;
|
||||
@FXML
|
||||
private CheckBox cbMunition;
|
||||
@FXML
|
||||
private CheckBox cbOutfit;
|
||||
@FXML
|
||||
private CheckBox cbShipyard;
|
||||
|
||||
private final List<OfferModel> sells = FXCollections.observableArrayList();
|
||||
private final List<OfferModel> buys = FXCollections.observableArrayList();
|
||||
@@ -106,7 +118,6 @@ public class OffersController {
|
||||
}
|
||||
|
||||
station = stations.isEmpty() ? null : stations.get(0);
|
||||
LOG.info("Change station to {}", station);
|
||||
fillTables(station);
|
||||
}
|
||||
|
||||
@@ -117,9 +128,24 @@ public class OffersController {
|
||||
}
|
||||
|
||||
private void fillTables(StationModel station){
|
||||
LOG.info("Change station to {}", station);
|
||||
sells.clear();
|
||||
buys.clear();
|
||||
distance.setText("");
|
||||
cbMarket.setSelected(false);
|
||||
cbBlackMarket.setSelected(false);
|
||||
cbMunition.setSelected(false);
|
||||
cbRepair.setSelected(false);
|
||||
cbOutfit.setSelected(false);
|
||||
cbShipyard.setSelected(false);
|
||||
if (station != null){
|
||||
distance.setText(String.valueOf(station.getDistance()));
|
||||
cbMarket.setSelected(station.hasService(SERVICE_TYPE.MARKET));
|
||||
cbBlackMarket.setSelected(station.hasService(SERVICE_TYPE.BLACK_MARKET));
|
||||
cbMunition.setSelected(station.hasService(SERVICE_TYPE.MUNITION));
|
||||
cbRepair.setSelected(station.hasService(SERVICE_TYPE.REPAIR));
|
||||
cbOutfit.setSelected(station.hasService(SERVICE_TYPE.OUTFIT));
|
||||
cbShipyard.setSelected(station.hasService(SERVICE_TYPE.SHIPYARD));
|
||||
sells.addAll(station.getSells());
|
||||
buys.addAll(station.getBuys());
|
||||
}
|
||||
@@ -202,6 +228,7 @@ public class OffersController {
|
||||
|
||||
@Override
|
||||
public void add(StationModel station) {
|
||||
stationsBar.getButtons().add(buildStationNode(station));
|
||||
refresh();
|
||||
sort();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class Screeners {
|
||||
private static Parent topOrdersScreen;
|
||||
private static Parent pathsScreen;
|
||||
private static Parent settingsScreen;
|
||||
private static Parent sEditorScreen;
|
||||
|
||||
private static MainController mainController;
|
||||
private static ItemDescController itemDescController;
|
||||
@@ -37,6 +38,7 @@ public class Screeners {
|
||||
private static TopOrdersController topOrdersController;
|
||||
private static PathsController pathsController;
|
||||
private static SettingsController settingsController;
|
||||
private static SystemsEditorController systemsEditorController;
|
||||
|
||||
private static FXMLLoader initLoader(URL url){
|
||||
FXMLLoader loader = new FXMLLoader(url, Localization.getResources());
|
||||
@@ -118,6 +120,14 @@ public class Screeners {
|
||||
stage.setScene(new Scene(settingsScreen));
|
||||
}
|
||||
|
||||
public static void loadSEditorStage(URL fxml) throws IOException {
|
||||
FXMLLoader loader = initLoader(fxml);
|
||||
sEditorScreen = loader.load();
|
||||
addStylesheet(sEditorScreen);
|
||||
systemsEditorController = loader.getController();
|
||||
}
|
||||
|
||||
|
||||
public static void show(Node node){
|
||||
mainController.getMainPane().setCenter(node);
|
||||
}
|
||||
@@ -131,6 +141,10 @@ public class Screeners {
|
||||
return Dialogs.create().owner(mainScreen).message(text).showConfirm();
|
||||
}
|
||||
|
||||
public static void showSystemsEditor(SystemModel system){
|
||||
systemsEditorController.showDialog(mainScreen, sEditorScreen, system);
|
||||
}
|
||||
|
||||
public static void showAddStation(SystemModel system){
|
||||
vEditorController.showDialog(mainScreen, vEditorScreen, system, null);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package ru.trader.controllers;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.util.converter.LongStringConverter;
|
||||
import org.controlsfx.control.ButtonBar;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
@@ -12,6 +14,7 @@ import org.controlsfx.dialog.DialogAction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.EMDNUpdater;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.model.*;
|
||||
import ru.trader.model.support.StationUpdater;
|
||||
import ru.trader.view.support.Localization;
|
||||
@@ -19,6 +22,7 @@ import ru.trader.view.support.NumberField;
|
||||
import ru.trader.view.support.PriceStringConverter;
|
||||
import ru.trader.view.support.ViewUtils;
|
||||
import ru.trader.view.support.cells.EditOfferCell;
|
||||
import ru.trader.view.support.cells.TextFieldCell;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -35,13 +39,25 @@ public class StationEditorController {
|
||||
private TableColumn<StationUpdater.FakeOffer, Double> buy;
|
||||
@FXML
|
||||
private TableColumn<StationUpdater.FakeOffer, Double> sell;
|
||||
@FXML
|
||||
private TableColumn<StationUpdater.FakeOffer, Long> supply;
|
||||
@FXML
|
||||
private TableColumn<StationUpdater.FakeOffer, Long> demand;
|
||||
|
||||
@FXML
|
||||
private NumberField x;
|
||||
private NumberField distance;
|
||||
@FXML
|
||||
private NumberField y;
|
||||
private CheckBox cbMarket;
|
||||
@FXML
|
||||
private NumberField z;
|
||||
private CheckBox cbBlackMarket;
|
||||
@FXML
|
||||
private CheckBox cbRepair;
|
||||
@FXML
|
||||
private CheckBox cbMunition;
|
||||
@FXML
|
||||
private CheckBox cbOutfit;
|
||||
@FXML
|
||||
private CheckBox cbShipyard;
|
||||
|
||||
private StationUpdater updater;
|
||||
|
||||
@@ -61,11 +77,11 @@ public class StationEditorController {
|
||||
items.getSelectionModel().setCellSelectionEnabled(true);
|
||||
buy.setCellFactory(EditOfferCell.forTable(new PriceStringConverter(), false));
|
||||
sell.setCellFactory(EditOfferCell.forTable(new PriceStringConverter(), true));
|
||||
actSave.disabledProperty().bind(x.wrongProperty().or(y.wrongProperty().or(z.wrongProperty())));
|
||||
name.setOnAction((v)->x.requestFocus());
|
||||
x.setOnAction((v) -> z.requestFocus());
|
||||
z.setOnAction((v) -> y.requestFocus());
|
||||
y.setOnAction((v) -> {
|
||||
demand.setCellFactory(TextFieldCell.forTableColumn(new LongStringConverter()));
|
||||
supply.setCellFactory(TextFieldCell.forTableColumn(new LongStringConverter()));
|
||||
actSave.disabledProperty().bind(distance.wrongProperty());
|
||||
name.setOnAction((v)->distance.requestFocus());
|
||||
distance.setOnAction((v) -> {
|
||||
items.requestFocus();
|
||||
items.getSelectionModel().select(0, buy);
|
||||
});
|
||||
@@ -73,11 +89,19 @@ public class StationEditorController {
|
||||
}
|
||||
|
||||
private void init(){
|
||||
if (updater != null){
|
||||
name.textProperty().unbindBidirectional(updater.nameProperty());
|
||||
distance.numberProperty().unbindBidirectional(updater.distanceProperty());
|
||||
}
|
||||
updater = new StationUpdater(MainController.getMarket());
|
||||
name.textProperty().bindBidirectional(updater.nameProperty());
|
||||
x.numberProperty().bindBidirectional(updater.xProperty());
|
||||
y.numberProperty().bindBidirectional(updater.yProperty());
|
||||
z.numberProperty().bindBidirectional(updater.zProperty());
|
||||
distance.numberProperty().bindBidirectional(updater.distanceProperty());
|
||||
cbMarket.selectedProperty().bindBidirectional(updater.serviceProperty(SERVICE_TYPE.MARKET));
|
||||
cbBlackMarket.selectedProperty().bindBidirectional(updater.serviceProperty(SERVICE_TYPE.BLACK_MARKET));
|
||||
cbMunition.selectedProperty().bindBidirectional(updater.serviceProperty(SERVICE_TYPE.MUNITION));
|
||||
cbRepair.selectedProperty().bindBidirectional(updater.serviceProperty(SERVICE_TYPE.REPAIR));
|
||||
cbOutfit.selectedProperty().bindBidirectional(updater.serviceProperty(SERVICE_TYPE.OUTFIT));
|
||||
cbShipyard.selectedProperty().bindBidirectional(updater.serviceProperty(SERVICE_TYPE.SHIPYARD));
|
||||
items.setItems(updater.getOffers());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package ru.trader.controllers;
|
||||
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.util.converter.DefaultStringConverter;
|
||||
import javafx.util.converter.DoubleStringConverter;
|
||||
import org.controlsfx.control.ButtonBar;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.controlsfx.dialog.DialogAction;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.model.MarketModel;
|
||||
import ru.trader.model.SystemModel;
|
||||
import ru.trader.view.support.Localization;
|
||||
import ru.trader.view.support.cells.TextFieldCell;
|
||||
|
||||
public class SystemsEditorController {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(SystemsEditorController.class);
|
||||
|
||||
|
||||
@FXML
|
||||
private TableView<SystemData> tblSystems;
|
||||
@FXML
|
||||
private TableColumn<SystemData, String> clnName;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnX;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnY;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnZ;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnS1;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnS2;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnS3;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnS4;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnS5;
|
||||
@FXML
|
||||
private TableColumn<SystemData, Double> clnS6;
|
||||
@FXML
|
||||
private ComboBox<SystemModel> system1;
|
||||
@FXML
|
||||
private ComboBox<SystemModel> system2;
|
||||
@FXML
|
||||
private ComboBox<SystemModel> system3;
|
||||
@FXML
|
||||
private ComboBox<SystemModel> system4;
|
||||
@FXML
|
||||
private ComboBox<SystemModel> system5;
|
||||
@FXML
|
||||
private ComboBox<SystemModel> system6;
|
||||
|
||||
private MarketModel market;
|
||||
|
||||
private final Action actSave = new DialogAction(Localization.getString("dialog.button.save"), ButtonBar.ButtonType.OK_DONE, false, true, false, (e) -> {
|
||||
tblSystems.getSelectionModel().selectFirst();
|
||||
commit();
|
||||
});
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
clnName.setCellFactory(TextFieldCell.forTableColumn(new DefaultStringConverter()));
|
||||
clnX.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnY.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnZ.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnS1.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnS2.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnS3.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnS4.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnS5.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
clnS6.setCellFactory(TextFieldCell.forTableColumn(new DoubleStringConverter()));
|
||||
tblSystems.setItems(FXCollections.observableArrayList());
|
||||
tblSystems.getSelectionModel().setCellSelectionEnabled(true);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init(){
|
||||
market = MainController.getMarket();
|
||||
system1.setItems(market.systemsProperty());
|
||||
system2.setItems(market.systemsProperty());
|
||||
system3.setItems(market.systemsProperty());
|
||||
system4.setItems(market.systemsProperty());
|
||||
system5.setItems(market.systemsProperty());
|
||||
system6.setItems(market.systemsProperty());
|
||||
}
|
||||
|
||||
public void showDialog(Parent parent, Parent content, SystemModel system){
|
||||
Dialog dlg = new Dialog(parent, Localization.getString("sEditor.title"));
|
||||
dlg.setContent(content);
|
||||
dlg.getActions().addAll(actSave, Dialog.ACTION_CANCEL);
|
||||
dlg.setResizable(false);
|
||||
if (system != null){
|
||||
tblSystems.getItems().add(new SystemData(system));
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {
|
||||
add();
|
||||
}
|
||||
dlg.show();
|
||||
reset();
|
||||
}
|
||||
|
||||
public void add() {
|
||||
tblSystems.getItems().add(new SystemData());
|
||||
}
|
||||
|
||||
|
||||
private void commit(){
|
||||
for (SystemData systemData : tblSystems.getItems()) {
|
||||
systemData.commit();
|
||||
}
|
||||
}
|
||||
|
||||
private void reset(){
|
||||
tblSystems.getItems().clear();
|
||||
}
|
||||
|
||||
public class SystemData {
|
||||
private final StringProperty name;
|
||||
private final DoubleProperty x;
|
||||
private final DoubleProperty y;
|
||||
private final DoubleProperty z;
|
||||
|
||||
private final DoubleProperty s1 = new SimpleDoubleProperty();
|
||||
private final DoubleProperty s2 = new SimpleDoubleProperty();
|
||||
private final DoubleProperty s3 = new SimpleDoubleProperty();
|
||||
private final DoubleProperty s4 = new SimpleDoubleProperty();
|
||||
private final DoubleProperty s5 = new SimpleDoubleProperty();
|
||||
private final DoubleProperty s6 = new SimpleDoubleProperty();
|
||||
private final SystemModel system;
|
||||
|
||||
private SystemData() {
|
||||
system = null;
|
||||
name = new SimpleStringProperty("");
|
||||
x = new SimpleDoubleProperty(Double.NaN);
|
||||
y = new SimpleDoubleProperty(Double.NaN);
|
||||
z = new SimpleDoubleProperty(Double.NaN);
|
||||
}
|
||||
|
||||
private SystemData(SystemModel system) {
|
||||
this.system = system;
|
||||
name = new SimpleStringProperty(system.getName());
|
||||
x = new SimpleDoubleProperty(system.getX());
|
||||
y = new SimpleDoubleProperty(system.getY());
|
||||
z = new SimpleDoubleProperty(system.getZ());
|
||||
}
|
||||
|
||||
public StringProperty nameProperty() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public DoubleProperty xProperty() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public DoubleProperty yProperty() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public DoubleProperty zProperty() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public DoubleProperty s1Property() {
|
||||
return s1;
|
||||
}
|
||||
|
||||
public DoubleProperty s2Property() {
|
||||
return s2;
|
||||
}
|
||||
|
||||
public DoubleProperty s3Property() {
|
||||
return s3;
|
||||
}
|
||||
|
||||
public DoubleProperty s4Property() {
|
||||
return s4;
|
||||
}
|
||||
|
||||
public DoubleProperty s5Property() {
|
||||
return s5;
|
||||
}
|
||||
|
||||
public DoubleProperty s6Property() {
|
||||
return s6;
|
||||
}
|
||||
|
||||
private void commit(){
|
||||
if (!name.get().isEmpty() && !Double.isNaN(x.get()) && !Double.isNaN(y.get()) && !Double.isNaN(z.get())){
|
||||
if (system != null){
|
||||
system.setName(name.get());
|
||||
system.setPosition(x.get(), y.get(), z.get());
|
||||
} else {
|
||||
market.add(name.get(), x.get(), y.get(), z.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.core.OFFER_TYPE;
|
||||
import ru.trader.core.Offer;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.core.Vendor;
|
||||
|
||||
import java.util.*;
|
||||
@@ -49,6 +50,26 @@ public class StationModel {
|
||||
station.setDistance(value);
|
||||
}
|
||||
|
||||
public boolean hasService(SERVICE_TYPE service){
|
||||
return station.has(service);
|
||||
}
|
||||
|
||||
public Collection<SERVICE_TYPE> getServices(){
|
||||
return station.getServices();
|
||||
}
|
||||
|
||||
public void addService(SERVICE_TYPE service){
|
||||
if (station.has(service)) return;
|
||||
LOG.info("Add service {} to station {}", service, station);
|
||||
station.add(service);
|
||||
}
|
||||
|
||||
public void removeService(SERVICE_TYPE service){
|
||||
if (!station.has(service)) return;
|
||||
LOG.info("Remove service {} from station {}", service, station);
|
||||
station.remove(service);
|
||||
}
|
||||
|
||||
public SystemModel getSystem(){
|
||||
return market.getModeler().get(station.getPlace());
|
||||
}
|
||||
|
||||
@@ -72,6 +72,10 @@ public class SystemModel {
|
||||
return system.getDistance(other.getSystem());
|
||||
}
|
||||
|
||||
public double getDistance(double x, double y, double z){
|
||||
return system.getDistance(x, y, z);
|
||||
}
|
||||
|
||||
public List<StationModel> getStations() {
|
||||
return system.get().stream().map(this::asModel).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@@ -6,17 +6,19 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import ru.trader.controllers.MainController;
|
||||
import ru.trader.core.OFFER_TYPE;
|
||||
import ru.trader.core.SERVICE_TYPE;
|
||||
import ru.trader.model.*;
|
||||
|
||||
|
||||
public class StationUpdater {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(StationUpdater.class);
|
||||
private final static SERVICE_TYPE[] SERVICE_TYPES = SERVICE_TYPE.values();
|
||||
private final ObservableList<FakeOffer> offers;
|
||||
private final StringProperty name;
|
||||
private final DoubleProperty x;
|
||||
private final DoubleProperty y;
|
||||
private final DoubleProperty z;
|
||||
private final DoubleProperty distance;
|
||||
private final BooleanProperty[] services;
|
||||
private final MarketModel market;
|
||||
|
||||
private SystemModel system;
|
||||
private StationModel station;
|
||||
private boolean updateOnly;
|
||||
@@ -25,9 +27,11 @@ public class StationUpdater {
|
||||
this.market = market;
|
||||
this.offers = BindingsHelper.observableList(MainController.getMarket().itemsProperty(), FakeOffer::new);
|
||||
this.name = new SimpleStringProperty();
|
||||
this.x = new SimpleDoubleProperty(0);
|
||||
this.y = new SimpleDoubleProperty(0);
|
||||
this.z = new SimpleDoubleProperty(0);
|
||||
this.distance = new SimpleDoubleProperty(0);
|
||||
this.services = new BooleanProperty[SERVICE_TYPES.length];
|
||||
for (int i = 0; i < services.length; i++) {
|
||||
services[i] = new SimpleBooleanProperty();
|
||||
}
|
||||
this.updateOnly = false;
|
||||
}
|
||||
|
||||
@@ -35,18 +39,20 @@ public class StationUpdater {
|
||||
LOG.debug("Init update of {}", station);
|
||||
this.station = station;
|
||||
this.system = system;
|
||||
for (BooleanProperty service : services) {
|
||||
service.set(false);
|
||||
}
|
||||
if (station != null){
|
||||
name.setValue(station.getName());
|
||||
x.setValue(system.getX());
|
||||
y.setValue(system.getY());
|
||||
z.setValue(system.getZ());
|
||||
distance.setValue(station.getDistance());
|
||||
for (SERVICE_TYPE service : station.getServices()) {
|
||||
serviceProperty(service).set(true);
|
||||
}
|
||||
station.getSells().forEach(this::fillOffer);
|
||||
station.getBuys().forEach(this::fillOffer);
|
||||
} else {
|
||||
name.setValue("");
|
||||
x.setValue(0);
|
||||
y.setValue(0);
|
||||
z.setValue(0);
|
||||
distance.setValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,28 +88,16 @@ public class StationUpdater {
|
||||
return name;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x.get();
|
||||
public double getDistance() {
|
||||
return distance.get();
|
||||
}
|
||||
|
||||
public DoubleProperty xProperty() {
|
||||
return x;
|
||||
public DoubleProperty distanceProperty() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y.get();
|
||||
}
|
||||
|
||||
public DoubleProperty yProperty() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z.get();
|
||||
}
|
||||
|
||||
public DoubleProperty zProperty() {
|
||||
return z;
|
||||
public BooleanProperty serviceProperty(SERVICE_TYPE service){
|
||||
return services[service.ordinal()];
|
||||
}
|
||||
|
||||
public void add(int index, ItemModel item){
|
||||
@@ -112,16 +106,29 @@ public class StationUpdater {
|
||||
|
||||
public void commit(){
|
||||
LOG.debug("Save changes of {}", station);
|
||||
system.setPosition(x.get(), y.get(), z.get());
|
||||
if (isNew()) {
|
||||
Notificator notificator = market.getNotificator();
|
||||
notificator.setAlert(false);
|
||||
station = system.add(name.get());
|
||||
station.setDistance(distance.get());
|
||||
for (int i = 0; i < services.length; i++) {
|
||||
if (services[i].get()){
|
||||
station.addService(SERVICE_TYPES[i]);
|
||||
}
|
||||
}
|
||||
offers.forEach(FakeOffer::commit);
|
||||
notificator.setAlert(true);
|
||||
notificator.sendAdd(station);
|
||||
} else {
|
||||
station.setName(name.get());
|
||||
station.setDistance(distance.get());
|
||||
for (int i = 0; i < services.length; i++) {
|
||||
if (services[i].get()){
|
||||
station.addService(SERVICE_TYPES[i]);
|
||||
} else {
|
||||
station.removeService(SERVICE_TYPES[i]);
|
||||
}
|
||||
}
|
||||
offers.forEach(FakeOffer::commit);
|
||||
}
|
||||
}
|
||||
@@ -268,11 +275,13 @@ public class StationUpdater {
|
||||
public void setSell(OfferModel sell) {
|
||||
this.sell = sell;
|
||||
sprice.set(sell.getPrice());
|
||||
supply.set(sell.getCount());
|
||||
}
|
||||
|
||||
public void setBuy(OfferModel buy) {
|
||||
this.buy = buy;
|
||||
bprice.set(buy.getPrice());
|
||||
demand.set(buy.getCount());
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
|
||||
@@ -19,6 +19,7 @@ public class ViewUtils {
|
||||
// Edit next cell
|
||||
public static <S> void editNext(TableView<S> tableView){
|
||||
TableView.TableViewSelectionModel<S> sm = tableView.getSelectionModel();
|
||||
if (!sm.isCellSelectionEnabled()) return;
|
||||
sm.selectNext();
|
||||
ObservableList<TablePosition> pos = sm.getSelectedCells();
|
||||
for (TablePosition p : pos) {
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
services.MARKET=Commodities
|
||||
services.BLACK_MARKET=Black Market
|
||||
services.REPAIR=Repair
|
||||
services.MUNITION=Munition
|
||||
services.OUTFIT=Outfit
|
||||
services.SHIPYARD=Shipyard
|
||||
item.explosives=Explosives
|
||||
item.hydrogenfuel=Hydrogen Fuels
|
||||
item.mineraloil=Mineral Oil
|
||||
|
||||
@@ -72,6 +72,8 @@ oEditor.sell=Sell:
|
||||
oEditor.buy=Buy:
|
||||
|
||||
# offers.fxml
|
||||
offers.text.distance=Distance:
|
||||
offers.text.services=Services:
|
||||
offers.pane.sell=Selling commodities
|
||||
offers.pane.buy=Buying commodities
|
||||
|
||||
@@ -84,6 +86,9 @@ topOrders.title=TOP orders
|
||||
# vEditor.fxml
|
||||
vEditor.title.add=Add Station
|
||||
vEditor.title.edit=Edit Station
|
||||
vEditor.text.distance=Distance (Ls)
|
||||
vEditor.text.services=Services
|
||||
|
||||
|
||||
# paths.fxml
|
||||
paths.title=Available routes
|
||||
@@ -112,3 +117,8 @@ settings.emdn.auto=Auto update (sec.):
|
||||
settings.performance=Performance
|
||||
settings.performance.segmentSize=Segment size (0 - auto):
|
||||
settings.performance.limit=Routes count:
|
||||
|
||||
# sEditor.fxml
|
||||
sEditor.title=Star systems editor
|
||||
sEditor.text.orientates=Landmarks:
|
||||
sEditor.table.distance=Distance (LY)
|
||||
|
||||
@@ -74,6 +74,8 @@ oEditor.sell=\u041F\u0440\u043E\u0434\u0430\u0436\u0430:
|
||||
oEditor.buy=\u041F\u043E\u043A\u0443\u043F\u043A\u0430:
|
||||
|
||||
# offers.fxml
|
||||
offers.text.distance=\u0414\u0438\u0441\u0442\u0430\u043D\u0446\u0438\u044F:
|
||||
offers.text.services=\u0421\u0435\u0440\u0432\u0438\u0441\u044B:
|
||||
offers.pane.sell=\u041F\u0440\u043E\u0434\u0430\u0432\u0430\u0435\u043C\u044B\u0435 \u0442\u043E\u0432\u0430\u0440\u044B
|
||||
offers.pane.buy=\u041F\u043E\u043A\u0443\u043F\u0430\u0435\u043C\u044B\u0435 \u0442\u043E\u0432\u0430\u0440\u044B
|
||||
|
||||
@@ -86,6 +88,8 @@ topOrders.title=TOP \u0437\u0430\u043A\u0430\u0437\u043E\u0432
|
||||
# vEditor.fxml
|
||||
vEditor.title.add=\u0414\u043E\u0431\u0430\u0432\u043B\u0435\u043D\u0438\u0435 \u0441\u0442\u0430\u043D\u0446\u0438\u0438
|
||||
vEditor.title.edit=\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0441\u0442\u0430\u043D\u0446\u0438\u0438
|
||||
vEditor.text.distance=\u0414\u0438\u0441\u0442\u0430\u043D\u0446\u0438\u044F (Ls)
|
||||
vEditor.text.services=\u0421\u0435\u0440\u0432\u0438\u0441\u044B
|
||||
|
||||
# paths.fxml
|
||||
paths.title=\u0414\u043E\u0441\u0442\u0443\u043F\u043D\u044B\u0435 \u043C\u0430\u0440\u0448\u0440\u0443\u0442\u044B
|
||||
@@ -115,3 +119,7 @@ settings.performance=\u041F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u0438\u044
|
||||
settings.performance.segmentSize=\u041C\u0430\u0440\u0448\u0440\u0443\u0442\u043E\u0432 \u0432 \u0441\u0435\u0433\u043C\u0435\u043D\u0442\u0435 (0 - \u0430\u0432\u0442\u043E):
|
||||
settings.performance.limit=\u041A\u043E\u043B-\u0432\u043E \u043C\u0430\u0440\u0448\u0440\u0443\u0442\u043E\u0432 \u043D\u0430 \u0432\u044B\u0432\u043E\u0434:
|
||||
|
||||
# sEditor.fxml
|
||||
sEditor.title=\u0420\u0435\u0434\u0430\u043A\u0442\u043E\u0440 \u0437\u0432\u0435\u0437\u0434\u043D\u044B\u0445 \u0441\u0438\u0441\u0442\u0435\u043C
|
||||
sEditor.text.orientates=\u041E\u0440\u0438\u0435\u043D\u0442\u0438\u0440\u044B:
|
||||
sEditor.table.distance=\u0414\u0438\u0441\u0442\u0430\u043D\u0446\u0438\u044F (LY)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<ColumnConstraints fillWidth="true"/>
|
||||
</columnConstraints>
|
||||
|
||||
<TitledPane GridPane.rowSpan="2" text="%market.systems" minWidth="250" prefHeight="510" collapsible="false">
|
||||
<TitledPane GridPane.rowSpan="3" text="%market.systems" minWidth="250" prefHeight="530" collapsible="false">
|
||||
<ListView fx:id="systems">
|
||||
<contextMenu>
|
||||
<ContextMenu>
|
||||
@@ -38,7 +38,23 @@
|
||||
<TitledPane GridPane.columnIndex="1" text="%market.stations" maxHeight="60" collapsible="false">
|
||||
<SegmentedButton fx:id="stationsBar" />
|
||||
</TitledPane>
|
||||
<Accordion GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
|
||||
<TitledPane GridPane.rowIndex="1" GridPane.columnIndex="1" text="" maxHeight="60" collapsible="false">
|
||||
<HBox spacing="4">
|
||||
<Label text="%offers.text.distance"/>
|
||||
<Label fx:id="distance" minWidth="60"/>
|
||||
<Label text="%offers.text.services"/>
|
||||
<HBox spacing="20">
|
||||
<CheckBox fx:id="cbMarket" text="%services.MARKET"/>
|
||||
<CheckBox fx:id="cbBlackMarket" text="%services.BLACK_MARKET"/>
|
||||
<CheckBox fx:id="cbRepair" text="%services.REPAIR"/>
|
||||
<CheckBox fx:id="cbMunition" text="%services.MUNITION"/>
|
||||
<CheckBox fx:id="cbOutfit" text="%services.OUTFIT"/>
|
||||
<CheckBox fx:id="cbShipyard" text="%services.SHIPYARD"/>
|
||||
</HBox>
|
||||
</HBox>
|
||||
|
||||
</TitledPane>
|
||||
<Accordion GridPane.rowIndex="2" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS" GridPane.vgrow="ALWAYS">
|
||||
<panes>
|
||||
<TitledPane fx:id="paneSells" animated="false" text="%offers.pane.sell">
|
||||
<TableView fx:id="tblSell" editable="true">
|
||||
|
||||
75
client/src/main/resources/view/sEditor.fxml
Normal file
75
client/src/main/resources/view/sEditor.fxml
Normal file
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<?import javafx.scene.control.cell.PropertyValueFactory?>
|
||||
<?import ru.trader.view.support.cells.PriceCellImpl?>
|
||||
<?import ru.trader.view.support.cells.OfferCellValueImpl?>
|
||||
|
||||
<?import ru.trader.view.support.cells.DoubleCell?>
|
||||
<?import org.controlsfx.glyphfont.Glyph?>
|
||||
<?import org.controlsfx.control.SegmentedButton?>
|
||||
<GridPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="ru.trader.controllers.SystemsEditorController" styleClass="dialog"
|
||||
hgap="10" vgap="5" prefHeight="400">
|
||||
|
||||
<columnConstraints>
|
||||
<ColumnConstraints />
|
||||
<ColumnConstraints minWidth="180" />
|
||||
<ColumnConstraints minWidth="180" />
|
||||
<ColumnConstraints minWidth="180" />
|
||||
</columnConstraints>
|
||||
|
||||
<Label text="%sEditor.text.orientates" prefWidth="170" GridPane.rowSpan="2"/>
|
||||
<ComboBox fx:id="system1" prefWidth="160" GridPane.columnIndex="1" />
|
||||
<ComboBox fx:id="system2" prefWidth="160" GridPane.columnIndex="2" />
|
||||
<ComboBox fx:id="system3" prefWidth="160" GridPane.columnIndex="3" />
|
||||
<ComboBox fx:id="system4" prefWidth="160" GridPane.rowIndex="1" GridPane.columnIndex="1" />
|
||||
<ComboBox fx:id="system5" prefWidth="160" GridPane.rowIndex="1" GridPane.columnIndex="2" />
|
||||
<ComboBox fx:id="system6" prefWidth="160" GridPane.rowIndex="1" GridPane.columnIndex="3" />
|
||||
|
||||
<TableView fx:id="tblSystems" editable="true" prefWidth="725.0" GridPane.rowIndex="2" GridPane.columnSpan="4">
|
||||
<columns>
|
||||
<TableColumn fx:id="clnName" minWidth="180.0" text="%market.systems">
|
||||
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="clnX" minWidth="60.0" text="x">
|
||||
<cellValueFactory><PropertyValueFactory property="x"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="clnY" minWidth="60.0" text="y">
|
||||
<cellValueFactory><PropertyValueFactory property="y"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="clnZ" minWidth="60.0" text="z">
|
||||
<cellValueFactory><PropertyValueFactory property="z"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn text="%sEditor.table.distance">
|
||||
<columns>
|
||||
<TableColumn fx:id="clnS1" minWidth="60.0" text="">
|
||||
<cellValueFactory><PropertyValueFactory property="s1"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="clnS2" minWidth="60.0" text="">
|
||||
<cellValueFactory><PropertyValueFactory property="s2"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="clnS3" minWidth="60.0" text="">
|
||||
<cellValueFactory><PropertyValueFactory property="s3"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="clnS4" minWidth="60.0" text="">
|
||||
<cellValueFactory><PropertyValueFactory property="s4"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="clnS5" minWidth="60.0" text="">
|
||||
<cellValueFactory><PropertyValueFactory property="s5"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="clnS6" minWidth="60.0" text="">
|
||||
<cellValueFactory><PropertyValueFactory property="s6"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
</columns>
|
||||
</TableColumn>
|
||||
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
</GridPane>
|
||||
@@ -14,13 +14,22 @@
|
||||
vgap="10" hgap="4">
|
||||
<fx:define><Insets fx:id="hbox_margin" left="10" /></fx:define>
|
||||
<TextField fx:id="name" GridPane.columnSpan="2" alignment="CENTER" />
|
||||
<HBox GridPane.rowIndex="1" GridPane.columnIndex="1" spacing="4" alignment="BASELINE_CENTER">
|
||||
<Label text="x:" HBox.margin="$hbox_margin" />
|
||||
<NumberField fx:id="x" prefWidth="60" />
|
||||
<Label text="z:" HBox.margin="$hbox_margin" />
|
||||
<NumberField fx:id="z" prefWidth="60" />
|
||||
<Label text="y:" HBox.margin="$hbox_margin" />
|
||||
<NumberField fx:id="y" prefWidth="60" />
|
||||
<HBox GridPane.rowIndex="1" GridPane.columnIndex="1" spacing="4">
|
||||
<VBox prefWidth="200" alignment="CENTER">
|
||||
<Label text="%vEditor.text.distance"/>
|
||||
<NumberField fx:id="distance" maxWidth="60" />
|
||||
</VBox>
|
||||
<VBox HBox.hgrow="ALWAYS" alignment="CENTER">
|
||||
<Label text="%vEditor.text.services"/>
|
||||
<TilePane hgap="5" vgap="5" maxWidth="320" tileAlignment="BASELINE_LEFT">
|
||||
<CheckBox fx:id="cbMarket" text="%services.MARKET"/>
|
||||
<CheckBox fx:id="cbBlackMarket" text="%services.BLACK_MARKET"/>
|
||||
<CheckBox fx:id="cbRepair" text="%services.REPAIR"/>
|
||||
<CheckBox fx:id="cbMunition" text="%services.MUNITION"/>
|
||||
<CheckBox fx:id="cbOutfit" text="%services.OUTFIT"/>
|
||||
<CheckBox fx:id="cbShipyard" text="%services.SHIPYARD"/>
|
||||
</TilePane>
|
||||
</VBox>
|
||||
</HBox>
|
||||
<VBox GridPane.rowIndex="2" alignment="CENTER" spacing="10">
|
||||
<Button prefWidth="30" onAction="#up"><graphic><Glyph text="FontAwesome|ARROW_UP"/></graphic></Button>
|
||||
@@ -28,7 +37,7 @@
|
||||
<Button prefWidth="30" onAction="#add"><graphic><Glyph text="FontAwesome|PLUS"/></graphic></Button>
|
||||
<Button prefWidth="30" onAction="#updateFromEMDN"><graphic><Glyph text="FontAwesome|REFRESH"/></graphic></Button>
|
||||
</VBox>
|
||||
<TableView fx:id="items" prefWidth="395.0" editable="true" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<TableView fx:id="items" prefWidth="575" editable="true" GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<columns>
|
||||
<TableColumn minWidth="200.0" text="%market.item.name" editable="false">
|
||||
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
||||
@@ -39,6 +48,12 @@
|
||||
<TableColumn fx:id="sell" minWidth="90.0" text="%market.offer.buy">
|
||||
<cellValueFactory><PropertyValueFactory property="sprice"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="demand" minWidth="90.0" text="%market.offer.demand">
|
||||
<cellValueFactory><PropertyValueFactory property="demand"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="supply" minWidth="90.0" text="%market.offer.supply">
|
||||
<cellValueFactory><PropertyValueFactory property="supply"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
</columns>
|
||||
</TableView>
|
||||
</GridPane>
|
||||
|
||||
Reference in New Issue
Block a user