From b804e890bfd10611eda53f78f44d68dcc3c85646 Mon Sep 17 00:00:00 2001 From: makejava <1353036300@qq.com> Date: Wed, 10 Jan 2018 23:51:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E5=AE=8C=E6=88=90=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/string.properties | 2 + resources/template/dao.vm | 1 + .../sjhy/plugin/comm/AbstractTableModel.java | 2 +- src/com/sjhy/plugin/entity/Template.java | 8 ++ .../sjhy/plugin/service/ConfigService.java | 8 +- .../service/impl/ConfigServiceImpl.java | 44 +++++--- src/com/sjhy/plugin/ui/EditTemplatePanel.form | 21 ++++ src/com/sjhy/plugin/ui/EditTemplatePanel.java | 39 +++++++ src/com/sjhy/plugin/ui/MainSetting.java | 3 +- src/com/sjhy/plugin/ui/TemplateSetting.form | 100 ++++++++++++++++++ src/com/sjhy/plugin/ui/TemplateSetting.java | 51 +++++++++ src/com/sjhy/plugin/ui/TypeMapperSetting.form | 7 +- 12 files changed, 261 insertions(+), 25 deletions(-) create mode 100644 resources/template/dao.vm create mode 100644 src/com/sjhy/plugin/ui/EditTemplatePanel.form create mode 100644 src/com/sjhy/plugin/ui/EditTemplatePanel.java create mode 100644 src/com/sjhy/plugin/ui/TemplateSetting.form create mode 100644 src/com/sjhy/plugin/ui/TemplateSetting.java diff --git a/resources/string.properties b/resources/string.properties index 6f73034..f07676c 100644 --- a/resources/string.properties +++ b/resources/string.properties @@ -1,4 +1,6 @@ button.type.mapper.copy.group=Copy Group label.author.name=&\u4F5C\u8005\u540D\u79F0\uFF1A label.default.encode=&\u9ED8\u8BA4\u7F16\u7801\uFF1A +label.operate=\u64CD\u4F5C +label.template.group=&\u6A21\u677F\u7EC4\uFF1A label.type.mapper=&\u7C7B\u578B\u6620\u5C04\u7EC4\uFF1A \ No newline at end of file diff --git a/resources/template/dao.vm b/resources/template/dao.vm new file mode 100644 index 0000000..1b5c732 --- /dev/null +++ b/resources/template/dao.vm @@ -0,0 +1 @@ +这里什么都没有 \ No newline at end of file diff --git a/src/com/sjhy/plugin/comm/AbstractTableModel.java b/src/com/sjhy/plugin/comm/AbstractTableModel.java index 6f9866e..04b61ee 100644 --- a/src/com/sjhy/plugin/comm/AbstractTableModel.java +++ b/src/com/sjhy/plugin/comm/AbstractTableModel.java @@ -19,7 +19,7 @@ public abstract class AbstractTableModel extends DefaultTableModel { } this.data = data; removeAllRow(); - data.forEach(this::addRow); + data.forEach(item-> super.addRow(toObj(item))); } diff --git a/src/com/sjhy/plugin/entity/Template.java b/src/com/sjhy/plugin/entity/Template.java index 3275893..a8775db 100644 --- a/src/com/sjhy/plugin/entity/Template.java +++ b/src/com/sjhy/plugin/entity/Template.java @@ -6,6 +6,14 @@ public class Template implements Cloneable { //模板代码 private String code; + public Template() { + } + + public Template(String name, String code) { + this.name = name; + this.code = code; + } + public String getName() { return name; } diff --git a/src/com/sjhy/plugin/service/ConfigService.java b/src/com/sjhy/plugin/service/ConfigService.java index d15829d..2e7bb09 100644 --- a/src/com/sjhy/plugin/service/ConfigService.java +++ b/src/com/sjhy/plugin/service/ConfigService.java @@ -2,6 +2,7 @@ package com.sjhy.plugin.service; import com.intellij.openapi.components.PersistentStateComponent; import com.intellij.openapi.components.ServiceManager; +import com.sjhy.plugin.entity.TemplateGroup; import com.sjhy.plugin.entity.TypeMapperGroup; import java.util.Map; @@ -9,6 +10,7 @@ import java.util.Map; public interface ConfigService extends PersistentStateComponent { //默认名称 String DEFAULT_NAME = "Default"; + static ConfigService getInstance() { return ServiceManager.getService(ConfigService.class); } @@ -23,8 +25,6 @@ public interface ConfigService extends PersistentStateComponent { void setCurrTemplateGroupName(String currTemplateGroupName); -// Map> getTemplateGroup(); - String getEncode(); void setEncode(String encode); @@ -34,4 +34,8 @@ public interface ConfigService extends PersistentStateComponent { void setAuthor(String author); void setTypeMapperGroupMap(Map typeMapperGroupMap); + + Map getTemplateGroupMap(); + + void setTemplateGroupMap(Map templateGroupMap); } diff --git a/src/com/sjhy/plugin/service/impl/ConfigServiceImpl.java b/src/com/sjhy/plugin/service/impl/ConfigServiceImpl.java index feb1195..6df5460 100644 --- a/src/com/sjhy/plugin/service/impl/ConfigServiceImpl.java +++ b/src/com/sjhy/plugin/service/impl/ConfigServiceImpl.java @@ -4,6 +4,8 @@ import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.xmlb.XmlSerializerUtil; +import com.sjhy.plugin.entity.Template; +import com.sjhy.plugin.entity.TemplateGroup; import com.sjhy.plugin.entity.TypeMapper; import com.sjhy.plugin.entity.TypeMapperGroup; import com.sjhy.plugin.service.ConfigService; @@ -23,13 +25,14 @@ public class ConfigServiceImpl implements ConfigService { private Map typeMapperGroupMap; //当前模板组名 private String currTemplateGroupName; -// //模板组 -// private Map> templateGroup; + //模板组 + private Map templateGroupMap; //默认编码 private String encode; //作者 private String author; + //是否初始化 private Boolean init = false; public ConfigServiceImpl() { @@ -51,6 +54,9 @@ public class ConfigServiceImpl implements ConfigService { if (configService.getTypeMapperGroupMap().isEmpty()) { return; } + if (configService.getTemplateGroupMap().isEmpty()) { + return; + } //加载配置信息 XmlSerializerUtil.copyBean(configService, this); } @@ -71,13 +77,17 @@ public class ConfigServiceImpl implements ConfigService { if (this.currTypeMapperGroupName==null) { this.currTypeMapperGroupName = DEFAULT_NAME; } -// //配置默认模板 -// if (this.templateGroup==null) { -// this.templateGroup = new LinkedHashMap<>(); -// } -// Map template = new LinkedHashMap<>(); -// template.put("entity", loadTemplate("entity")); -// this.templateGroup.put(DEFAULT_NAME, template); + //配置默认模板 + if (this.templateGroupMap==null) { + this.templateGroupMap = new LinkedHashMap<>(); + } + TemplateGroup templateGroup = new TemplateGroup(); + List