Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update title upon refresh #93

Merged
merged 3 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion framework/src/main/java/org/fulib/fx/FulibFxApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void stop() {
*/
protected void prepareDisplay(@Nullable String route, @NotNull Parent parent, @NotNull Object controller, @NotNull Map<String, Object> params) {
this.currentMainController = controller;
getTitle(currentMainController).ifPresent(title -> stage.setTitle(formatTitle(title)));
applyTitle(currentMainController, stage);
display(parent);
onShow(Optional.ofNullable(route), controller, parent, params);
}
Expand Down Expand Up @@ -406,6 +406,7 @@ public void refresh() {
throw new IllegalArgumentException(error(1011).formatted(controller.getClass().getName()));
}
ReflectionUtil.resetMouseHandler(stage());
applyTitle(controller, stage());
display(parent);
}

Expand Down Expand Up @@ -449,6 +450,16 @@ public Optional<String> getTitle(Object controller) {
return this.frameworkComponent.controllerManager().getTitle(controller);
}

/**
* Applies the title of the given controller to the stage.
*
* @param controller The controller instance
* @param stage The stage to apply the title to
*/
public void applyTitle(Object controller, Stage stage) {
getTitle(controller).ifPresent(title -> stage.setTitle(formatTitle(title)));
}

/**
* Sets the history size of the application.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public static <Display extends Node> void showModal(FulibFxApp app, Stage curren
}

// Set the title if present
app.getTitle(component).ifPresent(title -> modalStage.setTitle(app.formatTitle(title)));
app.applyTitle(component, modalStage);

// Configure scene to look like a popup (can be changed using the initializer)
Scene scene = new Scene(parent);
Expand Down