Files
contract-manager/src/main/java/com/ecep/contract/manager/util/FxmlUtils.java
songqq 6711657663 feat(u8): 添加用友U8配置窗口和数据迁移功能
新增用友U8配置窗口,支持日期和文本配置项的编辑与保存。实现从CloudInfo到CloudYu的数据迁移任务,优化任务执行方式。重构多个同步任务类继承Tasker基类,统一任务处理逻辑。扩展YongYouU8Service功能,添加配置相关接口。调整UI布局和菜单项,增加配置入口。

refactor: 重命名CompanyTableCell为EmployeeRoleTableCell

style: 清理无用导入和格式化代码

fix: 修复ContractTypeSyncTask中分类和方向字段设置错误
2025-08-25 18:57:17 +08:00

89 lines
3.1 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.ecep.contract.manager.util;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.CompletableFuture;
import com.ecep.contract.manager.AppV2;
import com.ecep.contract.manager.Desktop;
import com.ecep.contract.manager.SpringApp;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
public class FxmlUtils {
public static FXMLLoader newLoader(String path) {
FXMLLoader loader = new FXMLLoader();
URL location = AppV2.class.getResource(path);
if (location == null) {
throw new RuntimeException("无法找到窗口资源文件 " + path);
}
loader.setLocation(location);
loader.setControllerFactory(SpringApp::getBean);
return loader;
}
public static CompletableFuture<FXMLLoader> newLoaderAsync(String path,
java.util.function.Consumer<FXMLLoader> consumer) {
return CompletableFuture.supplyAsync(() -> {
FXMLLoader loader = newLoader(path);
try {
loader.load();
} catch (IOException e) {
throw new RuntimeException("Unable open " + path, e);
}
consumer.accept(loader);
return loader;
}).whenComplete((v, ex) -> {
if (ex != null) {
UITools.showExceptionAndWait("无法打开 " + path + " 界面", ex);
}
});
}
/**
* 异步载入显示界面
*
* @param path fxml文件路径类地址 / 开头 根路径
* @param initializeLoader fxml 文件加载完毕后,回调函数
* @param runLater 在JavaFx线程中执行的回调函数
* @return CompletableFuture
*/
public static CompletableFuture<Void> newLoaderAsyncWithRunLater(
String path,
java.util.function.Consumer<FXMLLoader> initializeLoader,
java.util.function.Consumer<FXMLLoader> runLater) {
CompletableFuture<Void> future = new CompletableFuture<>();
CompletableFuture.runAsync(() -> {
try {
FXMLLoader loader = newLoader(path);
if (initializeLoader != null) {
initializeLoader.accept(loader);
}
loader.load();
Platform.runLater(() -> {
try {
runLater.accept(loader);
future.complete(null);
} catch (Exception e) {
future.completeExceptionally(e);
}
});
} catch (IOException e) {
future.completeExceptionally(new RuntimeException("Unable open " + path, e));
}
}, Desktop.instance.getExecutorService()).whenComplete((v, ex) -> {
if (ex != null) {
future.completeExceptionally(ex);
}
});
future.whenComplete((v, ex) -> {
if (ex != null) {
UITools.showExceptionAndWait("无法打开 " + path + " 界面", ex);
}
});
return future;
}
}