cleanup in NotificationController

This commit is contained in:
Armin Schrenk
2025-12-10 12:34:09 +01:00
parent 2521cd2bfb
commit 7cfb63ed48
2 changed files with 18 additions and 25 deletions

View File

@@ -81,7 +81,7 @@ public class NotificationController implements FxController {
@FXML
public void processEvent() {
public void processSelectedEvent() {
try {
var ev = selectedEvent.get();
switch (ev.actualEvent()) {
@@ -90,17 +90,19 @@ public class NotificationController implements FxController {
} //normally nothing
}
} finally {
//remove processed event
int i = selectionIndex.get();
events.remove(i);
if (events.isEmpty()) {
close(); //no more events
} else if (events.size() == i) {
i = i - 1;
selectionIndex.set(i); //triggers event update
} else {
selectedEvent.set(events.get(i));
}
removeSelectedEvent();
}
}
private void removeSelectedEvent() {
int i = selectionIndex.get();
events.remove(i);
if (events.isEmpty()) {
close(); //no more events
} else if (events.size() == i) {
selectionIndex.set(i-1); //triggers event update
} else {
selectedEvent.set(events.get(i));
}
}
@@ -144,7 +146,7 @@ public class NotificationController implements FxController {
return description.get();
}
public ObservableValue<String> actionTextProperty() {
public StringProperty actionTextProperty() {
return actionText;
}
@@ -152,14 +154,6 @@ public class NotificationController implements FxController {
return Objects.requireNonNullElse(actionText.get(), "");
}
public ObservableBooleanValue buttonVisibleProperty() {
return actionText.isEmpty().not();
}
public boolean isButtonVisible() {
return actionText.get() != null && !actionText.get().isBlank();
}
public ObservableStringValue pagingProperty() {
return paging;
}

View File

@@ -13,7 +13,7 @@
<BorderPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="org.cryptomator.ui.notification.NotificationController"
prefHeight="200.0" prefWidth="300.0" maxHeight="300.0" maxWidth="400.0"
prefHeight="200.0" prefWidth="400.0" maxHeight="200.0" maxWidth="400.0"
styleClass="notification-window">
<padding>
<Insets top="12" right="12" bottom="12" left="12"/>
@@ -35,15 +35,14 @@
<center>
<VBox spacing="12">
<!--Label text="${controller.message}" styleClass="label-large" wrapText="true"/-->
<Label text="${controller.description}" styleClass="label" wrapText="true"/>
</VBox>
</center>
<bottom>
<HBox spacing="6" alignment="CENTER_LEFT">
<Button text="${controller.actionText}" onAction="#processEvent"
visible="${controller.buttonVisible}" managed="${controller.buttonVisible}"/>
<Button text="${controller.actionText}" onAction="#processSelectedEvent"
visible="${!controller.actionText.empty}" managed="${!controller.actionText.empty}"/>
<Region HBox.hgrow="ALWAYS"/>
<Button contentDisplay="GRAPHIC_ONLY" styleClass="nav-button" onAction="#previousNotification">
<graphic>