Java Code Examples for javafx.scene.control.TextField#setPrefWidth()

The following examples show how to use javafx.scene.control.TextField#setPrefWidth() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
protected void setupGrid() {
    GridPane grid = new GridPane();
    setupGridPane(grid);

    setTitle(BOARD_DIALOG_NAME);

    HBox nameArea = new HBox();

    Text prompt = new Text("New board name: ");

    nameField = new TextField(DEFAULT_NAME);
    nameField.setPrefWidth(300);
    Platform.runLater(() -> {
        nameField.requestFocus();
    });
    nameField.setId(IdGenerator.getBoardNameInputFieldId());

    nameArea.getChildren().addAll(prompt, nameField);
    grid.add(nameArea, 0, 0);

    errorText = new Text("");
    errorText.getStyleClass().add("text-red");
    grid.add(errorText, 0, 1);

    getDialogPane().setContent(grid);
}
 
Example 2
Source Project: WorkbenchFX   File: PieSkin.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void initializeParts() {
  double center = ARTBOARD_HEIGHT * 0.5;
  border = new Circle(center, center, center);
  border.getStyleClass().add("border");

  pieSlice = new Arc(center, center, center - 1, center - 1, 90, 0);
  pieSlice.getStyleClass().add("pieSlice");
  pieSlice.setType(ArcType.ROUND);

  valueField = new TextField();
  valueField.relocate(ARTBOARD_HEIGHT + 5, 2);
  valueField.setPrefWidth(ARTBOARD_WIDTH - ARTBOARD_HEIGHT - 5);
  valueField.getStyleClass().add("valueField");

  // always needed
  drawingPane = new Pane();
  drawingPane.setMaxSize(ARTBOARD_WIDTH, ARTBOARD_HEIGHT);
  drawingPane.setMinSize(ARTBOARD_WIDTH, ARTBOARD_HEIGHT);
  drawingPane.setPrefSize(ARTBOARD_WIDTH, ARTBOARD_HEIGHT);
}
 
Example 3
public DoubleComponent(int inputsize, Double minimum, Double maximum, NumberFormat format) {
  this.minimum = minimum;
  this.maximum = maximum;

  textField = new TextField();
  textField.setTextFormatter(new TextFormatter<>(new NumberStringConverter(format)));
  textField.setPrefWidth(inputsize);

  // Add an input verifier if any bounds are specified.
  if (minimum != null || maximum != null) {
    // textField.setInputVerifier(new MinMaxVerifier());
  }

  getChildren().add(textField);
}
 
Example 4
Source Project: chart-fx   File: EditAxis.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates the header for the Axis Editor popup, allowing to configure axis label and unit
 *
 * @param axis The axis to be edited
 * @return pane containing label, label editor and unit editor
 */
private Node getLabelEditor(final Axis axis, final boolean isHorizontal) {
    final GridPane header = new GridPane();
    header.setAlignment(Pos.BASELINE_LEFT);
    final TextField axisLabelTextField = new TextField(axis.getName());
    axisLabelTextField.textProperty().bindBidirectional(axis.nameProperty());
    header.addRow(0, new Label(" axis label: "), axisLabelTextField);

    final TextField axisUnitTextField = new TextField(axis.getUnit());
    axisUnitTextField.setPrefWidth(50.0);
    axisUnitTextField.textProperty().bindBidirectional(axis.unitProperty());
    header.addRow(isHorizontal ? 0 : 1, new Label(" unit: "), axisUnitTextField);

    final TextField unitScaling = new TextField();
    unitScaling.setPrefWidth(80.0);
    final CheckBox autoUnitScaling = new CheckBox(" auto");
    if (axis instanceof DefaultNumericAxis) {
        autoUnitScaling.selectedProperty()
                .bindBidirectional(((DefaultNumericAxis) axis).autoUnitScalingProperty());
        unitScaling.textProperty().bindBidirectional(((DefaultNumericAxis) axis).unitScalingProperty(),
                new NumberStringConverter(new DecimalFormat("0.0####E0")));
        unitScaling.disableProperty().bind(autoUnitScaling.selectedProperty());
    } else {
        // TODO: consider adding an interface on whether
        // autoUnitScaling is editable
        autoUnitScaling.setDisable(true);
        unitScaling.setDisable(true);
    }
    final HBox unitScalingBox = new HBox(unitScaling, autoUnitScaling);
    unitScalingBox.setAlignment(Pos.BASELINE_LEFT);
    header.addRow(isHorizontal ? 0 : 2, new Label(" unit scale:"), unitScalingBox);
    return header;
}
 
Example 5
Source Project: Recaf   File: RenamingTextField.java    License: MIT License 5 votes vote down vote up
private RenamingTextField(GuiController controller, String initialText, Consumer<RenamingTextField> renameAction) {
	this.controller = controller;
	setHideOnEscape(true);
	setAutoHide(true);
	setOnShown(e -> {
		// Center on main window
		Stage main = controller.windows().getMainWindow().getStage();
		int x = (int) (main.getX() + Math.round((main.getWidth() / 2) - (getWidth() / 2)));
		int y = (int) (main.getY() + Math.round((main.getHeight() / 2) - (getHeight() / 2)));
		setX(x);
		setY(y);
	});
	text = new TextField(initialText);
	text.getStyleClass().add("remap-field");
	text.setPrefWidth(400);
	// Close on hitting escape/close-window bind
	text.setOnKeyPressed(e -> {
		if (controller.config().keys().closeWindow.match(e) || e.getCode() == KeyCode.ESCAPE)
			hide();
	});
	// Set on-enter action
	text.setOnAction(e -> renameAction.accept(this));
	// Setup & show
	getScene().setRoot(text);
	Platform.runLater(() -> {
		text.requestFocus();
		text.selectAll();
	});
}
 
Example 6
private HBox getLine (Label label, TextField text)
{
  HBox line = new HBox (10);
  line.getChildren ().addAll (label, text);
  label.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (100);
  text.setFont (defaultFont);
  text.setEditable (true);
  text.setFocusTraversable (true);

  return line;
}
 
Example 7
private HBox getLine (Label label, TextField text, HBox hbox)
{
  HBox line = new HBox (10);

  line.getChildren ().addAll (label, text, hbox);
  label.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (100);
  text.setFont (defaultFont);
  text.setEditable (true);
  text.setFocusTraversable (true);

  return line;
}
 
Example 8
Source Project: dm3270   File: TransfersTab.java    License: Apache License 2.0 5 votes vote down vote up
private HBox getLine (RadioButton button, TextField text)
{
  HBox line = new HBox (10);
  line.getChildren ().addAll (button, text);
  button.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (300);
  text.setFont (defaultFont);
  text.setEditable (false);
  text.setFocusTraversable (false);
  button.setUserData (text);

  return line;
}
 
Example 9
Source Project: dm3270   File: TransfersTab.java    License: Apache License 2.0 5 votes vote down vote up
private HBox getLine (Label label, TextField text)
{
  HBox line = new HBox (10);
  line.getChildren ().addAll (label, text);
  label.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (100);
  text.setFont (defaultFont);
  text.setEditable (true);
  text.setFocusTraversable (true);

  return line;
}
 
Example 10
Source Project: dm3270   File: TransfersTab.java    License: Apache License 2.0 5 votes vote down vote up
private HBox getLine (Label label, TextField text, HBox hbox)
{
  HBox line = new HBox (10);

  line.getChildren ().addAll (label, text, hbox);
  label.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (100);
  text.setFont (defaultFont);
  text.setEditable (true);
  text.setFocusTraversable (true);

  return line;
}
 
Example 11
Source Project: GitFx   File: GitFxDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
    public String gitOpenDialog(String title, String header, String content) {
        String repo;
        DirectoryChooser chooser = new DirectoryChooser();
        Dialog<Pair<String, GitFxDialogResponse>> dialog = new Dialog<>();
        //Dialog<Pair<String, GitFxDialogResponse>> dialog = getCostumeDialog();
        dialog.setTitle(title);
        dialog.setHeaderText(header);
        dialog.setContentText(content);

        ButtonType okButton = new ButtonType("Ok");
        ButtonType cancelButton = new ButtonType("Cancel");
        dialog.getDialogPane().getButtonTypes().addAll(okButton, cancelButton);
        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));

        TextField repository = new TextField();
        repository.setPrefWidth(250.0);
        repository.setPromptText("Repo");
        grid.add(new Label("Repository:"), 0, 0);
        grid.add(repository, 1, 0);
        
        /////////////////////Modification of choose Button////////////////////////
        Button chooseButtonType = new Button("Choose");
        grid.add(chooseButtonType, 2, 0);
//			        Button btnCancel1 = new Button("Cancel");
//			        btnCancel1.setPrefWidth(90.0);
//			        Button btnOk1 = new Button("Ok");
//			        btnOk1.setPrefWidth(90.0);
//			        HBox hbox = new HBox(4);
//			        hbox.getChildren().addAll(btnOk1,btnCancel1);
//			        hbox.setPadding(new Insets(2));
//			        grid.add(hbox, 1, 1);
        chooseButtonType.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
               // label.setText("Accepted");
            	File path = chooser.showDialog(dialog.getOwner());
                getFileAndSeText(repository,path);
                chooser.setTitle(resourceBundle.getString("repo"));
            }
        });
//        btnCancel1.setOnAction(new EventHandler<ActionEvent>(){ 
//        	@Override public void handle(ActionEvent e) {
//        	System.out.println("Shyam : Testing");
//        	setResponse(GitFxDialogResponse.CANCEL);
//             }
//		});
        //////////////////////////////////////////////////////////////////////
        dialog.getDialogPane().setContent(grid);

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == okButton) {
                String filePath = repository.getText();
                //filePath = filePath.concat("/.git");
//[LOG]                logger.debug(filePath);
                if (!filePath.isEmpty() && new File(filePath).exists()) {
                    setResponse(GitFxDialogResponse.OK);
                    return new Pair<>(repository.getText(), GitFxDialogResponse.OK);
                } else {
                    this.gitErrorDialog(resourceBundle.getString("errorOpen"),
                            resourceBundle.getString("errorOpenTitle"),
                            resourceBundle.getString("errorOpenDesc"));
                }

            }
            if (dialogButton == cancelButton) {
//[LOG]                logger.debug("Cancel clicked");
                setResponse(GitFxDialogResponse.CANCEL);
                return new Pair<>(null, GitFxDialogResponse.CANCEL);
            }
            return null;
        });

        Optional<Pair<String, GitFxDialogResponse>> result = dialog.showAndWait();

        result.ifPresent(repoPath -> {
//[LOG]            logger.debug(repoPath.getKey() + " " + repoPath.getValue().toString());
        });

        Pair<String, GitFxDialogResponse> temp = null;
        if (result.isPresent()) {
            temp = result.get();
        }

        if(temp != null){
            return temp.getKey();// + "/.git";
        }
        return EMPTY_STRING;

    }
 
Example 12
LabelEntry(final List<LabelEntry> host, final Pane visualHost, final String attributeName, final ConstellationColor color, final float size) {
    attrCombo = new ComboBox<>(FXCollections.observableList(attributeNames));
    attrCombo.setPrefWidth(150);
    attrCombo.getSelectionModel().select(attributeName);
    attrCombo.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });

    colorRect = new Rectangle(20, 20);
    this.color = color.getJavaFXColor();
    colorRect.setFill(this.color);
    colorRect.setStroke(Color.LIGHTGREY);
    colorRect.setOnMouseClicked(getChooseColorEventHandler());

    sizeText = new TextField(String.valueOf(size));
    sizeText.setPrefWidth(50);
    sizeText.textProperty().addListener((o, n, v) -> {
        update();
    });

    final Button upButton = new Button("", new ImageView(UserInterfaceIconProvider.CHEVRON_UP.buildImage(16)));
    upButton.setOnAction(e -> {
        moveUp();
        update();
    });
    final Button downButton = new Button("", new ImageView(UserInterfaceIconProvider.CHEVRON_DOWN.buildImage(16)));
    downButton.setOnAction(e -> {
        moveDown();
        update();
    });
    final Button removeButton = new Button("", new ImageView(UserInterfaceIconProvider.CROSS.buildImage(16)));
    removeButton.setOnAction(e -> {
        remove();
        update();
    });

    entry = new HBox(10);
    entry.getChildren().addAll(attrCombo, colorRect, sizeText, upButton, downButton, removeButton);

    this.host = host;
    this.host.add(this);
    this.visualHost = visualHost;
    this.visualHost.getChildren().add(entry);
}
 
Example 13
Source Project: dm3270   File: PluginsStage.java    License: Apache License 2.0 4 votes vote down vote up
public PluginsStage (Preferences prefs)
// ---------------------------------------------------------------------------------//
{
  super (prefs);
  setTitle ("Plugin Manager");

  readPrefs ();

  editMenuItem.setOnAction (e -> this.show ());

  fields.add (new PreferenceField ("Menu entry", 130, Type.TEXT));
  fields.add (new PreferenceField ("Class name", 300, Type.TEXT));
  fields.add (new PreferenceField ("Active", 60, Type.BOOLEAN));

  VBox vbox = getHeadings ();

  for (PluginEntry pluginEntry : plugins)
  {
    HBox hbox = new HBox ();
    hbox.setSpacing (5);
    hbox.setPadding (new Insets (0, 5, 0, 5));    // trbl

    for (int i = 0; i < fields.size (); i++)
    {
      PreferenceField field = fields.get (i);
      if (field.type == Type.TEXT || field.type == Type.NUMBER)
      {
        TextField textField = pluginEntry.getTextField (i);
        textField.setPrefWidth (field.width);
        hbox.getChildren ().add (textField);
      }
      else if (field.type == Type.BOOLEAN)
      {
        HBox box = new HBox ();
        CheckBox checkBox = pluginEntry.getCheckBox (i);
        box.setPrefWidth (field.width);
        box.setAlignment (Pos.CENTER);
        box.getChildren ().add (checkBox);
        hbox.getChildren ().add (box);
      }
    }
    vbox.getChildren ().add (hbox);
  }

  BorderPane borderPane = new BorderPane ();
  borderPane.setCenter (vbox);
  borderPane.setBottom (buttons ());

  Scene scene = new Scene (borderPane);
  setScene (scene);

  saveButton.setOnAction (e ->
  {
    savePrefs ();
    this.hide ();
  });

  cancelButton.setOnAction (e -> this.hide ());
}
 
Example 14
@Override
public void start(final Stage primaryStage) {
    // init default 2D Chart
    final XYChart chart1 = getDefaultChart();
    final ErrorDataSetRenderer renderer = (ErrorDataSetRenderer) chart1.getRenderers().get(0);
    renderer.setAssumeSortedData(false); // necessary to suppress sorted-DataSet-only optimisations

    // alternate DataSet:
    // final CosineFunction dataSet1 = new CosineFunction("test cosine", N_SAMPLES);
    final DataSet dataSet1 = test8Function(0, 4, -1, 3, (Math.PI / N_SAMPLES) * 2 * N_TURNS, 0.2, N_SAMPLES);
    final TransposedDataSet transposedDataSet1 = TransposedDataSet.transpose(dataSet1, false);
    renderer.getDatasets().add(transposedDataSet1);

    // init default 3D Chart with HeatMapRenderer
    final XYChart chart2 = getDefaultChart();
    final ContourDataSetRenderer contourRenderer = new ContourDataSetRenderer();
    chart2.getRenderers().setAll(contourRenderer);

    final DataSet dataSet2 = createTestData();
    dataSet2.getAxisDescription(DIM_X).set("x-axis", "x-unit");
    dataSet2.getAxisDescription(DIM_Y).set("y-axis", "y-unit");
    final TransposedDataSet transposedDataSet2 = TransposedDataSet.transpose(dataSet2, false);
    contourRenderer.getDatasets().add(transposedDataSet2);

    // init ToolBar items to illustrate the two different methods to flip the DataSet
    final CheckBox cbTransposed = new CheckBox("flip data set");
    final TextField textPermutation = new TextField("0,1,2");
    textPermutation.setPrefWidth(100);
    cbTransposed.setTooltip(new Tooltip("press to transpose DataSet"));
    cbTransposed.setGraphic(new Glyph(FONT_AWESOME, FONT_SYMBOL_TRANSPOSE).size(FONT_SIZE));
    final Button bApplyPermutation = new Button(null, new Glyph(FONT_AWESOME, FONT_SYMBOL_CHECK).size(FONT_SIZE));
    bApplyPermutation.setTooltip(new Tooltip("press to apply permutation"));

    // flipping method #1: via 'setTransposed(boolean)' - flips only first two axes
    cbTransposed.setOnAction(evt -> {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.atInfo().addArgument(cbTransposed.isSelected()).log("set transpose state to '{}'");
        }
        transposedDataSet1.setTransposed(cbTransposed.isSelected());
        transposedDataSet2.setTransposed(cbTransposed.isSelected());
        textPermutation.setText(Arrays.stream(transposedDataSet2.getPermutation()).boxed().map(String::valueOf).collect(Collectors.joining(",")));
    });

    // flipping method #2: via 'setPermutation(int[])' - flips arbitrary combination of axes
    final Runnable permutationAction = () -> {
        final int[] parsedInt1 = Arrays.asList(textPermutation.getText().split(","))
                                         .subList(0, transposedDataSet1.getDimension())
                                         .stream()
                                         .map(String::trim)
                                         .mapToInt(Integer::parseInt)
                                         .toArray();
        final int[] parsedInt2 = Arrays.asList(textPermutation.getText().split(","))
                                         .subList(0, transposedDataSet2.getDimension())
                                         .stream()
                                         .map(String::trim)
                                         .mapToInt(Integer::parseInt)
                                         .toArray();

        transposedDataSet1.setPermutation(parsedInt1);
        transposedDataSet2.setPermutation(parsedInt2);
    };

    textPermutation.setOnAction(evt -> permutationAction.run());
    bApplyPermutation.setOnAction(evt -> permutationAction.run());

    // the usual JavaFX Application boiler-plate code
    final ToolBar toolBar = new ToolBar(new Label("method #1 - transpose: "), cbTransposed, new Separator(),
            new Label("method #2 - permutation: "), textPermutation, bApplyPermutation);
    final HBox hBox = new HBox(chart1, chart2);

    VBox.setVgrow(hBox, Priority.ALWAYS);
    final Scene scene = new Scene(new VBox(toolBar, hBox), 800, 600);
    primaryStage.setTitle(getClass().getSimpleName());
    primaryStage.setScene(scene);
    primaryStage.show();
    primaryStage.setOnCloseRequest(evt -> Platform.exit());
}
 
Example 15
Source Project: marathonv5   File: HTMLEditorSample.java    License: Apache License 2.0 4 votes vote down vote up
public HTMLEditorSample() {
    final VBox root = new VBox();
    root.setPadding(new Insets(8, 8, 8, 8));
    root.setSpacing(5);
    root.setAlignment(Pos.BOTTOM_LEFT);

    final GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(10);

    final ChoiceBox sendTo = new ChoiceBox(FXCollections.observableArrayList("To:", "Cc:", "Bcc:"));

    sendTo.setPrefWidth(100);
    GridPane.setConstraints(sendTo, 0, 0);
    grid.getChildren().add(sendTo);

    final TextField tbTo = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbTo, 1, 0);
    grid.getChildren().add(tbTo);

    final Label subjectLabel = new Label("Subject:");
    GridPane.setConstraints(subjectLabel, 0, 1);
    grid.getChildren().add(subjectLabel);

    final TextField tbSubject = new TextField();
    tbTo.setPrefWidth(400);
    GridPane.setConstraints(tbSubject, 1, 1);
    grid.getChildren().add(tbSubject);

    root.getChildren().add(grid);

    Platform.runLater(() -> {
        final HTMLEditor htmlEditor = new HTMLEditor();
        htmlEditor.setPrefHeight(370);
        root.getChildren().addAll(htmlEditor, new Button("Send"));
    });

    final Label htmlLabel = new Label();
    htmlLabel.setWrapText(true);
    getChildren().add(root);
}
 
Example 16
protected UserBalloon() {
    super();
    setId("user-balloon");
    instance = this;

    TextField label = new TextField("");
    label.setFont(defaultFont);
    if (defaultFont != null) {
        label.setFont(defaultFont);
    } else {
        label.setFont(LocalFont.defaultFont);
    }

    Button infoButton = new Button(Main.getString("?"));

    HBox textLine = new HBox(label, infoButton);
    content = label;

    Button sendButton = new Button(Main.getString("send"));
    Button closeButton = new Button(Main.getString("close"));

    HBox buttons = new HBox(sendButton, closeButton);
    buttons.setAlignment(Pos.CENTER);

    bubblePane = sprite;
    sprite.setSpriteContent(new VBox(textLine, buttons));
    getChildren().add(bubblePane);

    label.setPrefWidth(bubblePane.getContentWidth());

    setBalloonScaleFactor(Main.getProperties().getFloat("balloon.scale_factor", 100));
    setBalloonOpacity(Main.getProperties().getFloat("balloon.opacity", 100));

    label.setOnKeyReleased(event -> {
        if (event.getCode() == KeyCode.ENTER) sendPhrase();
    });

    sendButton.setOnAction(event -> {
        sendPhrase();
    });

    closeButton.setOnAction(event -> {
        close();
    });

    infoButton.setOnAction(event -> {
        Main.getPluginProxy().sendMessage("DeskChan:commands-list", null);
    });

    setOnMousePressed(event -> {
        startDrag(event);
    });

    dialog = new BalloonDialog(this);
}
 
Example 17
Source Project: GitFx   File: GitFxDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
    public Pair<String, String> gitCloneDialog(String title, String header,
                                               String content) {
        Dialog<Pair<String, String>> dialog = new Dialog<>();
        DirectoryChooser chooser = new DirectoryChooser();
        dialog.setTitle(title);
        dialog.setHeaderText(header);
        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));
        TextField remoteRepo = new TextField();
        remoteRepo.setPromptText("Remote Repo URL");
        remoteRepo.setPrefWidth(250.0);
        TextField localPath = new TextField();
        localPath.setPromptText("Local Path");
        localPath.setPrefWidth(250.0);
        grid.add(new Label("Remote Repo URL:"), 0, 0);
        grid.add(remoteRepo, 1, 0);
        grid.add(new Label("Local Path:"), 0, 1);
        grid.add(localPath, 1, 1);
        //ButtonType chooseButtonType = new ButtonType("Choose");
        ButtonType cloneButtonType = new ButtonType("Clone");
        ButtonType cancelButtonType = new ButtonType("Cancel");
        /////////////////////Modification of choose Button////////////////////////
        Button chooseButtonType = new Button("Choose");
        grid.add(chooseButtonType, 2, 1);
        chooseButtonType.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
            	chooser.setTitle(resourceBundle.getString("cloneRepo"));
                File cloneRepo = chooser.showDialog(dialog.getOwner());
                getFileAndSeText(localPath, cloneRepo);
            }
        });
        //////////////////////////////////////////////////////////////////////
        dialog.getDialogPane().setContent(grid);
        dialog.getDialogPane().getButtonTypes().addAll(
                cloneButtonType, cancelButtonType);

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == cloneButtonType) {
                setResponse(GitFxDialogResponse.CLONE);
                String remoteRepoURL = remoteRepo.getText();
                String localRepoPath = localPath.getText();
                if (!remoteRepoURL.isEmpty() && !localRepoPath.isEmpty()) {
                    return new Pair<>(remoteRepo.getText(), localPath.getText());
                } else {
                    this.gitErrorDialog(resourceBundle.getString("errorClone"),
                            resourceBundle.getString("errorCloneTitle"),
                            resourceBundle.getString("errorCloneDesc"));
                }
            }
            if (dialogButton == cancelButtonType) {
//[LOG]                logger.debug("Cancel clicked");
                setResponse(GitFxDialogResponse.CANCEL);
                return new Pair<>(null, null);
            }
            return null;
        });
        Optional<Pair<String, String>> result = dialog.showAndWait();
        Pair<String, String> temp = null;
        if (result.isPresent()) {
            temp = result.get();
        }
        return temp;
    }
 
Example 18
@Override
protected Parent content() {
    setTitle(DIALOG_TITLE);
    setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
    setStageStyle(StageStyle.UTILITY);

    GridPane grid = new GridPane();
    setupGridPane(grid);

    Label repoLabel = new Label(LABEL_REPO);
    grid.add(repoLabel, 0, 0);

    Label githubLabel = new Label(LABEL_GITHUB);
    grid.add(githubLabel, 1, 0);

    repoOwnerField = new TextField();
    repoOwnerField.setId(IdGenerator.getLoginDialogOwnerFieldId());
    repoOwnerField.setPrefWidth(140);
    grid.add(repoOwnerField, 2, 0);

    Label slash = new Label("/");
    grid.add(slash, 3, 0);

    repoNameField = new TextField();
    repoNameField.setPrefWidth(250);
    grid.add(repoNameField, 4, 0);

    Label usernameLabel = new Label(USERNAME_LABEL);
    grid.add(usernameLabel, 0, 1);

    usernameField = new TextField();
    grid.add(usernameField, 1, 1, 4, 1);

    Label passwordLabel = new Label(PASSWORD_LABEL);
    grid.add(passwordLabel, 0, 2);

    passwordField = new PasswordField();
    grid.add(passwordField, 1, 2, 4, 1);

    repoOwnerField.setOnAction(e -> login());
    repoNameField.setOnAction(e -> login());
    usernameField.setOnAction(e -> login());
    passwordField.setOnAction(e -> login());

    HBox buttons = new HBox(10);
    buttons.setAlignment(Pos.BOTTOM_RIGHT);
    loginButton = new Button(BUTTON_SIGN_IN);
    loginButton.setOnAction(e -> login());
    buttons.getChildren().add(loginButton);
    grid.add(buttons, 4, 3);

    return grid;
}
 
Example 19
Source Project: GitFx   File: GitFxDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
    public Pair<String, String> gitInitDialog(String title, String header, String content) {
        Pair<String, String> repo;
        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle(title);
        dialog.setHeaderText(header);
        dialog.setContentText(content);
        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));
        TextField localPath = new TextField();
        localPath.setPromptText("Local Path");
        localPath.setPrefWidth(250.0);
        grid.add(new Label("Local Path:"), 0, 0);
        grid.add(localPath, 1,0);
        ButtonType initRepo = new ButtonType("Initialize Repository");
        ButtonType cancelButtonType = new ButtonType("Cancel");
        dialog.getDialogPane().setContent(grid);
        dialog.getDialogPane().getButtonTypes().addAll( initRepo, cancelButtonType);
        
        /////////////////////Modification of choose Button////////////////////////
        Button chooseButtonType = new Button("Choose");
        grid.add(chooseButtonType, 2, 0);
        chooseButtonType.setOnAction(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent e) {
                DirectoryChooser chooser = new DirectoryChooser();
                chooser.setTitle(resourceBundle.getString("selectRepo"));
                File initialRepo = chooser.showDialog(dialog.getOwner());
                getFileAndSeText(localPath, initialRepo);
                dialog.getDialogPane();
            }
        });
        //////////////////////////////////////////////////////////////////////

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == initRepo) {
                setResponse(GitFxDialogResponse.INITIALIZE);
                String path = localPath.getText();
//[LOG]                logger.debug( "path" + path + path.isEmpty());
                if (new File(path).exists()) {
//[LOG]                   logger.debug(path.substring(localPath.getText().lastIndexOf(File.separator)));
                    String projectName= path.substring(localPath.getText().lastIndexOf(File.separator)+1);
                    return new Pair<>(projectName, localPath.getText());
                } else {
                    this.gitErrorDialog(resourceBundle.getString("errorInit"),
                            resourceBundle.getString("errorInitTitle"),
                            resourceBundle.getString("errorInitDesc"));
                }
            }
            if (dialogButton == cancelButtonType) {
                setResponse(GitFxDialogResponse.CANCEL);
                return new Pair<>(null, null);
            }
            return null;
        });
        Optional<Pair<String, String>> result = dialog.showAndWait();
        Pair<String, String> temp = null;
        if (result.isPresent()) {
            temp = result.get();
        }
        return temp;
    }
 
Example 20
private void showRaceReportOutputTarget(RaceOutputTarget t){
        HBox rotHBox = new HBox();
        rotHBox.setSpacing(4);
        ComboBox<ReportDestination> destinationChoiceBox = new ComboBox();
        
        //destinationChoiceBox.getItems().setAll(resultsDAO.listReportDestinations());
        
        destinationChoiceBox.setItems(resultsDAO.listReportDestinations());
        
        // ChoserBox for the OutputDestination
        destinationChoiceBox.getSelectionModel().selectedIndexProperty().addListener((ObservableValue<? extends Number> observableValue, Number number, Number number2) -> {
            if (t.getID() < 0) return; // deleted
            
            ReportDestination op = destinationChoiceBox.getItems().get((Integer) number2);
//            if(! Objects.equals(destinationChoiceBox.getSelectionModel().getSelectedItem(),op)) {
//                t.setOutputDestination(op.getID());
//                resultsDAO.saveRaceReportOutputTarget(t);
//            }
            t.setOutputDestination(op.getID());
            resultsDAO.saveRaceReportOutputTarget(t);
        });
        
        if (t.outputDestination() == null) destinationChoiceBox.getSelectionModel().selectFirst();
        else destinationChoiceBox.getSelectionModel().select(t.outputDestination());
        destinationChoiceBox.setPrefWidth(150);
        destinationChoiceBox.setMaxWidth(150);
        
        // TextField for the filename
        TextField filename = new TextField();
        filename.setText(t.getOutputFilename());
        filename.setPrefWidth(200);
        filename.setMaxWidth(400);
        
        filename.textProperty().addListener((observable, oldValue, newValue) -> {
            t.setOutputFilename(newValue);
            resultsDAO.saveRaceReportOutputTarget(t);    
        });
        
        // Remove 
        
        Button remove = new Button("Remove");
        remove.setOnAction((ActionEvent e) -> {
            removeRaceReportOutputTarget(t);
        });
        
        rotHBox.getChildren().addAll(destinationChoiceBox,filename,remove);
        // Add the rotVBox to the outputTargetsVBox
        rotHBoxMap.put(t, rotHBox);
        outputTargetsVBox.getChildren().add(rotHBox);
       
    }