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());
}
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());
}
}
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());
}
}
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;
}
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]);
}
Aggregations