package de.dakror.wseminar.controller;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;

public class EditWeightsDialogController {
	@FXML
	private Button add;
	
	@FXML
	private Button cancelButton;
	
	@FXML
	private ImageView logo;
	
	@FXML
	private Button okButton;
	
	@FXML
	private HBox okParent;
	
	@FXML
	private ListView<String> list;
	
	@FXML
	private Label messageLabel;
	
	@FXML
	private Button remove;
	
	@FXML
	void initialize() {
		cancelButton.setOnAction(e -> ((Stage) cancelButton.getScene().getWindow()).close());
		
		add.setOnAction(e -> list.getItems().add("Gewicht #" + (list.getItems().size() + 1)));
		list.getSelectionModel().selectedItemProperty().addListener((obs, oldVal, newVal) -> remove.setDisable(newVal == null));
	}
}

@@ -163,24 +163,76 @@
 l.ListView;%0A
+import javafx.scene.control.cell.TextFieldListCell;%0A
 import javaf
@@ -851,16 +851,115 @@
 + 1)));%0A
+%09%09remove.setOnAction(e -%3E list.getItems().remove(list.getSelectionModel().getSelectedIndex()));%0A%09%09%0A
 %09%09list.g
@@ -1073,13 +1073,150 @@
 null));%0A
+%09%09list.setCellFactory(TextFieldListCell.forListView());%0A%09%09list.setOnEditCommit(t -%3E list.getItems().set(t.getIndex(), t.getNewValue()));%0A
 %09%7D%0A%7D%0A

edit weight list