From 02d3d9e5d98c21cbe7673bfeba0de48710c8aee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8E=E5=9D=8E=E5=9D=B7=E5=9D=B7?= Date: Tue, 20 Oct 2020 16:34:22 +0800 Subject: [PATCH] =?UTF-8?q?update=20src/main/java/com/sjhy/plugin/ui/MainS?= =?UTF-8?q?etting.java.=20=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E6=8C=89?= =?UTF-8?q?=E9=92=AE=EF=BC=8C=E7=82=B9=E5=87=BB=E8=BE=93=E5=85=A5=E8=BF=9C?= =?UTF-8?q?=E7=A8=8BURL=E7=9B=B4=E6=8E=A5=E8=BF=94=E5=9B=9Ejson=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E5=8F=AF=E4=BB=A5=E6=90=AD=E5=BB=BA=E8=87=AA?= =?UTF-8?q?=E5=B7=B1=E7=9A=84=E6=A8=A1=E6=9D=BF=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/sjhy/plugin/ui/MainSetting.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/main/java/com/sjhy/plugin/ui/MainSetting.java b/src/main/java/com/sjhy/plugin/ui/MainSetting.java index 5a02743..0f6f9f5 100644 --- a/src/main/java/com/sjhy/plugin/ui/MainSetting.java +++ b/src/main/java/com/sjhy/plugin/ui/MainSetting.java @@ -168,6 +168,57 @@ public class MainSetting implements Configurable, Configurable.Composite { ExceptionUtil.rethrow(e1); } }); + //远程导入 + remoteBtn.addActionListener(e -> { + String url = Messages.showInputDialog("RemoteUrl:", MsgValue.TITLE_INFO, AllIcons.General.Tip, "", new InputValidator() { + @Override + public boolean checkInput(String inputString) { + return !StringUtils.isEmpty(inputString); + } + + @Override + public boolean canClose(String inputString) { + return this.checkInput(inputString); + } + }); + if (url == null) { + return; + } + String result = HttpUtils.getRemoteUrl(url); + if (result == null) { + return; + } + // 解析数据 + ObjectMapper objectMapper = new ObjectMapper(); + try { + JsonNode jsonNode = objectMapper.readTree(result); + if (jsonNode == null) { + return; + } + // 配置覆盖 + coverConfig(jsonNode, StrState.TYPE_MAPPER, TypeMapperGroup.class, settings.getTypeMapperGroupMap()); + coverConfig(jsonNode, StrState.TEMPLATE, TemplateGroup.class, settings.getTemplateGroupMap()); + coverConfig(jsonNode, StrState.COLUMN_CONFIG, ColumnConfigGroup.class, settings.getColumnConfigGroupMap()); + coverConfig(jsonNode, StrState.GLOBAL_CONFIG, GlobalConfigGroup.class, settings.getGlobalConfigGroupMap()); + // 重置配置 + allList.forEach(UnnamedConfigurable::reset); + if (CollectionUtil.isEmpty(saveList)) { + return; + } + // 保存 + allList.forEach(configurable -> { + try { + configurable.apply(); + } catch (ConfigurationException e1) { + e1.printStackTrace(); + } + }); + // 覆盖提示 + Messages.showInfoMessage("导入完成", MsgValue.TITLE_INFO); + } catch (IOException e1) { + ExceptionUtil.rethrow(e1); + } + }); // 模板导出事件 exportBtn.addActionListener(e -> { -- Gitee