Search in sources :

Example 1 with AccountComboBox

use of jgnash.uifx.control.AccountComboBox in project jgnash by ccavanaugh.

the class AccountBalanceChartController method trimAuxAccountCombos.

private void trimAuxAccountCombos() {
    final List<AccountComboBox> empty = auxAccountComboBoxList.stream().filter(accountComboBox -> accountComboBox.getValue() == NOP_ACCOUNT).collect(Collectors.toList());
    // Reverse order so we leave the last empty at the bottom
    Collections.reverse(empty);
    // work backwards through the list to avoid use of an iterator, and leave at least one empty account combo
    for (int i = empty.size() - 1; i > 0; i--) {
        final AccountComboBox accountComboBox = empty.get(i);
        accountComboVBox.getChildren().remove(accountComboBox);
        auxAccountComboBoxList.remove(accountComboBox);
        accountComboBox.valueProperty().removeListener(auxListener);
    }
}
Also used : Scene(javafx.scene.Scene) Engine(jgnash.engine.Engine) EngineFactory(jgnash.engine.EngineFactory) StackPane(javafx.scene.layout.StackPane) XYChart(javafx.scene.chart.XYChart) VBox(javafx.scene.layout.VBox) AccountComboBox(jgnash.uifx.control.AccountComboBox) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) EncodeDecode(jgnash.util.EncodeDecode) BigDecimal(java.math.BigDecimal) Nullable(jgnash.util.Nullable) ResourceBundle(java.util.ResourceBundle) ComboBox(javafx.scene.control.ComboBox) AccountType(jgnash.engine.AccountType) Tooltip(javafx.scene.control.Tooltip) CurrencyNode(jgnash.engine.CurrencyNode) DateUtils(jgnash.time.DateUtils) ObjectProperty(javafx.beans.property.ObjectProperty) InjectFXML(jgnash.uifx.util.InjectFXML) Collection(java.util.Collection) CheckBox(javafx.scene.control.CheckBox) BarChart(javafx.scene.chart.BarChart) Collectors(java.util.stream.Collectors) Preferences(java.util.prefs.Preferences) StoredObject(jgnash.engine.StoredObject) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) List(java.util.List) CommodityFormat(jgnash.text.CommodityFormat) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) RadioButton(javafx.scene.control.RadioButton) Account(jgnash.engine.Account) ReportPeriodUtils(jgnash.report.ReportPeriodUtils) ChangeListener(javafx.beans.value.ChangeListener) Collections(java.util.Collections) ReportPeriod(jgnash.report.ReportPeriod) DatePickerEx(jgnash.uifx.control.DatePickerEx) Options(jgnash.uifx.Options) AccountComboBox(jgnash.uifx.control.AccountComboBox)

Example 2 with AccountComboBox

use of jgnash.uifx.control.AccountComboBox in project jgnash by ccavanaugh.

the class AccountBalanceChartController method getSelectedAccounts.

private Collection<Account> getSelectedAccounts() {
    // Use a list for consistent sort order
    final List<Account> accountList = new ArrayList<>();
    accountList.add(accountComboBox.getValue());
    for (final AccountComboBox auxAccountComboBox : auxAccountComboBoxList) {
        final Account account = auxAccountComboBox.getValue();
        if (account != NOP_ACCOUNT && !accountList.contains(account)) {
            accountList.add(account);
        }
    }
    return accountList;
}
Also used : Account(jgnash.engine.Account) AccountComboBox(jgnash.uifx.control.AccountComboBox) ArrayList(java.util.ArrayList)

Example 3 with AccountComboBox

use of jgnash.uifx.control.AccountComboBox in project jgnash by ccavanaugh.

the class AccountBalanceChartController method addAuxAccountCombo.

private void addAuxAccountCombo(@Nullable Account account) {
    final AccountComboBox auxComboBox = new AccountComboBox();
    auxComboBox.setMaxWidth(Double.MAX_VALUE);
    auxComboBox.setPredicate(AccountComboBox.getShowAllPredicate());
    auxComboBox.getUnfilteredItems().add(0, NOP_ACCOUNT);
    auxComboBox.setValue(account == null ? NOP_ACCOUNT : account);
    auxComboBox.valueProperty().addListener(auxListener);
    auxAccountComboBoxList.add(auxComboBox);
    accountComboVBox.getChildren().add(auxComboBox);
}
Also used : AccountComboBox(jgnash.uifx.control.AccountComboBox)

Example 4 with AccountComboBox

use of jgnash.uifx.control.AccountComboBox in project jgnash by ccavanaugh.

the class ControlsTest method start.

@Override
public void start(final Stage primaryStage) throws Exception {
    Engine engine = createEngine();
    Objects.requireNonNull(engine);
    ThemeManager.restoreLastUsedTheme();
    DecimalTextField decimalTextField = new DecimalTextField();
    DecimalTextField decimalTextField2 = new DecimalTextField();
    decimalTextField2.scaleProperty().set(4);
    primaryStage.setTitle("Controls Test");
    Button btn = new Button();
    btn.setText("getDecimal()");
    // Create the DatePicker.
    DatePicker datePicker = new DatePickerEx();
    datePicker.setOnAction(event -> {
        LocalDate date = datePicker.getValue();
        System.out.println("Selected date: " + date);
    });
    decimalTextField.decimalProperty().addListener((observable, oldValue, newValue) -> System.out.println("decimalTextField: " + newValue));
    decimalTextField2.decimalProperty().addListener((observable, oldValue, newValue) -> System.out.println("decimalTextField2: " + newValue));
    ObjectProperty<BigDecimal> decimal = new SimpleObjectProperty<>();
    decimalTextField2.decimalProperty().bindBidirectional(decimal);
    decimal.set(BigDecimal.TEN);
    btn.setOnAction(event -> {
        decimal.set(BigDecimal.ONE);
        System.out.println(decimalTextField2.getDecimal());
    });
    System.out.println(decimal.isBound());
    System.out.println(decimalTextField2.decimalProperty().isBound());
    TransactionNumberComboBox numberComboBox = new TransactionNumberComboBox();
    numberComboBox.accountProperty().set(engine.getAccountList().get(0));
    Button exceptionButton = new Button("Show Exception");
    exceptionButton.setOnAction(event -> StaticUIMethods.displayException(new Exception("Test exception")));
    SecurityComboBox securityComboBox = new SecurityComboBox();
    TextFieldEx textFieldEx = new TextFieldEx();
    PopOverButton popOverButton = new PopOverButton(new FontAwesomeLabel(FontAwesomeLabel.FAIcon.EXCHANGE));
    popOverButton.setContentNode(new DecimalTextField());
    VBox vBox = new VBox();
    vBox.getChildren().addAll(decimalTextField, decimalTextField2, datePicker, new AccountComboBox(), numberComboBox, btn, exceptionButton, securityComboBox, new TimePeriodComboBox(), textFieldEx, popOverButton);
    primaryStage.setScene(new Scene(vBox, 300, 420));
    primaryStage.getScene().getStylesheets().add(MainView.DEFAULT_CSS);
    primaryStage.getScene().getRoot().getStyleClass().addAll("form", "dialog");
    primaryStage.show();
    primaryStage.requestFocus();
}
Also used : DatePickerEx(jgnash.uifx.control.DatePickerEx) TextFieldEx(jgnash.uifx.control.TextFieldEx) TimePeriodComboBox(jgnash.uifx.control.TimePeriodComboBox) Scene(javafx.scene.Scene) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) IOException(java.io.IOException) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) DecimalTextField(jgnash.uifx.control.DecimalTextField) FontAwesomeLabel(jgnash.resource.font.FontAwesomeLabel) AccountComboBox(jgnash.uifx.control.AccountComboBox) Button(javafx.scene.control.Button) PopOverButton(jgnash.uifx.control.PopOverButton) PopOverButton(jgnash.uifx.control.PopOverButton) DatePicker(javafx.scene.control.DatePicker) SecurityComboBox(jgnash.uifx.control.SecurityComboBox) TransactionNumberComboBox(jgnash.uifx.control.TransactionNumberComboBox) VBox(javafx.scene.layout.VBox) Engine(jgnash.engine.Engine)

Aggregations

AccountComboBox (jgnash.uifx.control.AccountComboBox)4 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)2 Scene (javafx.scene.Scene)2 VBox (javafx.scene.layout.VBox)2 Account (jgnash.engine.Account)2 Engine (jgnash.engine.Engine)2 DatePickerEx (jgnash.uifx.control.DatePickerEx)2 IOException (java.io.IOException)1 NumberFormat (java.text.NumberFormat)1 LocalDate (java.time.LocalDate)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1 ResourceBundle (java.util.ResourceBundle)1 Preferences (java.util.prefs.Preferences)1 Collectors (java.util.stream.Collectors)1 Platform (javafx.application.Platform)1