Search in sources :

Example 31 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project jgnash by ccavanaugh.

the class AbstractTransactionEntryDialog method buildTable.

@SuppressWarnings("unchecked")
private void buildTable() {
    final String[] columnNames = getSplitColumnName();
    final TableColumn<TransactionEntry, String> accountColumn = new TableColumn<>(columnNames[0]);
    accountColumn.setCellValueFactory(param -> new AccountNameWrapper(param.getValue()));
    final TableColumn<TransactionEntry, String> reconciledColumn = new TableColumn<>(columnNames[1]);
    reconciledColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getReconciled(account.get()).toString()));
    final TableColumn<TransactionEntry, String> memoColumn = new TableColumn<>(columnNames[2]);
    memoColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getMemo()));
    final TableColumn<TransactionEntry, BigDecimal> increaseColumn = new TableColumn<>(columnNames[3]);
    increaseColumn.setCellValueFactory(param -> new IncreaseAmountProperty(param.getValue().getAmount(accountProperty().getValue())));
    increaseColumn.setCellFactory(cell -> new TransactionEntryCommodityFormatTableCell(CommodityFormat.getShortNumberFormat(account.get().getCurrencyNode())));
    final TableColumn<TransactionEntry, BigDecimal> decreaseColumn = new TableColumn<>(columnNames[4]);
    decreaseColumn.setCellValueFactory(param -> new DecreaseAmountProperty(param.getValue().getAmount(accountProperty().getValue())));
    decreaseColumn.setCellFactory(cell -> new TransactionEntryCommodityFormatTableCell(CommodityFormat.getShortNumberFormat(account.get().getCurrencyNode())));
    final TableColumn<TransactionEntry, BigDecimal> balanceColumn = new TableColumn<>(columnNames[5]);
    balanceColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(getBalanceAt(param.getValue())));
    balanceColumn.setCellFactory(cell -> new TransactionEntryCommodityFormatTableCell(CommodityFormat.getFullNumberFormat(account.get().getCurrencyNode())));
    // do not allow a sort on the balance
    balanceColumn.setSortable(false);
    tableView.getColumns().addAll(memoColumn, accountColumn, reconciledColumn, increaseColumn, decreaseColumn, balanceColumn);
    tableViewManager.setColumnFormatFactory(param -> {
        if (param == balanceColumn) {
            return CommodityFormat.getFullNumberFormat(accountProperty().getValue().getCurrencyNode());
        } else if (param == increaseColumn || param == decreaseColumn) {
            return CommodityFormat.getShortNumberFormat(accountProperty().getValue().getCurrencyNode());
        }
        return null;
    });
}
Also used : SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) BigDecimal(java.math.BigDecimal) TransactionEntry(jgnash.engine.TransactionEntry)

Example 32 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project org.csstudio.display.builder by kasemir.

the class ColorMapDialog method createContent.

private Node createContent() {
    // Table for selecting a predefined color map
    predefined_table = new TableView<>();
    final TableColumn<PredefinedColorMaps.Predefined, String> name_column = new TableColumn<>(Messages.ColorMapDialog_PredefinedMap);
    name_column.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getDescription()));
    predefined_table.getColumns().add(name_column);
    predefined_table.getItems().addAll(PredefinedColorMaps.PREDEFINED);
    predefined_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    // Table for viewing/editing color sections
    sections_table = new TableView<>();
    // Value of color section
    final TableColumn<ColorSection, String> value_column = new TableColumn<>(Messages.ColorMapDialog_Value);
    value_column.setCellValueFactory(param -> new SimpleStringProperty(Integer.toString(param.getValue().value)));
    value_column.setCellFactory(TextFieldTableCell.forTableColumn());
    value_column.setOnEditCommit(event -> {
        final int index = event.getTablePosition().getRow();
        try {
            final int value = Math.max(0, Math.min(255, Integer.parseInt(event.getNewValue().trim())));
            color_sections.set(index, new ColorSection(value, color_sections.get(index).color));
            color_sections.sort((sec1, sec2) -> sec1.value - sec2.value);
            updateMapFromSections();
        } catch (NumberFormatException ex) {
        // Ignore, field will reset to original value
        }
    });
    // Color of color section
    final TableColumn<ColorSection, ColorPicker> color_column = new TableColumn<>(Messages.ColorMapDialog_Color);
    color_column.setCellValueFactory(param -> {
        final ColorSection segment = param.getValue();
        return new SimpleObjectProperty<ColorPicker>(createColorPicker(segment));
    });
    color_column.setCellFactory(column -> new ColorTableCell());
    sections_table.getColumns().add(value_column);
    sections_table.getColumns().add(color_column);
    sections_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    sections_table.setItems(color_sections);
    sections_table.setEditable(true);
    add = new Button(Messages.ColorMapDialog_Add, JFXUtil.getIcon("add.png"));
    add.setMaxWidth(Double.MAX_VALUE);
    remove = new Button(Messages.ColorMapDialog_Remove, JFXUtil.getIcon("delete.png"));
    remove.setMaxWidth(Double.MAX_VALUE);
    final VBox buttons = new VBox(10, add, remove);
    // Upper section with tables
    final HBox tables_and_buttons = new HBox(10, predefined_table, sections_table, buttons);
    HBox.setHgrow(predefined_table, Priority.ALWAYS);
    HBox.setHgrow(sections_table, Priority.ALWAYS);
    // Lower section with resulting color map
    final Region fill1 = new Region(), fill2 = new Region(), fill3 = new Region();
    HBox.setHgrow(fill1, Priority.ALWAYS);
    HBox.setHgrow(fill2, Priority.ALWAYS);
    HBox.setHgrow(fill3, Priority.ALWAYS);
    final HBox color_title = new HBox(fill1, new Label(Messages.ColorMapDialog_Result), fill2);
    color_bar = new Region();
    color_bar.setMinHeight(COLOR_BAR_HEIGHT);
    color_bar.setMaxHeight(COLOR_BAR_HEIGHT);
    color_bar.setPrefHeight(COLOR_BAR_HEIGHT);
    final HBox color_legend = new HBox(new Label("0"), fill3, new Label("255"));
    final VBox box = new VBox(10, tables_and_buttons, new Separator(), color_title, color_bar, color_legend);
    VBox.setVgrow(tables_and_buttons, Priority.ALWAYS);
    return box;
}
Also used : HBox(javafx.scene.layout.HBox) ColorPicker(javafx.scene.control.ColorPicker) Label(javafx.scene.control.Label) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) TableColumn(javafx.scene.control.TableColumn) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Button(javafx.scene.control.Button) Region(javafx.scene.layout.Region) VBox(javafx.scene.layout.VBox) Separator(javafx.scene.control.Separator)

Example 33 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project bisq-desktop by bisq-network.

the class BindingTest method start.

@Override
public void start(Stage primaryStage) {
    VBox root = new VBox();
    root.setSpacing(20);
    Label label = new AutoTooltipLabel();
    StringProperty txt = new SimpleStringProperty();
    txt.set("-");
    label.textProperty().bind(txt);
    Button button = new AutoTooltipButton("count up");
    button.setOnAction(e -> txt.set("counter " + counter++));
    root.getChildren().addAll(label, button);
    primaryStage.setScene(new Scene(root, 400, 400));
    primaryStage.show();
}
Also used : Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) Label(javafx.scene.control.Label) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Scene(javafx.scene.Scene) VBox(javafx.scene.layout.VBox) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton)

Example 34 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project bisq-desktop by bisq-network.

the class MainViewModel method initP2PNetwork.

// /////////////////////////////////////////////////////////////////////////////////////////
// Initialisation
// /////////////////////////////////////////////////////////////////////////////////////////
private BooleanProperty initP2PNetwork() {
    log.info("initP2PNetwork");
    StringProperty bootstrapState = new SimpleStringProperty();
    StringProperty bootstrapWarning = new SimpleStringProperty();
    BooleanProperty hiddenServicePublished = new SimpleBooleanProperty();
    BooleanProperty initialP2PNetworkDataReceived = new SimpleBooleanProperty();
    p2PNetworkInfoBinding = EasyBind.combine(bootstrapState, bootstrapWarning, p2PService.getNumConnectedPeers(), hiddenServicePublished, initialP2PNetworkDataReceived, (state, warning, numPeers, hiddenService, dataReceived) -> {
        String result = "";
        int peers = (int) numPeers;
        if (warning != null && peers == 0) {
            result = warning;
        } else {
            String p2pInfo = Res.get("mainView.footer.p2pInfo", numPeers);
            if (dataReceived && hiddenService) {
                result = p2pInfo;
            } else if (peers == 0)
                result = state;
            else
                result = state + " / " + p2pInfo;
        }
        return result;
    });
    p2PNetworkInfoBinding.subscribe((observable, oldValue, newValue) -> {
        p2PNetworkInfo.set(newValue);
    });
    bootstrapState.set(Res.get("mainView.bootstrapState.connectionToTorNetwork"));
    p2PService.getNetworkNode().addConnectionListener(new ConnectionListener() {

        @Override
        public void onConnection(Connection connection) {
        }

        @Override
        public void onDisconnect(CloseConnectionReason closeConnectionReason, Connection connection) {
            // Other disconnects might be caused by peers running an older version
            if (connection.getPeerType() == Connection.PeerType.SEED_NODE && closeConnectionReason == CloseConnectionReason.RULE_VIOLATION) {
                log.warn("RULE_VIOLATION onDisconnect closeConnectionReason=" + closeConnectionReason);
                log.warn("RULE_VIOLATION onDisconnect connection=" + connection);
            }
        }

        @Override
        public void onError(Throwable throwable) {
        }
    });
    final BooleanProperty p2pNetworkInitialized = new SimpleBooleanProperty();
    p2PService.start(new P2PServiceListener() {

        @Override
        public void onTorNodeReady() {
            log.debug("onTorNodeReady");
            bootstrapState.set(Res.get("mainView.bootstrapState.torNodeCreated"));
            p2PNetworkIconId.set("image-connection-tor");
            if (preferences.getUseTorForBitcoinJ())
                initWalletService();
            // We want to get early connected to the price relay so we call it already now
            priceFeedService.setCurrencyCodeOnInit();
            priceFeedService.initialRequestPriceFeed();
        }

        @Override
        public void onHiddenServicePublished() {
            log.debug("onHiddenServicePublished");
            hiddenServicePublished.set(true);
            bootstrapState.set(Res.get("mainView.bootstrapState.hiddenServicePublished"));
        }

        @Override
        public void onDataReceived() {
            log.debug("onRequestingDataCompleted");
            initialP2PNetworkDataReceived.set(true);
            bootstrapState.set(Res.get("mainView.bootstrapState.initialDataReceived"));
            splashP2PNetworkAnimationVisible.set(false);
            p2pNetworkInitialized.set(true);
        }

        @Override
        public void onNoSeedNodeAvailable() {
            log.warn("onNoSeedNodeAvailable");
            if (p2PService.getNumConnectedPeers().get() == 0)
                bootstrapWarning.set(Res.get("mainView.bootstrapWarning.noSeedNodesAvailable"));
            else
                bootstrapWarning.set(null);
            splashP2PNetworkAnimationVisible.set(false);
            p2pNetworkInitialized.set(true);
        }

        @Override
        public void onNoPeersAvailable() {
            log.warn("onNoPeersAvailable");
            if (p2PService.getNumConnectedPeers().get() == 0) {
                p2pNetworkWarnMsg.set(Res.get("mainView.p2pNetworkWarnMsg.noNodesAvailable"));
                bootstrapWarning.set(Res.get("mainView.bootstrapWarning.noNodesAvailable"));
                p2pNetworkLabelId.set("splash-error-state-msg");
            } else {
                bootstrapWarning.set(null);
                p2pNetworkLabelId.set("footer-pane");
            }
            splashP2PNetworkAnimationVisible.set(false);
            p2pNetworkInitialized.set(true);
        }

        @Override
        public void onUpdatedDataReceived() {
            log.debug("onBootstrapComplete");
            splashP2PNetworkAnimationVisible.set(false);
            bootstrapComplete.set(true);
        }

        @Override
        public void onSetupFailed(Throwable throwable) {
            log.warn("onSetupFailed");
            p2pNetworkWarnMsg.set(Res.get("mainView.p2pNetworkWarnMsg.connectionToP2PFailed", throwable.getMessage()));
            splashP2PNetworkAnimationVisible.set(false);
            bootstrapWarning.set(Res.get("mainView.bootstrapWarning.bootstrappingToP2PFailed"));
            p2pNetworkLabelId.set("splash-error-state-msg");
        }

        @Override
        public void onRequestCustomBridges() {
            showTorNetworkSettingsWindow();
        }
    });
    return p2pNetworkInitialized;
}
Also used : OpenOffer(bisq.core.offer.OpenOffer) User(bisq.core.user.User) ChainFileLockedException(org.bitcoinj.store.ChainFileLockedException) ListChangeListener(javafx.collections.ListChangeListener) BootstrapListener(bisq.network.p2p.BootstrapListener) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) Map(java.util.Map) BlockStoreException(org.bitcoinj.store.BlockStoreException) MonadicBinding(org.fxmisc.easybind.monadic.MonadicBinding) P2PServiceListener(bisq.network.p2p.P2PServiceListener) ClosedTradableManager(bisq.core.trade.closed.ClosedTradableManager) FilterManager(bisq.core.filter.FilterManager) Set(java.util.Set) PaymentMethod(bisq.core.payment.payload.PaymentMethod) BooleanProperty(javafx.beans.property.BooleanProperty) Slf4j(lombok.extern.slf4j.Slf4j) TxIdTextField(bisq.desktop.components.TxIdTextField) Stream(java.util.stream.Stream) TorNetworkSettingsWindow(bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow) AddressEntry(bisq.core.btc.AddressEntry) WalletsSetup(bisq.core.btc.wallet.WalletsSetup) TradeManager(bisq.core.trade.TradeManager) UserThread(bisq.common.UserThread) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) FeeService(bisq.core.provider.fee.FeeService) ObservableList(javafx.collections.ObservableList) StringProperty(javafx.beans.property.StringProperty) CryptoException(bisq.common.crypto.CryptoException) AlertManager(bisq.core.alert.AlertManager) SetupUtils(bisq.core.app.SetupUtils) FXCollections(javafx.collections.FXCollections) Dispute(bisq.core.arbitration.Dispute) NotificationCenter(bisq.desktop.main.overlays.notifications.NotificationCenter) IntegerProperty(javafx.beans.property.IntegerProperty) ConnectionListener(bisq.network.p2p.network.ConnectionListener) Nullable(javax.annotation.Nullable) EncryptionService(bisq.network.crypto.EncryptionService) DontShowAgainLookup(bisq.core.user.DontShowAgainLookup) GlobalSettings(bisq.core.locale.GlobalSettings) IOException(java.io.IOException) BisqEnvironment(bisq.core.app.BisqEnvironment) OpenOfferManager(bisq.core.offer.OpenOfferManager) PriceFeedService(bisq.core.provider.price.PriceFeedService) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) CloseConnectionReason(bisq.network.p2p.network.CloseConnectionReason) KeyRing(bisq.common.crypto.KeyRing) InetAddresses(com.google.common.net.InetAddresses) SealedAndSigned(bisq.common.crypto.SealedAndSigned) Transaction(org.bitcoinj.core.Transaction) DisplayAlertMessageWindow(bisq.desktop.main.overlays.windows.DisplayAlertMessageWindow) Coin(org.bitcoinj.core.Coin) Date(java.util.Date) DaoManager(bisq.core.dao.DaoManager) Clock(bisq.common.Clock) Inject(com.google.inject.Inject) PerfectMoneyAccount(bisq.core.payment.PerfectMoneyAccount) Security(java.security.Security) TimeoutException(java.util.concurrent.TimeoutException) Random(java.util.Random) DisputeManager(bisq.core.arbitration.DisputeManager) BSFormatter(bisq.desktop.util.BSFormatter) Alert(bisq.core.alert.Alert) Res(bisq.core.locale.Res) Popup(bisq.desktop.main.overlays.popups.Popup) WalletPasswordWindow(bisq.desktop.main.overlays.windows.WalletPasswordWindow) P2PService(bisq.network.p2p.P2PService) ArbitratorManager(bisq.core.arbitration.ArbitratorManager) Subscription(org.fxmisc.easybind.Subscription) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) TacWindow(bisq.desktop.main.overlays.windows.TacWindow) DevEnv(bisq.common.app.DevEnv) AppOptionKeys(bisq.core.app.AppOptionKeys) Preferences(bisq.core.user.Preferences) Optional(java.util.Optional) Address(org.bitcoinj.core.Address) BalanceWithConfirmationTextField(bisq.desktop.components.BalanceWithConfirmationTextField) Ping(bisq.network.p2p.peers.keepalive.messages.Ping) MarketPrice(bisq.core.provider.price.MarketPrice) DisplayUpdateDownloadWindow(bisq.desktop.main.overlays.windows.downloadupdate.DisplayUpdateDownloadWindow) GUIUtil(bisq.desktop.util.GUIUtil) BtcWalletService(bisq.core.btc.wallet.BtcWalletService) Socket(java.net.Socket) TradeCurrency(bisq.core.locale.TradeCurrency) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) SetChangeListener(javafx.collections.SetChangeListener) Timer(bisq.common.Timer) DoubleProperty(javafx.beans.property.DoubleProperty) HashMap(java.util.HashMap) TradeStatisticsManager(bisq.core.trade.statistics.TradeStatisticsManager) BalanceListener(bisq.core.btc.listeners.BalanceListener) WalletsManager(bisq.core.btc.wallet.WalletsManager) CurrencyUtil(bisq.core.locale.CurrencyUtil) Connection(bisq.network.p2p.network.Connection) PrivateNotificationManager(bisq.core.alert.PrivateNotificationManager) Version(bisq.common.app.Version) ObjectProperty(javafx.beans.property.ObjectProperty) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount) PrivateNotificationPayload(bisq.core.alert.PrivateNotificationPayload) Trade(bisq.core.trade.Trade) FailedTradesManager(bisq.core.trade.failed.FailedTradesManager) ViewModel(bisq.desktop.common.model.ViewModel) TimeUnit(java.util.concurrent.TimeUnit) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) EasyBind(org.fxmisc.easybind.EasyBind) DecryptedDataTuple(bisq.network.crypto.DecryptedDataTuple) ChangeListener(javafx.beans.value.ChangeListener) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Connection(bisq.network.p2p.network.Connection) P2PServiceListener(bisq.network.p2p.P2PServiceListener) StringProperty(javafx.beans.property.StringProperty) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) CloseConnectionReason(bisq.network.p2p.network.CloseConnectionReason) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ConnectionListener(bisq.network.p2p.network.ConnectionListener)

Example 35 with SimpleStringProperty

use of javafx.beans.property.SimpleStringProperty in project ParadoxosModManager by ThibautSF.

the class Mod method readFileMod.

/**
 * @throws IOException
 */
private void readFileMod() throws IOException {
    String sep = File.separator;
    Pattern p = Pattern.compile("\\\".*?\\\"");
    Matcher m;
    Path pth = Paths.get(ModManager.PATH + "mod" + sep + fileName.get());
    List<String> lines = Files.readAllLines(pth);
    for (String line : lines) {
        String lineWFirstChar = (line.length() > 0) ? line.substring(1, line.length()) : "";
        if (line.matches("\\s*name\\s*=.*") || lineWFirstChar.matches("\\s*name\\s*=.*")) {
            m = p.matcher(line);
            if (m.find())
                name = new SimpleStringProperty((String) m.group().subSequence(1, m.group().length() - 1));
        } else if (line.matches("\\s*path\\s*=.*") || lineWFirstChar.matches("\\s*path\\s*=.*")) {
            m = p.matcher(line);
            if (m.find())
                dirPath = new SimpleStringProperty((String) m.group().subSequence(1, m.group().length() - 1));
        } else if (line.matches("\\s*archive\\s*=.*") || lineWFirstChar.matches("\\s*archive\\s*=.*")) {
            m = p.matcher(line);
            if (m.find())
                archivePath = new SimpleStringProperty((String) m.group().subSequence(1, m.group().length() - 1));
        } else if (line.matches("\\s*supported_version\\s*=.*") || lineWFirstChar.matches("\\s*supported_version\\s*=.*")) {
            m = p.matcher(line);
            if (m.find())
                versionCompatible = new SimpleStringProperty((String) m.group().subSequence(1, m.group().length() - 1));
        } else if (line.matches("\\s*remote_file_id\\s*=.*") || lineWFirstChar.matches("\\s*remote_file_id\\s*=.*")) {
            m = p.matcher(line);
            if (m.find()) {
                remoteFileID = new SimpleStringProperty((String) m.group().subSequence(1, m.group().length() - 1));
                this.steamPath = new SimpleStringProperty("https://steamcommunity.com/sharedfiles/filedetails/?id=" + this.remoteFileID.get());
            }
        }
    }
}
Also used : Path(java.nio.file.Path) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) SimpleStringProperty(javafx.beans.property.SimpleStringProperty)

Aggregations

SimpleStringProperty (javafx.beans.property.SimpleStringProperty)40 StringProperty (javafx.beans.property.StringProperty)14 TableColumn (javafx.scene.control.TableColumn)12 FXML (javafx.fxml.FXML)9 BigDecimal (java.math.BigDecimal)7 Button (javafx.scene.control.Button)7 IOException (java.io.IOException)5 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)5 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)5 ObservableValue (javafx.beans.value.ObservableValue)5 MockedProperty (com.canoo.dp.impl.remoting.MockedProperty)4 Binding (com.canoo.platform.core.functional.Binding)4 List (java.util.List)4 Map (java.util.Map)4 Label (javafx.scene.control.Label)4 CellDataFeatures (javafx.scene.control.TableColumn.CellDataFeatures)4 ImageView (javafx.scene.image.ImageView)4 Test (org.testng.annotations.Test)4 ChunkWrapper (com.kyj.fx.voeditor.visual.diff.ChunkWrapper)3 CompareResult (com.kyj.fx.voeditor.visual.diff.CompareResult)3