hide access point in reveal button if it's empty

This commit is contained in:
Tobias Hagemann
2020-03-11 14:07:40 +01:00
parent 63a51ecee7
commit 96a3c025ab
2 changed files with 21 additions and 20 deletions

View File

@@ -10,14 +10,10 @@ package org.cryptomator.common.vaults;
import com.google.common.base.Strings;
import javafx.beans.Observable;
import javafx.beans.binding.Binding;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.binding.ObjectBinding;
import javafx.beans.binding.StringBinding;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.cryptomator.common.LazyInitializer;
import org.cryptomator.common.settings.VaultSettings;
@@ -27,32 +23,26 @@ import org.cryptomator.cryptofs.CryptoFileSystemProperties.FileSystemFlags;
import org.cryptomator.cryptofs.CryptoFileSystemProvider;
import org.cryptomator.cryptolib.api.CryptoException;
import org.cryptomator.cryptolib.api.InvalidPassphraseException;
import org.fxmisc.easybind.EasyBind;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Provider;
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.NotDirectoryException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate;
import static org.cryptomator.common.Constants.MASTERKEY_FILENAME;
@PerVault
public class Vault {
private static final Logger LOG = LoggerFactory.getLogger(Vault.class);
private static final Path HOME_DIR = Paths.get(SystemUtils.USER_HOME);
@@ -69,7 +59,8 @@ public class Vault {
private final BooleanBinding unlocked;
private final BooleanBinding missing;
private final BooleanBinding needsMigration;
private final ObjectBinding<Path> accessPoint;
private final StringBinding accessPoint;
private final BooleanBinding accessPointPresent;
private volatile Volume volume;
@@ -88,7 +79,8 @@ public class Vault {
this.unlocked = Bindings.createBooleanBinding(this::isUnlocked, state);
this.missing = Bindings.createBooleanBinding(this::isMissing, state);
this.needsMigration = Bindings.createBooleanBinding(this::isNeedsMigration, state);
this.accessPoint = Bindings.createObjectBinding(this::getAccessPoint, state);
this.accessPoint = Bindings.createStringBinding(this::getAccessPoint, state);
this.accessPointPresent = this.accessPoint.isNotEmpty();
}
// ******************************************************************************
@@ -188,11 +180,11 @@ public class Vault {
public boolean isMissing() {
return state.get() == VaultState.MISSING;
}
public BooleanBinding needsMigrationProperty() {
return needsMigration;
}
public boolean isNeedsMigration() {
return state.get() == VaultState.NEEDS_MIGRATION;
}
@@ -206,19 +198,27 @@ public class Vault {
return p.getFileName().toString();
}
public ObjectBinding<Path> accessPointProperty() {
public StringBinding accessPointProperty() {
return accessPoint;
}
public Path getAccessPoint() {
public String getAccessPoint() {
if (state.get() == VaultState.UNLOCKED) {
assert volume != null;
return volume.getMountPoint().orElse(Path.of(""));
return volume.getMountPoint().orElse(Path.of("")).toString();
} else {
return Path.of("");
return "";
}
}
public BooleanBinding accessPointPresentProperty() {
return accessPointPresent;
}
public boolean isAccessPointPresent() {
return accessPointPresent.get();
}
public StringBinding displayablePathProperty() {
return displayablePath;
}

View File

@@ -18,7 +18,8 @@
<FontAwesome5IconView glyph="HDD" glyphSize="24"/>
<VBox spacing="4" alignment="CENTER_LEFT">
<Label text="%main.vaultDetail.revealBtn"/>
<Label styleClass="label-extra-small" text="${controller.vault.accessPoint}" textOverrun="CENTER_ELLIPSIS"/>
<Label styleClass="label-extra-small" text="${controller.vault.accessPoint}" textOverrun="CENTER_ELLIPSIS"
visible="${controller.vault.accessPointPresent}" managed="${controller.vault.accessPointPresent}"/>
</VBox>
</HBox>
</graphic>