Search in sources :

Example 96 with FXML

use of javafx.fxml.FXML in project jgnash by ccavanaugh.

the class RemoteConnectionDialogController method handleOkAction.

@FXML
private void handleOkAction() {
    result = true;
    final Preferences preferences = Preferences.userNodeForPackage(RemoteConnectionDialogController.class);
    preferences.put(LAST_HOST, hostTextField.getText());
    preferences.putInt(LAST_PORT, portTextField.getInteger());
    ((Stage) parent.get().getWindow()).close();
}
Also used : Stage(javafx.stage.Stage) Preferences(java.util.prefs.Preferences) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 97 with FXML

use of javafx.fxml.FXML in project jgnash by ccavanaugh.

the class AddRemoveCurrencyController method initialize.

@FXML
@SuppressWarnings("unchecked")
void initialize() {
    availableList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    selectedList.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    selectedList.setCellFactory(param -> new LockedCommodityListCell<>());
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    newCurrencyTextField.textProperty().addListener((observable, oldValue, newValue) -> validProperty.set(engine.getCurrency(newCurrencyTextField.getText()) == null));
    addButton.disableProperty().bind(newCurrencyTextField.textProperty().isEmpty().or(validProperty.not()));
    loadModel();
}
Also used : Engine(jgnash.engine.Engine) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 98 with FXML

use of javafx.fxml.FXML in project jgnash by ccavanaugh.

the class StartupShutdownTabController method initialize.

@FXML
private void initialize() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    backupCountSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1000, 1, 1));
    if (engine != null) {
        backupCountSpinner.getValueFactory().setValue(engine.getRetainedBackupLimit());
        createBackupsCheckBox.setSelected(engine.createBackups());
        removeOldBackupsCheckBox.setSelected(engine.removeOldBackups());
        backupCountSpinner.valueProperty().addListener((observable, oldValue, newValue) -> engine.setRetainedBackupLimit(newValue));
        createBackupsCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> engine.setCreateBackups(newValue));
        removeOldBackupsCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> engine.setRemoveOldBackups(newValue));
    } else {
        backupCountSpinner.setDisable(true);
        createBackupsCheckBox.setDisable(true);
        removeOldBackupsCheckBox.setDisable(true);
    }
    updateSecurities.setSelected(UpdateFactory.getUpdateOnStartup());
    updateCurrencies.setSelected(CurrencyUpdateFactory.getUpdateOnStartup());
    updateSecurities.selectedProperty().addListener((observable, oldValue, newValue) -> UpdateFactory.setUpdateOnStartup(newValue));
    updateCurrencies.selectedProperty().addListener((observable, oldValue, newValue) -> CurrencyUpdateFactory.setUpdateOnStartup(newValue));
    openLastCheckBox.selectedProperty().bindBidirectional(Options.openLastProperty());
    checkForUpdatesCheckBox.selectedProperty().bindBidirectional(Options.checkForUpdatesProperty());
}
Also used : Engine(jgnash.engine.Engine) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) FXML(javafx.fxml.FXML)

Example 99 with FXML

use of javafx.fxml.FXML 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();
}
Also used : SecurityNode(jgnash.engine.SecurityNode) Engine(jgnash.engine.Engine) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 100 with FXML

use of javafx.fxml.FXML in project jgnash by ccavanaugh.

the class AddRemoveCurrencyController method handleNewCurrencyAction.

@FXML
private void handleNewCurrencyAction() {
    final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
    Objects.requireNonNull(engine);
    final CurrencyNode node = DefaultCurrencies.buildCustomNode(newCurrencyTextField.getText());
    // the add could fail if the commodity symbol is a duplicate
    if (engine.addCurrency(node)) {
        selectedList.getItems().add(new LockedCommodityNode<>(node, false));
        FXCollections.sort(selectedList.getItems());
        newCurrencyTextField.clear();
    }
}
Also used : CurrencyNode(jgnash.engine.CurrencyNode) Engine(jgnash.engine.Engine) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Aggregations

FXML (javafx.fxml.FXML)251 Engine (jgnash.engine.Engine)46 InjectFXML (jgnash.uifx.util.InjectFXML)43 File (java.io.File)35 IOException (java.io.IOException)32 Stage (javafx.stage.Stage)30 List (java.util.List)23 ArrayList (java.util.ArrayList)22 Preferences (java.util.prefs.Preferences)18 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)18 FXCollections (javafx.collections.FXCollections)16 Button (javafx.scene.control.Button)16 LocalDate (java.time.LocalDate)15 Scene (javafx.scene.Scene)15 BigDecimal (java.math.BigDecimal)14 ObjectProperty (javafx.beans.property.ObjectProperty)14 ObservableList (javafx.collections.ObservableList)13 Node (javafx.scene.Node)13 CurrencyNode (jgnash.engine.CurrencyNode)13 HashMap (java.util.HashMap)12