public ConfigurationsDialogBuilder setOwner(Window owner) {
    if (owner != null) {
      dialog.initOwner(owner);
      dialog.borderPanel.setMaxWidth(owner.getWidth());
      dialog.borderPanel.setMaxHeight(owner.getHeight());
    } else {
      dialog.setWidth(1000);
      dialog.setHeight(700);
    }

    return this;
  }
  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;
  }
  public ConfigurationsDialogBuilder addOkButton() {
    dialog.okButton = new Button("OK");
    dialog.okButton.setPrefWidth(BUTTON_WIDTH * 2);
    dialog.okButton.setOnAction(
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent t) {
            dialog.chosenConfiguration = getChosenConfiguration();
            dependencyDotFileGenerator.generateOutputForConfigurations(
                preferences, dialog.chosenConfiguration, outputFileName, os);
          }
        });
    dialog.buttonsPanel.getChildren().add(dialog.okButton);

    return this;
  }
  public ConfigurationsDialogBuilder create(
      DependencyDotFileGenerator dependencyDotFileGenerator,
      GradleScriptPreferences preferences,
      Os os,
      String outputFileName) {
    this.outputFileName = outputFileName;
    this.dependencyDotFileGenerator = dependencyDotFileGenerator;
    this.preferences = preferences;
    this.os = os;
    dialog = new ConfigurationChoiceDialog(this);
    dialog.setResizable(true);
    dialog.initStyle(UTILITY);
    dialog.initModality(APPLICATION_MODAL);
    dialog.setIconified(false);
    dialog.centerOnScreen();
    dialog.borderPanel = BorderPaneBuilder.create().styleClass("dialog").build();
    dialog.stackPane = new StackPane();

    StackPane stackPane = dialog.stackPane;

    dialog.log = new TextArea();

    TextArea log = dialog.log;
    BorderPane borderPanel = dialog.borderPanel;

    // message
    dialog.configurationsBox = new VBox();

    VBox configurationsBox = dialog.configurationsBox;

    dialog.configurationsBox = configurationsBox;
    dialog.progressIndicator = new ProgressIndicator();

    ProgressIndicator progressIndicator = dialog.progressIndicator;

    stackPane.getChildren().add(log);
    stackPane.getChildren().add(progressIndicator);
    progressIndicator.setPrefSize(50, 50);
    progressIndicator.setMaxSize(50, 50);
    configurationsBox.setSpacing(15);
    configurationsBox.setAlignment(CENTER_LEFT);
    dialog.scrollPane = new ScrollPane();

    ScrollPane scrollPane = dialog.scrollPane;

    scrollPane.setContent(configurationsBox);
    dialog.borderPanel.setCenter(stackPane);
    BorderPane.setAlignment(configurationsBox, CENTER_LEFT);
    BorderPane.setMargin(configurationsBox, new Insets(MARGIN, MARGIN, MARGIN, 2 * MARGIN));

    // buttons
    dialog.buttonsPanel = new HBox();

    final HBox buttonsPanel = dialog.buttonsPanel;

    buttonsPanel.setSpacing(MARGIN);
    buttonsPanel.setAlignment(BOTTOM_CENTER);
    BorderPane.setMargin(buttonsPanel, new Insets(0, 0, 1.5 * MARGIN, 0));
    borderPanel.setBottom(buttonsPanel);
    borderPanel
        .widthProperty()
        .addListener(
            new ChangeListener<Number>() {
              public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
                buttonsPanel.layout();
              }
            });
    dialog.scene = new Scene(borderPanel);
    dialog.setScene(dialog.scene);

    URL resource =
        ConfigurationsDialogBuilder.class.getResource(
            "/com/nurflugel/gradle/ui/dialogservice/dialog.css");
    String externalForm = resource.toExternalForm();

    // dialog.borderPanel.styleClass("dialog");
    dialog.getScene().getStylesheets().add(externalForm);

    return this;
  }
  public ConfigurationsDialogBuilder setTitle(String title) {
    dialog.setTitle(title);

    return this;
  }