Archived
0

- update item desc layout

- correct column size routers
- add show item dec on click right  button in orders
This commit is contained in:
iMoHax
2014-08-06 12:42:32 +04:00
parent 3bee31638e
commit 3c253e2b45
8 changed files with 44 additions and 13 deletions

View File

@@ -24,6 +24,7 @@ public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Trader");
primaryStage.setMinHeight(590);
primaryStage.setScene(new Scene(Screeners.newScreeners(Main.class.getResource("/view/main.fxml"),getUrl("style.css").toExternalForm())));
primaryStage.setOnCloseRequest((we)->{
try {

View File

@@ -25,6 +25,7 @@ public class ItemDescController {
public void setItemDesc(ItemDescModel itemDesc){
item = itemDesc;
if (popup!=null) popup.setDetachedTitle(item.nameProperty().get());
fill();
}
@@ -39,7 +40,7 @@ public class ItemDescController {
if (popup != null && popup.isShowing()) return;
if (popup == null) {
popup = new PopOver(itemDescScreen);
popup.detach();
popup.setDetachedTitle(item.nameProperty().get());
popup.setAutoHide(true);
}

View File

@@ -2,6 +2,7 @@ package ru.trader.controllers;
import javafx.collections.FXCollections;
import javafx.scene.control.ListView;
import javafx.scene.input.MouseButton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javafx.fxml.FXML;
@@ -40,6 +41,23 @@ public class OffersController {
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();
}

View File

@@ -4,13 +4,17 @@
<?import javafx.scene.layout.*?>
<?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"
fx:controller="ru.trader.controllers.ItemDescController">
<Label text="Продавцы:"/>
fx:controller="ru.trader.controllers.ItemDescController"
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">
<cellFactory><OfferListCell/></cellFactory>
</ListView>
<Label text="Покупатели:"/>
<Label text="Покупатели:" VBox.margin="$vbox_margin"/>
<ListView fx:id="buyer" maxHeight="200.0">
<cellFactory><OfferListCell/></cellFactory>
</ListView>

View File

@@ -20,7 +20,7 @@
<TitledPane fx:id="sells" animated="false" text="Продаваемые товары">
<TableView fx:id="tblSell" editable="true">
<columns>
<TableColumn minWidth="235.0" text="Товар">
<TableColumn minWidth="230.0" text="Товар">
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
</TableColumn>
<TableColumn minWidth="110.0" resizable="false" text="Цена" onEditCommit="#editPrice">
@@ -57,7 +57,7 @@
<TitledPane animated="false" text="Покупаемые товары">
<TableView fx:id="tblBuy" editable="true">
<columns>
<TableColumn minWidth="235.0" text="Товар">
<TableColumn minWidth="230.0" text="Товар">
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
</TableColumn>
<TableColumn minWidth="110.0" resizable="false" text="Цена" editable="true" onEditCommit="#editPrice">

View File

@@ -56,10 +56,10 @@
</VBox>
<TableView fx:id="tblOrders" HBox.hgrow="ALWAYS">
<columns>
<TableColumn minWidth="235.0" text="Продавец">
<TableColumn minWidth="230.0" text="Продавец">
<cellValueFactory><PropertyValueFactory property="vendor"/></cellValueFactory>
</TableColumn>
<TableColumn minWidth="235.0" text="Товар">
<TableColumn minWidth="230.0" text="Товар">
<cellValueFactory><PropertyValueFactory property="name"/></cellValueFactory>
</TableColumn>
<TableColumn minWidth="80.0" text="Цена">

View File

@@ -14,6 +14,13 @@
-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 {
-fx-spacing: 2;
-fx-padding: 5 10;

View File

@@ -154,25 +154,25 @@ public abstract class MarketSupport implements Market {
LOG.debug("Get top {}", limit);
TreeSet<Order> top = new TreeSet<>();
for (Vendor vendor : getVendors()) {
LOG.debug("Check vendor {}", vendor);
LOG.trace("Check vendor {}", vendor);
for (Offer sell : vendor.getAllSellOffers()) {
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;
Iterator<Offer> buyers = getStatBuy(sell.getItem()).getOffers().descendingIterator();
while (buyers.hasNext()){
Offer buy = buyers.next();
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 (top.size() == limit){
LOG.debug("Min order {}", top.first());
LOG.trace("Min order {}", top.first());
if (top.first().getProfit() < order.getProfit()) {
LOG.debug("Add to top");
top.add(order);
top.pollFirst();
} else {
LOG.debug("Is low profit, skip");
LOG.trace("Is low profit, skip");
break;
}
} else {