use of jgnash.engine.SecurityNode in project jgnash by ccavanaugh.
the class CreateModifySecuritiesController method handleApplyAction.
@FXML
private void handleApplyAction() {
// always ensure a positive scale is entered
if (scaleTextField.getInteger() <= 0) {
scaleTextField.setInteger((int) reportedCurrencyComboBox.getValue().getScale());
}
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
final SecurityNode newNode = buildSecurityNode();
if (selectedSecurityNode.get() != null) {
if (!engine.updateCommodity(selectedSecurityNode.get(), newNode)) {
StaticUIMethods.displayError(ResourceUtils.getString("Message.Error.SecurityUpdate", newNode.getSymbol()));
}
} else {
if (!engine.addSecurity(newNode)) {
StaticUIMethods.displayError(ResourceUtils.getString("Message.Error.SecurityAdd", newNode.getSymbol()));
}
}
clearForm();
}
use of jgnash.engine.SecurityNode in project jgnash by ccavanaugh.
the class CreateModifySecuritiesController method buildSecurityNode.
private SecurityNode buildSecurityNode() {
final SecurityNode node = new SecurityNode(reportedCurrencyComboBox.getValue());
node.setDescription(descriptionTextField.getText());
node.setScale(scaleTextField.getInteger().byteValue());
node.setSymbol(symbolTextField.getText().trim());
node.setISIN(cusipTextField.getText());
node.setQuoteSource(quoteSourceComboBox.getValue());
return node;
}
use of jgnash.engine.SecurityNode in project jgnash by ccavanaugh.
the class CreateModifySecuritiesController method loadForm.
private void loadForm() {
if (selectedSecurityNode.get() != null) {
final SecurityNode node = selectedSecurityNode.get();
symbolTextField.setText(node.getSymbol());
cusipTextField.setText(node.getISIN().trim());
descriptionTextField.setText(node.getDescription());
scaleTextField.setInteger((int) node.getScale());
reportedCurrencyComboBox.setValue(node.getReportedCurrencyNode());
quoteSourceComboBox.setValue(node.getQuoteSource());
}
}
use of jgnash.engine.SecurityNode in project jgnash by ccavanaugh.
the class CreateModifySecuritiesController method loadList.
private void loadList() {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
final List<SecurityNode> securityNodeList = engine.getSecurities();
JavaFXUtils.runLater(() -> {
listView.getItems().setAll(securityNodeList);
FXCollections.sort(listView.getItems());
clearForm();
});
}
use of jgnash.engine.SecurityNode in project jgnash by ccavanaugh.
the class SecurityComboBox method loadModel.
private void loadModel() {
final Collection<SecurityNode> securityNodes;
if (account.get() != null) {
items.clear();
securityNodes = account.get().getSecurities();
} else {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
securityNodes = engine.getSecurities();
}
if (!securityNodes.isEmpty()) {
final List<SecurityNode> sortedNodeList = new ArrayList<>(securityNodes);
Collections.sort(sortedNodeList);
items.addAll(sortedNodeList);
getSelectionModel().select(0);
}
}
Aggregations