瀏覽代碼

null-safe status indicators

Sebastian Stenzel 9 年之前
父節點
當前提交
73fde5d020
共有 1 個文件被更改,包括 2 次插入7 次删除
  1. 2 7
      main/ui/src/main/java/org/cryptomator/ui/controls/DirectoryListCell.java

+ 2 - 7
main/ui/src/main/java/org/cryptomator/ui/controls/DirectoryListCell.java

@@ -56,13 +56,8 @@ public class DirectoryListCell extends DraggableListCell<Vault> {
 		pathText.setTextOverrun(OverrunStyle.ELLIPSIS);
 		pathText.getStyleClass().add("detail-label");
 
-		statusIndicator.fillProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::unlockedProperty).map(unlocked -> {
-			return unlocked ? GREEN_FILL : RED_FILL;
-		}));
-
-		statusIndicator.strokeProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::unlockedProperty).map(unlocked -> {
-			return unlocked ? GREEN_STROKE : RED_STROKE;
-		}));
+		statusIndicator.fillProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::unlockedProperty).filter(Boolean.TRUE::equals).map(unlocked -> GREEN_FILL).orElse(RED_FILL));
+		statusIndicator.strokeProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::unlockedProperty).filter(Boolean.TRUE::equals).map(unlocked -> GREEN_STROKE).orElse(RED_STROKE));
 
 		tooltipProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::path).map(p -> new Tooltip(p.toString())));
 		contextMenuProperty().bind(EasyBind.monadic(itemProperty()).flatMap(Vault::unlockedProperty).map(unlocked -> {