2525import de .doubleslash .keeptime .rest .integration .heimat .model .ExistingAndInvalidMappings ;
2626import de .doubleslash .keeptime .rest .integration .heimat .model .HeimatTask ;
2727import javafx .application .Platform ;
28+ import javafx .beans .property .SimpleBooleanProperty ;
2829import javafx .beans .property .SimpleObjectProperty ;
2930import javafx .beans .property .SimpleStringProperty ;
3031import javafx .collections .FXCollections ;
3334import javafx .collections .transformation .FilteredList ;
3435import javafx .fxml .FXML ;
3536import javafx .scene .control .*;
37+ import javafx .scene .control .cell .CheckBoxTableCell ;
38+ import javafx .scene .control .cell .PropertyValueFactory ;
3639import javafx .scene .layout .VBox ;
3740import javafx .stage .Stage ;
3841import org .slf4j .Logger ;
@@ -208,39 +211,51 @@ private List<HeimatTask> showMultiSelectDialog(final List<HeimatTask> externalPr
208211 ButtonType cancelButtonType = new ButtonType ("Cancel" , ButtonBar .ButtonData .CANCEL_CLOSE );
209212 dialog .getDialogPane ().getButtonTypes ().addAll (okButtonType , cancelButtonType );
210213
211- ListView <HeimatTask > listView = new ListView <>();
212- listView .setCellFactory (param -> new ListCell <>() {
213- @ Override
214- protected void updateItem (HeimatTask item , boolean empty ) {
215- super .updateItem (item , empty );
216- if (item == null || empty ) {
217- setGraphic (null );
218- setText (null );
219- } else {
220- // TODO maybe show if the project was already mapped
221- setText (item .taskHolderName () + " - " + item .name ());
222- }
223- }
214+ TableView <HeimatTask > tableView = new TableView <>();
215+ TableColumn <HeimatTask , HeimatTask > nameColumn = new TableColumn <>("HEIMAT Project" );
216+ nameColumn .setCellValueFactory (data -> new SimpleObjectProperty <>(data .getValue ()));
217+ nameColumn .setCellFactory (param -> new TableCell <>() {
218+ @ Override
219+ protected void updateItem (HeimatTask item , boolean empty ) {
220+ super .updateItem (item , empty );
221+ if (item == null || empty ) {
222+ setGraphic (null );
223+ setText (null );
224+ } else {
225+ setText (item .taskHolderName () + " - " + item .name ());
226+ }
227+ }
224228 });
225- listView .getSelectionModel ().setSelectionMode (SelectionMode .MULTIPLE );
226- listView .setItems (FXCollections .observableArrayList (externalProjects ));
229+
230+ // Column for Mapped Status (Read-Only CheckBox)
231+ TableColumn <HeimatTask , Boolean > mappedColumn = new TableColumn <>("Mapped" );
232+ mappedColumn .setCellValueFactory (cellData -> new SimpleBooleanProperty (!unmappedHeimatTasks .contains (cellData .getValue ())));
233+ mappedColumn .setCellFactory (CheckBoxTableCell .forTableColumn (mappedColumn ));
234+ mappedColumn .setEditable (false );
235+
236+ mappedColumn .setPrefWidth (75 );
237+ tableView .getColumns ().addAll (mappedColumn , nameColumn );
238+ tableView .setEditable (false );
239+
240+ tableView .getSelectionModel ().setSelectionMode (SelectionMode .MULTIPLE );
241+ tableView .setItems (FXCollections .observableArrayList (externalProjects ));
227242
228243 Button selectAllUnmappedButton = new Button ("Select unmapped projects (" + unmappedHeimatTasks .size () + ")" );
229244 selectAllUnmappedButton .getStyleClass ().add ("secondary-button" );
230245 selectAllUnmappedButton .setOnAction (e -> {
231- listView .getSelectionModel ().clearSelection ();
246+ tableView .getSelectionModel ().clearSelection ();
232247 for (HeimatTask ht : unmappedHeimatTasks ) {
233- listView .getSelectionModel ().select (ht );
248+ tableView .getSelectionModel ().select (ht );
234249 }
235- listView .requestFocus ();
250+ tableView .requestFocus ();
236251 });
237252
238- VBox content = new VBox (10 , selectAllUnmappedButton , listView );
253+ VBox content = new VBox (10 , selectAllUnmappedButton , tableView );
239254 dialog .getDialogPane ().setContent (content );
240255 final List <HeimatTask > emptyList = List .of ();
241256 dialog .setResultConverter (dialogButton -> {
242257 if (dialogButton == okButtonType ) {
243- return listView .getSelectionModel ().getSelectedItems ().stream ().toList ();
258+ return tableView .getSelectionModel ().getSelectedItems ().stream ().toList ();
244259 }
245260 return emptyList ; // cancel was clicked
246261 });
@@ -254,8 +269,8 @@ protected void updateItem(HeimatTask item, boolean empty) {
254269 dialog .getDialogPane ().getStylesheets ().add (Resources .getResource (Resources .RESOURCE .CSS_DS_STYLE ).toExternalForm ());
255270
256271
257- listView .getSelectionModel ().getSelectedItems ().addListener ((ListChangeListener <HeimatTask >) change -> {
258- int selectedCount = listView .getSelectionModel ().getSelectedItems ().size ();
272+ tableView .getSelectionModel ().getSelectedItems ().addListener ((ListChangeListener <HeimatTask >) change -> {
273+ int selectedCount = tableView .getSelectionModel ().getSelectedItems ().size ();
259274 okButton .setText ("Import (" + selectedCount + ")" );
260275 });
261276
0 commit comments