wrap locations in scrollPane

This commit is contained in:
Armin Schrenk 2024-01-11 23:48:26 +01:00
parent 2e6c228f3f
commit 4de25afde0
No known key found for this signature in database
GPG Key ID: 8F2992163CBBA7FC
2 changed files with 27 additions and 27 deletions

View File

@ -148,6 +148,8 @@ public class CreateNewVaultLocationController implements FxController {
}
private void createRadioButtonFor(LocationPreset preset) {
assert !radioButtonVBox.getChildren().isEmpty();
Platform.runLater(() -> {
var btn = new RadioButton(preset.name());
btn.setUserData(preset.path());
@ -155,9 +157,7 @@ public class CreateNewVaultLocationController implements FxController {
//in place sorting
var vboxElements = radioButtonVBox.getChildren();
boolean added = false;
int listIndex = 0; //first item of vbox is the list header
while (listIndex < vboxElements.size()) {
listIndex++;
for (int listIndex = 0; listIndex < vboxElements.size(); listIndex++) {
if (vboxElements.get(listIndex) instanceof RadioButton rb) {
//another radio button
if (rb.getText().compareTo(preset.name()) > 0) {
@ -165,13 +165,11 @@ public class CreateNewVaultLocationController implements FxController {
added = true;
break;
}
} else {
//end of all radiobuttons
break;
}
}
if (!added) {
vboxElements.add(listIndex, btn);
vboxElements.add(vboxElements.size() - 1, btn); //last element is always the custom location btn
}
locationPresetsToggler.getToggles().add(btn);

View File

@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
<?import org.cryptomator.ui.controls.FontAwesome5Spinner?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ButtonBar?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.ToggleGroup?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<?import org.cryptomator.ui.controls.FontAwesome5Spinner?>
<?import javafx.scene.layout.StackPane?>
<VBox xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
fx:controller="org.cryptomator.ui.addvaultwizard.CreateNewVaultLocationController"
@ -31,24 +31,26 @@
<children>
<Region VBox.vgrow="ALWAYS"/>
<VBox fx:id="radioButtonVBox" spacing="6">
<Label wrapText="true" text="%addvaultwizard.new.locationInstruction"/>
<!-- PLACEHOLDER, more radio buttons are added programmatically via controller -->
<HBox spacing="12" alignment="CENTER_LEFT">
<RadioButton fx:id="customRadioButton" toggleGroup="${locationPresetsToggler}" text="%addvaultwizard.new.directoryPickerLabel"/>
<Button contentDisplay="LEFT" text="%addvaultwizard.new.directoryPickerButton" onAction="#chooseCustomVaultPath" disable="${controller.usePresetPath}">
<graphic>
<FontAwesome5IconView glyph="FOLDER_OPEN"/>
</graphic>
</Button>
</HBox>
<Region prefHeight="2"/>
<Label wrapText="true" text="%addvaultwizard.new.locationLoading" visible="${controller.loadingPresetLocations}" managed="${controller.loadingPresetLocations}" graphicTextGap="8">
<graphic>
<FontAwesome5Spinner />
</graphic>
</Label>
</VBox>
<Label wrapText="true" text="%addvaultwizard.new.locationInstruction"/>
<ScrollPane hbarPolicy="NEVER">
<VBox fx:id="radioButtonVBox" spacing="6">
<!-- PLACEHOLDER, more radio buttons are added programmatically via controller -->
<HBox spacing="12" alignment="CENTER_LEFT">
<RadioButton fx:id="customRadioButton" toggleGroup="${locationPresetsToggler}" text="%addvaultwizard.new.directoryPickerLabel"/>
<Button contentDisplay="LEFT" text="%addvaultwizard.new.directoryPickerButton" onAction="#chooseCustomVaultPath" disable="${controller.usePresetPath}">
<graphic>
<FontAwesome5IconView glyph="FOLDER_OPEN"/>
</graphic>
</Button>
</HBox>
</VBox>
</ScrollPane>
<Region prefHeight="2"/>
<Label wrapText="true" text="%addvaultwizard.new.locationLoading" visible="${controller.loadingPresetLocations}" managed="${controller.loadingPresetLocations}" graphicTextGap="8">
<graphic>
<FontAwesome5Spinner/>
</graphic>
</Label>
<Region prefHeight="12" VBox.vgrow="NEVER"/>