Select updates tab when showing preferences window and an update is available

This commit is contained in:
Sebastian Stenzel
2019-07-31 19:28:27 +02:00
parent be43279574
commit e32fbc1d79
2 changed files with 31 additions and 3 deletions

View File

@@ -1,13 +1,40 @@
package org.cryptomator.ui.preferences;
import javafx.beans.binding.BooleanBinding;
import javafx.fxml.FXML;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.fxapp.UpdateChecker;
import javax.inject.Inject;
@PreferencesScoped
public class PreferencesController implements FxController {
private final Stage window;
private final BooleanBinding updateAvailable;
public TabPane tabPane;
public Tab generalTab;
public Tab updatesTab;
@Inject
public PreferencesController() {}
public PreferencesController(@PreferencesWindow Stage window, UpdateChecker updateChecker) {
this.window = window;
this.updateAvailable = updateChecker.latestVersionProperty().isNotNull();
}
@FXML
public void initialize() {
window.setOnShowing(this::windowWillAppear);
}
private void windowWillAppear(WindowEvent windowEvent) {
if (updateAvailable.get()) {
tabPane.getSelectionModel().select(updatesTab);
}
}
}

View File

@@ -4,17 +4,18 @@
<?import javafx.scene.control.TabPane?>
<TabPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:id="tabPane"
fx:controller="org.cryptomator.ui.preferences.PreferencesController"
side="TOP"
tabClosingPolicy="UNAVAILABLE"
tabDragPolicy="FIXED">
<tabs>
<Tab text="TODO General">
<Tab fx:id="generalTab" text="TODO General">
<content>
<fx:include source="/fxml/preferences_general.fxml"/>
</content>
</Tab>
<Tab text="TODO Updates">
<Tab fx:id="updatesTab" text="TODO Updates">
<content>
<fx:include source="/fxml/preferences_updates.fxml"/>
</content>