- update item desc layout
- correct column size routers - add show item dec on click right button in orders
This commit is contained in:
@@ -24,6 +24,7 @@ public class Main extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
primaryStage.setTitle("Trader");
|
primaryStage.setTitle("Trader");
|
||||||
|
primaryStage.setMinHeight(590);
|
||||||
primaryStage.setScene(new Scene(Screeners.newScreeners(Main.class.getResource("/view/main.fxml"),getUrl("style.css").toExternalForm())));
|
primaryStage.setScene(new Scene(Screeners.newScreeners(Main.class.getResource("/view/main.fxml"),getUrl("style.css").toExternalForm())));
|
||||||
primaryStage.setOnCloseRequest((we)->{
|
primaryStage.setOnCloseRequest((we)->{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class ItemDescController {
|
|||||||
|
|
||||||
public void setItemDesc(ItemDescModel itemDesc){
|
public void setItemDesc(ItemDescModel itemDesc){
|
||||||
item = itemDesc;
|
item = itemDesc;
|
||||||
|
if (popup!=null) popup.setDetachedTitle(item.nameProperty().get());
|
||||||
fill();
|
fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ public class ItemDescController {
|
|||||||
if (popup != null && popup.isShowing()) return;
|
if (popup != null && popup.isShowing()) return;
|
||||||
if (popup == null) {
|
if (popup == null) {
|
||||||
popup = new PopOver(itemDescScreen);
|
popup = new PopOver(itemDescScreen);
|
||||||
popup.detach();
|
popup.setDetachedTitle(item.nameProperty().get());
|
||||||
popup.setAutoHide(true);
|
popup.setAutoHide(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package ru.trader.controllers;
|
|||||||
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.scene.input.MouseButton;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@@ -40,6 +41,23 @@ public class OffersController {
|
|||||||
vendors.getSelectionModel().select(oldValue);
|
vendors.getSelectionModel().select(oldValue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
tblSell.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
|
||||||
|
if (n!=null) Screeners.changeItemDesc(n);
|
||||||
|
});
|
||||||
|
tblBuy.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> {
|
||||||
|
if (n!=null) Screeners.changeItemDesc(n);
|
||||||
|
});
|
||||||
|
tblSell.setOnMouseClicked((e) -> {
|
||||||
|
if (e.getButton() == MouseButton.SECONDARY){
|
||||||
|
Screeners.showItemDesc(tblSell);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tblBuy.setOnMouseClicked((e) -> {
|
||||||
|
if (e.getButton() == MouseButton.SECONDARY){
|
||||||
|
Screeners.showItemDesc(tblBuy);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,17 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<?import ru.trader.view.support.cells.OfferListCell?>
|
<?import ru.trader.view.support.cells.OfferListCell?>
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="ru.trader.controllers.ItemDescController">
|
fx:controller="ru.trader.controllers.ItemDescController"
|
||||||
<Label text="Продавцы:"/>
|
spacing="4" >
|
||||||
|
<fx:define><Insets fx:id="vbox_margin" left="6" top="3" bottom="3"/></fx:define>
|
||||||
|
|
||||||
|
<Label text="Продавцы:" VBox.margin="$vbox_margin"/>
|
||||||
<ListView fx:id="seller" maxHeight="200.0">
|
<ListView fx:id="seller" maxHeight="200.0">
|
||||||
<cellFactory><OfferListCell/></cellFactory>
|
<cellFactory><OfferListCell/></cellFactory>
|
||||||
</ListView>
|
</ListView>
|
||||||
<Label text="Покупатели:"/>
|
<Label text="Покупатели:" VBox.margin="$vbox_margin"/>
|
||||||
<ListView fx:id="buyer" maxHeight="200.0">
|
<ListView fx:id="buyer" maxHeight="200.0">
|
||||||
<cellFactory><OfferListCell/></cellFactory>
|
<cellFactory><OfferListCell/></cellFactory>
|
||||||
</ListView>
|
</ListView>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<TitledPane fx:id="sells" animated="false" text="Продаваемые товары">
|
<TitledPane fx:id="sells" animated="false" text="Продаваемые товары">
|
||||||
<TableView fx:id="tblSell" editable="true">
|
<TableView fx:id="tblSell" editable="true">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn minWidth="235.0" text="Товар">
|
<TableColumn minWidth="230.0" text="Товар">
|
||||||
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn minWidth="110.0" resizable="false" text="Цена" onEditCommit="#editPrice">
|
<TableColumn minWidth="110.0" resizable="false" text="Цена" onEditCommit="#editPrice">
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
<TitledPane animated="false" text="Покупаемые товары">
|
<TitledPane animated="false" text="Покупаемые товары">
|
||||||
<TableView fx:id="tblBuy" editable="true">
|
<TableView fx:id="tblBuy" editable="true">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn minWidth="235.0" text="Товар">
|
<TableColumn minWidth="230.0" text="Товар">
|
||||||
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn minWidth="110.0" resizable="false" text="Цена" editable="true" onEditCommit="#editPrice">
|
<TableColumn minWidth="110.0" resizable="false" text="Цена" editable="true" onEditCommit="#editPrice">
|
||||||
|
|||||||
@@ -56,10 +56,10 @@
|
|||||||
</VBox>
|
</VBox>
|
||||||
<TableView fx:id="tblOrders" HBox.hgrow="ALWAYS">
|
<TableView fx:id="tblOrders" HBox.hgrow="ALWAYS">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn minWidth="235.0" text="Продавец">
|
<TableColumn minWidth="230.0" text="Продавец">
|
||||||
<cellValueFactory><PropertyValueFactory property="vendor"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="vendor"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn minWidth="235.0" text="Товар">
|
<TableColumn minWidth="230.0" text="Товар">
|
||||||
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
|
||||||
</TableColumn>
|
</TableColumn>
|
||||||
<TableColumn minWidth="80.0" text="Цена">
|
<TableColumn minWidth="80.0" text="Цена">
|
||||||
|
|||||||
@@ -14,6 +14,13 @@
|
|||||||
-fx-background-radius: 0, 0;
|
-fx-background-radius: 0, 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.list-view:focused {
|
||||||
|
-fx-background-color: -fx-box-border, -fx-control-inner-background;
|
||||||
|
-fx-background-insets: 0,1;
|
||||||
|
-fx-background-radius: 0, 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
HBox.fields-group {
|
HBox.fields-group {
|
||||||
-fx-spacing: 2;
|
-fx-spacing: 2;
|
||||||
-fx-padding: 5 10;
|
-fx-padding: 5 10;
|
||||||
|
|||||||
@@ -154,25 +154,25 @@ public abstract class MarketSupport implements Market {
|
|||||||
LOG.debug("Get top {}", limit);
|
LOG.debug("Get top {}", limit);
|
||||||
TreeSet<Order> top = new TreeSet<>();
|
TreeSet<Order> top = new TreeSet<>();
|
||||||
for (Vendor vendor : getVendors()) {
|
for (Vendor vendor : getVendors()) {
|
||||||
LOG.debug("Check vendor {}", vendor);
|
LOG.trace("Check vendor {}", vendor);
|
||||||
for (Offer sell : vendor.getAllSellOffers()) {
|
for (Offer sell : vendor.getAllSellOffers()) {
|
||||||
long count = Math.min(max, (long) Math.floor(balance / sell.getPrice()));
|
long count = Math.min(max, (long) Math.floor(balance / sell.getPrice()));
|
||||||
LOG.debug("Sell offer {}, count = {}", sell, count);
|
LOG.trace("Sell offer {}, count = {}", sell, count);
|
||||||
if (count == 0) continue;
|
if (count == 0) continue;
|
||||||
Iterator<Offer> buyers = getStatBuy(sell.getItem()).getOffers().descendingIterator();
|
Iterator<Offer> buyers = getStatBuy(sell.getItem()).getOffers().descendingIterator();
|
||||||
while (buyers.hasNext()){
|
while (buyers.hasNext()){
|
||||||
Offer buy = buyers.next();
|
Offer buy = buyers.next();
|
||||||
Order order = new Order(sell, buy, count);
|
Order order = new Order(sell, buy, count);
|
||||||
LOG.debug("Buy offer {} profit = {}", buy, order.getProfit());
|
LOG.trace("Buy offer {} profit = {}", buy, order.getProfit());
|
||||||
if (order.getProfit() <= 0 ) break;
|
if (order.getProfit() <= 0 ) break;
|
||||||
if (top.size() == limit){
|
if (top.size() == limit){
|
||||||
LOG.debug("Min order {}", top.first());
|
LOG.trace("Min order {}", top.first());
|
||||||
if (top.first().getProfit() < order.getProfit()) {
|
if (top.first().getProfit() < order.getProfit()) {
|
||||||
LOG.debug("Add to top");
|
LOG.debug("Add to top");
|
||||||
top.add(order);
|
top.add(order);
|
||||||
top.pollFirst();
|
top.pollFirst();
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Is low profit, skip");
|
LOG.trace("Is low profit, skip");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user