예제 #1
0
  public static Tuple2<Label, RadioButton> addLabelRadioButton(
      GridPane gridPane,
      int rowIndex,
      ToggleGroup toggleGroup,
      String title,
      String radioButtonTitle) {
    Label label = addLabel(gridPane, rowIndex, title, 0);

    RadioButton radioButton = new RadioButton(radioButtonTitle);
    radioButton.setToggleGroup(toggleGroup);
    radioButton.setPadding(new Insets(6, 0, 0, 0));
    GridPane.setRowIndex(radioButton, rowIndex);
    GridPane.setColumnIndex(radioButton, 1);
    gridPane.getChildren().add(radioButton);

    return new Tuple2<>(label, radioButton);
  }
  public ConfigurationsDialogBuilder addConfigurations(List<Configuration> configurations) {
    dialog.setTitle("Choose a configuration to graph");
    dialog.configurations = configurations;
    dialog.borderPanel.setCenter(dialog.scrollPane);

    ObservableList<Node> children = dialog.configurationsBox.getChildren();
    ToggleGroup toggleGroup = new ToggleGroup();

    for (Configuration configuration : configurations) {
      String name = configuration.getName();
      RadioButton configurationRadioButton = new RadioButton(name);

      configurationRadioButton.setToggleGroup(toggleGroup);

      if (name.equals("compile")) {
        configurationRadioButton.setSelected(true); // todo select default from prefs
      }

      children.add(configurationRadioButton);
    }

    return this;
  }
  private Configuration getChosenConfiguration() {
    ObservableList<Node> children = dialog.configurationsBox.getChildren();

    for (Node child : children) {
      if (child instanceof RadioButton) {
        RadioButton radioButton = (RadioButton) child;

        if (radioButton.isSelected()) {
          String text = radioButton.getText();
          List<Configuration> configurations = dialog.configurations;

          for (Configuration configuration : configurations) {
            String name = configuration.getName();

            if (name.equals(text)) {
              return configuration;
            }
          }
        }
      }
    }

    return null;
  }