use of com.almuradev.almura.shared.item.VanillaStack in project Almura by AlmuraDev.
the class StoreListScreen method listOrModify.
private void listOrModify() {
if (!this.buttonList.isEnabled()) {
return;
}
// Check if there are any valid combinations
final boolean isBuyValid = !this.buyQtyTextBox.getText().isEmpty() && !this.buyPricePerTextBox.getText().isEmpty();
final boolean isSellValid = !this.sellQtyTextBox.getText().isEmpty() && !this.sellPricePerTextBox.getText().isEmpty();
if (isBuyValid) {
// We're modifying an existing listing
if (this.toModifyBuy != null) {
final int newBuyQuantity = Integer.valueOf(this.buyQtyTextBox.getText());
storeManager.requestModifyBuyingItem(this.store.getId(), this.toModifyBuy.getRecord(), newBuyQuantity, 0, new BigDecimal(this.buyPricePerTextBox.getText()));
} else {
// We're adding a new listing
final VanillaStack toListBuy = new BasicVanillaStack(this.toList);
toListBuy.setQuantity(Integer.valueOf(this.buyQtyTextBox.getText()));
storeManager.requestListBuyingItem(this.store.getId(), toListBuy, 0, new BigDecimal(this.buyPricePerTextBox.getText()));
}
} else if (this.toModifyBuy != null) {
// We're unlisting an existing listing
storeManager.requestDelistBuyingItem(this.store.getId(), this.toModifyBuy.getRecord());
}
if (isSellValid) {
// We're modifying an existing listing
if (this.toModifySell != null) {
final int newQuantity = Integer.valueOf(this.sellQtyTextBox.getText());
storeManager.requestModifySellingItem(this.store.getId(), this.toModifySell.getRecord(), newQuantity, 0, new BigDecimal(this.sellPricePerTextBox.getText()));
} else {
// We're adding a new listing
final VanillaStack toListSell = new BasicVanillaStack(this.toList);
toListSell.setQuantity(Integer.valueOf(this.sellQtyTextBox.getText()));
storeManager.requestListSellingItem(this.store.getId(), toListSell, 0, new BigDecimal(this.sellPricePerTextBox.getText()));
}
} else if (this.toModifySell != null) {
// We're unlisting an existing listing
storeManager.requestDelistSellingItem(this.store.getId(), this.toModifySell.getRecord());
}
((StoreScreen) this.parent).refresh(true);
this.close();
}
Aggregations