remove don't used controllers
This commit is contained in:
@@ -91,8 +91,6 @@ public class Main extends Application {
|
||||
private static void loadResources() throws IOException {
|
||||
Screeners.loadItemDescStage(getUrl(("itemDesc.fxml")));
|
||||
Screeners.loadVEditorStage(getUrl(("vEditor.fxml")));
|
||||
Screeners.loadAddOfferStage(getUrl(("oEditor.fxml")));
|
||||
Screeners.loadOrdersStage(getUrl(("orders.fxml")));
|
||||
Screeners.loadTopOrdersStage(getUrl(("topOrders.fxml")));
|
||||
Screeners.loadPathsStage(getUrl(("paths.fxml")));
|
||||
Screeners.loadSettingsStage(getUrl(("settings.fxml")));
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package ru.trader.controllers;
|
||||
|
||||
public class ItemEditorController {
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package ru.trader.controllers;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Label;
|
||||
import org.controlsfx.control.ButtonBar;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.controlsfx.dialog.DialogAction;
|
||||
import ru.trader.model.ItemModel;
|
||||
import ru.trader.view.support.NumberField;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class OffersEditorController {
|
||||
private final Action OK = new DialogAction("OK", ButtonBar.ButtonType.OK_DONE, false, true, false);
|
||||
|
||||
|
||||
@FXML
|
||||
private Label name;
|
||||
|
||||
@FXML
|
||||
private NumberField sell;
|
||||
|
||||
@FXML
|
||||
private NumberField buy;
|
||||
|
||||
|
||||
public Optional<DialogResult> showDialog(Parent parent, Parent content, ItemModel item, Number sell, Number buy) {
|
||||
name.setText(item.getName());
|
||||
|
||||
this.sell.setValue(sell);
|
||||
this.buy.setValue(buy);
|
||||
|
||||
OK.disabledProperty().bind(this.sell.wrongProperty().or(this.buy.wrongProperty()));
|
||||
|
||||
Dialog dlg = new Dialog(parent, "Создание заказов");
|
||||
dlg.setContent(content);
|
||||
dlg.getActions().addAll(OK, Dialog.ACTION_CANCEL);
|
||||
dlg.setResizable(false);
|
||||
return Optional.ofNullable(dlg.show() == OK ? new DialogResult() : null);
|
||||
}
|
||||
|
||||
|
||||
public class DialogResult {
|
||||
|
||||
private double _sell;
|
||||
private double _buy;
|
||||
|
||||
public DialogResult() {
|
||||
_sell = sell.getValue().doubleValue();
|
||||
_buy = buy.getValue().doubleValue();
|
||||
}
|
||||
|
||||
public double getSell() {
|
||||
return _sell;
|
||||
}
|
||||
|
||||
public double getBuy() {
|
||||
return _buy;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package ru.trader.controllers;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
import javafx.util.converter.LongStringConverter;
|
||||
import org.controlsfx.control.ButtonBar;
|
||||
import org.controlsfx.control.action.Action;
|
||||
import org.controlsfx.dialog.Dialog;
|
||||
import org.controlsfx.dialog.DialogAction;
|
||||
import ru.trader.model.OfferModel;
|
||||
import ru.trader.model.OrderModel;
|
||||
import ru.trader.model.support.BindingsHelper;
|
||||
import ru.trader.view.support.Localization;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class OrdersController {
|
||||
private final Action OK = new DialogAction("OK", ButtonBar.ButtonType.OK_DONE, false, true, false);
|
||||
|
||||
@FXML
|
||||
private TableView<OrderModel> tblOrders;
|
||||
|
||||
@FXML
|
||||
private TableView<OfferModel> tblBuyers;
|
||||
|
||||
@FXML
|
||||
private TableColumn<OrderModel, Long> count;
|
||||
|
||||
@FXML
|
||||
private TableColumn<OrderModel, Long> maxCount;
|
||||
|
||||
@FXML
|
||||
private TableColumn<OfferModel, Number> curProfit;
|
||||
|
||||
@FXML
|
||||
private TableColumn<OfferModel, Double> curDistance;
|
||||
|
||||
private final List<OrderModel> orders = FXCollections.observableArrayList();
|
||||
private final List<OfferModel> buyers = FXCollections.observableArrayList();
|
||||
private OrderModel order;
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
count.setCellFactory(TextFieldTableCell.forTableColumn(new LongStringConverter()));
|
||||
maxCount.setCellFactory(TextFieldTableCell.forTableColumn(new LongStringConverter()));
|
||||
tblOrders.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> changeOrder(n));
|
||||
tblBuyers.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> setBuyer(n));
|
||||
curProfit.setCellValueFactory(param -> {
|
||||
OfferModel offer = param.getValue();
|
||||
return order !=null ? order.getProfit(offer) : new SimpleDoubleProperty(Double.NaN);
|
||||
});
|
||||
curDistance.setCellValueFactory(param -> {
|
||||
OfferModel offer = param.getValue();
|
||||
return new SimpleDoubleProperty(order !=null ? order.getStation().getDistance(offer.getStation()) :Double.NaN).asObject();
|
||||
});
|
||||
BindingsHelper.setTableViewItems(tblOrders, orders);
|
||||
BindingsHelper.setTableViewItems(tblBuyers, buyers);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Collection<OrderModel> showDialog(Parent parent, Parent content, Collection<OfferModel> offers, double balance, long max) {
|
||||
|
||||
init(offers, balance, max);
|
||||
|
||||
Dialog dlg = new Dialog(parent, Localization.getString("orders.title"));
|
||||
dlg.setContent(content);
|
||||
dlg.getActions().addAll(OK, Dialog.ACTION_CANCEL);
|
||||
dlg.setResizable(false);
|
||||
Collection<OrderModel> res = dlg.show() == OK ? getOrders() : null;
|
||||
orders.clear();
|
||||
return res;
|
||||
}
|
||||
|
||||
private List<OrderModel> getOrders() {
|
||||
return orders.stream().filter(o -> o.getCount() > 0 && o.getBuyOffer() != null).collect(toList());
|
||||
}
|
||||
|
||||
private void init(Collection<OfferModel> offers, double balance, long max) {
|
||||
orders.clear();
|
||||
offers.forEach(o -> orders.add(new OrderModel(o, balance, max)));
|
||||
}
|
||||
|
||||
private void changeOrder(OrderModel order) {
|
||||
this.order = order;
|
||||
buyers.clear();
|
||||
if (order != null) buyers.addAll(order.getBuyers());
|
||||
tblBuyers.getSelectionModel().clearSelection();
|
||||
}
|
||||
|
||||
private void setBuyer(OfferModel offer) {
|
||||
if (order != null && offer!=null) {
|
||||
order.setBuyOffer(offer);
|
||||
order.setCount(order.getMax());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,19 +81,12 @@ dialog.group.type=Type:
|
||||
itemDesc.sellers=Sellers:
|
||||
itemDesc.buyers=Buyers:
|
||||
|
||||
# oEditor.fxml
|
||||
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
|
||||
|
||||
# orders.fxml
|
||||
orders.title=Create orders
|
||||
|
||||
# topOrders.fxml
|
||||
topOrders.title=TOP orders
|
||||
|
||||
|
||||
@@ -82,19 +82,12 @@ dialog.group.type=\u0422\u0438\u043F:
|
||||
itemDesc.sellers=\u041F\u0440\u043E\u0434\u0430\u0432\u0446\u044B:
|
||||
itemDesc.buyers=\u041F\u043E\u043A\u0443\u043F\u0430\u0442\u0435\u043B\u0438:
|
||||
|
||||
# oEditor.fxml
|
||||
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
|
||||
|
||||
# orders.fxml
|
||||
orders.title=\u0421\u043E\u0437\u0434\u0430\u043D\u0438\u0435 \u0437\u0430\u043A\u0430\u0437\u043E\u0432
|
||||
|
||||
# topOrders.fxml
|
||||
topOrders.title=TOP \u0437\u0430\u043A\u0430\u0437\u043E\u0432
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<?import ru.trader.view.support.NumberField?>
|
||||
<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="ru.trader.controllers.OffersEditorController">
|
||||
<Label fx:id="name"/>
|
||||
<HBox>
|
||||
<Label text="%oEditor.sell"/>
|
||||
<NumberField fx:id="sell"/>
|
||||
<Label text="%oEditor.buy"/>
|
||||
<NumberField fx:id="buy"/>
|
||||
</HBox>
|
||||
</VBox>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.cell.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
|
||||
|
||||
<?import ru.trader.view.support.cells.DoubleCell?>
|
||||
|
||||
<?import ru.trader.view.support.cells.OfferCellValueImpl?>
|
||||
<?import ru.trader.view.support.cells.OfferTableCell?>
|
||||
<?import ru.trader.view.support.cells.DistanceCell?>
|
||||
<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="ru.trader.controllers.OrdersController" styleClass="dialog"
|
||||
prefWidth="1010">
|
||||
<TableView fx:id="tblOrders" editable="true">
|
||||
<columns>
|
||||
<TableColumn minWidth="160.0" text="%market.item.name">
|
||||
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn minWidth="60.0" text="%market.offer.price">
|
||||
<cellFactory><DoubleCell/></cellFactory>
|
||||
<cellValueFactory><PropertyValueFactory property="price"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="count" minWidth="60.0" prefWidth="60.0" text="%market.order.count">
|
||||
<cellValueFactory><PropertyValueFactory property="count"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn minWidth="160.0" text="%market.order.buyer">
|
||||
<cellValueFactory><OfferCellValueImpl property="buyOffer"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn minWidth="80.0" text="%market.order.profit">
|
||||
<cellFactory><DoubleCell/></cellFactory>
|
||||
<cellValueFactory><PropertyValueFactory property="profit"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
|
||||
<TableColumn resizable="false" text="%market.offer.max.full">
|
||||
<columns>
|
||||
<TableColumn fx:id="maxCount" minWidth="60.0" prefWidth="60.0" text="%market.order.count">
|
||||
<cellValueFactory><PropertyValueFactory property="max"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="bestProfit" minWidth="80.0" text="%market.order.profit" sortType="DESCENDING">
|
||||
<cellFactory><DoubleCell/></cellFactory>
|
||||
<cellValueFactory><PropertyValueFactory property="bestProfit"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
</columns>
|
||||
</TableColumn>
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
|
||||
</columnResizePolicy>
|
||||
<sortOrder>
|
||||
<fx:reference source="bestProfit"/>
|
||||
</sortOrder>
|
||||
</TableView>
|
||||
<TableView fx:id="tblBuyers" minWidth="335">
|
||||
<columns>
|
||||
<TableColumn minWidth="160.0" text="%market.order.buyer">
|
||||
<cellFactory><OfferTableCell/></cellFactory>
|
||||
<cellValueFactory><PropertyValueFactory property="price"/></cellValueFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="curDistance" minWidth="80.0" text="%market.order.distance">
|
||||
<cellFactory><DistanceCell/></cellFactory>
|
||||
</TableColumn>
|
||||
<TableColumn fx:id="curProfit" minWidth="80.0" text="%market.order.profit" sortType="DESCENDING">
|
||||
<cellFactory><DoubleCell/></cellFactory>
|
||||
</TableColumn>
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="UNCONSTRAINED_RESIZE_POLICY"/>
|
||||
</columnResizePolicy>
|
||||
<sortOrder>
|
||||
<fx:reference source="curProfit"/>
|
||||
</sortOrder>
|
||||
</TableView>
|
||||
</HBox>
|
||||
Reference in New Issue
Block a user