diff --git a/src/main/java/com/sjhy/plugin/ui/MainSetting.java b/src/main/java/com/sjhy/plugin/ui/MainSetting.java index 5a027432106a7105a4b00feed72b5ce26cbb50cd..0f6f9f55ddadb72ed5ce16c3103131b0c09c76fa 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 -> {