Skip to content
Snippets Groups Projects
Commit 31330cc1 authored by Andreas Bayha's avatar Andreas Bayha
Browse files

Kernel: Added Dynamic Combo Columns for DynamicTreeTableViewer.

There is an addComboColumn(...) method now. The combo columnb is dynamic
in a sense, that every cell/row might have it's own choices for the
combo, depending on the element.

Issue-Ref: 4014
Issue-Url: https://af3-developer.fortiss.org/issues/4014


Signed-off-by: default avatarAndreas Bayha <bayha@fortiss.org>
parent 420f3f21
No related branches found
No related tags found
1 merge request!1254014
DynamicTextFieldTreeTableCell.java 7724630c17dada26e8d4063f3491757cdaeb8350 YELLOW
DynamicTextFieldTreeTableCell.java de24117e6f785b328f1ff62383626a0b4b54e8ff YELLOW
DynamicTreeContentProviderBase.java 6760a6dc5721175b1dada8f30fd9da05f7bcc4b3 GREEN
DynamicTreeItem.java 75dc5534b119ffdb3c10a65810c2a0f330b7955e GREEN
DynamicTreeTableUIProviderBase.java f78c0f8b52fbc939166b3f94f7f6006cc0f4d32b GREEN
DynamicTreeTableViewer.java 5e58a31a63f8e56d8c8e69e2c4d095809bc46bf1 GREEN
DynamicTreeTableViewer.java ca3984b2fc404e3b37e409ce11859bcdc61aaf66 YELLOW
DynamicTreeUIProviderBase.java e9b68607683de279d0cb8712a28dc131c5c33ece GREEN
DynamicTreeViewer.java 725f41f4fb4b6bfa813f010fb9083ab02eea164a GREEN
DynamicTreeViewerBase.java a2013538b62d86f6a09efdf2cd78babac2072484 GREEN
......
......@@ -57,7 +57,9 @@ public class DynamicTextFieldTreeTableCell<T> extends TextFieldTreeTableCell<T,
this.setOnKeyPressed(event -> {
if(event.getCode().equals(KeyCode.ESCAPE)) {
escapePressed = true;
if(currentlyEditedElement != null) {
escapePressed = true;
}
}
});
}
......
......@@ -16,8 +16,14 @@
package org.fortiss.tooling.common.ui.javafx.control.treetableview;
import static java.lang.Integer.MAX_VALUE;
import static javafx.collections.FXCollections.observableArrayList;
import static javafx.scene.control.cell.ComboBoxTreeTableCell.forTreeTableColumn;
import java.util.Collection;
import java.util.function.Function;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableColumn;
......@@ -165,6 +171,41 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> {
return column;
}
/**
* Adds a column with Combo editing support to the view. The labels, context menus and
* icons are shown as defined in the {@link DynamicTreeTableUIProviderBase}.
*
* @param headerLabel
* The Label for the column header.
* @param prefWidth
* The preferred width of the new column in px.
* @param comboValueFactory
* A Function, that maps cell elements to choices for the combo box.
*
* @return The newly created an configured column.
*/
public TreeTableColumn<T, String> addComboColumn(String headerLabel, int prefWidth,
Function<T, Collection<String>> comboValueFactory) {
TreeTableColumn<T, String> column = addColumn(headerLabel, prefWidth);
// The list with the choices to be offered in the combo.
ObservableList<String> items = observableArrayList();
column.setCellFactory(forTreeTableColumn(items));
// Changes the choices of the combo for every editing of every cell dynamically.
column.setOnEditStart(event -> {
TreeItem<T> treeItem = event.getRowValue();
T rowEntry = treeItem.getValue();
Collection<String> comboValues = comboValueFactory.apply(rowEntry);
items.clear();
items.addAll(comboValues);
});
return column;
}
/**
* Adds a column to the table part of the view. The labels, context menus and icons are shown as
* defined in the {@link DynamicTreeTableUIProviderBase}.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment