Search in sources :

Example 56 with TextField

use of javafx.scene.control.TextField in project trex-stateless-gui by cisco-system-traffic-generator.

the class UDPProtocolView method buildCustomProtocolView.

/**
     * Build custom view
     */
@Override
protected void buildCustomProtocolView() {
    // add src port
    srcPortCB = new CheckBox("Override source port");
    addCheckBox(srcPortCB, 13, 10);
    srcPort = new TextField();
    addInput(srcPort, 10, 210, 220);
    srcPort.disableProperty().bind(srcPortCB.selectedProperty().not());
    // add dst port
    dstPortCB = new CheckBox("Override destination port");
    addCheckBox(dstPortCB, 48, 10);
    dstPort = new TextField();
    addInput(dstPort, 45, 210, 220);
    dstPort.disableProperty().bind(dstPortCB.selectedProperty().not());
    // add length
    lengthCB = new CheckBox("Override length");
    addCheckBox(lengthCB, 83, 10);
    length = new TextField();
    addInput(length, 80, 210, 220);
    length.disableProperty().bind(lengthCB.selectedProperty().not());
}
Also used : CheckBox(javafx.scene.control.CheckBox) TextField(javafx.scene.control.TextField)

Example 57 with TextField

use of javafx.scene.control.TextField in project trex-stateless-gui by cisco-system-traffic-generator.

the class IPV4ProtocolView method buildCustomProtocolView.

/**
     * Build custom view
     */
@Override
protected void buildCustomProtocolView() {
    addLabel("Destination", 35, 10);
    addLabel("Source", 75, 10);
    addLabel("Address", 5, 100);
    dstAddress = new TextField();
    addInput(dstAddress, 30, 100, 170);
    srcAddress = new TextField();
    addInput(srcAddress, 72, 100, 170);
    addLabel("Mode", 5, 280);
    dstMode = new ComboBox<>();
    addCombo(dstMode, 30, 280, 170);
    srcMode = new ComboBox<>();
    addCombo(srcMode, 70, 280, 170);
    addLabel("Count", 5, 460);
    dstCount = new TextField();
    addInput(dstCount, 30, 460, 80);
    srcCount = new TextField();
    addInput(srcCount, 70, 460, 80);
    addLabel("Step", 5, STEP_CONTROL_OFFSET);
    dstStep = new TextField(DEFAULT_STEP);
    addInput(dstStep, 30, STEP_CONTROL_OFFSET, 80);
    srcStep = new TextField(DEFAULT_STEP);
    addInput(srcStep, 70, STEP_CONTROL_OFFSET, 80);
    // define options
    srcMode.getItems().clear();
    dstMode.getItems().clear();
    for (IPV4Type type : IPV4Type.values()) {
        srcMode.getItems().add(type.getTitle());
        dstMode.getItems().add(type.getTitle());
    }
}
Also used : TextField(javafx.scene.control.TextField)

Example 58 with TextField

use of javafx.scene.control.TextField in project trex-stateless-gui by cisco-system-traffic-generator.

the class MacProtocolView method buildCustomProtocolView.

/**
     *
     */
@Override
protected void buildCustomProtocolView() {
    addLabel("Destination", 35, 10);
    addLabel("Source", 75, 10);
    addLabel("Address", 5, 100);
    dstAddress = new TextField();
    dstAddress.setId("macDstAddress");
    addInput(dstAddress, 30, 100, 220);
    srcAddress = new TextField();
    srcAddress.setId("macSrcAddress");
    addInput(srcAddress, 72, 100, 220);
    addLabel("Mode", 5, 330);
    dstMode = new ComboBox<>();
    dstMode.setId("macDstMode");
    addCombo(dstMode, 30, 330, 150);
    srcMode = new ComboBox<>();
    srcMode.setId("macsrcMode");
    addCombo(srcMode, 70, 330, 150);
    addLabel("Count", 5, 490);
    dstCount = new TextField();
    addInput(dstCount, 30, 490, 80);
    srcCount = new TextField();
    addInput(srcCount, 70, 490, 80);
    addLabel("Step", 5, 580);
    dstStep = new TextField();
    addInput(dstStep, 30, 580, 80);
    srcStep = new TextField();
    addInput(srcStep, 70, 580, 80);
    srcMode.getItems().clear();
    dstMode.getItems().clear();
    for (MacType type : MacType.values()) {
        srcMode.getItems().add(type.getTitle());
        dstMode.getItems().add(type.getTitle());
    }
}
Also used : TextField(javafx.scene.control.TextField)

Example 59 with TextField

use of javafx.scene.control.TextField in project jgnash by ccavanaugh.

the class IncomeExpensePayeePieChartDialogController method createPieDataSet.

private ObservableList<PieChart.Data>[] createPieDataSet(@NotNull final Account account) {
    @SuppressWarnings("unchecked") final ObservableList<PieChart.Data>[] chartData = (ObservableList<PieChart.Data>[]) new ObservableList[2];
    chartData[CREDIT] = FXCollections.observableArrayList();
    chartData[DEBIT] = FXCollections.observableArrayList();
    final Map<String, BigDecimal> names = new HashMap<>();
    final List<TranTuple> list = getTransactions(account, new ArrayList<>(), startDatePicker.getValue(), endDatePicker.getValue());
    final CurrencyNode currency = account.getCurrencyNode();
    // Create a list of predicates
    final List<Predicate<Transaction>> predicates = getPayeeTextFields().stream().filter(textField -> !textField.getText().isEmpty()).map(textField -> new PayeePredicate(textField.getText(), Options.regexForFiltersProperty().get())).collect(Collectors.toList());
    // Iterate through the list and add up filtered payees
    for (final TranTuple tranTuple : list) {
        final String payee = tranTuple.transaction.getPayee();
        BigDecimal sum = tranTuple.transaction.getAmount(tranTuple.account);
        sum = sum.multiply(tranTuple.account.getCurrencyNode().getExchangeRate(currency));
        boolean keep = false;
        if (predicates.isEmpty()) {
            keep = true;
        } else {
            for (final Predicate<Transaction> predicate : predicates) {
                if (predicate.test(tranTuple.transaction)) {
                    keep = true;
                    break;
                }
            }
        }
        if (keep) {
            if (names.containsKey(payee)) {
                sum = sum.add(names.get(payee));
            }
            names.put(payee, sum);
        }
    }
    final Map<String, BigDecimal> sortedNames = CollectionUtils.sortMapByValue(names);
    for (final Map.Entry<String, BigDecimal> entry : sortedNames.entrySet()) {
        final PieChart.Data data = new PieChart.Data(truncateString(entry.getKey()), entry.getValue().abs().doubleValue());
        // nodes are created lazily.  Set the user data (Account) after the node is created
        data.nodeProperty().addListener((observable, oldValue, newValue) -> newValue.setUserData(entry.getKey()));
        if (entry.getValue().signum() == -1) {
            chartData[DEBIT].add(data);
        } else {
            chartData[CREDIT].add(data);
        }
    }
    return chartData;
}
Also used : CurrencyNode(jgnash.engine.CurrencyNode) DoughnutChart(jgnash.uifx.control.DoughnutChart) Scene(javafx.scene.Scene) Engine(jgnash.engine.Engine) TextInputControl(javafx.scene.control.TextInputControl) Transaction(jgnash.engine.Transaction) EngineFactory(jgnash.engine.EngineFactory) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) VBox(javafx.scene.layout.VBox) Side(javafx.geometry.Side) AccountComboBox(jgnash.uifx.control.AccountComboBox) NumberFormat(java.text.NumberFormat) ArrayList(java.util.ArrayList) EncodeDecode(jgnash.util.EncodeDecode) BigDecimal(java.math.BigDecimal) ResourceBundle(java.util.ResourceBundle) Map(java.util.Map) Tooltip(javafx.scene.control.Tooltip) GridPane(javafx.scene.layout.GridPane) CurrencyNode(jgnash.engine.CurrencyNode) ObjectProperty(javafx.beans.property.ObjectProperty) TextField(javafx.scene.control.TextField) InjectFXML(jgnash.uifx.util.InjectFXML) TitledPane(javafx.scene.control.TitledPane) NotNull(jgnash.util.NotNull) Comparators(jgnash.engine.Comparators) Predicate(java.util.function.Predicate) Collectors(java.util.stream.Collectors) Preferences(java.util.prefs.Preferences) Objects(java.util.Objects) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) PieChart(javafx.scene.chart.PieChart) List(java.util.List) CommodityFormat(jgnash.text.CommodityFormat) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) LocalDate(java.time.LocalDate) Account(jgnash.engine.Account) ObservableList(javafx.collections.ObservableList) PayeePredicate(jgnash.util.function.PayeePredicate) ChangeListener(javafx.beans.value.ChangeListener) Collections(java.util.Collections) DatePickerEx(jgnash.uifx.control.DatePickerEx) CollectionUtils(jgnash.util.CollectionUtils) Options(jgnash.uifx.Options) HashMap(java.util.HashMap) BigDecimal(java.math.BigDecimal) Predicate(java.util.function.Predicate) PayeePredicate(jgnash.util.function.PayeePredicate) PieChart(javafx.scene.chart.PieChart) Transaction(jgnash.engine.Transaction) ObservableList(javafx.collections.ObservableList) PayeePredicate(jgnash.util.function.PayeePredicate) HashMap(java.util.HashMap) Map(java.util.Map)

Example 60 with TextField

use of javafx.scene.control.TextField in project jgnash by ccavanaugh.

the class NetworkAuthenticator method getPasswordAuthentication.

@Override
protected PasswordAuthentication getPasswordAuthentication() {
    final Preferences auth = Preferences.userRoot().node(NODEHTTP);
    final ResourceBundle resources = ResourceUtils.getBundle();
    final char[][] pass = { null };
    final String[] user = new String[1];
    // get the password
    if (auth.get(HTTPPASS, null) != null && !auth.get(HTTPPASS, null).isEmpty()) {
        pass[0] = auth.get(HTTPPASS, null).toCharArray();
    }
    // get the user
    user[0] = auth.get(HTTPUSER, null);
    if (user[0] != null) {
        if (user[0].length() <= 0) {
            user[0] = null;
        }
    }
    // if either returns null, pop a dialog
    if (user[0] == null || pass[0] == null) {
        final Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle(resources.getString("Title.HTTPProxy"));
        dialog.setHeaderText(resources.getString("Message.EnterNetworkAuth"));
        // Set the button types.
        final ButtonType loginButtonType = new ButtonType(resources.getString("Button.Ok"), ButtonBar.ButtonData.OK_DONE);
        dialog.getDialogPane().getStylesheets().addAll(MainView.DEFAULT_CSS);
        dialog.getDialogPane().getStyleClass().addAll("dialog");
        dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);
        // Create the username and password labels and fields.
        final GridPane grid = new GridPane();
        grid.getStylesheets().addAll(MainView.DEFAULT_CSS);
        grid.getStyleClass().addAll("form");
        final TextField userNameField = new TextField();
        final PasswordField passwordField = new PasswordField();
        grid.add(new Label(resources.getString("Label.UserName")), 0, 0);
        grid.add(userNameField, 1, 0);
        grid.add(new Label(resources.getString("Label.Password")), 0, 1);
        grid.add(passwordField, 1, 1);
        // Enable/Disable login button depending on whether a username was entered.
        final Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);
        // bind the button, must not be empty
        loginButton.disableProperty().bind(userNameField.textProperty().isEmpty());
        dialog.getDialogPane().setContent(grid);
        // Request focus on the username field by default.
        Platform.runLater(userNameField::requestFocus);
        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(userNameField.getText(), passwordField.getText());
            }
            return null;
        });
        final Optional<Pair<String, String>> result = dialog.showAndWait();
        result.ifPresent(usernamePassword -> {
            user[0] = usernamePassword.getKey();
            pass[0] = usernamePassword.getValue().toCharArray();
        });
    }
    return new PasswordAuthentication(user[0], pass[0]);
}
Also used : GridPane(javafx.scene.layout.GridPane) Node(javafx.scene.Node) Label(javafx.scene.control.Label) Dialog(javafx.scene.control.Dialog) TextField(javafx.scene.control.TextField) ResourceBundle(java.util.ResourceBundle) PasswordField(javafx.scene.control.PasswordField) Preferences(java.util.prefs.Preferences) ButtonType(javafx.scene.control.ButtonType) Pair(javafx.util.Pair) PasswordAuthentication(java.net.PasswordAuthentication)

Aggregations

TextField (javafx.scene.control.TextField)60 Label (javafx.scene.control.Label)20 Button (javafx.scene.control.Button)14 InputTextField (io.bitsquare.gui.components.InputTextField)13 Scene (javafx.scene.Scene)13 Insets (javafx.geometry.Insets)9 Tooltip (javafx.scene.control.Tooltip)8 GridPane (javafx.scene.layout.GridPane)8 Pair (javafx.util.Pair)8 BorderPane (javafx.scene.layout.BorderPane)7 VBox (javafx.scene.layout.VBox)7 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Dialog (javafx.scene.control.Dialog)5 Color (javafx.scene.paint.Color)5 Stage (javafx.stage.Stage)5 FormBuilder.addLabelInputTextField (io.bitsquare.gui.util.FormBuilder.addLabelInputTextField)4 FormBuilder.addLabelTextField (io.bitsquare.gui.util.FormBuilder.addLabelTextField)4 File (java.io.File)4 ObjectProperty (javafx.beans.property.ObjectProperty)4