add offer type to search page
This commit is contained in:
@@ -9,6 +9,7 @@ import javafx.util.StringConverter;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import ru.trader.core.MarketFilter;
|
import ru.trader.core.MarketFilter;
|
||||||
|
import ru.trader.core.OFFER_TYPE;
|
||||||
import ru.trader.core.SERVICE_TYPE;
|
import ru.trader.core.SERVICE_TYPE;
|
||||||
import ru.trader.model.*;
|
import ru.trader.model.*;
|
||||||
import ru.trader.model.support.BindingsHelper;
|
import ru.trader.model.support.BindingsHelper;
|
||||||
@@ -26,6 +27,10 @@ public class SearchController {
|
|||||||
@FXML
|
@FXML
|
||||||
private ComboBox<SystemModel> source;
|
private ComboBox<SystemModel> source;
|
||||||
@FXML
|
@FXML
|
||||||
|
private RadioButton rbSeller;
|
||||||
|
@FXML
|
||||||
|
private RadioButton rbBuyer;
|
||||||
|
@FXML
|
||||||
private ComboBox<ItemModel> items;
|
private ComboBox<ItemModel> items;
|
||||||
@FXML
|
@FXML
|
||||||
private NumberField distance;
|
private NumberField distance;
|
||||||
@@ -50,11 +55,17 @@ public class SearchController {
|
|||||||
|
|
||||||
private final List<ResultEntry> results = FXCollections.observableArrayList();
|
private final List<ResultEntry> results = FXCollections.observableArrayList();
|
||||||
private final ObservableList<ItemModel> itemsList = FXCollections.observableArrayList();
|
private final ObservableList<ItemModel> itemsList = FXCollections.observableArrayList();
|
||||||
|
private final ToggleGroup offerType = new ToggleGroup();
|
||||||
|
|
||||||
private MarketModel market;
|
private MarketModel market;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
|
rbBuyer.setToggleGroup(offerType);
|
||||||
|
rbBuyer.setUserData(OFFER_TYPE.BUY);
|
||||||
|
rbSeller.setToggleGroup(offerType);
|
||||||
|
rbSeller.setUserData(OFFER_TYPE.SELL);
|
||||||
|
rbSeller.setSelected(true);
|
||||||
items.setCellFactory(new CustomListCell<>(ItemModel::getName));
|
items.setCellFactory(new CustomListCell<>(ItemModel::getName));
|
||||||
items.setConverter(new StringConverter<ItemModel>() {
|
items.setConverter(new StringConverter<ItemModel>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -108,7 +119,8 @@ public class SearchController {
|
|||||||
Collection<StationModel> stations = market.getStations(filter);
|
Collection<StationModel> stations = market.getStations(filter);
|
||||||
fill(stations);
|
fill(stations);
|
||||||
} else {
|
} else {
|
||||||
Collection<OfferModel> offers = market.getOffers(item, filter);
|
OFFER_TYPE oType = (OFFER_TYPE) offerType.getSelectedToggle().getUserData();
|
||||||
|
Collection<OfferModel> offers = market.getOffers(oType, item, filter);
|
||||||
fill(offers);
|
fill(offers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ public class MarketModel {
|
|||||||
return market.getStat(type, item);
|
return market.getStat(type, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableList<OfferModel> getOffers(ItemModel item, MarketFilter filter){
|
public ObservableList<OfferModel> getOffers(OFFER_TYPE offerType, ItemModel item, MarketFilter filter){
|
||||||
return BindingsHelper.observableList(analyzer.getOffers(item.getItem(), filter), modeler::get);
|
return BindingsHelper.observableList(analyzer.getOffers(offerType, item.getItem(), filter), modeler::get);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<StationModel> getStations(MarketFilter filter){
|
public Collection<StationModel> getStations(MarketFilter filter){
|
||||||
|
|||||||
@@ -26,12 +26,16 @@
|
|||||||
</columnConstraints>
|
</columnConstraints>
|
||||||
<Label text="%search.text.from" />
|
<Label text="%search.text.from" />
|
||||||
<ComboBox fx:id="source" prefWidth="150" GridPane.columnIndex="1" />
|
<ComboBox fx:id="source" prefWidth="150" GridPane.columnIndex="1" />
|
||||||
<Label text="%search.text.item" GridPane.rowIndex="1"/>
|
<HBox GridPane.columnSpan="2" GridPane.rowIndex="1" spacing="10" alignment="BOTTOM_CENTER">
|
||||||
<ComboBox fx:id="items" prefWidth="150" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
<RadioButton fx:id="rbSeller" text="%market.order.seller"/>
|
||||||
<Label text="%search.text.distance" GridPane.rowIndex="2" />
|
<RadioButton fx:id="rbBuyer" text="%market.order.buyer" />
|
||||||
<NumberField fx:id="distance" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
</HBox>
|
||||||
<Label text="%filter.services" GridPane.rowIndex="3" />
|
<Label text="%search.text.item" GridPane.rowIndex="2"/>
|
||||||
<TilePane hgap="5" vgap="5" tileAlignment="BASELINE_LEFT" GridPane.columnSpan="2" GridPane.rowIndex="4" >
|
<ComboBox fx:id="items" prefWidth="150" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||||
|
<Label text="%search.text.distance" GridPane.rowIndex="3" />
|
||||||
|
<NumberField fx:id="distance" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||||
|
<Label text="%filter.services" GridPane.rowIndex="4" />
|
||||||
|
<TilePane hgap="5" vgap="5" tileAlignment="BASELINE_LEFT" GridPane.columnSpan="2" GridPane.rowIndex="5" >
|
||||||
<CheckBox fx:id="cbMarket" text="%services.MARKET"/>
|
<CheckBox fx:id="cbMarket" text="%services.MARKET"/>
|
||||||
<CheckBox fx:id="cbBlackMarket" text="%services.BLACK_MARKET"/>
|
<CheckBox fx:id="cbBlackMarket" text="%services.BLACK_MARKET"/>
|
||||||
<CheckBox fx:id="cbRepair" text="%services.REPAIR"/>
|
<CheckBox fx:id="cbRepair" text="%services.REPAIR"/>
|
||||||
@@ -41,8 +45,8 @@
|
|||||||
<CheckBox fx:id="cbMediumLandpad" text="%services.MEDIUM_LANDPAD"/>
|
<CheckBox fx:id="cbMediumLandpad" text="%services.MEDIUM_LANDPAD"/>
|
||||||
<CheckBox fx:id="cbLargeLandpad" text="%services.LARGE_LANDPAD"/>
|
<CheckBox fx:id="cbLargeLandpad" text="%services.LARGE_LANDPAD"/>
|
||||||
</TilePane>
|
</TilePane>
|
||||||
<Separator GridPane.columnSpan="2" GridPane.rowIndex="5" GridPane.margin="$separator_margin"/>
|
<Separator GridPane.columnSpan="2" GridPane.rowIndex="6" GridPane.margin="$separator_margin"/>
|
||||||
<HBox GridPane.columnSpan="2" GridPane.rowIndex="6" spacing="10" alignment="CENTER">
|
<HBox GridPane.columnSpan="2" GridPane.rowIndex="7" spacing="10" alignment="CENTER">
|
||||||
<Button text="%search.button.find" onAction="#searchStations" />
|
<Button text="%search.button.find" onAction="#searchStations" />
|
||||||
</HBox>
|
</HBox>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ public interface Market {
|
|||||||
return getStatBuy(item).getOffers();
|
return getStatBuy(item).getOffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Collection<Offer> getOffers(OFFER_TYPE offerType, Item item){
|
||||||
|
return getStat(offerType, item).getOffers();
|
||||||
|
}
|
||||||
|
|
||||||
default void add(Market market){
|
default void add(Market market){
|
||||||
// add groups
|
// add groups
|
||||||
Collection<Group> groups = market.getGroups();
|
Collection<Group> groups = market.getGroups();
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ public class MarketAnalyzer {
|
|||||||
this.limit = count;
|
this.limit = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<Offer> getOffers(Item item, MarketFilter filter){
|
public Collection<Offer> getOffers(OFFER_TYPE offerType, Item item, MarketFilter filter){
|
||||||
Collection<Offer> offers = market.getSell(item);
|
Collection<Offer> offers = market.getOffers(offerType, item);
|
||||||
Collection<Offer> res = new ArrayList<>(offers.size());
|
Collection<Offer> res = new ArrayList<>(offers.size());
|
||||||
callback.setMax(offers.size());
|
callback.setMax(offers.size());
|
||||||
for (Offer offer : offers) {
|
for (Offer offer : offers) {
|
||||||
|
|||||||
Reference in New Issue
Block a user