增加文件管理功能
BIN
.image/javafx/文件列表1.png
Normal file
After Width: | Height: | Size: 404 KiB |
BIN
.image/javafx/文件列表2.png
Normal file
After Width: | Height: | Size: 424 KiB |
BIN
.image/javafx/文件列表3.png
Normal file
After Width: | Height: | Size: 418 KiB |
BIN
.image/javafx/文件配置1.png
Normal file
After Width: | Height: | Size: 158 KiB |
BIN
.image/javafx/文件配置2.png
Normal file
After Width: | Height: | Size: 166 KiB |
BIN
.image/javafx/文件配置3.png
Normal file
After Width: | Height: | Size: 163 KiB |
BIN
.image/swing/文件列表1.png
Normal file
After Width: | Height: | Size: 302 KiB |
BIN
.image/swing/文件列表2.png
Normal file
After Width: | Height: | Size: 346 KiB |
BIN
.image/swing/文件列表3.png
Normal file
After Width: | Height: | Size: 649 KiB |
BIN
.image/swing/文件配置1.png
Normal file
After Width: | Height: | Size: 154 KiB |
BIN
.image/swing/文件配置2.png
Normal file
After Width: | Height: | Size: 185 KiB |
BIN
.image/swing/文件配置3.png
Normal file
After Width: | Height: | Size: 491 KiB |
@ -144,6 +144,8 @@ HTTP库:使用 OpenFeign HTTP库,该库提供了方便的 HTTP 请求和响
|
||||
| 操作日志 |  |  |  |
|
||||
| 登录日志 |  |  |  |
|
||||
| 令牌管理 |  |  |  |
|
||||
| 文件配置 |  |  |  |
|
||||
| 文件列表 |  |  |  |
|
||||
|
||||
### Java Swing
|
||||
|
||||
@ -159,8 +161,9 @@ HTTP库:使用 OpenFeign HTTP库,该库提供了方便的 HTTP 请求和响
|
||||
| 字典数据 |  |  |  |
|
||||
| 通知公告 |  |  |  |
|
||||
| 消息模板 |  |  |  |
|
||||
| 消息记录 |  |  |  |
|
||||
| 我的消息 |  |  |  |
|
||||
| 消息记录 |  |  |  |
|
||||
| 我的消息 |  |  |  |
|
||||
| 操作日志 |  |  |  |
|
||||
| 登录日志 |  |  |  |
|
||||
|
||||
| 文件配置 |  |  |  |
|
||||
| 文件列表 |  |  |  |
|
||||
|
@ -82,7 +82,7 @@
|
||||
<jfreechart.version>1.5.3</jfreechart.version>
|
||||
<!-- pinyin4j -->
|
||||
<pinyin4j.version>2.5.1</pinyin4j.version>
|
||||
<openfeign.version>13.2.1</openfeign.version>
|
||||
<openfeign.version>13.3</openfeign.version>
|
||||
|
||||
</properties>
|
||||
|
||||
@ -686,6 +686,11 @@
|
||||
<version>${openfeign.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-form</artifactId>
|
||||
<version>${openfeign.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
@ -43,9 +43,11 @@ public class FileController {
|
||||
public CommonResult<String> uploadFile(FileUploadReqVO uploadReqVO) throws Exception {
|
||||
MultipartFile file = uploadReqVO.getFile();
|
||||
String path = uploadReqVO.getPath();
|
||||
|
||||
return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/presigned-url")
|
||||
@Operation(summary = "获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器")
|
||||
public CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@RequestParam("path") String path) throws Exception {
|
||||
|
@ -47,6 +47,16 @@
|
||||
<artifactId>feign-slf4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign.form</groupId>
|
||||
<artifactId>feign-form</artifactId>
|
||||
<version>3.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign.form</groupId>
|
||||
<artifactId>feign-form-spring</artifactId>
|
||||
<version>3.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
@ -66,6 +76,12 @@
|
||||
<artifactId>Java-WebSocket</artifactId>
|
||||
<version>1.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.lw.dillon</groupId>
|
||||
<artifactId>dillon-module-infra-biz</artifactId>
|
||||
<version>2.1.0-jdk8-snapshot</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,44 @@
|
||||
package com.lw.ui.request.api.file;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.framework.common.pojo.PageResult;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.config.FileConfigRespVO;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import com.lw.ui.request.api.BaseFeignApi;
|
||||
import feign.Param;
|
||||
import feign.QueryMap;
|
||||
import feign.RequestLine;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface FileConfigFeign extends BaseFeignApi {
|
||||
|
||||
//"创建文件配置")
|
||||
@RequestLine("POST /admin-api/infra/file-config/create")
|
||||
CommonResult<Long> createFileConfig( FileConfigSaveReqVO createReqVO);
|
||||
|
||||
//"更新文件配置")
|
||||
@RequestLine("PUT /admin-api/infra/file-config/update")
|
||||
CommonResult<Boolean> updateFileConfig( FileConfigSaveReqVO updateReqVO);
|
||||
|
||||
//"更新文件配置为 Master")
|
||||
@RequestLine("PUT /admin-api/infra/file-config/update-master?id={id}")
|
||||
CommonResult<Boolean> updateFileConfigMaster(@Param("id") Long id);
|
||||
|
||||
//"删除文件配置")
|
||||
@RequestLine("DELETE /admin-api/infra/file-config/delete?id={id}")
|
||||
CommonResult<Boolean> deleteFileConfig(@Param("id") Long id);
|
||||
|
||||
//"获得文件配置")
|
||||
@RequestLine("GET /admin-api/infra/file-config/get?id={id}")
|
||||
CommonResult<JsonObject> getFileConfig(@Param("id") Long id);
|
||||
|
||||
//"获得文件配置分页")
|
||||
@RequestLine("GET /admin-api/infra/file-config/page")
|
||||
CommonResult<PageResult<JsonObject>> getFileConfigPage(@QueryMap Map<String,Object> map);
|
||||
|
||||
//"测试文件配置是否正确")
|
||||
@RequestLine("GET /admin-api/infra/file-config/test?id={id}")
|
||||
CommonResult<String> testFileConfig(@Param("id") Long id) throws Exception;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.lw.ui.request.api.file;
|
||||
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.framework.common.pojo.PageResult;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.file.FileCreateReqVO;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.file.FileRespVO;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.file.FileUploadReqVO;
|
||||
import com.lw.ui.request.api.BaseFeignApi;
|
||||
import feign.Headers;
|
||||
import feign.Param;
|
||||
import feign.QueryMap;
|
||||
import feign.RequestLine;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
public interface FileFeign extends BaseFeignApi {
|
||||
|
||||
|
||||
// "上传文件", description = "模式一:后端上传文件")
|
||||
@RequestLine("POST /admin-api/infra/file/upload")
|
||||
@Headers("Content-Type: multipart/form-data; boundary=----WebKitFormBoundarypATHfppjzqwXomVO")
|
||||
CommonResult<String> uploadFile(@Param("path") String path, @Param("file") File file);
|
||||
|
||||
|
||||
// "获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器")
|
||||
@RequestLine("GET /admin-api/infra/file/presigned-url?path={path}")
|
||||
CommonResult<FilePresignedUrlRespVO> getFilePresignedUrl(@Param("path") String path);
|
||||
|
||||
// "创建文件", description = "模式二:前端上传文件:配合 presigned-url 接口,记录上传了上传的文件")
|
||||
@RequestLine("POST /admin-api/infra/file/create")
|
||||
CommonResult<Long> createFile(FileCreateReqVO createReqVO);
|
||||
|
||||
// "删除文件")
|
||||
@RequestLine("DELETE /admin-api/infra/file/delete?id={id}")
|
||||
CommonResult<Boolean> deleteFile(@Param("id") Long id);
|
||||
|
||||
// "下载文件")
|
||||
@RequestLine("GET /admin-api/infra/file/{configId}/get/**")
|
||||
void getFileContent(@Param("configId") Long configId) throws Exception;
|
||||
|
||||
// "获得文件分页")
|
||||
@RequestLine("GET /admin-api/infra/file/page")
|
||||
CommonResult<PageResult<FileRespVO>> getFilePage(@QueryMap Map<String, Object> pageVO);
|
||||
|
||||
}
|
@ -221,6 +221,7 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
@ -2,9 +2,12 @@ package com.lw.fx.request;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.lw.dillon.admin.module.infra.framework.file.core.client.FileClientConfig;
|
||||
import com.lw.fx.request.feign.FileClientConfigAdapter;
|
||||
import com.lw.fx.request.feign.interceptor.ForwardedForInterceptor;
|
||||
import com.lw.fx.request.feign.interceptor.OkHttpInterceptor;
|
||||
import com.lw.ui.request.api.BaseFeignApi;
|
||||
import com.lw.ui.request.api.file.FileFeign;
|
||||
import com.lw.ui.request.gson.LocalDateTimeTypeAdapter;
|
||||
import com.lw.ui.request.gson.LocalDateTypeAdapter;
|
||||
import com.lw.ui.request.gson.ZonedDateTimeTypeAdapter;
|
||||
@ -14,8 +17,10 @@ import feign.Logger;
|
||||
import feign.Retryer;
|
||||
import feign.codec.Decoder;
|
||||
import feign.codec.Encoder;
|
||||
import feign.form.spring.SpringFormEncoder;
|
||||
import feign.gson.GsonDecoder;
|
||||
import feign.gson.GsonEncoder;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.okhttp.OkHttpClient;
|
||||
import feign.querymap.BeanQueryMapEncoder;
|
||||
import feign.slf4j.Slf4jLogger;
|
||||
@ -47,6 +52,7 @@ public class Request {
|
||||
|
||||
private static final okhttp3.OkHttpClient OK_HTTP_CLIENT = createOkHttpClient();
|
||||
private static final Feign.Builder BUILDER = createFeignBuilder();
|
||||
private static final Feign.Builder FILE_BUILDER = createFileFeignBuilder();
|
||||
private static final AsyncFeign.AsyncBuilder ASYNC_BUILDER = createAsyncFeignBuilder();
|
||||
|
||||
private Request() {
|
||||
@ -62,6 +68,10 @@ public class Request {
|
||||
return connector(connectorClass, READ_TIME_OUT_MILLIS);
|
||||
}
|
||||
|
||||
public static <T extends BaseFeignApi> T fileConnector(Class<T> connectorClass) {
|
||||
return FILE_BUILDER.target(connectorClass, API_URL);
|
||||
}
|
||||
|
||||
|
||||
public static <T extends BaseFeignApi> T asyncConnector(Class<T> connectorClass, int readTimeOut) {
|
||||
final String key = connectorClass.getSimpleName() + readTimeOut;
|
||||
@ -102,4 +112,14 @@ public class Request {
|
||||
.requestInterceptor(new ForwardedForInterceptor())
|
||||
.retryer(new Retryer.Default()); // 默认重试策略
|
||||
}
|
||||
|
||||
private static Feign.Builder createFileFeignBuilder() {
|
||||
|
||||
|
||||
return Feign.builder()
|
||||
.encoder(new SpringFormEncoder())
|
||||
.decoder(new JacksonDecoder())
|
||||
.requestInterceptor(new ForwardedForInterceptor());
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.lw.fx.request.feign;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.lw.dillon.admin.module.infra.framework.file.core.client.FileClientConfig;
|
||||
import com.lw.dillon.admin.module.infra.framework.file.core.client.db.DBFileClientConfig;
|
||||
import com.lw.dillon.admin.module.infra.framework.file.core.client.ftp.FtpFileClientConfig;
|
||||
import com.lw.dillon.admin.module.infra.framework.file.core.client.local.LocalFileClientConfig;
|
||||
import com.lw.dillon.admin.module.infra.framework.file.core.client.s3.S3FileClientConfig;
|
||||
import com.lw.dillon.admin.module.infra.framework.file.core.client.sftp.SftpFileClientConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
// TypeAdapter 实现
|
||||
public class FileClientConfigAdapter extends TypeAdapter<FileClientConfig> {
|
||||
|
||||
@Override
|
||||
public void write(JsonWriter out, FileClientConfig value) throws IOException {
|
||||
out.beginObject();
|
||||
|
||||
out.endObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileClientConfig read(JsonReader in) throws IOException {
|
||||
JsonObject jsonObject = JsonParser.parseReader(in).getAsJsonObject();
|
||||
String className = jsonObject.get("@class").getAsString();
|
||||
className = StrUtil.subAfter(className, ".", true);
|
||||
|
||||
switch (className) {
|
||||
case "DBFileClientConfig":
|
||||
return new Gson().fromJson(jsonObject, DBFileClientConfig.class);
|
||||
case "FtpFileClientConfig":
|
||||
return new Gson().fromJson(jsonObject, FtpFileClientConfig.class);
|
||||
case "LocalFileClientConfig":
|
||||
return new Gson().fromJson(jsonObject, LocalFileClientConfig.class);
|
||||
case "SftpFileClientConfig":
|
||||
return new Gson().fromJson(jsonObject, SftpFileClientConfig.class);
|
||||
case "S3FileClientConfig":
|
||||
return new Gson().fromJson(jsonObject, S3FileClientConfig.class);
|
||||
default:
|
||||
throw new JsonParseException("未知的 FileClientConfig 类型:" + className);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,5 +10,7 @@ public class ForwardedForInterceptor implements RequestInterceptor {
|
||||
public void apply(RequestTemplate template) {
|
||||
|
||||
template.header("Authorization", AppStore.getToken());
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,202 @@
|
||||
package com.lw.fx.view.infra.file;
|
||||
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.fx.store.AppStore;
|
||||
import de.saxsys.mvvmfx.FxmlView;
|
||||
import de.saxsys.mvvmfx.InjectViewModel;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.RadioButton;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static com.lw.ui.utils.DictTypeEnum.INFRA_FILE_STORAGE;
|
||||
|
||||
public class FileConfigFormView implements FxmlView<FileConfigFormViewModel>, Initializable {
|
||||
|
||||
@InjectViewModel
|
||||
private FileConfigFormViewModel viewModel;
|
||||
@FXML
|
||||
private HBox accessKeyBox;
|
||||
|
||||
@FXML
|
||||
private TextField accessKeyField;
|
||||
|
||||
@FXML
|
||||
private HBox accessSecretBox;
|
||||
|
||||
@FXML
|
||||
private TextField accessSecretField;
|
||||
|
||||
@FXML
|
||||
private HBox basePathBox;
|
||||
|
||||
@FXML
|
||||
private TextField basePathField;
|
||||
|
||||
@FXML
|
||||
private HBox bucketBox;
|
||||
|
||||
@FXML
|
||||
private TextField bucketField;
|
||||
|
||||
@FXML
|
||||
private TextField domainField;
|
||||
|
||||
@FXML
|
||||
private HBox endpointBox;
|
||||
|
||||
@FXML
|
||||
private TextField endpointField;
|
||||
|
||||
@FXML
|
||||
private ToggleGroup group;
|
||||
|
||||
@FXML
|
||||
private HBox hostBox;
|
||||
|
||||
@FXML
|
||||
private TextField hostField;
|
||||
|
||||
@FXML
|
||||
private HBox modeBox;
|
||||
|
||||
@FXML
|
||||
private RadioButton modeRadioBut1;
|
||||
|
||||
@FXML
|
||||
private RadioButton modeRadioBut2;
|
||||
|
||||
@FXML
|
||||
private TextField nameField;
|
||||
|
||||
@FXML
|
||||
private TextField remarkField;
|
||||
|
||||
@FXML
|
||||
private HBox passwordBox;
|
||||
|
||||
@FXML
|
||||
private TextField passwordField;
|
||||
|
||||
@FXML
|
||||
private HBox portBox;
|
||||
|
||||
@FXML
|
||||
private TextField portField;
|
||||
|
||||
@FXML
|
||||
private VBox rootBox;
|
||||
@FXML
|
||||
private HBox domainBox;
|
||||
|
||||
@FXML
|
||||
private ComboBox<DictDataSimpleRespVO> storageComboBox;
|
||||
|
||||
@FXML
|
||||
private HBox usernameBox;
|
||||
|
||||
@FXML
|
||||
private TextField usernameField;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
|
||||
storageComboBox.setItems(FXCollections.observableArrayList(AppStore.getDictDataList(INFRA_FILE_STORAGE)));
|
||||
nameField.textProperty().bindBidirectional(viewModel.nameProperty());
|
||||
remarkField.textProperty().bindBidirectional(viewModel.remarkProperty());
|
||||
storageComboBox.valueProperty().bindBidirectional(viewModel.selStorageProperty());
|
||||
storageComboBox.disableProperty().bind(viewModel.editProperty());
|
||||
domainField.textProperty().bindBidirectional(viewModel.domainProperty());
|
||||
basePathField.textProperty().bindBidirectional(viewModel.basePathProperty());
|
||||
hostField.textProperty().bindBidirectional(viewModel.hostProperty());
|
||||
portField.textProperty().bindBidirectional(viewModel.portProperty());
|
||||
usernameField.textProperty().bindBidirectional(viewModel.usernameProperty());
|
||||
passwordField.textProperty().bindBidirectional(viewModel.passwordProperty());
|
||||
endpointField.textProperty().bindBidirectional(viewModel.endpointProperty());
|
||||
bucketField.textProperty().bindBidirectional(viewModel.bucketProperty());
|
||||
accessKeyField.textProperty().bindBidirectional(viewModel.accessKeyProperty());
|
||||
accessSecretField.textProperty().bindBidirectional(viewModel.accessSecretProperty());
|
||||
storageComboBox.valueProperty().addListener((observableValue, dictDataSimpleRespVO, t1) -> showStorage(Optional.of(t1).map(DictDataSimpleRespVO::getLabel).orElse("")));
|
||||
|
||||
domainBox.managedProperty().bind(domainBox.visibleProperty());
|
||||
basePathBox.managedProperty().bind(basePathBox.visibleProperty());
|
||||
hostBox.managedProperty().bind(hostBox.visibleProperty());
|
||||
portBox.managedProperty().bind(portBox.visibleProperty());
|
||||
usernameBox.managedProperty().bind(usernameBox.visibleProperty());
|
||||
passwordBox.managedProperty().bind(passwordBox.visibleProperty());
|
||||
endpointBox.managedProperty().bind(endpointBox.visibleProperty());
|
||||
bucketBox.managedProperty().bind(bucketBox.visibleProperty());
|
||||
accessKeyBox.managedProperty().bind(accessKeyBox.visibleProperty());
|
||||
accessSecretBox.managedProperty().bind(accessSecretBox.visibleProperty());
|
||||
modeBox.managedProperty().bind(modeBox.visibleProperty());
|
||||
|
||||
showStorage("");
|
||||
}
|
||||
|
||||
|
||||
private void showStorage(String type) {
|
||||
|
||||
domainBox.setVisible(false);
|
||||
basePathBox.setVisible(false);
|
||||
hostBox.setVisible(false);
|
||||
portBox.setVisible(false);
|
||||
usernameBox.setVisible(false);
|
||||
passwordBox.setVisible(false);
|
||||
endpointBox.setVisible(false);
|
||||
bucketBox.setVisible(false);
|
||||
accessKeyBox.setVisible(false);
|
||||
accessSecretBox.setVisible(false);
|
||||
modeBox.setVisible(false);
|
||||
|
||||
switch (type) {
|
||||
case "数据库": {
|
||||
domainBox.setVisible(true);
|
||||
break;
|
||||
}
|
||||
case "本地磁盘": {
|
||||
domainBox.setVisible(true);
|
||||
basePathBox.setVisible(true);
|
||||
break;
|
||||
}
|
||||
case "FTP 服务器": {
|
||||
domainBox.setVisible(true);
|
||||
basePathBox.setVisible(true);
|
||||
hostBox.setVisible(true);
|
||||
portBox.setVisible(true);
|
||||
usernameBox.setVisible(true);
|
||||
passwordBox.setVisible(true);
|
||||
break;
|
||||
}
|
||||
case "SFTP 服务器": {
|
||||
domainBox.setVisible(true);
|
||||
basePathBox.setVisible(true);
|
||||
hostBox.setVisible(true);
|
||||
portBox.setVisible(true);
|
||||
usernameBox.setVisible(true);
|
||||
passwordBox.setVisible(true);
|
||||
modeBox.setVisible(true);
|
||||
break;
|
||||
}
|
||||
case "S3 对象存储": {
|
||||
|
||||
endpointBox.setVisible(true);
|
||||
bucketBox.setVisible(true);
|
||||
accessKeyBox.setVisible(true);
|
||||
accessSecretBox.setVisible(true);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,267 @@
|
||||
package com.lw.fx.view.infra.file;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.fx.request.Request;
|
||||
import com.lw.fx.store.AppStore;
|
||||
import com.lw.ui.request.api.file.FileConfigFeign;
|
||||
import de.saxsys.mvvmfx.ViewModel;
|
||||
import io.datafx.core.concurrent.ProcessChain;
|
||||
import javafx.beans.property.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.lw.ui.utils.DictTypeEnum.INFRA_FILE_STORAGE;
|
||||
|
||||
public class FileConfigFormViewModel implements ViewModel {
|
||||
|
||||
private ObjectProperty<Long> id = new SimpleObjectProperty<>();
|
||||
private StringProperty name = new SimpleStringProperty();
|
||||
private StringProperty remark = new SimpleStringProperty();
|
||||
private StringProperty domain = new SimpleStringProperty();
|
||||
private StringProperty basePath = new SimpleStringProperty();
|
||||
private StringProperty host = new SimpleStringProperty();
|
||||
private StringProperty port = new SimpleStringProperty();
|
||||
private StringProperty username = new SimpleStringProperty();
|
||||
private StringProperty password = new SimpleStringProperty();
|
||||
private StringProperty mode = new SimpleStringProperty();
|
||||
private StringProperty endpoint = new SimpleStringProperty();
|
||||
private StringProperty bucket = new SimpleStringProperty();
|
||||
private StringProperty accessKey = new SimpleStringProperty();
|
||||
private StringProperty accessSecret = new SimpleStringProperty();
|
||||
private BooleanProperty edit = new SimpleBooleanProperty(false);
|
||||
|
||||
|
||||
private ObjectProperty<DictDataSimpleRespVO> selStorage = new SimpleObjectProperty<>();
|
||||
|
||||
public void updateData(Long id, boolean isAdd) {
|
||||
|
||||
this.id.set(id);
|
||||
edit.set(!isAdd);
|
||||
ProcessChain.create()
|
||||
.addSupplierInExecutor(() -> {
|
||||
if (id == null) {
|
||||
return new FileConfigSaveReqVO();
|
||||
}
|
||||
JsonObject jsonObject = Request.connector(FileConfigFeign.class).getFileConfig(id).getData();
|
||||
FileConfigSaveReqVO saveReqVO = new FileConfigSaveReqVO();
|
||||
saveReqVO.setName(jsonObject.get("name").getAsString());
|
||||
saveReqVO.setStorage(jsonObject.get("storage").getAsInt());
|
||||
saveReqVO.setRemark(jsonObject.get("remark").getAsString());
|
||||
saveReqVO.setId(jsonObject.get("id").getAsLong());
|
||||
JsonObject config = jsonObject.getAsJsonObject("config");
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Iterator<String> keys = config.keySet().iterator();
|
||||
while (keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
Object value = config.get(key).getAsString();
|
||||
map.put(key, value);
|
||||
}
|
||||
saveReqVO.setConfig(map);
|
||||
return saveReqVO;
|
||||
|
||||
})
|
||||
.addConsumerInPlatformThread(rel -> {
|
||||
|
||||
name.set(rel.getName());
|
||||
remark.set(rel.getRemark());
|
||||
if (rel.getConfig() != null) {
|
||||
|
||||
domain.set(Convert.toStr(rel.getConfig().get("domain")));
|
||||
basePath.set(Convert.toStr(rel.getConfig().get("basePath")));
|
||||
host.set(Convert.toStr(rel.getConfig().get("host")));
|
||||
port.set(Convert.toStr(rel.getConfig().get("port")));
|
||||
username.set(Convert.toStr(rel.getConfig().get("username")));
|
||||
password.set(Convert.toStr(rel.getConfig().get("password")));
|
||||
mode.set(Convert.toStr(rel.getConfig().get("mode")));
|
||||
endpoint.set(Convert.toStr(rel.getConfig().get("endpoint")));
|
||||
bucket.set(Convert.toStr(rel.getConfig().get("bucket")));
|
||||
accessKey.set(Convert.toStr(rel.getConfig().get("accessKey")));
|
||||
accessSecret.set(Convert.toStr(rel.getConfig().get("accessSecret")));
|
||||
|
||||
}
|
||||
|
||||
if (isEdit()) {
|
||||
DictDataSimpleRespVO sel = AppStore.getDictDataValueMap(INFRA_FILE_STORAGE).get(rel.getStorage() + "");
|
||||
selStorage.set(sel);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
.run();
|
||||
|
||||
}
|
||||
|
||||
public CommonResult save(boolean isAdd) {
|
||||
|
||||
if (isAdd) {
|
||||
return Request.connector(FileConfigFeign.class).createFileConfig(getSaveReqVO());
|
||||
} else {
|
||||
return Request.connector(FileConfigFeign.class).updateFileConfig(getSaveReqVO());
|
||||
}
|
||||
}
|
||||
|
||||
public FileConfigSaveReqVO getSaveReqVO() {
|
||||
FileConfigSaveReqVO saveReqVO = new FileConfigSaveReqVO();
|
||||
|
||||
saveReqVO.setName(name.get());
|
||||
saveReqVO.setId(id.get());
|
||||
saveReqVO.setRemark(remark.get());
|
||||
saveReqVO.setStorage(Convert.toInt(selStorage.get().getValue(),null));
|
||||
Map<String, Object> config = new HashMap<>();
|
||||
createConfig("domain", domain.get(), config);
|
||||
createConfig("basePath", basePath.get(), config);
|
||||
createConfig("host", host.get(), config);
|
||||
createConfig("username", username.get(), config);
|
||||
createConfig("mode", mode.get(), config);
|
||||
createConfig("endpoint", endpoint.get(), config);
|
||||
createConfig("bucket", bucket.get(), config);
|
||||
createConfig("accessKey", accessKey.get(), config);
|
||||
createConfig("accessSecret", accessSecret.get(), config);
|
||||
saveReqVO.setConfig(config);
|
||||
return saveReqVO;
|
||||
}
|
||||
|
||||
private void createConfig(String key,String value, Map<String, Object> config) {
|
||||
|
||||
if ( StrUtil.isNotBlank(value)) {
|
||||
config.put(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DictDataSimpleRespVO getSelStorage() {
|
||||
return selStorage.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<DictDataSimpleRespVO> selStorageProperty() {
|
||||
return selStorage;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name.get();
|
||||
}
|
||||
|
||||
public StringProperty nameProperty() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark.get();
|
||||
}
|
||||
|
||||
public StringProperty remarkProperty() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain.get();
|
||||
}
|
||||
|
||||
public StringProperty domainProperty() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public String getBasePath() {
|
||||
return basePath.get();
|
||||
}
|
||||
|
||||
public StringProperty basePathProperty() {
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host.get();
|
||||
}
|
||||
|
||||
public StringProperty hostProperty() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port.get();
|
||||
}
|
||||
|
||||
public StringProperty portProperty() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username.get();
|
||||
}
|
||||
|
||||
public StringProperty usernameProperty() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password.get();
|
||||
}
|
||||
|
||||
public StringProperty passwordProperty() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getMode() {
|
||||
return mode.get();
|
||||
}
|
||||
|
||||
public StringProperty modeProperty() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint.get();
|
||||
}
|
||||
|
||||
public StringProperty endpointProperty() {
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
public String getBucket() {
|
||||
return bucket.get();
|
||||
}
|
||||
|
||||
public StringProperty bucketProperty() {
|
||||
return bucket;
|
||||
}
|
||||
|
||||
public String getAccessKey() {
|
||||
return accessKey.get();
|
||||
}
|
||||
|
||||
public StringProperty accessKeyProperty() {
|
||||
return accessKey;
|
||||
}
|
||||
|
||||
public String getAccessSecret() {
|
||||
return accessSecret.get();
|
||||
}
|
||||
|
||||
public StringProperty accessSecretProperty() {
|
||||
return accessSecret;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<Long> idProperty() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isEdit() {
|
||||
return edit.get();
|
||||
}
|
||||
|
||||
public BooleanProperty editProperty() {
|
||||
return edit;
|
||||
}
|
||||
}
|
@ -0,0 +1,391 @@
|
||||
package com.lw.fx.view.infra.file;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.dlsc.gemsfx.DialogPane;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.config.FileConfigRespVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.fx.request.Request;
|
||||
import com.lw.fx.store.AppStore;
|
||||
import com.lw.fx.util.MessageType;
|
||||
import com.lw.fx.view.control.PagingControl;
|
||||
import com.lw.fx.view.control.WFXGenericDialog;
|
||||
import com.lw.ui.request.api.file.FileConfigFeign;
|
||||
import de.saxsys.mvvmfx.*;
|
||||
import io.datafx.core.concurrent.ProcessChain;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.Callback;
|
||||
import org.kordamp.ikonli.feather.Feather;
|
||||
import org.kordamp.ikonli.javafx.FontIcon;
|
||||
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static atlantafx.base.theme.Styles.*;
|
||||
import static com.lw.ui.utils.DictTypeEnum.INFRA_BOOLEAN_STRING;
|
||||
import static com.lw.ui.utils.DictTypeEnum.INFRA_FILE_STORAGE;
|
||||
|
||||
public class FileConfigView implements FxmlView<FileConfigViewModel>, Initializable {
|
||||
@InjectViewModel
|
||||
private FileConfigViewModel viewModel;
|
||||
@FXML
|
||||
private VBox contentPane;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileConfigRespVO, LocalDateTime> createTimeCol;
|
||||
|
||||
@FXML
|
||||
private Button addBut;
|
||||
|
||||
@FXML
|
||||
private DatePicker endDatePicker;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileConfigRespVO, ?> idCol;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileConfigRespVO, ?> nameCol;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileConfigRespVO, Long> optCol;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileConfigRespVO, Boolean> primaryCol;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileConfigRespVO, ?> remarkCol;
|
||||
|
||||
@FXML
|
||||
private Button resetBut;
|
||||
|
||||
@FXML
|
||||
private StackPane rootPane;
|
||||
|
||||
@FXML
|
||||
private Button searchBut;
|
||||
|
||||
@FXML
|
||||
private DatePicker startDatePicker;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileConfigRespVO, Integer> storageCol;
|
||||
|
||||
@FXML
|
||||
private TableView<FileConfigRespVO> tableView;
|
||||
|
||||
@FXML
|
||||
private TextField nameField;
|
||||
|
||||
@FXML
|
||||
private ComboBox<DictDataSimpleRespVO> storageComboBox;
|
||||
|
||||
private PagingControl pagingControl;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
|
||||
pagingControl = new PagingControl();
|
||||
contentPane.getChildren().add(pagingControl);
|
||||
|
||||
pagingControl.totalProperty().bind(viewModel.totalProperty());
|
||||
viewModel.pageNumProperty().bind(pagingControl.pageNumProperty());
|
||||
viewModel.pageSizeProperty().bind(pagingControl.pageSizeProperty());
|
||||
pagingControl.pageNumProperty().addListener((observable, oldValue, newValue) -> {
|
||||
viewModel.loadTableData();
|
||||
});
|
||||
|
||||
pagingControl.pageSizeProperty().addListener((observable, oldValue, newValue) -> {
|
||||
viewModel.loadTableData();
|
||||
});
|
||||
|
||||
storageComboBox.setItems(FXCollections.observableArrayList(AppStore.getDictDataList(INFRA_FILE_STORAGE)));
|
||||
storageComboBox.valueProperty().bindBidirectional(viewModel.storageProperty());
|
||||
nameField.textProperty().bindBidirectional(viewModel.nameProperty());
|
||||
|
||||
|
||||
idCol.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
idCol.setStyle("-fx-alignment: CENTER");
|
||||
|
||||
nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||
nameCol.setStyle("-fx-alignment: CENTER");
|
||||
|
||||
storageCol.setCellValueFactory(new PropertyValueFactory<>("storage"));
|
||||
storageCol.setStyle("-fx-alignment: CENTER");
|
||||
storageCol.setCellFactory(new Callback<TableColumn<FileConfigRespVO, Integer>, TableCell<FileConfigRespVO, Integer>>() {
|
||||
@Override
|
||||
public TableCell<FileConfigRespVO, Integer> call(TableColumn<FileConfigRespVO, Integer> param) {
|
||||
return new TableCell<>() {
|
||||
@Override
|
||||
protected void updateItem(Integer item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
|
||||
|
||||
DictDataSimpleRespVO dict = AppStore.getDictDataValueMap(INFRA_FILE_STORAGE).get(item + "");
|
||||
Button state = new Button(dict.getLabel());
|
||||
switch (dict.getColorType()) {
|
||||
case "primary":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED, ACCENT);
|
||||
break;
|
||||
case "success":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED, SUCCESS);
|
||||
break;
|
||||
case "info":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED);
|
||||
break;
|
||||
case "warning":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED, WARNING);
|
||||
break;
|
||||
case "danger":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED, DANGER);
|
||||
break;
|
||||
default:
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED);
|
||||
}
|
||||
|
||||
HBox box = new HBox(state);
|
||||
box.setPadding(new Insets(7, 7, 7, 7));
|
||||
box.setAlignment(Pos.CENTER);
|
||||
setGraphic(box);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
remarkCol.setCellValueFactory(new PropertyValueFactory<>("remark"));
|
||||
remarkCol.setStyle("-fx-alignment: CENTER");
|
||||
|
||||
|
||||
primaryCol.setCellValueFactory(new PropertyValueFactory<>("master"));
|
||||
primaryCol.setStyle("-fx-alignment: CENTER");
|
||||
primaryCol.setCellFactory(new Callback<TableColumn<FileConfigRespVO, Boolean>, TableCell<FileConfigRespVO, Boolean>>() {
|
||||
@Override
|
||||
public TableCell<FileConfigRespVO, Boolean> call(TableColumn<FileConfigRespVO, Boolean> param) {
|
||||
return new TableCell<>() {
|
||||
@Override
|
||||
protected void updateItem(Boolean item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
|
||||
DictDataSimpleRespVO dict = AppStore.getDictDataValueMap(INFRA_BOOLEAN_STRING).get(item + "");
|
||||
Button state = new Button(dict.getLabel());
|
||||
switch (dict.getColorType()) {
|
||||
case "primary":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED, ACCENT);
|
||||
break;
|
||||
case "success":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED, SUCCESS);
|
||||
break;
|
||||
case "info":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED);
|
||||
break;
|
||||
case "warning":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED, WARNING);
|
||||
break;
|
||||
case "danger":
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED, DANGER);
|
||||
break;
|
||||
default:
|
||||
state.getStyleClass().addAll(BUTTON_OUTLINED);
|
||||
}
|
||||
|
||||
HBox box = new HBox(state);
|
||||
box.setPadding(new Insets(7, 7, 7, 7));
|
||||
box.setAlignment(Pos.CENTER);
|
||||
setGraphic(box);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
createTimeCol.setCellValueFactory(new PropertyValueFactory<>("createTime"));
|
||||
createTimeCol.setStyle("-fx-alignment: CENTER");
|
||||
createTimeCol.setCellFactory(new Callback<TableColumn<FileConfigRespVO, LocalDateTime>, TableCell<FileConfigRespVO, LocalDateTime>>() {
|
||||
@Override
|
||||
public TableCell<FileConfigRespVO, LocalDateTime> call(TableColumn<FileConfigRespVO, LocalDateTime> param) {
|
||||
return new TableCell<>() {
|
||||
@Override
|
||||
protected void updateItem(LocalDateTime item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
} else {
|
||||
|
||||
|
||||
if (item != null) {
|
||||
this.setText(DateUtil.format(item, "yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
optCol.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
optCol.setCellFactory(new Callback<TableColumn<FileConfigRespVO, Long>, TableCell<FileConfigRespVO, Long>>() {
|
||||
@Override
|
||||
public TableCell<FileConfigRespVO, Long> call(TableColumn<FileConfigRespVO, Long> param) {
|
||||
|
||||
TableCell cell = new TableCell<FileConfigRespVO, Long>() {
|
||||
@Override
|
||||
protected void updateItem(Long item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
|
||||
|
||||
Button editBut = new Button("编辑");
|
||||
editBut.setOnAction(event -> showFormView(getTableRow().getItem().getId()));
|
||||
editBut.setGraphic(FontIcon.of(Feather.EDIT));
|
||||
editBut.getStyleClass().addAll(FLAT, ACCENT);
|
||||
|
||||
Button masterBut = new Button("主配置");
|
||||
masterBut.setOnAction(event -> showMasterDialog(getTableRow().getItem()));
|
||||
masterBut.setGraphic(FontIcon.of(Feather.EDIT));
|
||||
masterBut.getStyleClass().addAll(FLAT, ACCENT);
|
||||
|
||||
Button delBut = new Button("删除");
|
||||
delBut.setOnAction(actionEvent -> showDelDialog(getTableRow().getItem()));
|
||||
delBut.setGraphic(FontIcon.of(Feather.TRASH));
|
||||
delBut.getStyleClass().addAll(FLAT, DANGER);
|
||||
HBox box = new HBox(editBut,masterBut, delBut);
|
||||
box.setAlignment(Pos.CENTER);
|
||||
// box.setSpacing(7);
|
||||
setGraphic(box);
|
||||
}
|
||||
}
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
});
|
||||
|
||||
tableView.setItems(viewModel.getTableItems());
|
||||
|
||||
addBut.setOnAction(actionEvent -> showFormView(null));
|
||||
searchBut.setOnAction(actionEvent -> viewModel.loadTableData());
|
||||
resetBut.setOnAction(actionEvent -> {
|
||||
nameField.setText(null);
|
||||
storageComboBox.getSelectionModel().select(null);
|
||||
startDatePicker.setValue(null);
|
||||
endDatePicker.setValue(null);
|
||||
viewModel.loadTableData();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 显示编辑对话框
|
||||
*/
|
||||
private void showFormView(Long id) {
|
||||
WFXGenericDialog dialog = new WFXGenericDialog();
|
||||
|
||||
boolean isAdd = (id == null);
|
||||
ViewTuple<FileConfigFormView, FileConfigFormViewModel> load = FluentViewLoader.fxmlView(FileConfigFormView.class).load();
|
||||
load.getViewModel().updateData(id,isAdd);
|
||||
dialog.addActions(
|
||||
Map.entry(new Button("取消"), event -> dialog.close()),
|
||||
Map.entry(new Button("确定"), event -> {
|
||||
ProcessChain.create()
|
||||
.addSupplierInExecutor(() -> {
|
||||
return load.getViewModel().save(isAdd);
|
||||
})
|
||||
.addConsumerInPlatformThread(r -> {
|
||||
if (r.isSuccess()) {
|
||||
dialog.close();
|
||||
MvvmFX.getNotificationCenter().publish("message", "保存成功", MessageType.SUCCESS);
|
||||
|
||||
viewModel.loadTableData();
|
||||
|
||||
}
|
||||
}).onException(e -> e.printStackTrace())
|
||||
.run();
|
||||
})
|
||||
);
|
||||
|
||||
dialog.setHeaderIcon(FontIcon.of(Feather.INFO));
|
||||
dialog.setHeaderText(id != null ? "编辑角色" : "添加角色");
|
||||
dialog.setContent(load.getView());
|
||||
dialog.show(rootPane.getScene());
|
||||
|
||||
}
|
||||
|
||||
private void showDelDialog(FileConfigRespVO respVO) {
|
||||
WFXGenericDialog dialog = new WFXGenericDialog();
|
||||
dialog.setHeaderIcon(FontIcon.of(Feather.INFO));
|
||||
dialog.setHeaderText("删除");
|
||||
dialog.addActions(
|
||||
Map.entry(new Button("取消"), event -> dialog.close()),
|
||||
Map.entry(new Button("确定"), event -> {
|
||||
ProcessChain.create()
|
||||
.addSupplierInExecutor(() -> {
|
||||
return Request.connector(FileConfigFeign.class).deleteFileConfig(respVO.getId());
|
||||
})
|
||||
.addConsumerInPlatformThread(r -> {
|
||||
if (r.isSuccess()) {
|
||||
dialog.close();
|
||||
MvvmFX.getNotificationCenter().publish("message", "删除成功", MessageType.SUCCESS);
|
||||
|
||||
viewModel.loadTableData();
|
||||
}
|
||||
}).onException(e -> e.printStackTrace())
|
||||
.run();
|
||||
})
|
||||
);
|
||||
|
||||
dialog.setContent(new Label("是否确认删除名称为" + respVO.getName() + "的数据项?"));
|
||||
dialog.show(rootPane.getScene());
|
||||
}
|
||||
|
||||
private void showMasterDialog(FileConfigRespVO respVO) {
|
||||
WFXGenericDialog dialog = new WFXGenericDialog();
|
||||
dialog.setHeaderIcon(FontIcon.of(Feather.INFO));
|
||||
dialog.setHeaderText("系统提示");
|
||||
dialog.addActions(
|
||||
Map.entry(new Button("取消"), event -> dialog.close()),
|
||||
Map.entry(new Button("确定"), event -> {
|
||||
ProcessChain.create()
|
||||
.addSupplierInExecutor(() -> {
|
||||
return Request.connector(FileConfigFeign.class).updateFileConfigMaster(respVO.getId());
|
||||
})
|
||||
.addConsumerInPlatformThread(r -> {
|
||||
if (r.isSuccess()) {
|
||||
dialog.close();
|
||||
MvvmFX.getNotificationCenter().publish("message", "修改成功", MessageType.SUCCESS);
|
||||
|
||||
viewModel.loadTableData();
|
||||
}
|
||||
}).onException(e -> e.printStackTrace())
|
||||
.run();
|
||||
})
|
||||
);
|
||||
|
||||
dialog.setContent(new Label("是否确认修改配置名称为" + respVO.getName() + "的数据项为主配置?"));
|
||||
dialog.show(rootPane.getScene());
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package com.lw.fx.view.infra.file;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.config.FileConfigRespVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSaveReqVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.fx.request.Request;
|
||||
import com.lw.ui.request.api.file.FileConfigFeign;
|
||||
import de.saxsys.mvvmfx.ViewModel;
|
||||
import io.datafx.core.concurrent.ProcessChain;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FileConfigViewModel implements ViewModel {
|
||||
private SimpleIntegerProperty total = new SimpleIntegerProperty(0);
|
||||
private IntegerProperty pageNum = new SimpleIntegerProperty(0);
|
||||
private IntegerProperty pageSize = new SimpleIntegerProperty(10);
|
||||
private ObjectProperty<LocalDate> beginDate = new SimpleObjectProperty<>();
|
||||
private ObjectProperty<LocalDate> endDate = new SimpleObjectProperty<>();
|
||||
|
||||
private StringProperty name = new SimpleStringProperty();
|
||||
private ObjectProperty<DictDataSimpleRespVO> storage = new SimpleObjectProperty<>();
|
||||
|
||||
private ObservableList<FileConfigRespVO> tableItems = FXCollections.observableArrayList();
|
||||
|
||||
public FileConfigViewModel() {
|
||||
loadTableData();
|
||||
}
|
||||
|
||||
|
||||
public void loadTableData() {
|
||||
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
queryMap.put("pageNo", pageNum.get() + 1);
|
||||
queryMap.put("pageSize", pageSize.get());
|
||||
|
||||
queryMap.put("name", name.get());
|
||||
if (storage.get() != null) {
|
||||
queryMap.put("storage", Convert.toInt(storage.get().getValue(), null));
|
||||
}
|
||||
|
||||
if (ObjectUtil.isAllNotEmpty(getBeginDate(), getEndDate())) {
|
||||
String sd = getBeginDate().atTime(0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
String ed = getEndDate().atTime(23, 59, 59).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
queryMap.put("createTime", new String[]{sd, ed});
|
||||
}
|
||||
|
||||
ProcessChain.create()
|
||||
.addRunnableInPlatformThread(() -> tableItems.clear())
|
||||
.addSupplierInExecutor(() -> Request.connector(FileConfigFeign.class).getFileConfigPage(queryMap))
|
||||
.addConsumerInPlatformThread(listCommonResult -> {
|
||||
if (listCommonResult.isSuccess()) {
|
||||
List<JsonObject> list = listCommonResult.getData().getList();
|
||||
for (JsonObject jsonObject:list) {
|
||||
FileConfigRespVO fileConfigRespVO = new FileConfigRespVO();
|
||||
fileConfigRespVO.setId(jsonObject.get("id").getAsLong());
|
||||
fileConfigRespVO.setName(jsonObject.get("name").getAsString());
|
||||
fileConfigRespVO.setStorage(jsonObject.get("storage").getAsInt());
|
||||
fileConfigRespVO.setRemark(jsonObject.get("remark").getAsString());
|
||||
fileConfigRespVO.setMaster(jsonObject.get("master").getAsBoolean());
|
||||
fileConfigRespVO.setCreateTime(Convert.toLocalDateTime(jsonObject.get("createTime")));
|
||||
tableItems.add(fileConfigRespVO);
|
||||
}
|
||||
totalProperty().set(listCommonResult.getData().getTotal().intValue());
|
||||
}
|
||||
}).onException(e -> e.printStackTrace())
|
||||
.run();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total.get();
|
||||
}
|
||||
|
||||
public SimpleIntegerProperty totalProperty() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public int getPageNum() {
|
||||
return pageNum.get();
|
||||
}
|
||||
|
||||
public IntegerProperty pageNumProperty() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize.get();
|
||||
}
|
||||
|
||||
public IntegerProperty pageSizeProperty() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public LocalDate getBeginDate() {
|
||||
return beginDate.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<LocalDate> beginDateProperty() {
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<LocalDate> endDateProperty() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public ObservableList<FileConfigRespVO> getTableItems() {
|
||||
return tableItems;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name.get();
|
||||
}
|
||||
|
||||
public StringProperty nameProperty() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public DictDataSimpleRespVO getStorage() {
|
||||
return storage.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<DictDataSimpleRespVO> storageProperty() {
|
||||
return storage;
|
||||
}
|
||||
}
|
@ -0,0 +1,324 @@
|
||||
package com.lw.fx.view.infra.file;
|
||||
|
||||
import atlantafx.base.controls.ModalPane;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.file.FileRespVO;
|
||||
import com.lw.fx.request.Request;
|
||||
import com.lw.fx.util.MessageType;
|
||||
import com.lw.fx.view.control.PagingControl;
|
||||
import com.lw.fx.view.control.WFXGenericDialog;
|
||||
import com.lw.ui.request.api.file.FileFeign;
|
||||
import de.saxsys.mvvmfx.FxmlView;
|
||||
import de.saxsys.mvvmfx.InjectViewModel;
|
||||
import de.saxsys.mvvmfx.MvvmFX;
|
||||
import io.datafx.core.concurrent.ProcessChain;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.FileChooser;
|
||||
import javafx.util.Callback;
|
||||
import org.kordamp.ikonli.feather.Feather;
|
||||
import org.kordamp.ikonli.javafx.FontIcon;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static atlantafx.base.theme.Styles.DANGER;
|
||||
import static atlantafx.base.theme.Styles.FLAT;
|
||||
|
||||
public class FileListView implements FxmlView<FileListViewModel>, Initializable {
|
||||
@InjectViewModel
|
||||
private FileListViewModel viewModel;
|
||||
@FXML
|
||||
private VBox contentPane;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileRespVO, LocalDateTime> createTimeCol;
|
||||
|
||||
@FXML
|
||||
private Button uploadBut;
|
||||
|
||||
@FXML
|
||||
private DatePicker endDatePicker;
|
||||
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileRespVO, ?> nameCol;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileRespVO, Long> optCol;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileRespVO, ?> pathCol;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileRespVO, ?> urlCol;
|
||||
|
||||
@FXML
|
||||
private Button resetBut;
|
||||
|
||||
@FXML
|
||||
private StackPane rootPane;
|
||||
|
||||
@FXML
|
||||
private Button searchBut;
|
||||
|
||||
@FXML
|
||||
private DatePicker startDatePicker;
|
||||
|
||||
@FXML
|
||||
private TableColumn<FileRespVO, ?> sizeCol;
|
||||
@FXML
|
||||
private TableColumn<FileRespVO, ?> typeCol;
|
||||
@FXML
|
||||
private TableColumn<FileRespVO, String> centerCol;
|
||||
|
||||
@FXML
|
||||
private TableView<FileRespVO> tableView;
|
||||
|
||||
@FXML
|
||||
private TextField typeField;
|
||||
@FXML
|
||||
private TextField pathField;
|
||||
|
||||
private PagingControl pagingControl;
|
||||
|
||||
private ImageView modalImage = new ImageView();
|
||||
|
||||
private final ModalPane modalPane = new ModalPane();
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
pagingControl = new PagingControl();
|
||||
rootPane.getChildren().add(0, modalPane);
|
||||
contentPane.getChildren().add(pagingControl);
|
||||
|
||||
pagingControl.totalProperty().bind(viewModel.totalProperty());
|
||||
viewModel.pageNumProperty().bind(pagingControl.pageNumProperty());
|
||||
viewModel.pageSizeProperty().bind(pagingControl.pageSizeProperty());
|
||||
pagingControl.pageNumProperty().addListener((observable, oldValue, newValue) -> {
|
||||
viewModel.loadTableData();
|
||||
});
|
||||
|
||||
pagingControl.pageSizeProperty().addListener((observable, oldValue, newValue) -> {
|
||||
viewModel.loadTableData();
|
||||
});
|
||||
|
||||
|
||||
pathField.textProperty().bindBidirectional(viewModel.pathProperty());
|
||||
typeField.textProperty().bindBidirectional(viewModel.typeProperty());
|
||||
|
||||
|
||||
nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||
nameCol.setStyle("-fx-alignment: CENTER");
|
||||
|
||||
pathCol.setCellValueFactory(new PropertyValueFactory<>("path"));
|
||||
pathCol.setStyle("-fx-alignment: CENTER");
|
||||
|
||||
urlCol.setCellValueFactory(new PropertyValueFactory<>("url"));
|
||||
urlCol.setStyle("-fx-alignment: CENTER");
|
||||
sizeCol.setCellValueFactory(new PropertyValueFactory<>("size"));
|
||||
sizeCol.setStyle("-fx-alignment: CENTER");
|
||||
typeCol.setCellValueFactory(new PropertyValueFactory<>("type"));
|
||||
typeCol.setStyle("-fx-alignment: CENTER");
|
||||
centerCol.setCellValueFactory(new PropertyValueFactory<>("url"));
|
||||
centerCol.setStyle("-fx-alignment: CENTER");
|
||||
createTimeCol.setCellValueFactory(new PropertyValueFactory<>("createTime"));
|
||||
createTimeCol.setStyle("-fx-alignment: CENTER");
|
||||
createTimeCol.setCellFactory(new Callback<TableColumn<FileRespVO, LocalDateTime>, TableCell<FileRespVO, LocalDateTime>>() {
|
||||
@Override
|
||||
public TableCell<FileRespVO, LocalDateTime> call(TableColumn<FileRespVO, LocalDateTime> param) {
|
||||
return new TableCell<>() {
|
||||
@Override
|
||||
protected void updateItem(LocalDateTime item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
} else {
|
||||
|
||||
|
||||
if (item != null) {
|
||||
this.setText(DateUtil.format(item, "yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
centerCol.setCellFactory(new Callback<TableColumn<FileRespVO, String>, TableCell<FileRespVO, String>>() {
|
||||
@Override
|
||||
public TableCell<FileRespVO, String> call(TableColumn<FileRespVO, String> param) {
|
||||
return new TableCell<>() {
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
|
||||
FileRespVO fileRespVO = getTableRow().getItem();
|
||||
if (StrUtil.contains(fileRespVO.getType(), "image")) {
|
||||
Image image = new Image(item, true);
|
||||
ImageView view = new ImageView();
|
||||
view.setImage(image);
|
||||
view.setFitWidth(180);
|
||||
view.setFitHeight(120);
|
||||
view.setCursor(Cursor.HAND);
|
||||
|
||||
view.setOnMouseClicked(evt -> {
|
||||
modalImage.setImage(view.getImage());
|
||||
modalPane.show(modalImage);
|
||||
modalImage.requestFocus();
|
||||
});
|
||||
VBox vBox = new VBox(view);
|
||||
vBox.setPadding(new Insets(10,10,10,10));
|
||||
vBox.setAlignment(Pos.CENTER);
|
||||
setGraphic(vBox);
|
||||
|
||||
}else {
|
||||
Hyperlink hyperlink = new Hyperlink("下载");
|
||||
hyperlink.setOnAction(event -> {
|
||||
try {
|
||||
// Check if Desktop API is supported on the current platform
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(new URI(item));
|
||||
} else {
|
||||
// showAlert("Error", "Desktop API is not supported on this platform.");
|
||||
}
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
// showAlert("Error", "Failed to open URL: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
VBox vBox = new VBox(hyperlink);
|
||||
vBox.setAlignment(Pos.CENTER);
|
||||
setGraphic(vBox);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
optCol.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
optCol.setCellFactory(new Callback<TableColumn<FileRespVO, Long>, TableCell<FileRespVO, Long>>() {
|
||||
@Override
|
||||
public TableCell<FileRespVO, Long> call(TableColumn<FileRespVO, Long> param) {
|
||||
|
||||
TableCell cell = new TableCell<FileRespVO, Long>() {
|
||||
@Override
|
||||
protected void updateItem(Long item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty) {
|
||||
setText(null);
|
||||
setGraphic(null);
|
||||
} else {
|
||||
|
||||
Button delBut = new Button("删除");
|
||||
delBut.setOnAction(actionEvent -> showDelDialog(getTableRow().getItem()));
|
||||
delBut.setGraphic(FontIcon.of(Feather.TRASH));
|
||||
delBut.getStyleClass().addAll(FLAT, DANGER);
|
||||
HBox box = new HBox(delBut);
|
||||
box.setAlignment(Pos.CENTER);
|
||||
setGraphic(box);
|
||||
}
|
||||
}
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
});
|
||||
|
||||
tableView.setItems(viewModel.getTableItems());
|
||||
|
||||
uploadBut.setOnAction(actionEvent -> addFile());
|
||||
searchBut.setOnAction(actionEvent -> viewModel.loadTableData());
|
||||
resetBut.setOnAction(actionEvent -> {
|
||||
pathField.setText(null);
|
||||
typeField.setText(null);
|
||||
startDatePicker.setValue(null);
|
||||
endDatePicker.setValue(null);
|
||||
viewModel.loadTableData();
|
||||
});
|
||||
}
|
||||
|
||||
private void addFile() {
|
||||
var fileChooser = new FileChooser();
|
||||
fileChooser.setTitle("选择要上传的文件");
|
||||
File file = fileChooser.showOpenDialog(rootPane.getScene().getWindow());
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessChain.create()
|
||||
.addSupplierInExecutor(() -> {
|
||||
|
||||
return Request.fileConnector(FileFeign.class).uploadFile("", file);
|
||||
})
|
||||
.addConsumerInPlatformThread(r -> {
|
||||
if (r.isSuccess()) {
|
||||
|
||||
viewModel.loadTableData();
|
||||
} else {
|
||||
MvvmFX.getNotificationCenter().publish("message", r.getMsg(), MessageType.WARNING);
|
||||
|
||||
}
|
||||
|
||||
}).onException(e -> e.printStackTrace())
|
||||
.run();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void showDelDialog(FileRespVO respVO) {
|
||||
WFXGenericDialog dialog = new WFXGenericDialog();
|
||||
dialog.setHeaderIcon(FontIcon.of(Feather.INFO));
|
||||
dialog.setHeaderText("删除");
|
||||
dialog.addActions(
|
||||
Map.entry(new Button("取消"), event -> dialog.close()),
|
||||
Map.entry(new Button("确定"), event -> {
|
||||
ProcessChain.create()
|
||||
.addSupplierInExecutor(() -> {
|
||||
return Request.connector(FileFeign.class).deleteFile(respVO.getId());
|
||||
})
|
||||
.addConsumerInPlatformThread(r -> {
|
||||
if (r.isSuccess()) {
|
||||
dialog.close();
|
||||
MvvmFX.getNotificationCenter().publish("message", "删除成功", MessageType.SUCCESS);
|
||||
|
||||
viewModel.loadTableData();
|
||||
}
|
||||
}).onException(e -> e.printStackTrace())
|
||||
.run();
|
||||
})
|
||||
);
|
||||
|
||||
dialog.setContent(new Label("是否确认删除名称为" + respVO.getName() + "的数据项?"));
|
||||
dialog.show(rootPane.getScene());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
package com.lw.fx.view.infra.file;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.file.FileRespVO;
|
||||
import com.lw.fx.request.Request;
|
||||
import com.lw.ui.request.api.file.FileFeign;
|
||||
import de.saxsys.mvvmfx.ViewModel;
|
||||
import io.datafx.core.concurrent.ProcessChain;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FileListViewModel implements ViewModel {
|
||||
private SimpleIntegerProperty total = new SimpleIntegerProperty(0);
|
||||
private IntegerProperty pageNum = new SimpleIntegerProperty(0);
|
||||
private IntegerProperty pageSize = new SimpleIntegerProperty(10);
|
||||
private ObjectProperty<LocalDate> beginDate = new SimpleObjectProperty<>();
|
||||
private ObjectProperty<LocalDate> endDate = new SimpleObjectProperty<>();
|
||||
|
||||
private StringProperty path = new SimpleStringProperty();
|
||||
private StringProperty type = new SimpleStringProperty();
|
||||
|
||||
private ObservableList<FileRespVO> tableItems = FXCollections.observableArrayList();
|
||||
|
||||
public FileListViewModel() {
|
||||
loadTableData();
|
||||
}
|
||||
|
||||
|
||||
public void loadTableData() {
|
||||
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
queryMap.put("pageNo", pageNum.get() + 1);
|
||||
queryMap.put("pageSize", pageSize.get());
|
||||
|
||||
queryMap.put("path", path.get());
|
||||
queryMap.put("type", type.get());
|
||||
|
||||
if (ObjectUtil.isAllNotEmpty(getBeginDate(), getEndDate())) {
|
||||
String sd = getBeginDate().atTime(0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
String ed = getEndDate().atTime(23, 59, 59).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
queryMap.put("createTime", new String[]{sd, ed});
|
||||
}
|
||||
|
||||
ProcessChain.create()
|
||||
.addRunnableInPlatformThread(() -> tableItems.clear())
|
||||
.addSupplierInExecutor(() -> Request.connector(FileFeign.class).getFilePage(queryMap))
|
||||
.addConsumerInPlatformThread(listCommonResult -> {
|
||||
if (listCommonResult.isSuccess()) {
|
||||
tableItems.setAll(listCommonResult.getData().getList());
|
||||
totalProperty().set(listCommonResult.getData().getTotal().intValue());
|
||||
}
|
||||
}).onException(e -> e.printStackTrace())
|
||||
.run();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total.get();
|
||||
}
|
||||
|
||||
public SimpleIntegerProperty totalProperty() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public int getPageNum() {
|
||||
return pageNum.get();
|
||||
}
|
||||
|
||||
public IntegerProperty pageNumProperty() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize.get();
|
||||
}
|
||||
|
||||
public IntegerProperty pageSizeProperty() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public LocalDate getBeginDate() {
|
||||
return beginDate.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<LocalDate> beginDateProperty() {
|
||||
return beginDate;
|
||||
}
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate.get();
|
||||
}
|
||||
|
||||
public ObjectProperty<LocalDate> endDateProperty() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public ObservableList<FileRespVO> getTableItems() {
|
||||
return tableItems;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path.get();
|
||||
}
|
||||
|
||||
public StringProperty pathProperty() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type.get();
|
||||
}
|
||||
|
||||
public StringProperty typeProperty() {
|
||||
return type;
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package com.lw.fx.vo;
|
||||
|
||||
import com.lw.dillon.admin.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.RadioButton?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.control.ToggleGroup?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<VBox fx:id="rootBox" alignment="TOP_CENTER" prefHeight="323.0" prefWidth="620.0" spacing="10.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.lw.fx.view.infra.file.FileConfigFormView">
|
||||
<children>
|
||||
<HBox alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*配置名" />
|
||||
<TextField fx:id="nameField" promptText="请输入配置名" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="备注" />
|
||||
<TextField fx:id="remarkField" promptText="请输入备注" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*存储器" />
|
||||
<ComboBox fx:id="storageComboBox" maxWidth="1.7976931348623157E308" promptText="请选择存储器" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="basePathBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*基础路径" />
|
||||
<TextField fx:id="basePathField" promptText="请输入基础路径" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="hostBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*主机地址" />
|
||||
<TextField fx:id="hostField" promptText="请输入主机地址" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="portBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*主机端口" />
|
||||
<TextField fx:id="portField" promptText="请输入主机端口" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="usernameBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*用户名" />
|
||||
<TextField fx:id="usernameField" promptText="请输入用户名" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="passwordBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*密码" />
|
||||
<TextField fx:id="passwordField" promptText="请输入密码" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="modeBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*连接模式" />
|
||||
<RadioButton fx:id="modeRadioBut1" mnemonicParsing="false" text="主动模式">
|
||||
<toggleGroup>
|
||||
<ToggleGroup fx:id="group" />
|
||||
</toggleGroup>
|
||||
</RadioButton>
|
||||
<RadioButton fx:id="modeRadioBut2" mnemonicParsing="false" text="被动模式" toggleGroup="$group" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="endpointBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*节点地址" />
|
||||
<TextField fx:id="endpointField" promptText="请输入节点地址" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="bucketBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*存储 bucket" />
|
||||
<TextField fx:id="bucketField" promptText="请输入 bucket" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="accessKeyBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*accessKey" />
|
||||
<TextField fx:id="accessKeyField" promptText="请输入 accessKey" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="accessSecretBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*accessSecret" />
|
||||
<TextField fx:id="accessSecretField" promptText="请输入 accessSecret" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox fx:id="domainBox" alignment="CENTER_LEFT" spacing="10.0">
|
||||
<children>
|
||||
<Label alignment="CENTER_RIGHT" contentDisplay="RIGHT" minWidth="80.0" text="*自定义域名" />
|
||||
<TextField fx:id="domainField" promptText="请输入配置名" HBox.hgrow="ALWAYS" />
|
||||
</children>
|
||||
</HBox>
|
||||
|
||||
</children>
|
||||
<padding>
|
||||
<Insets right="10.0" />
|
||||
</padding>
|
||||
|
||||
</VBox>
|
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.DatePicker?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
|
||||
<StackPane fx:id="rootPane" prefHeight="609.0" prefWidth="1223.0" styleClass="tab-center-pane" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.lw.fx.view.infra.file.FileConfigView">
|
||||
<children>
|
||||
<VBox fx:id="contentPane" prefHeight="200.0" prefWidth="100.0" spacing="7.0" styleClass="sample">
|
||||
<children>
|
||||
<HBox alignment="CENTER_LEFT" spacing="5.0">
|
||||
<children>
|
||||
<TextField fx:id="nameField" prefWidth="150.0" promptText="请输入配置名" />
|
||||
<ComboBox fx:id="storageComboBox" promptText="请选择存储器" />
|
||||
<Label text="创建日期" />
|
||||
<DatePicker fx:id="startDatePicker" prefWidth="140.0" />
|
||||
<Label text="-" />
|
||||
<DatePicker fx:id="endDatePicker" prefWidth="140.0" />
|
||||
<Button fx:id="searchBut" mnemonicParsing="false" text="查询">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fth-search" />
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="resetBut" mnemonicParsing="false" text="重置">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fth-refresh-cw" />
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="addBut" mnemonicParsing="false" text="新增">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fth-plus" />
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
</HBox>
|
||||
<TableView fx:id="tableView" editable="true" VBox.vgrow="ALWAYS">
|
||||
<columns>
|
||||
<TableColumn fx:id="idCol" text="编号" />
|
||||
<TableColumn fx:id="nameCol" text="配置名" />
|
||||
<TableColumn fx:id="storageCol" text="存储器" />
|
||||
<TableColumn fx:id="remarkCol" text="备注" />
|
||||
<TableColumn fx:id="primaryCol" text="主配置" />
|
||||
<TableColumn fx:id="createTimeCol" text="创建时间" />
|
||||
<TableColumn fx:id="optCol" text="操作" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
</StackPane>
|
@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.DatePicker?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.StackPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
|
||||
<StackPane fx:id="rootPane" prefHeight="609.0" prefWidth="1223.0" styleClass="tab-center-pane" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.lw.fx.view.infra.file.FileListView">
|
||||
<children>
|
||||
<VBox fx:id="contentPane" prefHeight="200.0" prefWidth="100.0" spacing="7.0" styleClass="sample">
|
||||
<children>
|
||||
<HBox alignment="CENTER_LEFT" spacing="5.0">
|
||||
<children>
|
||||
<Label text="文件路径" />
|
||||
<TextField fx:id="pathField" prefWidth="150.0" promptText="请输入文件路径" />
|
||||
<Label text="文件类型" />
|
||||
<TextField fx:id="typeField" promptText="请输入文件类型" />
|
||||
<Label text="创建日期" />
|
||||
<DatePicker fx:id="startDatePicker" prefWidth="140.0" />
|
||||
<Label text="-" />
|
||||
<DatePicker fx:id="endDatePicker" prefWidth="140.0" />
|
||||
<Button fx:id="searchBut" mnemonicParsing="false" text="查询">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fth-search" />
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="resetBut" mnemonicParsing="false" text="重置">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fth-refresh-cw" />
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="uploadBut" mnemonicParsing="false" text="上传文件">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fth-plus" />
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
</opaqueInsets>
|
||||
</HBox>
|
||||
<TableView fx:id="tableView" editable="true" VBox.vgrow="ALWAYS">
|
||||
<columns>
|
||||
<TableColumn fx:id="nameCol" text="文件名" />
|
||||
<TableColumn fx:id="pathCol" text="文件路径" />
|
||||
<TableColumn fx:id="urlCol" text="URL" />
|
||||
<TableColumn fx:id="sizeCol" text="文件大小" />
|
||||
<TableColumn fx:id="typeCol" text="文件类型" />
|
||||
<TableColumn fx:id="centerCol" text="文件内容" />
|
||||
<TableColumn fx:id="createTimeCol" text="上传时间" />
|
||||
<TableColumn fx:id="optCol" text="操作" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
</StackPane>
|
@ -1,104 +0,0 @@
|
||||
package com.lw.swing.components.table.renderer;
|
||||
|
||||
//import sun.reflect.misc.ReflectUtil;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import java.awt.*;
|
||||
import java.util.EventObject;
|
||||
|
||||
public class WNumberEditor extends DefaultCellEditor {
|
||||
|
||||
Class[] argTypes = new Class[]{String.class};
|
||||
java.lang.reflect.Constructor constructor;
|
||||
Object value;
|
||||
|
||||
public WNumberEditor( JTextField textField) {
|
||||
super(textField);
|
||||
|
||||
editorComponent = textField;
|
||||
delegate = new EditorDelegate() {
|
||||
@Override
|
||||
public void setValue(Object value) {
|
||||
textField.setText((value != null) ? value.toString() : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
return textField.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSelectCell(EventObject anEvent) {
|
||||
textField.selectAll();
|
||||
return super.shouldSelectCell(anEvent);
|
||||
}
|
||||
};
|
||||
getComponent().setName("Table.editor");
|
||||
|
||||
textField.addActionListener(delegate);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stopCellEditing() {
|
||||
String s = (String) super.getCellEditorValue();
|
||||
// Here we are dealing with the case where a user
|
||||
// has deleted the string value in a cell, possibly
|
||||
// after a failed validation. Return null, so that
|
||||
// they have the option to replace the value with
|
||||
// null or use escape to restore the original.
|
||||
// For Strings, return "" for backward compatibility.
|
||||
try {
|
||||
if ("".equals(s)) {
|
||||
if (constructor.getDeclaringClass() == String.class) {
|
||||
value = s;
|
||||
}
|
||||
return super.stopCellEditing();
|
||||
}
|
||||
|
||||
SwingUtilities2.checkAccess(constructor.getModifiers());
|
||||
value = constructor.newInstance(new Object[]{s});
|
||||
} catch (Exception e) {
|
||||
((JComponent) getComponent()).setBorder(new LineBorder(Color.red));
|
||||
return false;
|
||||
}
|
||||
return super.stopCellEditing();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Component getTableCellEditorComponent(JTable table, Object value,
|
||||
boolean isSelected,
|
||||
int row, int column) {
|
||||
this.value = null;
|
||||
((JComponent) getComponent()).setBorder(new LineBorder(Color.black));
|
||||
try {
|
||||
Class<?> type = table.getColumnClass(column);
|
||||
// Since our obligation is to produce a value which is
|
||||
// assignable for the required type it is OK to use the
|
||||
// String constructor for columns which are declared
|
||||
// to contain Objects. A String is an Object.
|
||||
if (type == Object.class) {
|
||||
type = String.class;
|
||||
}
|
||||
// ReflectUtil.checkPackageAccess(type);
|
||||
SwingUtilities2.checkAccess(type.getModifiers());
|
||||
constructor = type.getConstructor(argTypes);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
Component component= super.getTableCellEditorComponent(table, value, isSelected, row, column);
|
||||
if (editorComponent instanceof JTextComponent) {
|
||||
((JTextComponent) editorComponent).selectAll();
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCellEditorValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
@ -14,8 +14,10 @@ import feign.Logger;
|
||||
import feign.Retryer;
|
||||
import feign.codec.Decoder;
|
||||
import feign.codec.Encoder;
|
||||
import feign.form.spring.SpringFormEncoder;
|
||||
import feign.gson.GsonDecoder;
|
||||
import feign.gson.GsonEncoder;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.okhttp.OkHttpClient;
|
||||
import feign.querymap.BeanQueryMapEncoder;
|
||||
import feign.slf4j.Slf4jLogger;
|
||||
@ -46,6 +48,8 @@ public class Request {
|
||||
|
||||
private static final okhttp3.OkHttpClient OK_HTTP_CLIENT = createOkHttpClient();
|
||||
private static final Feign.Builder BUILDER = createFeignBuilder();
|
||||
private static final Feign.Builder FILE_BUILDER = createFileFeignBuilder();
|
||||
|
||||
private static final AsyncFeign.AsyncBuilder ASYNC_BUILDER = createAsyncFeignBuilder();
|
||||
|
||||
private Request() {
|
||||
@ -101,4 +105,19 @@ public class Request {
|
||||
.requestInterceptor(new ForwardedForInterceptor())
|
||||
.retryer(new Retryer.Default()); // 默认重试策略
|
||||
}
|
||||
|
||||
|
||||
public static <T extends BaseFeignApi> T fileConnector(Class<T> connectorClass) {
|
||||
return FILE_BUILDER.target(connectorClass, System.getProperty("app.server.url"));
|
||||
}
|
||||
|
||||
private static Feign.Builder createFileFeignBuilder() {
|
||||
|
||||
|
||||
return Feign.builder()
|
||||
.encoder(new SpringFormEncoder())
|
||||
.decoder(new JacksonDecoder())
|
||||
.requestInterceptor(new ForwardedForInterceptor());
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -68,11 +68,11 @@ public class SidePane extends WPanel {
|
||||
((JLabel) component).setText(menuVO.getName());
|
||||
String icon = menuVO.getIcon();
|
||||
if (StrUtil.isBlank(menuVO.getIcon())) {
|
||||
icon="icons/menu/item.svg";
|
||||
icon="icons/item.svg";
|
||||
}else if (StrUtil.contains(icon,":")){
|
||||
icon="icons/menu/"+icon.split(":")[1]+".svg";
|
||||
}
|
||||
FlatSVGIcon svgIcon = IconLoader.getSvgIcon(icon, 25, 25);
|
||||
FlatSVGIcon svgIcon = new FlatSVGIcon(icon, 25, 25);
|
||||
|
||||
svgIcon.setColorFilter(new FlatSVGIcon.ColorFilter(color -> {
|
||||
return component.getForeground();
|
||||
|
@ -0,0 +1,607 @@
|
||||
/*
|
||||
* Created by JFormDesigner on Sun Jul 28 10:24:06 CST 2024
|
||||
*/
|
||||
|
||||
package com.lw.swing.view.intra.file;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.swing.request.Request;
|
||||
import com.lw.swing.store.AppStore;
|
||||
import com.lw.ui.request.api.file.FileConfigFeign;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jdesktop.swingx.HorizontalLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.lw.ui.utils.DictTypeEnum.INFRA_FILE_STORAGE;
|
||||
|
||||
/**
|
||||
* @author wenli
|
||||
*/
|
||||
public class FileConfigFromPane extends JPanel {
|
||||
private Long id = null;
|
||||
|
||||
public FileConfigFromPane() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents @formatter:off
|
||||
// Generated using JFormDesigner non-commercial license
|
||||
namePane = new JPanel();
|
||||
label1 = new JLabel();
|
||||
nameField = new JTextField();
|
||||
remarkPane = new JPanel();
|
||||
label2 = new JLabel();
|
||||
remarkField = new JTextField();
|
||||
storagePane = new JPanel();
|
||||
label3 = new JLabel();
|
||||
storageComboBox = new JComboBox();
|
||||
basePathPane = new JPanel();
|
||||
label4 = new JLabel();
|
||||
basePathField = new JTextField();
|
||||
hostPane = new JPanel();
|
||||
label5 = new JLabel();
|
||||
hostField = new JTextField();
|
||||
portPane = new JPanel();
|
||||
label6 = new JLabel();
|
||||
portField = new JTextField();
|
||||
usernamePane = new JPanel();
|
||||
label7 = new JLabel();
|
||||
usernameField = new JTextField();
|
||||
passwordPane = new JPanel();
|
||||
label8 = new JLabel();
|
||||
passwordField = new JTextField();
|
||||
modePane = new JPanel();
|
||||
label9 = new JLabel();
|
||||
panel3 = new JPanel();
|
||||
activeRb = new JRadioButton();
|
||||
passiveRb = new JRadioButton();
|
||||
endpointPane = new JPanel();
|
||||
label10 = new JLabel();
|
||||
endpointField = new JTextField();
|
||||
bucketPane = new JPanel();
|
||||
label11 = new JLabel();
|
||||
bucketField = new JTextField();
|
||||
accessKeyPane = new JPanel();
|
||||
label13 = new JLabel();
|
||||
accessKeyField = new JTextField();
|
||||
accessSecretPane = new JPanel();
|
||||
label14 = new JLabel();
|
||||
accessSecretField = new JTextField();
|
||||
domainPane = new JPanel();
|
||||
label15 = new JLabel();
|
||||
domainField = new JTextField();
|
||||
|
||||
//======== this ========
|
||||
setMinimumSize(new Dimension(340, 500));
|
||||
setLayout(new MigLayout(
|
||||
"fill,insets 0,gap 10 5",
|
||||
// columns
|
||||
"[500,grow,fill]",
|
||||
// rows
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//======== namePane ========
|
||||
{
|
||||
namePane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[320,fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label1 ----
|
||||
label1.setText("\u914d\u7f6e\u540d");
|
||||
label1.setMinimumSize(new Dimension(80, 16));
|
||||
label1.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
namePane.add(label1, "cell 0 0");
|
||||
|
||||
//---- nameField ----
|
||||
nameField.setMinimumSize(new Dimension(180, 34));
|
||||
nameField.setPreferredSize(new Dimension(240, 34));
|
||||
namePane.add(nameField, "cell 0 0,growx");
|
||||
}
|
||||
add(namePane, "cell 0 0,grow");
|
||||
|
||||
//======== remarkPane ========
|
||||
{
|
||||
remarkPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label2 ----
|
||||
label2.setText("\u5907\u6ce8");
|
||||
label2.setMinimumSize(new Dimension(80, 16));
|
||||
label2.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
remarkPane.add(label2, "cell 0 0");
|
||||
remarkPane.add(remarkField, "cell 0 0,growx");
|
||||
}
|
||||
add(remarkPane, "cell 0 1,grow");
|
||||
|
||||
//======== storagePane ========
|
||||
{
|
||||
storagePane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label3 ----
|
||||
label3.setText("\u5b58\u50a8\u5668");
|
||||
label3.setMinimumSize(new Dimension(80, 16));
|
||||
label3.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
storagePane.add(label3, "cell 0 0");
|
||||
storagePane.add(storageComboBox, "cell 0 0,growx");
|
||||
}
|
||||
add(storagePane, "cell 0 2,grow");
|
||||
|
||||
//======== basePathPane ========
|
||||
{
|
||||
basePathPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label4 ----
|
||||
label4.setText("\u57fa\u7840\u8def\u5f84");
|
||||
label4.setMinimumSize(new Dimension(80, 16));
|
||||
label4.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
basePathPane.add(label4, "cell 0 0");
|
||||
basePathPane.add(basePathField, "cell 0 0,growx");
|
||||
}
|
||||
add(basePathPane, "cell 0 3,grow");
|
||||
|
||||
//======== hostPane ========
|
||||
{
|
||||
hostPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label5 ----
|
||||
label5.setText("\u4e3b\u673a\u5730\u5740");
|
||||
label5.setMinimumSize(new Dimension(80, 16));
|
||||
label5.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
hostPane.add(label5, "cell 0 0");
|
||||
hostPane.add(hostField, "cell 0 0,growx");
|
||||
}
|
||||
add(hostPane, "cell 0 4,grow");
|
||||
|
||||
//======== portPane ========
|
||||
{
|
||||
portPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label6 ----
|
||||
label6.setText("\u4e3b\u673a\u7aef\u53e3");
|
||||
label6.setMinimumSize(new Dimension(80, 16));
|
||||
label6.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
portPane.add(label6, "cell 0 0");
|
||||
portPane.add(portField, "cell 0 0,growx");
|
||||
}
|
||||
add(portPane, "cell 0 5,grow");
|
||||
|
||||
//======== usernamePane ========
|
||||
{
|
||||
usernamePane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label7 ----
|
||||
label7.setText("\u7528\u6237\u540d");
|
||||
label7.setMinimumSize(new Dimension(80, 16));
|
||||
label7.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
usernamePane.add(label7, "cell 0 0");
|
||||
usernamePane.add(usernameField, "cell 0 0,growx");
|
||||
}
|
||||
add(usernamePane, "cell 0 6,grow");
|
||||
|
||||
//======== passwordPane ========
|
||||
{
|
||||
passwordPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label8 ----
|
||||
label8.setText("\u5bc6\u7801");
|
||||
label8.setMinimumSize(new Dimension(80, 16));
|
||||
label8.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
passwordPane.add(label8, "cell 0 0");
|
||||
passwordPane.add(passwordField, "cell 0 0,growx");
|
||||
}
|
||||
add(passwordPane, "cell 0 7,grow");
|
||||
|
||||
//======== modePane ========
|
||||
{
|
||||
modePane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label9 ----
|
||||
label9.setText("\u8fde\u63a5\u6a21\u5f0f");
|
||||
label9.setMinimumSize(new Dimension(80, 16));
|
||||
label9.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
modePane.add(label9, "cell 0 0");
|
||||
|
||||
//======== panel3 ========
|
||||
{
|
||||
panel3.setLayout(new HorizontalLayout());
|
||||
|
||||
//---- activeRb ----
|
||||
activeRb.setText("\u4e3b\u52a8\u6a21\u5f0f");
|
||||
panel3.add(activeRb);
|
||||
|
||||
//---- passiveRb ----
|
||||
passiveRb.setText("\u88ab\u52a8\u6a21\u5f0f");
|
||||
panel3.add(passiveRb);
|
||||
}
|
||||
modePane.add(panel3, "cell 0 0,growx");
|
||||
}
|
||||
add(modePane, "cell 0 8,grow");
|
||||
|
||||
//======== endpointPane ========
|
||||
{
|
||||
endpointPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label10 ----
|
||||
label10.setText("\u8282\u70b9\u5730\u5740");
|
||||
label10.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
label10.setMinimumSize(new Dimension(80, 16));
|
||||
endpointPane.add(label10, "cell 0 0,alignx left,growx 0");
|
||||
endpointPane.add(endpointField, "cell 0 0,growx");
|
||||
}
|
||||
add(endpointPane, "cell 0 9,grow");
|
||||
|
||||
//======== bucketPane ========
|
||||
{
|
||||
bucketPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label11 ----
|
||||
label11.setText("\u5b58\u50a8 bucket");
|
||||
label11.setMinimumSize(new Dimension(80, 16));
|
||||
label11.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
bucketPane.add(label11, "cell 0 0");
|
||||
bucketPane.add(bucketField, "cell 0 0,growx");
|
||||
}
|
||||
add(bucketPane, "cell 0 10,grow");
|
||||
|
||||
//======== accessKeyPane ========
|
||||
{
|
||||
accessKeyPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label13 ----
|
||||
label13.setText("accessKey");
|
||||
label13.setMinimumSize(new Dimension(80, 16));
|
||||
label13.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
accessKeyPane.add(label13, "cell 0 0");
|
||||
accessKeyPane.add(accessKeyField, "cell 0 0,growx");
|
||||
}
|
||||
add(accessKeyPane, "cell 0 11,grow");
|
||||
|
||||
//======== accessSecretPane ========
|
||||
{
|
||||
accessSecretPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label14 ----
|
||||
label14.setText("accessSecret");
|
||||
label14.setMinimumSize(new Dimension(80, 16));
|
||||
label14.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
accessSecretPane.add(label14, "cell 0 0");
|
||||
accessSecretPane.add(accessSecretField, "cell 0 0,growx");
|
||||
}
|
||||
add(accessSecretPane, "cell 0 12,grow");
|
||||
|
||||
//======== domainPane ========
|
||||
{
|
||||
domainPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]"));
|
||||
|
||||
//---- label15 ----
|
||||
label15.setText("\u81ea\u5b9a\u4e49\u57df\u540d");
|
||||
label15.setMinimumSize(new Dimension(80, 16));
|
||||
label15.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
domainPane.add(label15, "cell 0 0");
|
||||
domainPane.add(domainField, "cell 0 0,growx");
|
||||
}
|
||||
add(domainPane, "cell 0 13,grow");
|
||||
|
||||
//---- buttonGroup1 ----
|
||||
ButtonGroup buttonGroup1 = new ButtonGroup();
|
||||
buttonGroup1.add(activeRb);
|
||||
buttonGroup1.add(passiveRb);
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents @formatter:on
|
||||
|
||||
|
||||
AppStore.getDictDataList(INFRA_FILE_STORAGE).forEach(dictDataSimpleRespVO -> {
|
||||
storageComboBox.addItem(dictDataSimpleRespVO);
|
||||
});
|
||||
|
||||
storageComboBox.addItemListener(e -> {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
showStorage(((DictDataSimpleRespVO) e.getItem()).getLabel()); //修改后
|
||||
}
|
||||
});
|
||||
|
||||
showStorage("");
|
||||
}
|
||||
|
||||
private void showStorage(String type) {
|
||||
|
||||
domainPane.setVisible(false);
|
||||
basePathPane.setVisible(false);
|
||||
hostPane.setVisible(false);
|
||||
portPane.setVisible(false);
|
||||
usernamePane.setVisible(false);
|
||||
passwordPane.setVisible(false);
|
||||
endpointPane.setVisible(false);
|
||||
bucketPane.setVisible(false);
|
||||
accessKeyPane.setVisible(false);
|
||||
accessSecretPane.setVisible(false);
|
||||
modePane.setVisible(false);
|
||||
|
||||
switch (type) {
|
||||
case "数据库": {
|
||||
domainPane.setVisible(true);
|
||||
break;
|
||||
}
|
||||
case "本地磁盘": {
|
||||
domainPane.setVisible(true);
|
||||
basePathPane.setVisible(true);
|
||||
break;
|
||||
}
|
||||
case "FTP 服务器": {
|
||||
domainPane.setVisible(true);
|
||||
basePathPane.setVisible(true);
|
||||
hostPane.setVisible(true);
|
||||
portPane.setVisible(true);
|
||||
usernamePane.setVisible(true);
|
||||
passwordPane.setVisible(true);
|
||||
break;
|
||||
}
|
||||
case "SFTP 服务器": {
|
||||
domainPane.setVisible(true);
|
||||
basePathPane.setVisible(true);
|
||||
hostPane.setVisible(true);
|
||||
portPane.setVisible(true);
|
||||
usernamePane.setVisible(true);
|
||||
passwordPane.setVisible(true);
|
||||
modePane.setVisible(true);
|
||||
break;
|
||||
}
|
||||
case "S3 对象存储": {
|
||||
|
||||
endpointPane.setVisible(true);
|
||||
bucketPane.setVisible(true);
|
||||
accessKeyPane.setVisible(true);
|
||||
accessSecretPane.setVisible(true);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
}
|
||||
}
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void updateData(Long id) {
|
||||
|
||||
this.id = id;
|
||||
|
||||
SwingWorker<FileConfigSaveReqVO, FileConfigSaveReqVO> swingWorker = new SwingWorker<FileConfigSaveReqVO, FileConfigSaveReqVO>() {
|
||||
@Override
|
||||
protected FileConfigSaveReqVO doInBackground() throws Exception {
|
||||
FileConfigSaveReqVO saveReqVO = new FileConfigSaveReqVO();
|
||||
if (id != null) {
|
||||
JsonObject jsonObject = Request.connector(FileConfigFeign.class).getFileConfig(id).getData();
|
||||
|
||||
saveReqVO.setName(jsonObject.get("name").getAsString());
|
||||
saveReqVO.setStorage(jsonObject.get("storage").getAsInt());
|
||||
saveReqVO.setRemark(jsonObject.get("remark").getAsString());
|
||||
saveReqVO.setId(jsonObject.get("id").getAsLong());
|
||||
JsonObject config = jsonObject.getAsJsonObject("config");
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Iterator<String> keys = config.keySet().iterator();
|
||||
while (keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
Object value = config.get(key).getAsString();
|
||||
map.put(key, value);
|
||||
}
|
||||
saveReqVO.setConfig(map);
|
||||
}
|
||||
|
||||
return saveReqVO;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
|
||||
try {
|
||||
setValue(get());
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
}
|
||||
|
||||
private void setValue(FileConfigSaveReqVO rel) {
|
||||
nameField.setText(rel.getName());
|
||||
remarkField.setText(rel.getRemark());
|
||||
DictDataSimpleRespVO sel = AppStore.getDictDataValueMap(INFRA_FILE_STORAGE).get(rel.getStorage() + "");
|
||||
storageComboBox.setSelectedItem(sel);
|
||||
if (rel.getConfig() != null) {
|
||||
|
||||
domainField.setText(Convert.toStr(rel.getConfig().get("domain")));
|
||||
basePathField.setText(Convert.toStr(rel.getConfig().get("basePath")));
|
||||
hostField.setText(Convert.toStr(rel.getConfig().get("host")));
|
||||
portField.setText(Convert.toStr(rel.getConfig().get("port")));
|
||||
usernameField.setText(Convert.toStr(rel.getConfig().get("username")));
|
||||
passwordField.setText(Convert.toStr(rel.getConfig().get("password")));
|
||||
activeRb.setSelected(StrUtil.equals(Convert.toStr(rel.getConfig().get("mode")), "Active"));
|
||||
endpointField.setText(Convert.toStr(rel.getConfig().get("endpoint")));
|
||||
bucketField.setText(Convert.toStr(rel.getConfig().get("bucket")));
|
||||
accessKeyField.setText(Convert.toStr(rel.getConfig().get("accessKey")));
|
||||
accessSecretField.setText(Convert.toStr(rel.getConfig().get("accessSecret")));
|
||||
|
||||
}
|
||||
|
||||
showStorage(Optional.ofNullable(sel).map(DictDataSimpleRespVO::getLabel).orElse(""));
|
||||
|
||||
}
|
||||
|
||||
public FileConfigSaveReqVO getValue() {
|
||||
FileConfigSaveReqVO saveReqVO = new FileConfigSaveReqVO();
|
||||
|
||||
saveReqVO.setName(nameField.getText());
|
||||
saveReqVO.setId(id);
|
||||
saveReqVO.setRemark(remarkField.getText());
|
||||
if (storageComboBox.getSelectedItem() != null) {
|
||||
DictDataSimpleRespVO dictDataSimpleRespVO = (DictDataSimpleRespVO) storageComboBox.getSelectedItem();
|
||||
saveReqVO.setStorage(Convert.toInt(dictDataSimpleRespVO.getValue()));
|
||||
}
|
||||
Map<String, Object> config = new HashMap<>();
|
||||
createConfig("domain", domainField.getText(), config);
|
||||
createConfig("basePath", basePathField.getText(), config);
|
||||
createConfig("host", hostField.getText(), config);
|
||||
createConfig("username", usernameField.getText(), config);
|
||||
createConfig("mode", activeRb.isSelected() ? "Active" : "Passive", config);
|
||||
createConfig("endpoint", endpointField.getText(), config);
|
||||
createConfig("bucket", bucketField.getText(), config);
|
||||
createConfig("accessKey", accessKeyField.getText(), config);
|
||||
createConfig("accessSecret", accessSecretField.getText(), config);
|
||||
saveReqVO.setConfig(config);
|
||||
return saveReqVO;
|
||||
}
|
||||
|
||||
private void createConfig(String key, String value, Map<String, Object> config) {
|
||||
|
||||
if (StrUtil.isNotBlank(value)) {
|
||||
config.put(key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables @formatter:off
|
||||
// Generated using JFormDesigner non-commercial license
|
||||
private JPanel namePane;
|
||||
private JLabel label1;
|
||||
private JTextField nameField;
|
||||
private JPanel remarkPane;
|
||||
private JLabel label2;
|
||||
private JTextField remarkField;
|
||||
private JPanel storagePane;
|
||||
private JLabel label3;
|
||||
private JComboBox storageComboBox;
|
||||
private JPanel basePathPane;
|
||||
private JLabel label4;
|
||||
private JTextField basePathField;
|
||||
private JPanel hostPane;
|
||||
private JLabel label5;
|
||||
private JTextField hostField;
|
||||
private JPanel portPane;
|
||||
private JLabel label6;
|
||||
private JTextField portField;
|
||||
private JPanel usernamePane;
|
||||
private JLabel label7;
|
||||
private JTextField usernameField;
|
||||
private JPanel passwordPane;
|
||||
private JLabel label8;
|
||||
private JTextField passwordField;
|
||||
private JPanel modePane;
|
||||
private JLabel label9;
|
||||
private JPanel panel3;
|
||||
private JRadioButton activeRb;
|
||||
private JRadioButton passiveRb;
|
||||
private JPanel endpointPane;
|
||||
private JLabel label10;
|
||||
private JTextField endpointField;
|
||||
private JPanel bucketPane;
|
||||
private JLabel label11;
|
||||
private JTextField bucketField;
|
||||
private JPanel accessKeyPane;
|
||||
private JLabel label13;
|
||||
private JTextField accessKeyField;
|
||||
private JPanel accessSecretPane;
|
||||
private JLabel label14;
|
||||
private JTextField accessSecretField;
|
||||
private JPanel domainPane;
|
||||
private JLabel label15;
|
||||
private JTextField domainField;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables @formatter:on
|
||||
}
|
@ -0,0 +1,343 @@
|
||||
JFDML JFormDesigner: "8.2.3.0.386" Java: "17.0.11" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
root: new FormRoot {
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "fill,insets 0,gap 10 5"
|
||||
"$columnConstraints": "[500,grow,fill]"
|
||||
"$rowConstraints": "[][][][][][][][][][][][][][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
"minimumSize": new java.awt.Dimension( 340, 500 )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[320,fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "namePane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label1"
|
||||
"text": "配置名"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "nameField"
|
||||
"minimumSize": new java.awt.Dimension( 180, 34 )
|
||||
"preferredSize": new java.awt.Dimension( 240, 34 )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "remarkPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label2"
|
||||
"text": "备注"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "remarkField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "storagePane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label3"
|
||||
"text": "存储器"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||
name: "storageComboBox"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "basePathPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label4"
|
||||
"text": "基础路径"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "basePathField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "hostPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label5"
|
||||
"text": "主机地址"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "hostField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "portPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label6"
|
||||
"text": "主机端口"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "portField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "usernamePane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label7"
|
||||
"text": "用户名"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "usernameField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 6,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "passwordPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label8"
|
||||
"text": "密码"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "passwordField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 7,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "modePane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label9"
|
||||
"text": "连接模式"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class org.jdesktop.swingx.HorizontalLayout ) ) {
|
||||
name: "panel3"
|
||||
add( new FormComponent( "javax.swing.JRadioButton" ) {
|
||||
name: "activeRb"
|
||||
"text": "主动模式"
|
||||
"$buttonGroup": new FormReference( "buttonGroup1" )
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JRadioButton" ) {
|
||||
name: "passiveRb"
|
||||
"text": "被动模式"
|
||||
"$buttonGroup": new FormReference( "buttonGroup1" )
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 8,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "endpointPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label10"
|
||||
"text": "节点地址"
|
||||
"horizontalAlignment": 4
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,alignx left,growx 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "endpointField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 9,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "bucketPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label11"
|
||||
"text": "存储 bucket"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "bucketField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 10,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "accessKeyPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label13"
|
||||
"text": "accessKey"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "accessKeyField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 11,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "accessSecretPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label14"
|
||||
"text": "accessSecret"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "accessSecretField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 12,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[]"
|
||||
"$layoutConstraints": "fill,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "domainPane"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label15"
|
||||
"text": "自定义域名"
|
||||
"minimumSize": new java.awt.Dimension( 80, 16 )
|
||||
"horizontalAlignment": 4
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "domainField"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0,growx"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 13,grow"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 550, 880 )
|
||||
} )
|
||||
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
|
||||
name: "buttonGroup1"
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 896 )
|
||||
} )
|
||||
}
|
||||
}
|
@ -0,0 +1,523 @@
|
||||
/*
|
||||
* Created by JFormDesigner on Thu Jun 13 19:52:21 CST 2024
|
||||
*/
|
||||
|
||||
package com.lw.swing.view.intra.file;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.framework.common.pojo.PageResult;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.config.FileConfigSaveReqVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.dict.vo.data.DictDataSimpleRespVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.permission.vo.permission.PermissionAssignRoleDataScopeReqVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.permission.vo.permission.PermissionAssignRoleMenuReqVO;
|
||||
import com.lw.dillon.admin.module.system.controller.admin.permission.vo.role.RoleRespVO;
|
||||
import com.lw.swing.components.*;
|
||||
import com.lw.swing.components.notice.WMessage;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellEditor;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellRenderer;
|
||||
import com.lw.swing.request.Request;
|
||||
import com.lw.swing.store.AppStore;
|
||||
import com.lw.swing.utils.BadgeLabelUtil;
|
||||
import com.lw.swing.view.MainFrame;
|
||||
import com.lw.swing.view.system.role.RoleAssignMenuPane;
|
||||
import com.lw.ui.request.api.file.FileConfigFeign;
|
||||
import com.lw.ui.request.api.system.PermissionFeign;
|
||||
import com.lw.ui.request.api.system.RoleFeign;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jdesktop.swingx.JXTable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.lw.ui.utils.DictTypeEnum.INFRA_BOOLEAN_STRING;
|
||||
import static com.lw.ui.utils.DictTypeEnum.INFRA_FILE_STORAGE;
|
||||
import static javax.swing.JOptionPane.*;
|
||||
|
||||
/**
|
||||
* @author wenli
|
||||
*/
|
||||
public class FileConfigPane extends JPanel {
|
||||
private String[] COLUMN_ID = {"编号", "配置名", "存储器", "备注", "主配置", "创建时间", "操作"};
|
||||
|
||||
private DefaultTableModel tableModel;
|
||||
|
||||
private WPaginationPane paginationPane;
|
||||
|
||||
public FileConfigPane() {
|
||||
initComponents();
|
||||
initListeners();
|
||||
loadTableData();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
textField = new JTextField();
|
||||
scrollPane1 = new WScrollPane();
|
||||
centerPane = new JPanel();
|
||||
scrollPane2 = new WScrollPane();
|
||||
table = new JXTable(tableModel = new DefaultTableModel());
|
||||
toolPane = new WPanel();
|
||||
label7 = new JLabel();
|
||||
nameTextField = new JTextField();
|
||||
label9 = new JLabel();
|
||||
storageComboBox = new JComboBox();
|
||||
label10 = new JLabel();
|
||||
startDateTextField = new WLocalDateCombo();
|
||||
label11 = new JLabel();
|
||||
endDateTextField = new WLocalDateCombo();
|
||||
searchBut = new JButton();
|
||||
reseBut = new JButton();
|
||||
newBut = new JButton();
|
||||
|
||||
//======== this ========
|
||||
setOpaque(false);
|
||||
setLayout(new BorderLayout(10, 10));
|
||||
|
||||
|
||||
//======== centerPane ========
|
||||
{
|
||||
centerPane.setOpaque(false);
|
||||
centerPane.setLayout(new BorderLayout(10, 10));
|
||||
|
||||
//======== scrollPane2 ========
|
||||
{
|
||||
tableModel.setColumnIdentifiers(COLUMN_ID);
|
||||
scrollPane2.setViewportView(table);
|
||||
}
|
||||
|
||||
JPanel panel = new WPanel();
|
||||
panel.setLayout(new BorderLayout());
|
||||
panel.add(scrollPane2);
|
||||
paginationPane = new WPaginationPane() {
|
||||
@Override
|
||||
public void setPageIndex(long pageIndex) {
|
||||
super.setPageIndex(pageIndex);
|
||||
loadTableData();
|
||||
}
|
||||
};
|
||||
paginationPane.setOpaque(false);
|
||||
panel.add(paginationPane, BorderLayout.SOUTH);
|
||||
centerPane.add(panel, BorderLayout.CENTER);
|
||||
|
||||
//======== toolPane ========
|
||||
{
|
||||
toolPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[left]",
|
||||
// rows
|
||||
"[]"));
|
||||
toolPane.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
//---- label7 ----
|
||||
label7.setText("配置名");
|
||||
toolPane.add(label7, "cell 0 0");
|
||||
|
||||
//---- userNameTextField ----
|
||||
nameTextField.setColumns(15);
|
||||
toolPane.add(nameTextField, "cell 0 0");
|
||||
|
||||
//---- label9 ----
|
||||
label9.setText("存储器");
|
||||
toolPane.add(label9, "cell 0 0");
|
||||
toolPane.add(storageComboBox, "cell 0 0");
|
||||
|
||||
//---- label10 ----
|
||||
label10.setText("创建时间");
|
||||
toolPane.add(label10, "cell 0 0");
|
||||
|
||||
//---- startDateTextField ----
|
||||
toolPane.add(startDateTextField, "cell 0 0");
|
||||
|
||||
//---- label11 ----
|
||||
label11.setText("-");
|
||||
toolPane.add(label11, "cell 0 0");
|
||||
|
||||
//---- endDateTextField ----
|
||||
toolPane.add(endDateTextField, "cell 0 0");
|
||||
|
||||
//---- button1 ----
|
||||
searchBut.setText("\u641c\u7d22");
|
||||
toolPane.add(searchBut, "cell 0 0");
|
||||
|
||||
//---- reseBut ----
|
||||
reseBut.setText("\u91cd\u7f6e");
|
||||
toolPane.add(reseBut, "cell 0 0");
|
||||
|
||||
//---- newBut ----
|
||||
newBut.setText("\u65b0\u589e");
|
||||
toolPane.add(newBut, "cell 0 0");
|
||||
}
|
||||
centerPane.add(toolPane, BorderLayout.NORTH);
|
||||
}
|
||||
add(centerPane, BorderLayout.CENTER);
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents @formatter:on
|
||||
|
||||
table.setRowHeight(40);
|
||||
|
||||
AppStore.getDictDataList(INFRA_FILE_STORAGE).forEach(dictDataSimpleRespVO -> {
|
||||
storageComboBox.addItem(dictDataSimpleRespVO);
|
||||
});
|
||||
|
||||
storageComboBox.setSelectedItem(null);
|
||||
startDateTextField.setValue(null);
|
||||
endDateTextField.setValue(null);
|
||||
|
||||
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
|
||||
|
||||
}
|
||||
|
||||
private JToolBar creatBar() {
|
||||
JToolBar optBar = new JToolBar();
|
||||
optBar.setOpaque(false);
|
||||
JButton edit = new JButton("修改");
|
||||
edit.setForeground(UIManager.getColor("App.accentColor"));
|
||||
edit.setIcon(new FlatSVGIcon("icons/xiugai.svg", 15, 15));
|
||||
edit.addActionListener(e -> showEditDialog());
|
||||
edit.setForeground(UIManager.getColor("App.accentColor"));
|
||||
|
||||
JButton del = new JButton("删除");
|
||||
del.setIcon(new FlatSVGIcon("icons/delte.svg", 15, 15));
|
||||
del.addActionListener(e -> del());
|
||||
del.setForeground(UIManager.getColor("app-error-color-5"));
|
||||
|
||||
JButton primaryBut = new JButton("主配置");
|
||||
primaryBut.addActionListener(e -> updateFileConfigMaster());
|
||||
primaryBut.setForeground(UIManager.getColor("App.accentColor"));
|
||||
primaryBut.setIcon(new FlatSVGIcon("icons/xinzeng.svg", 15, 15));
|
||||
|
||||
optBar.add(Box.createGlue());
|
||||
optBar.add(edit);
|
||||
optBar.add(primaryBut);
|
||||
optBar.add(del);
|
||||
optBar.add(Box.createGlue());
|
||||
return optBar;
|
||||
|
||||
}
|
||||
|
||||
private void initListeners() {
|
||||
|
||||
reseBut.addActionListener(e -> reset());
|
||||
searchBut.addActionListener(e -> loadTableData());
|
||||
newBut.addActionListener(e -> showAddDialog(null));
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
nameTextField.setText("");
|
||||
storageComboBox.setSelectedItem(null);
|
||||
startDateTextField.setValue(null);
|
||||
endDateTextField.setValue(null);
|
||||
loadTableData();
|
||||
}
|
||||
|
||||
private void showAddDialog(Long id) {
|
||||
FileConfigFromPane roleEditPane = new FileConfigFromPane();
|
||||
roleEditPane.updateData(id);
|
||||
int opt = WOptionPane.showOptionDialog(null, roleEditPane, "添加", OK_CANCEL_OPTION, PLAIN_MESSAGE, null, new Object[]{"确定", "取消"}, "确定");
|
||||
if (opt == 0) {
|
||||
add(roleEditPane.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void showEditDialog() {
|
||||
|
||||
|
||||
int selRow = table.getSelectedRow();
|
||||
Long id = null;
|
||||
if (selRow != -1) {
|
||||
id = Convert.toLong(table.getValueAt(selRow, 0));
|
||||
}
|
||||
|
||||
FileConfigFromPane roleEditPane = new FileConfigFromPane();
|
||||
roleEditPane.updateData(id);
|
||||
roleEditPane.revalidate();
|
||||
int opt = WOptionPane.showOptionDialog(null, roleEditPane, "修改", OK_CANCEL_OPTION, PLAIN_MESSAGE, null, new Object[]{"确定", "取消"}, "确定");
|
||||
if (opt == 0) {
|
||||
edit(roleEditPane.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
if (table != null) {
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
private void add(FileConfigSaveReqVO roleSaveReqVO) {
|
||||
|
||||
SwingWorker<CommonResult<Long>, Object> swingWorker = new SwingWorker<CommonResult<Long>, Object>() {
|
||||
@Override
|
||||
protected CommonResult<Long> doInBackground() throws Exception {
|
||||
return Request.connector(FileConfigFeign.class).createFileConfig(roleSaveReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
if (get().isSuccess()) {
|
||||
WMessage.showMessageSuccess(MainFrame.getInstance(), "添加成功!");
|
||||
loadTableData();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
private void edit(FileConfigSaveReqVO roleSaveReqVO) {
|
||||
|
||||
|
||||
SwingWorker<CommonResult<Boolean>, Object> swingWorker = new SwingWorker<CommonResult<Boolean>, Object>() {
|
||||
@Override
|
||||
protected CommonResult<Boolean> doInBackground() throws Exception {
|
||||
return Request.connector(FileConfigFeign.class).updateFileConfig(roleSaveReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
if (get().isSuccess()) {
|
||||
WMessage.showMessageSuccess(MainFrame.getInstance(), "修改成功!");
|
||||
loadTableData();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
private void del() {
|
||||
Long id = null;
|
||||
String userName = null;
|
||||
|
||||
int selRow = table.getSelectedRow();
|
||||
if (selRow != -1) {
|
||||
id = Convert.toLong(table.getValueAt(selRow, 0));
|
||||
userName = Convert.toStr(table.getValueAt(selRow, 1));
|
||||
}
|
||||
|
||||
int opt = WOptionPane.showOptionDialog(this, "是否确定删除[" + userName + "]?", "提示", OK_CANCEL_OPTION, WARNING_MESSAGE, null, null, null);
|
||||
|
||||
if (opt != 0) {
|
||||
return;
|
||||
}
|
||||
Long finalId = id;
|
||||
SwingWorker<CommonResult<Boolean>, Object> swingWorker = new SwingWorker<CommonResult<Boolean>, Object>() {
|
||||
@Override
|
||||
protected CommonResult<Boolean> doInBackground() throws Exception {
|
||||
return Request.connector(FileConfigFeign.class).deleteFileConfig(finalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
if (get().isSuccess()) {
|
||||
WMessage.showMessageSuccess(MainFrame.getInstance(), "删除成功!");
|
||||
loadTableData();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void updateFileConfigMaster() {
|
||||
|
||||
Long id = null;
|
||||
|
||||
int selRow = table.getSelectedRow();
|
||||
if (selRow != -1) {
|
||||
id = Convert.toLong(table.getValueAt(selRow, 0));
|
||||
}
|
||||
|
||||
int opt = WOptionPane.showOptionDialog(this, "是否确认修改配置编号为"+id+"的数据项为主配置?", "提示", OK_CANCEL_OPTION, WARNING_MESSAGE, null, null, null);
|
||||
|
||||
if (opt != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Long finalId = id;
|
||||
SwingWorker<CommonResult<Boolean>, Object> swingWorker = new SwingWorker<CommonResult<Boolean>, Object>() {
|
||||
@Override
|
||||
protected CommonResult<Boolean> doInBackground() throws Exception {
|
||||
return Request.connector(FileConfigFeign.class).updateFileConfigMaster(finalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
if (get().isSuccess()) {
|
||||
WMessage.showMessageSuccess(MainFrame.getInstance(), "修改成功!");
|
||||
loadTableData();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void loadTableData() {
|
||||
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
queryMap.put("pageNo", paginationPane.getPageIndex());
|
||||
queryMap.put("pageSize", paginationPane.getPageSize());
|
||||
|
||||
String name = null;
|
||||
if (StrUtil.isNotBlank(nameTextField.getText())) {
|
||||
name = nameTextField.getText();
|
||||
}
|
||||
|
||||
Integer storage = null;
|
||||
if (storageComboBox.getSelectedItem() != null) {
|
||||
DictDataSimpleRespVO dictDataSimpleRespVO = (DictDataSimpleRespVO) storageComboBox.getSelectedItem();
|
||||
storage = Convert.toInt(dictDataSimpleRespVO.getValue(), null);
|
||||
}
|
||||
|
||||
queryMap.put("name", name);
|
||||
queryMap.put("storage", storage);
|
||||
|
||||
if (ObjectUtil.isAllNotEmpty(startDateTextField.getValue(), endDateTextField.getValue())) {
|
||||
String[] dateTimes = new String[2];
|
||||
dateTimes[0] = DateUtil.format(startDateTextField.getValue().atTime(0, 0, 0), "yyyy-MM-dd HH:mm:ss");
|
||||
dateTimes[1] = DateUtil.format(endDateTextField.getValue().atTime(23, 59, 59), "yyyy-MM-dd HH:mm:ss");
|
||||
queryMap.put("createTime", dateTimes);
|
||||
}
|
||||
|
||||
SwingWorker<Vector<Vector>, Long> swingWorker = new SwingWorker<Vector<Vector>, Long>() {
|
||||
@Override
|
||||
protected Vector<Vector> doInBackground() throws Exception {
|
||||
CommonResult<PageResult<JsonObject>> result = Request.connector(FileConfigFeign.class).getFileConfigPage(queryMap);
|
||||
|
||||
Vector<Vector> tableData = new Vector<>();
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
|
||||
result.getData().getList().forEach(roleRespVO -> {
|
||||
Vector rowV = new Vector();
|
||||
rowV.add(roleRespVO.get("id").getAsLong());
|
||||
rowV.add(roleRespVO.get("name").getAsString());
|
||||
rowV.add(roleRespVO.get("storage").getAsInt());
|
||||
rowV.add(roleRespVO.get("remark").getAsString());
|
||||
rowV.add(roleRespVO.get("master").getAsBoolean());
|
||||
rowV.add(DateUtil.format(Convert.toLocalDateTime(roleRespVO.get("createTime")), "yyyy-MM-dd HH:mm:ss"));
|
||||
rowV.add(roleRespVO);
|
||||
tableData.add(rowV);
|
||||
});
|
||||
|
||||
publish(result.getData().getTotal());
|
||||
}
|
||||
return tableData;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void process(List<Long> chunks) {
|
||||
chunks.forEach(total -> paginationPane.setTotal(total));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
|
||||
|
||||
tableModel.setDataVector(get(), new Vector<>(Arrays.asList(COLUMN_ID)));
|
||||
table.getColumn("操作").setMinWidth(180);
|
||||
table.getColumn("操作").setCellRenderer(new OptButtonTableCellRenderer(creatBar()));
|
||||
table.getColumn("操作").setCellEditor(new OptButtonTableCellEditor(creatBar()));
|
||||
|
||||
table.getColumn("存储器").setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 10));
|
||||
JLabel label = BadgeLabelUtil.getBadgeLabel(INFRA_FILE_STORAGE, value);
|
||||
panel.add(label);
|
||||
panel.setBackground(component.getBackground());
|
||||
panel.setOpaque(isSelected);
|
||||
return panel;
|
||||
}
|
||||
});
|
||||
table.getColumn("主配置").setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 10));
|
||||
JLabel label = BadgeLabelUtil.getBadgeLabel(INFRA_BOOLEAN_STRING, value);
|
||||
panel.add(label);
|
||||
panel.setBackground(component.getBackground());
|
||||
panel.setOpaque(isSelected);
|
||||
return panel;
|
||||
}
|
||||
});
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables @formatter:off
|
||||
// Generated using JFormDesigner non-commercial license
|
||||
private JTextField textField;
|
||||
private JScrollPane scrollPane1;
|
||||
private JPanel centerPane;
|
||||
private JScrollPane scrollPane2;
|
||||
private JTable table;
|
||||
private JPanel toolPane;
|
||||
private JLabel label7;
|
||||
private JTextField nameTextField;
|
||||
private JLabel label9;
|
||||
private JComboBox<DictDataSimpleRespVO> storageComboBox;
|
||||
private JLabel label10;
|
||||
private WLocalDateCombo startDateTextField;
|
||||
private JLabel label11;
|
||||
private WLocalDateCombo endDateTextField;
|
||||
private JButton searchBut;
|
||||
private JButton reseBut;
|
||||
private JButton newBut;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables @formatter:on
|
||||
}
|
@ -0,0 +1,448 @@
|
||||
/*
|
||||
* Created by JFormDesigner on Thu Jun 13 19:52:21 CST 2024
|
||||
*/
|
||||
|
||||
package com.lw.swing.view.intra.file;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.formdev.flatlaf.extras.FlatSVGIcon;
|
||||
import com.lw.dillon.admin.framework.common.pojo.CommonResult;
|
||||
import com.lw.dillon.admin.framework.common.pojo.PageResult;
|
||||
import com.lw.dillon.admin.module.infra.controller.admin.file.vo.file.FileRespVO;
|
||||
import com.lw.swing.components.*;
|
||||
import com.lw.swing.components.notice.WMessage;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellEditor;
|
||||
import com.lw.swing.components.table.renderer.OptButtonTableCellRenderer;
|
||||
import com.lw.swing.request.Request;
|
||||
import com.lw.swing.view.MainFrame;
|
||||
import com.lw.ui.request.api.file.FileConfigFeign;
|
||||
import com.lw.ui.request.api.file.FileFeign;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.jdesktop.swingx.JXTable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static javax.swing.JOptionPane.*;
|
||||
|
||||
/**
|
||||
* @author wenli
|
||||
*/
|
||||
public class FileListPane extends JPanel {
|
||||
private String[] COLUMN_ID = {"文件名", "文件路径", "URL", "文件类型", "文件内容", "上传时间", "操作"};
|
||||
|
||||
private DefaultTableModel tableModel;
|
||||
|
||||
private WPaginationPane paginationPane;
|
||||
|
||||
public FileListPane() {
|
||||
initComponents();
|
||||
initListeners();
|
||||
loadTableData();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
textField = new JTextField();
|
||||
scrollPane1 = new WScrollPane();
|
||||
centerPane = new JPanel();
|
||||
scrollPane2 = new WScrollPane();
|
||||
table = new JXTable(tableModel = new DefaultTableModel());
|
||||
toolPane = new WPanel();
|
||||
label7 = new JLabel();
|
||||
pathField = new JTextField();
|
||||
label9 = new JLabel();
|
||||
typeField = new JTextField();
|
||||
label10 = new JLabel();
|
||||
startDateTextField = new WLocalDateCombo();
|
||||
label11 = new JLabel();
|
||||
endDateTextField = new WLocalDateCombo();
|
||||
searchBut = new JButton();
|
||||
reseBut = new JButton();
|
||||
newBut = new JButton();
|
||||
|
||||
//======== this ========
|
||||
setOpaque(false);
|
||||
setLayout(new BorderLayout(10, 10));
|
||||
|
||||
|
||||
//======== centerPane ========
|
||||
{
|
||||
centerPane.setOpaque(false);
|
||||
centerPane.setLayout(new BorderLayout(10, 10));
|
||||
|
||||
//======== scrollPane2 ========
|
||||
{
|
||||
tableModel.setColumnIdentifiers(COLUMN_ID);
|
||||
scrollPane2.setViewportView(table);
|
||||
}
|
||||
|
||||
JPanel panel = new WPanel();
|
||||
panel.setLayout(new BorderLayout());
|
||||
panel.add(scrollPane2);
|
||||
paginationPane = new WPaginationPane() {
|
||||
@Override
|
||||
public void setPageIndex(long pageIndex) {
|
||||
super.setPageIndex(pageIndex);
|
||||
loadTableData();
|
||||
}
|
||||
};
|
||||
paginationPane.setOpaque(false);
|
||||
panel.add(paginationPane, BorderLayout.SOUTH);
|
||||
centerPane.add(panel, BorderLayout.CENTER);
|
||||
|
||||
//======== toolPane ========
|
||||
{
|
||||
toolPane.setLayout(new MigLayout(
|
||||
"fill,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[left]",
|
||||
// rows
|
||||
"[]"));
|
||||
toolPane.setBorder(new EmptyBorder(10, 10, 10, 10));
|
||||
//---- label7 ----
|
||||
label7.setText("文件路径");
|
||||
toolPane.add(label7, "cell 0 0");
|
||||
|
||||
//---- userNameTextField ----
|
||||
pathField.setColumns(15);
|
||||
toolPane.add(pathField, "cell 0 0");
|
||||
|
||||
//---- label9 ----
|
||||
label9.setText("文件类型");
|
||||
toolPane.add(label9, "cell 0 0");
|
||||
toolPane.add(typeField, "cell 0 0");
|
||||
|
||||
//---- label10 ----
|
||||
label10.setText("创建时间");
|
||||
toolPane.add(label10, "cell 0 0");
|
||||
|
||||
//---- startDateTextField ----
|
||||
toolPane.add(startDateTextField, "cell 0 0");
|
||||
|
||||
//---- label11 ----
|
||||
label11.setText("-");
|
||||
toolPane.add(label11, "cell 0 0");
|
||||
|
||||
//---- endDateTextField ----
|
||||
toolPane.add(endDateTextField, "cell 0 0");
|
||||
|
||||
//---- button1 ----
|
||||
searchBut.setText("搜索");
|
||||
toolPane.add(searchBut, "cell 0 0");
|
||||
|
||||
//---- reseBut ----
|
||||
reseBut.setText("重置");
|
||||
toolPane.add(reseBut, "cell 0 0");
|
||||
|
||||
//---- newBut ----
|
||||
newBut.setText("上传文件");
|
||||
toolPane.add(newBut, "cell 0 0");
|
||||
}
|
||||
centerPane.add(toolPane, BorderLayout.NORTH);
|
||||
}
|
||||
add(centerPane, BorderLayout.CENTER);
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents @formatter:on
|
||||
|
||||
table.setRowHeight(40);
|
||||
|
||||
startDateTextField.setValue(null);
|
||||
endDateTextField.setValue(null);
|
||||
|
||||
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
|
||||
|
||||
}
|
||||
|
||||
private JToolBar creatBar() {
|
||||
JToolBar optBar = new JToolBar();
|
||||
optBar.setOpaque(false);
|
||||
|
||||
JButton del = new JButton("删除");
|
||||
del.setIcon(new FlatSVGIcon("icons/delte.svg", 15, 15));
|
||||
del.addActionListener(e -> del());
|
||||
del.setForeground(UIManager.getColor("app-error-color-5"));
|
||||
|
||||
JButton downLoadBut = new JButton("下载");
|
||||
downLoadBut.setIcon(new FlatSVGIcon("icons/xiazai.svg", 15, 15));
|
||||
downLoadBut.addActionListener(e -> download());
|
||||
del.setForeground(UIManager.getColor("App.accentColor"));
|
||||
|
||||
optBar.add(Box.createGlue());
|
||||
optBar.add(downLoadBut);
|
||||
optBar.add(del);
|
||||
optBar.add(Box.createGlue());
|
||||
return optBar;
|
||||
}
|
||||
|
||||
|
||||
private void initListeners() {
|
||||
|
||||
reseBut.addActionListener(e -> reset());
|
||||
searchBut.addActionListener(e -> loadTableData());
|
||||
newBut.addActionListener(e -> uploadFile());
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
pathField.setText("");
|
||||
typeField.setText(null);
|
||||
startDateTextField.setValue(null);
|
||||
endDateTextField.setValue(null);
|
||||
loadTableData();
|
||||
}
|
||||
|
||||
private void uploadFile() {
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
int result = fileChooser.showOpenDialog(this);
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
File selectedFile = fileChooser.getSelectedFile();
|
||||
SwingWorker<CommonResult<String>, Object> swingWorker = new SwingWorker<CommonResult<String>, Object>() {
|
||||
@Override
|
||||
protected CommonResult<String> doInBackground() throws Exception {
|
||||
return Request.fileConnector(FileFeign.class).uploadFile("", selectedFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
if (get().isSuccess()) {
|
||||
WMessage.showMessageSuccess(MainFrame.getInstance(), "上传成功!");
|
||||
loadTableData();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
if (table != null) {
|
||||
table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void del() {
|
||||
Long id = null;
|
||||
String userName = null;
|
||||
|
||||
int selRow = table.getSelectedRow();
|
||||
if (selRow != -1) {
|
||||
id = Convert.toLong(table.getValueAt(selRow, 0));
|
||||
userName = Convert.toStr(table.getValueAt(selRow, 1));
|
||||
}
|
||||
|
||||
int opt = WOptionPane.showOptionDialog(this, "是否确定删除[" + userName + "]?", "提示", OK_CANCEL_OPTION, WARNING_MESSAGE, null, null, null);
|
||||
|
||||
if (opt != 0) {
|
||||
return;
|
||||
}
|
||||
Long finalId = id;
|
||||
SwingWorker<CommonResult<Boolean>, Object> swingWorker = new SwingWorker<CommonResult<Boolean>, Object>() {
|
||||
@Override
|
||||
protected CommonResult<Boolean> doInBackground() throws Exception {
|
||||
return Request.connector(FileConfigFeign.class).deleteFileConfig(finalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
if (get().isSuccess()) {
|
||||
WMessage.showMessageSuccess(MainFrame.getInstance(), "删除成功!");
|
||||
loadTableData();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void download() {
|
||||
|
||||
FileRespVO respVO=null;
|
||||
int selRow = table.getSelectedRow();
|
||||
if (selRow != -1) {
|
||||
respVO = (FileRespVO) table.getValueAt(selRow, COLUMN_ID.length - 1);
|
||||
}
|
||||
|
||||
|
||||
if (respVO == null) {
|
||||
return;
|
||||
}
|
||||
// Check if Desktop API is supported on the current platform
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI(respVO.getUrl()));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
// showAlert("Error", "Desktop API is not supported on this platform.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void loadTableData() {
|
||||
|
||||
Map<String, Object> queryMap = new HashMap<>();
|
||||
queryMap.put("pageNo", paginationPane.getPageIndex());
|
||||
queryMap.put("pageSize", paginationPane.getPageSize());
|
||||
|
||||
String path = null;
|
||||
String type = null;
|
||||
if (StrUtil.isNotBlank(pathField.getText())) {
|
||||
path = pathField.getText();
|
||||
}
|
||||
if (StrUtil.isNotBlank(typeField.getText())) {
|
||||
type = typeField.getText();
|
||||
}
|
||||
|
||||
|
||||
queryMap.put("path", path);
|
||||
queryMap.put("type", type);
|
||||
|
||||
if (ObjectUtil.isAllNotEmpty(startDateTextField.getValue(), endDateTextField.getValue())) {
|
||||
String[] dateTimes = new String[2];
|
||||
dateTimes[0] = DateUtil.format(startDateTextField.getValue().atTime(0, 0, 0), "yyyy-MM-dd HH:mm:ss");
|
||||
dateTimes[1] = DateUtil.format(endDateTextField.getValue().atTime(23, 59, 59), "yyyy-MM-dd HH:mm:ss");
|
||||
queryMap.put("createTime", dateTimes);
|
||||
}
|
||||
|
||||
SwingWorker<Vector<Vector>, Long> swingWorker = new SwingWorker<Vector<Vector>, Long>() {
|
||||
@Override
|
||||
protected Vector<Vector> doInBackground() throws Exception {
|
||||
CommonResult<PageResult<FileRespVO>> result = Request.connector(FileFeign.class).getFilePage(queryMap);
|
||||
|
||||
Vector<Vector> tableData = new Vector<>();
|
||||
|
||||
|
||||
if (result.isSuccess()) {
|
||||
|
||||
result.getData().getList().forEach(respVO -> {
|
||||
Vector rowV = new Vector();
|
||||
rowV.add(respVO.getName());
|
||||
rowV.add(respVO.getPath());
|
||||
rowV.add(respVO.getUrl());
|
||||
rowV.add(respVO.getType());
|
||||
rowV.add(respVO);
|
||||
rowV.add(DateUtil.format(respVO.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
|
||||
rowV.add(respVO);
|
||||
tableData.add(rowV);
|
||||
});
|
||||
|
||||
publish(result.getData().getTotal());
|
||||
}
|
||||
return tableData;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void process(List<Long> chunks) {
|
||||
chunks.forEach(total -> paginationPane.setTotal(total));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
try {
|
||||
|
||||
|
||||
tableModel.setDataVector(get(), new Vector<>(Arrays.asList(COLUMN_ID)));
|
||||
table.getColumn("操作").setMinWidth(180);
|
||||
table.getColumn("操作").setCellRenderer(new OptButtonTableCellRenderer(creatBar()));
|
||||
table.getColumn("操作").setCellEditor(new OptButtonTableCellEditor(creatBar()));
|
||||
|
||||
table.getColumn("文件内容").setCellRenderer(new DefaultTableCellRenderer() {
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
table.setRowHeight(row, 35);
|
||||
if (value instanceof FileRespVO) {
|
||||
|
||||
if (StrUtil.contains(((FileRespVO) value).getType(), "image")) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(((FileRespVO) value).getUrl());
|
||||
ImageIcon imageIcon = new ImageIcon(url);
|
||||
// Create a label and set the icon
|
||||
JLabel imageLabel = new JLabel(imageIcon);
|
||||
panel.add(imageLabel);
|
||||
table.setRowHeight(row, 180);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||
panel.setBackground(component.getBackground());
|
||||
panel.setOpaque(isSelected);
|
||||
return panel;
|
||||
}
|
||||
});
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
swingWorker.execute();
|
||||
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables @formatter:off
|
||||
// Generated using JFormDesigner non-commercial license
|
||||
private JTextField textField;
|
||||
private JScrollPane scrollPane1;
|
||||
private JPanel centerPane;
|
||||
private JScrollPane scrollPane2;
|
||||
private JTable table;
|
||||
private JPanel toolPane;
|
||||
private JLabel label7;
|
||||
private JTextField pathField;
|
||||
private JLabel label9;
|
||||
private JTextField typeField;
|
||||
private JLabel label10;
|
||||
private WLocalDateCombo startDateTextField;
|
||||
private JLabel label11;
|
||||
private WLocalDateCombo endDateTextField;
|
||||
private JButton searchBut;
|
||||
private JButton reseBut;
|
||||
private JButton newBut;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables @formatter:on
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg class="icon" width="200px" height="200.00px" viewBox="0 0 1024 1024" version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M832 800v64H192v-64h640zM545.664 160l-0.032 460.8 156.704-157.12 47.616 47.68L512 750.016 274.048 511.36l47.616-47.712 156.672 157.088V160h67.328z"
|
||||
fill="#6e6e6e"/>
|
||||
</svg>
|
After Width: | Height: | Size: 467 B |