diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings index 4de0c6343a63bba5f7b25626407bc580f8b33158..98f04cc5a4327f41632007b10c6deffb3a75feeb 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/.ratings @@ -5,8 +5,8 @@ DynamicTextFieldTreeTableCell.java de24117e6f785b328f1ff62383626a0b4b54e8ff GREE DynamicTreeContentProviderBase.java 91896b1fb5104d126544c44c1ff8c30f2a13a8d6 GREEN DynamicTreeItem.java 7486071d20e896d6ca9a9101bf105caccf3656d0 GREEN DynamicTreeItemBase.java d883066ecc181120302ca32f328538de7a45b093 GREEN -DynamicTreeTableUIProviderBase.java 735766bf3b046dc696eb3324378754ae6db5f4d0 GREEN -DynamicTreeTableViewer.java 9198fbd64af2c15829e63bafcab8095a173c6ff4 GREEN +DynamicTreeTableUIProviderBase.java d150a4c379cc41aab2a44a5f1643f4956332c8e3 YELLOW +DynamicTreeTableViewer.java cb289413d15159abbcccfea87d731738905b4b28 YELLOW DynamicTreeUIProviderBase.java 82d3c051213f0147f4c67ad247a08696cee73110 GREEN DynamicTreeViewer.java 545f1ca10b7b3cad171b294a4b447875da45c9ed GREEN DynamicTreeViewerBase.java a2013538b62d86f6a09efdf2cd78babac2072484 GREEN diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java index 735766bf3b046dc696eb3324378754ae6db5f4d0..d150a4c379cc41aab2a44a5f1643f4956332c8e3 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableUIProviderBase.java @@ -77,7 +77,6 @@ public abstract class DynamicTreeTableUIProviderBase<T> { /** * Returns the style that shall be applied to the {@link TreeItem} of the given element. Return - * * {@code null} for the default style. * * @param element @@ -87,6 +86,19 @@ public abstract class DynamicTreeTableUIProviderBase<T> { * @return style of the element in the CSS format. */ public String getCellStyle(T element, int column) { + if(element == null) { + return null; + } + + Color bgColor = getBackgroundColor(column, element); + if(bgColor != null) { + // Some transparency is necessary here, for correctly displaying the selection + // bar when selecting a row. WIth out transparency, it would not be visible on + // this cell. + double alpha = 0.5; + String colorStr = colorToRgbaString(bgColor, alpha); + return "-fx-background-color: " + colorStr + ";"; + } return null; } @@ -294,25 +306,20 @@ public abstract class DynamicTreeTableUIProviderBase<T> { T data = cell.getTreeTableRow().getItem(); if(data != null) { - Color bgColor = getBackgroundColor(columnIndex, data); - if(bgColor != null) { - // Some transparency is necessary here, for correctly displaying the selection - // bar when selecting a row. WIth out transparency, it would not be visible on - // this cell. - double alpha = 0.5; - String colorStr = colorToRgbaString(bgColor, alpha); - cell.setStyle("-fx-background-color: " + colorStr); - } - final Node icon = getIconNode(data, columnIndex); cell.setGraphic(icon); + cell.setStyle(getCellStyle(data, columnIndex)); + } else { + // reset icon for cases, in which a row was styled before, but became empty by now. + cell.setGraphic(null); + cell.setStyle(null); } } } /** Converts a {@link Color} object into a rgba format as used in css. */ private final static String colorToRgbaString(Color color, double alpha) { - return String.format("rgba(%d,%d,%d,%.1f)", (int)(color.getRed() * 255), + return String.format("rgba(%d,%d,%d,%s)", (int)(color.getRed() * 255), (int)(color.getGreen() * 255), (int)(color.getBlue() * 255), alpha); } @@ -511,11 +518,6 @@ public abstract class DynamicTreeTableUIProviderBase<T> { // JFX-builtin handling is non-operation in Linux. addContextMenuHandler(menu, data); } - - String style = getCellStyle(data, colIndex); - if(style != null) { - this.setStyle(style); - } } this.setContextMenu(menu); diff --git a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java index 9198fbd64af2c15829e63bafcab8095a173c6ff4..cb289413d15159abbcccfea87d731738905b4b28 100644 --- a/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java +++ b/org.fortiss.tooling.common.ui/src/org/fortiss/tooling/common/ui/javafx/control/treetableview/DynamicTreeTableViewer.java @@ -278,7 +278,8 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> { /** {@inheritDoc} */ @Override protected T getSelectedObject() { - T value = view.getSelectionModel().getSelectedItem().getValue(); + final TreeItem<T> selectedItem = view.getSelectionModel().getSelectedItem(); + T value = selectedItem != null ? selectedItem.getValue() : null; return value; }