get();
- /**
- * Quietly closes the Object. If the object was closed before, nothing
- * happens.
- */
- public void close();
-
/**
* @return an empty object.
*/
diff --git a/main/ui/src/main/java/org/cryptomator/ui/util/DeferredCloser.java b/main/ui/src/main/java/org/cryptomator/ui/util/DeferredCloser.java
index c738e9f59..f2de9324f 100644
--- a/main/ui/src/main/java/org/cryptomator/ui/util/DeferredCloser.java
+++ b/main/ui/src/main/java/org/cryptomator/ui/util/DeferredCloser.java
@@ -13,12 +13,10 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
import org.cryptomator.common.ConsumerThrowingException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.annotations.VisibleForTesting;
@@ -31,7 +29,7 @@ import com.google.common.annotations.VisibleForTesting;
*
*
* If you have a {@link DeferredCloser} instance present, call
- * {@link #closeLater(Object, Closer)} immediately after you have opened the
+ * {@link #closeLater(Object, ConsumerThrowingException)} immediately after you have opened the
* resource and return a resource handle. If {@link #close()} is called, the
* resource will be closed. Calling {@link DeferredClosable#close()} on the resource
* handle will also close the resource and prevent a second closing by
@@ -42,8 +40,6 @@ import com.google.common.annotations.VisibleForTesting;
*/
public class DeferredCloser implements AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(DeferredCloser.class);
-
@VisibleForTesting
final Map> cleanups = new ConcurrentSkipListMap<>();
@@ -51,33 +47,32 @@ public class DeferredCloser implements AutoCloseable {
final AtomicLong counter = new AtomicLong();
private class ManagedResource implements DeferredClosable {
+
private final long number = counter.incrementAndGet();
-
- private final AtomicReference object = new AtomicReference<>();
+ private final T object;
private final ConsumerThrowingException closer;
+ private boolean closed = false;
public ManagedResource(T object, ConsumerThrowingException closer) {
super();
- this.object.set(object);
- this.closer = closer;
+ this.object = Objects.requireNonNull(object);
+ this.closer = Objects.requireNonNull(closer);
}
@Override
- public void close() {
- final T oldObject = object.getAndSet(null);
- if (oldObject != null) {
- cleanups.remove(number);
- try {
- closer.accept(oldObject);
- } catch (Exception e) {
- LOG.error("Closing resource failed.", e);
- }
- }
+ public synchronized void close() throws Exception {
+ closer.accept(object);
+ cleanups.remove(number);
+ closed = true;
}
@Override
public Optional get() throws IllegalStateException {
- return Optional.ofNullable(object.get());
+ if (closed) {
+ return Optional.empty();
+ } else {
+ return Optional.of(object);
+ }
}
}
@@ -85,11 +80,23 @@ public class DeferredCloser implements AutoCloseable {
* Closes all added objects which have not been closed before and releases references.
*/
@Override
- public void close() {
+ public void close() throws ExecutionException {
+ ExecutionException exception = null;
for (Iterator> iterator = cleanups.values().iterator(); iterator.hasNext();) {
final ManagedResource> closableProvider = iterator.next();
- closableProvider.close();
- iterator.remove();
+ try {
+ closableProvider.close();
+ iterator.remove();
+ } catch (Exception e) {
+ if (exception == null) {
+ exception = new ExecutionException(e);
+ } else {
+ exception.addSuppressed(e);
+ }
+ }
+ }
+ if (exception != null) {
+ throw exception;
}
}
diff --git a/main/ui/src/main/resources/css/linux_theme.css b/main/ui/src/main/resources/css/linux_theme.css
index cb3c407f0..38f453feb 100644
--- a/main/ui/src/main/resources/css/linux_theme.css
+++ b/main/ui/src/main/resources/css/linux_theme.css
@@ -325,6 +325,32 @@
-fx-background-color: COLOR_TEXT;
}
+/*******************************************************************************
+ * *
+ * ChoiceBox *
+ * *
+ ******************************************************************************/
+
+.choice-box {
+ -fx-background-color: COLOR_BORDER_DARK, COLOR_BACKGROUND;
+ -fx-background-insets: 0, 1;
+ -fx-background-radius: 0, 0;
+ -fx-padding: 0.1em 0.6em 0.1em 0.6em;
+ -fx-text-fill: COLOR_TEXT;
+}
+
+.choice-box > .open-button > .arrow {
+ -fx-background-color: transparent, COLOR_TEXT;
+ -fx-background-insets: 0 0 -1 0, 0;
+ -fx-padding: 0.166667em 0.333333em 0.166667em 0.333333em; /* 2 4 2 4 */
+ -fx-shape: "M 0 0 h 7 l -3.5 4 z";
+}
+
+.choice-box .context-menu {
+ -fx-background-color: COLOR_BORDER, #FFF;
+ -fx-background-insets: 0, 1;
+}
+
/****************************************************************************
* *
* ProgressIndicator *
diff --git a/main/ui/src/main/resources/fxml/settings.fxml b/main/ui/src/main/resources/fxml/settings.fxml
index 73f26630f..41f770be2 100644
--- a/main/ui/src/main/resources/fxml/settings.fxml
+++ b/main/ui/src/main/resources/fxml/settings.fxml
@@ -15,6 +15,7 @@
+
@@ -40,6 +41,11 @@
+
+
+
+
+
diff --git a/main/ui/src/main/resources/localization/en.txt b/main/ui/src/main/resources/localization/en.txt
index f7bae8e29..3fe3d213c 100644
--- a/main/ui/src/main/resources/localization/en.txt
+++ b/main/ui/src/main/resources/localization/en.txt
@@ -94,6 +94,7 @@ settings.checkForUpdates.label=Check for updates
settings.port.label=WebDAV Port *
settings.port.prompt=0 = Choose automatically
settings.useipv6.label=Use IPv6 literal
+settings.prefGvfsScheme.label=WebDAV scheme
settings.requiresRestartLabel=* Cryptomator needs to restart
# tray icon