|
@@ -1,9 +1,7 @@
|
|
|
package org.cryptomator.ui.preferences;
|
|
|
|
|
|
-import javafx.beans.Observable;
|
|
|
import javafx.beans.binding.BooleanBinding;
|
|
|
import javafx.beans.property.ObjectProperty;
|
|
|
-import javafx.beans.value.ObservableValue;
|
|
|
import javafx.fxml.FXML;
|
|
|
import javafx.scene.control.Tab;
|
|
|
import javafx.scene.control.TabPane;
|
|
@@ -11,12 +9,16 @@ import javafx.stage.Stage;
|
|
|
import javafx.stage.WindowEvent;
|
|
|
import org.cryptomator.ui.common.FxController;
|
|
|
import org.cryptomator.ui.fxapp.UpdateChecker;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
@PreferencesScoped
|
|
|
public class PreferencesController implements FxController {
|
|
|
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(PreferencesController.class);
|
|
|
+
|
|
|
private final Stage window;
|
|
|
private final ObjectProperty<SelectedPreferencesTab> selectedTabProperty;
|
|
|
private final BooleanBinding updateAvailable;
|
|
@@ -37,6 +39,7 @@ public class PreferencesController implements FxController {
|
|
|
public void initialize() {
|
|
|
window.setOnShowing(this::windowWillAppear);
|
|
|
selectedTabProperty.addListener(observable -> this.selectChosenTab());
|
|
|
+ tabPane.getSelectionModel().selectedItemProperty().addListener(observable -> this.selectedTabChanged());
|
|
|
}
|
|
|
|
|
|
private void selectChosenTab() {
|
|
@@ -60,6 +63,16 @@ public class PreferencesController implements FxController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void selectedTabChanged() {
|
|
|
+ Tab selectedTab = tabPane.getSelectionModel().getSelectedItem();
|
|
|
+ try {
|
|
|
+ SelectedPreferencesTab selectedPreferencesTab = SelectedPreferencesTab.valueOf(selectedTab.getId());
|
|
|
+ selectedTabProperty.set(selectedPreferencesTab);
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
+ LOG.error("Unknown preferences tab id: {}", selectedTab.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void windowWillAppear(@SuppressWarnings("unused") WindowEvent windowEvent) {
|
|
|
selectChosenTab();
|
|
|
}
|