From 4ecec56a123fb9ca34267bfb12f048a1fa5d66d3 Mon Sep 17 00:00:00 2001 From: makejava <1353036300@qq.com> Date: Wed, 18 Jul 2018 16:26:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=A7=E9=87=8F=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=85=B3=E9=97=AD=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=97=B6=E7=BC=96=E8=BE=91=E6=A1=86=E6=9C=AA=E9=87=8A?= =?UTF-8?q?=E6=94=BE=E5=AF=BC=E8=87=B4=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/sjhy/plugin/comm/ServiceComm.java | 31 +-- .../com/sjhy/plugin/entity/ColumnConfig.java | 9 + .../sjhy/plugin/service/ConfigService.java | 64 ----- .../service/impl/ConfigServiceImpl.java | 218 ------------------ .../java/com/sjhy/plugin/tool/ConfigInfo.java | 158 +++++++++++++ .../com/sjhy/plugin/tool/VelocityUtils.java | 53 ++--- .../sjhy/plugin/ui/AbstractGroupPanel.java | 52 ++--- .../plugin/ui/AbstractTableGroupPanel.java | 57 +++-- .../com/sjhy/plugin/ui/ConfigTableDialog.java | 10 +- .../com/sjhy/plugin/ui/EditTemplatePanel.java | 36 +++ .../java/com/sjhy/plugin/ui/MainSetting.java | 37 +-- .../com/sjhy/plugin/ui/SelectSavePath.java | 32 +-- .../com/sjhy/plugin/ui/TableSettingPanel.java | 15 +- .../sjhy/plugin/ui/TemplateSettingPanel.java | 56 ++++- .../com/sjhy/plugin/ui/TypeMapperSetting.java | 40 ++-- src/main/resources/META-INF/plugin.xml | 2 +- 16 files changed, 422 insertions(+), 448 deletions(-) delete mode 100644 src/main/java/com/sjhy/plugin/service/ConfigService.java delete mode 100644 src/main/java/com/sjhy/plugin/service/impl/ConfigServiceImpl.java create mode 100644 src/main/java/com/sjhy/plugin/tool/ConfigInfo.java diff --git a/src/main/java/com/sjhy/plugin/comm/ServiceComm.java b/src/main/java/com/sjhy/plugin/comm/ServiceComm.java index 8687d99..966067c 100644 --- a/src/main/java/com/sjhy/plugin/comm/ServiceComm.java +++ b/src/main/java/com/sjhy/plugin/comm/ServiceComm.java @@ -1,35 +1,20 @@ package com.sjhy.plugin.comm; import com.sjhy.plugin.entity.TypeMapperGroup; -import com.sjhy.plugin.service.ConfigService; -import com.sjhy.plugin.service.impl.ConfigServiceImpl; +import com.sjhy.plugin.tool.ConfigInfo; public abstract class ServiceComm { - protected ConfigService getConfigService() { - try { - return ConfigService.getInstance(); - } catch (Exception e) { - e.printStackTrace(); - return new ConfigServiceImpl(); - } + protected ConfigInfo getConfigInfo() { + return ConfigInfo.getInstance(); } + protected TypeMapperGroup getCurrMapper() { - ConfigService configService = getConfigService(); - return configService.getTypeMapperGroupMap().get(configService.getCurrTemplateGroupName()); + ConfigInfo configInfo = getConfigInfo(); + return configInfo.getTypeMapperGroupMap().get(configInfo.getCurrTemplateGroupName()); } protected void setCurrMapper(TypeMapperGroup typeMapper) { - ConfigService configService = getConfigService(); - configService.getTypeMapperGroupMap().put(configService.getCurrTypeMapperGroupName(), typeMapper); + ConfigInfo configInfo = getConfigInfo(); + configInfo.getTypeMapperGroupMap().put(configInfo.getCurrTypeMapperGroupName(), typeMapper); } - -// protected Map getCurrTemplate() { -// ConfigService configService = getConfigService(); -// return configService.getTemplateGroup().get(configService.getCurrTemplateGroupName()); -// } -// -// protected void setCurrTemplate(Map template) { -// ConfigService configService = getConfigService(); -// configService.getTemplateGroup().put(configService.getCurrTemplateGroupName(), template); -// } } diff --git a/src/main/java/com/sjhy/plugin/entity/ColumnConfig.java b/src/main/java/com/sjhy/plugin/entity/ColumnConfig.java index c784583..87c8a17 100644 --- a/src/main/java/com/sjhy/plugin/entity/ColumnConfig.java +++ b/src/main/java/com/sjhy/plugin/entity/ColumnConfig.java @@ -12,8 +12,17 @@ import lombok.Data; */ @Data public class ColumnConfig extends CommClone { + /** + * 标题 + */ private String title; + /** + * 类型 + */ private ColumnConfigType type; + /** + * 可选值,逗号分割 + */ private String selectValue; public ColumnConfig(String title, ColumnConfigType type) { diff --git a/src/main/java/com/sjhy/plugin/service/ConfigService.java b/src/main/java/com/sjhy/plugin/service/ConfigService.java deleted file mode 100644 index 56ea90e..0000000 --- a/src/main/java/com/sjhy/plugin/service/ConfigService.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.sjhy.plugin.service; - -import com.intellij.openapi.components.PersistentStateComponent; -import com.intellij.openapi.components.ServiceManager; -import com.sjhy.plugin.entity.ColumnConfigGroup; -import com.sjhy.plugin.entity.TemplateGroup; -import com.sjhy.plugin.entity.TypeMapperGroup; - -import java.util.Map; - -/** - * 配置服务接口 - * - * @author makejava - * @version 1.0.0 - * @since 2018/07/17 13:10 - */ -public interface ConfigService extends PersistentStateComponent { - /** - * 默认名称 - */ - String DEFAULT_NAME = "Default"; - - /** - * 获取单例实例对象 - * - * @return 实例对象 - */ - static ConfigService getInstance() { - return ServiceManager.getService(ConfigService.class); - } - - String getCurrTypeMapperGroupName(); - - void setCurrTypeMapperGroupName(String currTypeMapperGroupName); - - Map getTypeMapperGroupMap(); - - String getCurrTemplateGroupName(); - - void setCurrTemplateGroupName(String currTemplateGroupName); - - String getEncode(); - - void setEncode(String encode); - - String getAuthor(); - - void setAuthor(String author); - - void setTypeMapperGroupMap(Map typeMapperGroupMap); - - Map getTemplateGroupMap(); - - void setTemplateGroupMap(Map templateGroupMap); - - Map getColumnConfigGroupMap(); - - void setColumnConfigGroupMap(Map columnConfigGroupMap); - - String getCurrColumnConfigGroupName(); - - void setCurrColumnConfigGroupName(String currColumnConfigGroupName); -} diff --git a/src/main/java/com/sjhy/plugin/service/impl/ConfigServiceImpl.java b/src/main/java/com/sjhy/plugin/service/impl/ConfigServiceImpl.java deleted file mode 100644 index 7b0bf22..0000000 --- a/src/main/java/com/sjhy/plugin/service/impl/ConfigServiceImpl.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.sjhy.plugin.service.impl; - -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; -import com.intellij.util.xmlb.XmlSerializerUtil; -import com.sjhy.plugin.entity.*; -import com.sjhy.plugin.service.ConfigService; -import com.sjhy.plugin.tool.FileUtils; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * 配置服务实现类 - * - * @author makejava - * @version 1.0.0 - * @since 2018/07/17 13:10 - */ -@State(name = "EasyCodeSetting", storages = @Storage("$APP_CONFIG$/EasyCode-settings.xml")) -public class ConfigServiceImpl implements ConfigService { - //当前类型映射组名 - private String currTypeMapperGroupName; - //类型映射组 - private Map typeMapperGroupMap; - //当前模板组名 - private String currTemplateGroupName; - //模板组 - private Map templateGroupMap; - //当前配置表组名 - private String currColumnConfigGroupName; - //配置表组 - private Map columnConfigGroupMap; - //默认编码 - private String encode; - //作者 - private String author; - - - public ConfigServiceImpl() { - initDefault(); - } - - @Nullable - @Override - public ConfigService getState() { - return this; - } - - @Override - public void loadState(ConfigService configService) { - if (configService==null || configService.getTemplateGroupMap()==null || configService.getTypeMapperGroupMap()==null || configService.getColumnConfigGroupMap()==null) { - return; - } - //重点,没有数据时,不要序列化 - if (configService.getTypeMapperGroupMap().isEmpty()) { - return; - } - if (configService.getTemplateGroupMap().isEmpty()) { - return; - } - if (configService.getColumnConfigGroupMap().isEmpty()) { - return; - } - //加载配置信息 - XmlSerializerUtil.copyBean(configService, this); - } - - /** - * 初始化默认设置 - */ - private void initDefault() { - if (this.encode==null) { - this.encode = "UTF-8"; - } - if (this.author==null) { - this.author = "Mr.Wang"; - } - if (this.currTemplateGroupName==null) { - this.currTemplateGroupName = DEFAULT_NAME; - } - if (this.currTypeMapperGroupName==null) { - this.currTypeMapperGroupName = DEFAULT_NAME; - } - if (this.currColumnConfigGroupName==null) { - this.currColumnConfigGroupName = DEFAULT_NAME; - } - //配置默认模板 - if (this.templateGroupMap==null) { - this.templateGroupMap = new LinkedHashMap<>(); - } - TemplateGroup templateGroup = new TemplateGroup(); - List