mirror of https://gitee.com/makejava/EasyCode.git
优化设置中心
This commit is contained in:
parent
2d67950ff8
commit
257cd63d63
|
@ -1,7 +1,7 @@
|
|||
package com.sjhy.plugin.comm;
|
||||
|
||||
import com.sjhy.plugin.entity.TypeMapperGroup;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
|
||||
/**
|
||||
* 抽象的服务
|
||||
|
@ -14,7 +14,7 @@ public abstract class AbstractService {
|
|||
/**
|
||||
* 配置信息对象
|
||||
*/
|
||||
protected ConfigInfo configInfo = ConfigInfo.getInstance();
|
||||
protected Settings settings = Settings.getInstance();
|
||||
|
||||
/**
|
||||
* 获取当前的类型映射Mapper
|
||||
|
@ -22,7 +22,7 @@ public abstract class AbstractService {
|
|||
* @return 类型映射Mapper
|
||||
*/
|
||||
protected TypeMapperGroup getCurrMapper() {
|
||||
return configInfo.getTypeMapperGroupMap().get(configInfo.getCurrTypeMapperGroupName());
|
||||
return settings.getTypeMapperGroupMap().get(settings.getCurrTypeMapperGroupName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,6 @@ public abstract class AbstractService {
|
|||
* @param typeMapper 类型映射Mapper
|
||||
*/
|
||||
protected void setCurrMapper(TypeMapperGroup typeMapper) {
|
||||
configInfo.getTypeMapperGroupMap().put(configInfo.getCurrTypeMapperGroupName(), typeMapper);
|
||||
settings.getTypeMapperGroupMap().put(settings.getCurrTypeMapperGroupName(), typeMapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,57 +1,260 @@
|
|||
package com.sjhy.plugin.config;
|
||||
|
||||
import com.intellij.ide.fileTemplates.impl.UrlUtil;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import com.sjhy.plugin.entity.*;
|
||||
import lombok.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 全局设置
|
||||
* 全局配置信息
|
||||
*
|
||||
* @author makejava
|
||||
* @version 1.0.0
|
||||
* @since 2018/08/09 15:00
|
||||
* @since 2018/07/18 09:33
|
||||
*/
|
||||
@Data
|
||||
@State(name = "EasyCodeSetting", storages = @Storage("easy-code-setting.xml"))
|
||||
public class Settings implements PersistentStateComponent<Settings> {
|
||||
/**
|
||||
* 获取实例对象
|
||||
* 默认名称
|
||||
*/
|
||||
@Transient
|
||||
public static final String DEFAULT_NAME = "Default";
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* 当前类型映射组名
|
||||
*/
|
||||
private String currTypeMapperGroupName;
|
||||
/**
|
||||
* 类型映射组
|
||||
*/
|
||||
private Map<String, TypeMapperGroup> typeMapperGroupMap;
|
||||
/**
|
||||
* 当前模板组名
|
||||
*/
|
||||
private String currTemplateGroupName;
|
||||
/**
|
||||
* 模板组
|
||||
*/
|
||||
private Map<String, TemplateGroup> templateGroupMap;
|
||||
/**
|
||||
* 当前配置表组名
|
||||
*/
|
||||
private String currColumnConfigGroupName;
|
||||
/**
|
||||
* 配置表组
|
||||
*/
|
||||
private Map<String, ColumnConfigGroup> columnConfigGroupMap;
|
||||
/**
|
||||
* 当前全局配置组名
|
||||
*/
|
||||
private String currGlobalConfigGroupName;
|
||||
/**
|
||||
* 全局配置组
|
||||
*/
|
||||
private Map<String, GlobalConfigGroup> globalConfigGroupMap;
|
||||
/**
|
||||
* 默认编码
|
||||
*/
|
||||
private String encode;
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
private String author;
|
||||
|
||||
/**
|
||||
* 获取单例实例对象
|
||||
*
|
||||
* @return 实例对象
|
||||
*/
|
||||
public static Settings getInstance() {
|
||||
return ServiceManager.getService(Settings.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取持久化状态信息
|
||||
*
|
||||
* @return 持久化状态信息
|
||||
* 默认构造方法
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public Settings() {
|
||||
initDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化默认设置
|
||||
*/
|
||||
public void initDefault() {
|
||||
// 版本号
|
||||
this.version = "1.1.0";
|
||||
// 默认编码
|
||||
this.encode = "UTF-8";
|
||||
// 作者名称
|
||||
this.author = "makejava";
|
||||
// 当前各项分组名称
|
||||
this.currTemplateGroupName = DEFAULT_NAME;
|
||||
this.currTypeMapperGroupName = DEFAULT_NAME;
|
||||
this.currColumnConfigGroupName = DEFAULT_NAME;
|
||||
this.currGlobalConfigGroupName = DEFAULT_NAME;
|
||||
//配置默认模板
|
||||
if (this.templateGroupMap == null) {
|
||||
this.templateGroupMap = new LinkedHashMap<>();
|
||||
}
|
||||
this.templateGroupMap.put(DEFAULT_NAME, loadTemplateGroup(DEFAULT_NAME, "entity", "dao", "service", "serviceImpl", "controller"));
|
||||
this.templateGroupMap.put("MybatisPlus", loadTemplateGroup("MybatisPlus", "entity", "dao", "service", "serviceImpl", "controller"));
|
||||
|
||||
//配置默认类型映射
|
||||
if (this.typeMapperGroupMap == null) {
|
||||
this.typeMapperGroupMap = new LinkedHashMap<>();
|
||||
}
|
||||
TypeMapperGroup typeMapperGroup = new TypeMapperGroup();
|
||||
List<TypeMapper> typeMapperList = new ArrayList<>();
|
||||
typeMapperList.add(new TypeMapper("varchar(\\(\\d+\\))?", "java.lang.String"));
|
||||
typeMapperList.add(new TypeMapper("text", "java.lang.String"));
|
||||
typeMapperList.add(new TypeMapper("decimal(\\(\\d+\\))?", "java.lang.Double"));
|
||||
typeMapperList.add(new TypeMapper("integer", "java.lang.Integer"));
|
||||
typeMapperList.add(new TypeMapper("int(\\(\\d+\\))?", "java.lang.Integer"));
|
||||
typeMapperList.add(new TypeMapper("int4", "java.lang.Integer"));
|
||||
typeMapperList.add(new TypeMapper("int8", "java.lang.Long"));
|
||||
typeMapperList.add(new TypeMapper("bigint(\\(\\d+\\))?", "java.lang.Long"));
|
||||
typeMapperList.add(new TypeMapper("datetime", "java.util.Date"));
|
||||
typeMapperList.add(new TypeMapper("timestamp", "java.util.Date"));
|
||||
typeMapperList.add(new TypeMapper("boolean", "java.lang.Boolean"));
|
||||
typeMapperGroup.setName(DEFAULT_NAME);
|
||||
typeMapperGroup.setElementList(typeMapperList);
|
||||
typeMapperGroupMap.put(DEFAULT_NAME, typeMapperGroup);
|
||||
|
||||
//初始化表配置
|
||||
if (this.columnConfigGroupMap == null) {
|
||||
this.columnConfigGroupMap = new LinkedHashMap<>();
|
||||
}
|
||||
ColumnConfigGroup columnConfigGroup = new ColumnConfigGroup();
|
||||
List<ColumnConfig> columnConfigList = new ArrayList<>();
|
||||
columnConfigList.add(new ColumnConfig("disable", ColumnConfigType.BOOLEAN));
|
||||
columnConfigGroup.setName(DEFAULT_NAME);
|
||||
columnConfigGroup.setElementList(columnConfigList);
|
||||
columnConfigGroupMap.put(DEFAULT_NAME, columnConfigGroup);
|
||||
|
||||
//初始化全局配置
|
||||
if (this.globalConfigGroupMap == null) {
|
||||
this.globalConfigGroupMap = new LinkedHashMap<>();
|
||||
}
|
||||
this.globalConfigGroupMap.put(DEFAULT_NAME, loadGlobalConfigGroup(DEFAULT_NAME, "init", "define", "autoImport"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载模板文件
|
||||
*
|
||||
* @param filePath 模板路径
|
||||
* @return 模板文件内容
|
||||
*/
|
||||
private static String loadTemplate(String filePath) {
|
||||
try {
|
||||
return UrlUtil.loadText(Settings.class.getResource(filePath)).replace("\r", "");
|
||||
} catch (IOException e) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载模板组
|
||||
*
|
||||
* @param groupName 组名
|
||||
* @param templateNames 模板名称
|
||||
* @return 模板组
|
||||
*/
|
||||
private static TemplateGroup loadTemplateGroup(String groupName, String... templateNames) {
|
||||
TemplateGroup templateGroup = new TemplateGroup();
|
||||
templateGroup.setName(groupName);
|
||||
templateGroup.setElementList(new ArrayList<>());
|
||||
for (String templateName : templateNames) {
|
||||
String path = "/template/" + groupName + "/" + templateName + ".vm";
|
||||
templateGroup.getElementList().add(new Template(templateName, loadTemplate(path)));
|
||||
}
|
||||
return templateGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载全局配置组
|
||||
*
|
||||
* @param groupName 组名
|
||||
* @param templateNames 模板名称
|
||||
* @return 模板组
|
||||
*/
|
||||
private static GlobalConfigGroup loadGlobalConfigGroup(String groupName, String... templateNames) {
|
||||
GlobalConfigGroup globalConfigGroup = new GlobalConfigGroup();
|
||||
globalConfigGroup.setName(groupName);
|
||||
globalConfigGroup.setElementList(new ArrayList<>());
|
||||
for (String templateName : templateNames) {
|
||||
String path = "/globalConfig/" + groupName + "/" + templateName + ".vm";
|
||||
globalConfigGroup.getElementList().add(new GlobalConfig(templateName, loadTemplate(path)));
|
||||
}
|
||||
return globalConfigGroup;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Settings getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取系统中保存的持久化状态信息
|
||||
*
|
||||
* @param state 读取到的持久化状态信息
|
||||
*/
|
||||
@Override
|
||||
public void loadState(@NotNull Settings state) {
|
||||
XmlSerializerUtil.copyBean(state, this);
|
||||
}
|
||||
public void loadState(@NotNull Settings settings) {
|
||||
// 备份初始配置
|
||||
Map<String, TemplateGroup> templateGroupMap = this.getTemplateGroupMap();
|
||||
Map<String, GlobalConfigGroup> globalConfigGroupMap = this.getGlobalConfigGroupMap();
|
||||
String version = this.getVersion();
|
||||
// 覆盖初始配置
|
||||
XmlSerializerUtil.copyBean(settings, this);
|
||||
|
||||
/**
|
||||
* 未读取到持久化状态信息前进行初始化操作
|
||||
*/
|
||||
@Override
|
||||
public void noStateLoaded() {
|
||||
// 已经合并不再重复合并
|
||||
if (settings.getVersion() != null && settings.getVersion().equals(version)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 模板备份
|
||||
TemplateGroup oldTemplateGroup = settings.getTemplateGroupMap().get(DEFAULT_NAME);
|
||||
String newName = oldTemplateGroup.getName() + "Bak";
|
||||
int i = 0;
|
||||
while (settings.getTemplateGroupMap().containsKey(newName)) {
|
||||
newName = newName + i++;
|
||||
}
|
||||
oldTemplateGroup.setName(newName);
|
||||
// 保存
|
||||
settings.getTemplateGroupMap().put(newName, oldTemplateGroup);
|
||||
// 覆盖
|
||||
settings.getTemplateGroupMap().replace(DEFAULT_NAME, templateGroupMap.get(DEFAULT_NAME));
|
||||
|
||||
|
||||
|
||||
// 全局配置备份
|
||||
GlobalConfigGroup oldGlobalConfigGroup = settings.getGlobalConfigGroupMap().get(DEFAULT_NAME);
|
||||
newName = oldGlobalConfigGroup.getName() + "Bak";
|
||||
i = 0;
|
||||
while (settings.getGlobalConfigGroupMap().containsKey(newName)) {
|
||||
newName = newName + i++;
|
||||
}
|
||||
oldGlobalConfigGroup.setName(newName);
|
||||
// 保存
|
||||
settings.getGlobalConfigGroupMap().put(newName, oldGlobalConfigGroup);
|
||||
// 覆盖
|
||||
settings.getGlobalConfigGroupMap().replace(DEFAULT_NAME, globalConfigGroupMap.get(DEFAULT_NAME));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,231 +0,0 @@
|
|||
package com.sjhy.plugin.tool;
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import com.sjhy.plugin.entity.*;
|
||||
import lombok.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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/18 09:33
|
||||
*/
|
||||
@Data
|
||||
@State(name = "EasyCodeSetting", storages = @Storage("easy-code-setting.xml"))
|
||||
public class ConfigInfo implements PersistentStateComponent<ConfigInfo> {
|
||||
/**
|
||||
* 默认名称
|
||||
*/
|
||||
@Transient
|
||||
public static final String DEFAULT_NAME = "Default";
|
||||
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* 当前类型映射组名
|
||||
*/
|
||||
private String currTypeMapperGroupName;
|
||||
/**
|
||||
* 类型映射组
|
||||
*/
|
||||
private Map<String, TypeMapperGroup> typeMapperGroupMap;
|
||||
/**
|
||||
* 当前模板组名
|
||||
*/
|
||||
private String currTemplateGroupName;
|
||||
/**
|
||||
* 模板组
|
||||
*/
|
||||
private Map<String, TemplateGroup> templateGroupMap;
|
||||
/**
|
||||
* 当前配置表组名
|
||||
*/
|
||||
private String currColumnConfigGroupName;
|
||||
/**
|
||||
* 配置表组
|
||||
*/
|
||||
private Map<String, ColumnConfigGroup> columnConfigGroupMap;
|
||||
/**
|
||||
* 当前全局配置组名
|
||||
*/
|
||||
private String currGlobalConfigGroupName;
|
||||
/**
|
||||
* 全局配置组
|
||||
*/
|
||||
private Map<String, GlobalConfigGroup> globalConfigGroupMap;
|
||||
/**
|
||||
* 默认编码
|
||||
*/
|
||||
private String encode;
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
private String author;
|
||||
|
||||
/**
|
||||
* 获取单例实例对象
|
||||
*
|
||||
* @return 实例对象
|
||||
*/
|
||||
public static ConfigInfo getInstance() {
|
||||
return ServiceManager.getService(ConfigInfo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认构造方法
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public ConfigInfo() {
|
||||
initDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化默认设置
|
||||
*/
|
||||
public void initDefault() {
|
||||
// 版本号
|
||||
this.version = "1.1.0";
|
||||
// 默认编码
|
||||
this.encode = "UTF-8";
|
||||
// 作者名称
|
||||
this.author = "makejava";
|
||||
// 当前各项分组名称
|
||||
this.currTemplateGroupName = DEFAULT_NAME;
|
||||
this.currTypeMapperGroupName = DEFAULT_NAME;
|
||||
this.currColumnConfigGroupName = DEFAULT_NAME;
|
||||
this.currGlobalConfigGroupName = DEFAULT_NAME;
|
||||
//配置默认模板
|
||||
if (this.templateGroupMap == null) {
|
||||
this.templateGroupMap = new LinkedHashMap<>();
|
||||
}
|
||||
this.templateGroupMap.put(DEFAULT_NAME, loadTemplateGroup(DEFAULT_NAME, "entity", "dao", "service", "serviceImpl", "controller"));
|
||||
this.templateGroupMap.put("MybatisPlus", loadTemplateGroup("MybatisPlus", "entity", "dao", "service", "serviceImpl", "controller"));
|
||||
|
||||
//配置默认类型映射
|
||||
if (this.typeMapperGroupMap == null) {
|
||||
this.typeMapperGroupMap = new LinkedHashMap<>();
|
||||
}
|
||||
TypeMapperGroup typeMapperGroup = new TypeMapperGroup();
|
||||
List<TypeMapper> typeMapperList = new ArrayList<>();
|
||||
typeMapperList.add(new TypeMapper("varchar(\\(\\d+\\))?", "java.lang.String"));
|
||||
typeMapperList.add(new TypeMapper("text", "java.lang.String"));
|
||||
typeMapperList.add(new TypeMapper("decimal(\\(\\d+\\))?", "java.lang.Double"));
|
||||
typeMapperList.add(new TypeMapper("integer", "java.lang.Integer"));
|
||||
typeMapperList.add(new TypeMapper("int(\\(\\d+\\))?", "java.lang.Integer"));
|
||||
typeMapperList.add(new TypeMapper("int4", "java.lang.Integer"));
|
||||
typeMapperList.add(new TypeMapper("int8", "java.lang.Long"));
|
||||
typeMapperList.add(new TypeMapper("bigint(\\(\\d+\\))?", "java.lang.Long"));
|
||||
typeMapperList.add(new TypeMapper("datetime", "java.util.Date"));
|
||||
typeMapperList.add(new TypeMapper("timestamp", "java.util.Date"));
|
||||
typeMapperList.add(new TypeMapper("boolean", "java.lang.Boolean"));
|
||||
typeMapperGroup.setName(DEFAULT_NAME);
|
||||
typeMapperGroup.setElementList(typeMapperList);
|
||||
typeMapperGroupMap.put(DEFAULT_NAME, typeMapperGroup);
|
||||
|
||||
//初始化表配置
|
||||
if (this.columnConfigGroupMap == null) {
|
||||
this.columnConfigGroupMap = new LinkedHashMap<>();
|
||||
}
|
||||
ColumnConfigGroup columnConfigGroup = new ColumnConfigGroup();
|
||||
List<ColumnConfig> columnConfigList = new ArrayList<>();
|
||||
columnConfigList.add(new ColumnConfig("disable", ColumnConfigType.BOOLEAN));
|
||||
columnConfigGroup.setName(DEFAULT_NAME);
|
||||
columnConfigGroup.setElementList(columnConfigList);
|
||||
columnConfigGroupMap.put(DEFAULT_NAME, columnConfigGroup);
|
||||
|
||||
//初始化全局配置
|
||||
if (this.globalConfigGroupMap == null) {
|
||||
this.globalConfigGroupMap = new LinkedHashMap<>();
|
||||
}
|
||||
this.globalConfigGroupMap.put(DEFAULT_NAME, loadGlobalConfigGroup(DEFAULT_NAME, "init", "define", "autoImport"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载模板文件
|
||||
*
|
||||
* @param filePath 模板路径
|
||||
* @return 模板文件内容
|
||||
*/
|
||||
private static String loadTemplate(String filePath) {
|
||||
return FileUtils.getInstance().read(ConfigInfo.class.getResourceAsStream(filePath)).replaceAll("\r", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载模板组
|
||||
*
|
||||
* @param groupName 组名
|
||||
* @param templateNames 模板名称
|
||||
* @return 模板组
|
||||
*/
|
||||
private static TemplateGroup loadTemplateGroup(String groupName, String... templateNames) {
|
||||
TemplateGroup templateGroup = new TemplateGroup();
|
||||
templateGroup.setName(groupName);
|
||||
templateGroup.setElementList(new ArrayList<>());
|
||||
for (String templateName : templateNames) {
|
||||
String path = "/template/" + groupName + "/" + templateName + ".vm";
|
||||
templateGroup.getElementList().add(new Template(templateName, loadTemplate(path)));
|
||||
}
|
||||
return templateGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载全局配置组
|
||||
*
|
||||
* @param groupName 组名
|
||||
* @param templateNames 模板名称
|
||||
* @return 模板组
|
||||
*/
|
||||
private static GlobalConfigGroup loadGlobalConfigGroup(String groupName, String... templateNames) {
|
||||
GlobalConfigGroup globalConfigGroup = new GlobalConfigGroup();
|
||||
globalConfigGroup.setName(groupName);
|
||||
globalConfigGroup.setElementList(new ArrayList<>());
|
||||
for (String templateName : templateNames) {
|
||||
String path = "/globalConfig/" + groupName + "/" + templateName + ".vm";
|
||||
globalConfigGroup.getElementList().add(new GlobalConfig(templateName, loadTemplate(path)));
|
||||
}
|
||||
return globalConfigGroup;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ConfigInfo getState() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(@NotNull ConfigInfo configInfo) {
|
||||
// 备份初始配置
|
||||
Map<String, TemplateGroup> templateGroupMap = this.getTemplateGroupMap();
|
||||
String version = this.getVersion();
|
||||
// 覆盖初始配置
|
||||
XmlSerializerUtil.copyBean(configInfo, this);
|
||||
|
||||
// 已经合并不再重复合并
|
||||
if (configInfo.getVersion() != null && configInfo.getVersion().equals(version)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 合并配置
|
||||
templateGroupMap.forEach((name, templateGroup) -> {
|
||||
if (this.getTemplateGroupMap().containsKey(name)) {
|
||||
return;
|
||||
}
|
||||
this.getTemplateGroupMap().put(name, templateGroup);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.intellij.openapi.ui.MessageDialogBuilder;
|
|||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import com.sjhy.plugin.constants.MsgValue;
|
||||
import com.sjhy.plugin.entity.Callback;
|
||||
import com.sjhy.plugin.entity.GlobalConfig;
|
||||
|
@ -105,12 +106,12 @@ public class VelocityUtils {
|
|||
* @return 全局参数
|
||||
*/
|
||||
private Map<String, Object> handlerMap() {
|
||||
ConfigInfo configInfo = ConfigInfo.getInstance();
|
||||
Settings settings = Settings.getInstance();
|
||||
Map<String, Object> map = new HashMap<>(16);
|
||||
// 编码类型
|
||||
String encode = configInfo.getEncode();
|
||||
String encode = settings.getEncode();
|
||||
// 坐着名称
|
||||
String author = configInfo.getAuthor();
|
||||
String author = settings.getAuthor();
|
||||
// 表信息集合
|
||||
List<TableInfo> tableInfoList = tableInfoUtils.handler(cacheDataUtils.getDbTableList());
|
||||
// 选中的module
|
||||
|
@ -206,14 +207,14 @@ public class VelocityUtils {
|
|||
if (!createPath(cacheDataUtils.getSavePath())) {
|
||||
return;
|
||||
}
|
||||
ConfigInfo configInfo = ConfigInfo.getInstance();
|
||||
Settings settings = Settings.getInstance();
|
||||
// 获取覆盖的表配置信息
|
||||
List<TableInfo> tableInfoList = coverConfigInfo();
|
||||
List<Template> templateList = CloneUtils.getInstance().cloneList(cacheDataUtils.getSelectTemplate());
|
||||
// 预处理加入全局变量
|
||||
templateList.forEach(template -> {
|
||||
String templateContent = template.getCode() + "\n";
|
||||
for (GlobalConfig globalConfig : configInfo.getGlobalConfigGroupMap().get(configInfo.getCurrGlobalConfigGroupName()).getElementList()) {
|
||||
for (GlobalConfig globalConfig : settings.getGlobalConfigGroupMap().get(settings.getCurrGlobalConfigGroupName()).getElementList()) {
|
||||
// 需要替换两次,防止$在正则中出现问题
|
||||
templateContent = templateContent.replaceAll("\\$!?\\{?" + globalConfig.getName() + "([^a-zA-Z0-9])}?", ":::{" + globalConfig.getName() + "}$1");
|
||||
templateContent = templateContent.replace(":::{" + globalConfig.getName() + "}", globalConfig.getValue());
|
||||
|
@ -221,7 +222,7 @@ public class VelocityUtils {
|
|||
template.setCode(templateContent);
|
||||
});
|
||||
// 获取编码信息
|
||||
String encode = configInfo.getEncode();
|
||||
String encode = settings.getEncode();
|
||||
// 获取默认的配置信息
|
||||
Map<String, Object> map = handlerMap();
|
||||
// 项目路径
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.sjhy.plugin.constants.MsgValue;
|
|||
import com.sjhy.plugin.entity.AbstractGroup;
|
||||
import com.sjhy.plugin.entity.ColumnConfig;
|
||||
import com.sjhy.plugin.tool.CloneUtils;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import com.sjhy.plugin.tool.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
|
@ -211,12 +211,12 @@ public abstract class AbstractTableGroupPanel<T extends AbstractGroup<E>, E> {
|
|||
return;
|
||||
}
|
||||
if (MessageDialogBuilder.yesNo(MsgValue.TITLE_INFO, "Confirm Delete Group " + currGroupName + "?").isYes()) {
|
||||
if (ConfigInfo.DEFAULT_NAME.equals(currGroupName)) {
|
||||
if (Settings.DEFAULT_NAME.equals(currGroupName)) {
|
||||
Messages.showWarningDialog("Can't Delete Default Group!", MsgValue.TITLE_INFO);
|
||||
return;
|
||||
}
|
||||
group.remove(currGroupName);
|
||||
currGroupName = ConfigInfo.DEFAULT_NAME;
|
||||
currGroupName = Settings.DEFAULT_NAME;
|
||||
init();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.intellij.util.ui.ComboBoxCellEditor;
|
|||
import com.sjhy.plugin.constants.MsgValue;
|
||||
import com.sjhy.plugin.entity.*;
|
||||
import com.sjhy.plugin.tool.CacheDataUtils;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import com.sjhy.plugin.tool.TableInfoUtils;
|
||||
import com.sjhy.plugin.tool.StringUtils;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class ConfigTableDialog extends JDialog {
|
|||
/**
|
||||
* 配置信息对象
|
||||
*/
|
||||
private ConfigInfo configInfo = ConfigInfo.getInstance();
|
||||
private Settings settings = Settings.getInstance();
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
|
@ -127,7 +127,7 @@ public class ConfigTableDialog extends JDialog {
|
|||
*/
|
||||
private void init() {
|
||||
initFlag = false;
|
||||
ColumnConfigGroup columnConfigGroup = configInfo.getColumnConfigGroupMap().get(configInfo.getCurrColumnConfigGroupName());
|
||||
ColumnConfigGroup columnConfigGroup = settings.getColumnConfigGroupMap().get(settings.getCurrColumnConfigGroupName());
|
||||
// 拿到列配置信息
|
||||
columnConfigList = getInitColumn(columnConfigGroup.getElementList());
|
||||
//读取表配置信息(一次只能配置一张表)
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.intellij.util.ExceptionUtil;
|
|||
import com.sjhy.plugin.entity.GlobalConfig;
|
||||
import com.sjhy.plugin.entity.GlobalConfigGroup;
|
||||
import com.sjhy.plugin.tool.CloneUtils;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import com.sjhy.plugin.ui.base.BaseGroupPanel;
|
||||
import com.sjhy.plugin.ui.base.BaseItemSelectPanel;
|
||||
import com.sjhy.plugin.ui.base.TemplateEditor;
|
||||
|
@ -40,7 +40,7 @@ public class GlobalConfigSettingPanel implements Configurable {
|
|||
static {
|
||||
String descriptionInfo = "";
|
||||
try {
|
||||
descriptionInfo = UrlUtil.loadText(TemplateSettingPanel.class.getResource("/description/templateDescription.html"));
|
||||
descriptionInfo = UrlUtil.loadText(TemplateSettingPanel.class.getResource("/description/globalConfigDescription.html"));
|
||||
} catch (IOException e) {
|
||||
ExceptionUtil.rethrow(e);
|
||||
} finally {
|
||||
|
@ -51,7 +51,7 @@ public class GlobalConfigSettingPanel implements Configurable {
|
|||
/**
|
||||
* 配置信息
|
||||
*/
|
||||
private ConfigInfo configInfo;
|
||||
private Settings settings;
|
||||
|
||||
/**
|
||||
* 编辑框面板
|
||||
|
@ -98,12 +98,12 @@ public class GlobalConfigSettingPanel implements Configurable {
|
|||
// 项目对象
|
||||
this.project = openProjects.length > 0 ? openProjects[0] : projectManager.getDefaultProject();
|
||||
// 配置服务实例化
|
||||
this.configInfo = ConfigInfo.getInstance();
|
||||
this.settings = Settings.getInstance();
|
||||
// 克隆工具实例化
|
||||
this.cloneUtils = CloneUtils.getInstance();
|
||||
// 克隆对象
|
||||
this.currGroupName = this.configInfo.getCurrGlobalConfigGroupName();
|
||||
this.group = this.cloneUtils.cloneMap(this.configInfo.getGlobalConfigGroupMap());
|
||||
this.currGroupName = this.settings.getCurrGlobalConfigGroupName();
|
||||
this.group = this.cloneUtils.cloneMap(this.settings.getGlobalConfigGroupMap());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,7 +147,7 @@ public class GlobalConfigSettingPanel implements Configurable {
|
|||
protected void deleteGroup(String name) {
|
||||
// 删除分组
|
||||
group.remove(name);
|
||||
currGroupName = ConfigInfo.DEFAULT_NAME;
|
||||
currGroupName = Settings.DEFAULT_NAME;
|
||||
baseGroupPanel.reset(new ArrayList<>(group.keySet()), currGroupName);
|
||||
}
|
||||
|
||||
|
@ -246,7 +246,7 @@ public class GlobalConfigSettingPanel implements Configurable {
|
|||
*/
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return !configInfo.getGlobalConfigGroupMap().equals(group) || !configInfo.getCurrGlobalConfigGroupName().equals(currGroupName);
|
||||
return !settings.getGlobalConfigGroupMap().equals(group) || !settings.getCurrGlobalConfigGroupName().equals(currGroupName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,8 +254,8 @@ public class GlobalConfigSettingPanel implements Configurable {
|
|||
*/
|
||||
@Override
|
||||
public void apply() {
|
||||
configInfo.setGlobalConfigGroupMap(group);
|
||||
configInfo.setCurrGlobalConfigGroupName(currGroupName);
|
||||
settings.setGlobalConfigGroupMap(group);
|
||||
settings.setCurrGlobalConfigGroupName(currGroupName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,8 +268,8 @@ public class GlobalConfigSettingPanel implements Configurable {
|
|||
return;
|
||||
}
|
||||
// 防止对象篡改,需要进行克隆
|
||||
this.group = cloneUtils.cloneMap(configInfo.getGlobalConfigGroupMap());
|
||||
this.currGroupName = configInfo.getCurrGlobalConfigGroupName();
|
||||
this.group = cloneUtils.cloneMap(settings.getGlobalConfigGroupMap());
|
||||
this.currGroupName = settings.getCurrGlobalConfigGroupName();
|
||||
// 重置元素选择面板
|
||||
baseGroupPanel.reset(new ArrayList<>(group.keySet()), currGroupName);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.intellij.openapi.ui.MessageDialogBuilder;
|
|||
import com.sjhy.plugin.comm.AbstractService;
|
||||
import com.sjhy.plugin.constants.MsgValue;
|
||||
import com.sjhy.plugin.tool.CollectionUtil;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -58,7 +58,7 @@ public class MainSetting extends AbstractService implements Configurable, Config
|
|||
init();
|
||||
|
||||
//初始化事件
|
||||
ConfigInfo configInfo = ConfigInfo.getInstance();
|
||||
Settings settings = Settings.getInstance();
|
||||
//重置配置信息
|
||||
resetBtn.addActionListener(e -> {
|
||||
if (MessageDialogBuilder.yesNo(MsgValue.TITLE_INFO, "确认重置默认配置?\n重置默认配置只会还原插件自带分组配置信息,不会删除用户新增分组信息。").isYes()) {
|
||||
|
@ -66,7 +66,7 @@ public class MainSetting extends AbstractService implements Configurable, Config
|
|||
return;
|
||||
}
|
||||
// 初始化默认配置
|
||||
configInfo.initDefault();
|
||||
settings.initDefault();
|
||||
resetList.forEach(UnnamedConfigurable::reset);
|
||||
if (CollectionUtil.isEmpty(saveList)) {
|
||||
return;
|
||||
|
@ -87,8 +87,8 @@ public class MainSetting extends AbstractService implements Configurable, Config
|
|||
*/
|
||||
private void init() {
|
||||
//初始化数据
|
||||
authorTextField.setText(configInfo.getAuthor());
|
||||
encodeComboBox.setSelectedItem(configInfo.getEncode());
|
||||
authorTextField.setText(settings.getAuthor());
|
||||
encodeComboBox.setSelectedItem(settings.getEncode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,7 +111,7 @@ public class MainSetting extends AbstractService implements Configurable, Config
|
|||
@Override
|
||||
public Configurable[] getConfigurables() {
|
||||
Configurable[] result = new Configurable[4];
|
||||
result[0] = new TypeMapperSetting(configInfo);
|
||||
result[0] = new TypeMapperSetting(settings);
|
||||
result[1] = new TemplateSettingPanel();
|
||||
result[2] = new TableSettingPanel();
|
||||
result[3] = new GlobalConfigSettingPanel();
|
||||
|
@ -145,7 +145,7 @@ public class MainSetting extends AbstractService implements Configurable, Config
|
|||
*/
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return !configInfo.getEncode().equals(encodeComboBox.getSelectedItem()) || !configInfo.getAuthor().equals(authorTextField.getText());
|
||||
return !settings.getEncode().equals(encodeComboBox.getSelectedItem()) || !settings.getAuthor().equals(authorTextField.getText());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,8 +154,8 @@ public class MainSetting extends AbstractService implements Configurable, Config
|
|||
@Override
|
||||
public void apply() {
|
||||
//保存数据
|
||||
configInfo.setAuthor(authorTextField.getText());
|
||||
configInfo.setEncode((String) encodeComboBox.getSelectedItem());
|
||||
settings.setAuthor(authorTextField.getText());
|
||||
settings.setEncode((String) encodeComboBox.getSelectedItem());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@ import com.sjhy.plugin.entity.TableInfo;
|
|||
import com.sjhy.plugin.entity.Template;
|
||||
import com.sjhy.plugin.entity.TemplateGroup;
|
||||
import com.sjhy.plugin.tool.CacheDataUtils;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import com.sjhy.plugin.tool.TableInfoUtils;
|
||||
import com.sjhy.plugin.tool.VelocityUtils;
|
||||
import com.sjhy.plugin.tool.StringUtils;
|
||||
|
@ -101,8 +101,8 @@ public class SelectSavePath extends JDialog {
|
|||
* 构造方法
|
||||
*/
|
||||
public SelectSavePath() {
|
||||
ConfigInfo configInfo = ConfigInfo.getInstance();
|
||||
this.templateGroup = configInfo.getTemplateGroupMap().get(configInfo.getCurrTemplateGroupName());
|
||||
Settings settings = Settings.getInstance();
|
||||
this.templateGroup = settings.getTemplateGroupMap().get(settings.getCurrTemplateGroupName());
|
||||
init();
|
||||
setContentPane(contentPane);
|
||||
setModal(true);
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.sjhy.plugin.entity.ColumnConfig;
|
|||
import com.sjhy.plugin.entity.ColumnConfigGroup;
|
||||
import com.sjhy.plugin.entity.ColumnConfigType;
|
||||
import com.sjhy.plugin.tool.CloneUtils;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -19,11 +19,11 @@ import javax.swing.*;
|
|||
* @since 2018/07/17 13:10
|
||||
*/
|
||||
public class TableSettingPanel extends AbstractTableGroupPanel<ColumnConfigGroup, ColumnConfig> implements Configurable {
|
||||
private ConfigInfo configInfo = ConfigInfo.getInstance();
|
||||
private Settings settings = Settings.getInstance();
|
||||
private CloneUtils cloneUtils = CloneUtils.getInstance();
|
||||
|
||||
TableSettingPanel() {
|
||||
super(CloneUtils.getInstance().cloneMap(ConfigInfo.getInstance().getColumnConfigGroupMap()), ConfigInfo.getInstance().getCurrColumnConfigGroupName());
|
||||
super(CloneUtils.getInstance().cloneMap(Settings.getInstance().getColumnConfigGroupMap()), Settings.getInstance().getCurrColumnConfigGroupName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,19 +70,19 @@ public class TableSettingPanel extends AbstractTableGroupPanel<ColumnConfigGroup
|
|||
@Override
|
||||
public boolean isModified() {
|
||||
refresh();
|
||||
return !configInfo.getColumnConfigGroupMap().equals(group) || !configInfo.getCurrColumnConfigGroupName().equals(currGroupName);
|
||||
return !settings.getColumnConfigGroupMap().equals(group) || !settings.getCurrColumnConfigGroupName().equals(currGroupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
configInfo.setColumnConfigGroupMap(group);
|
||||
configInfo.setCurrColumnConfigGroupName(currGroupName);
|
||||
settings.setColumnConfigGroupMap(group);
|
||||
settings.setCurrColumnConfigGroupName(currGroupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.group = cloneUtils.cloneMap(configInfo.getColumnConfigGroupMap());
|
||||
this.currGroupName = configInfo.getCurrColumnConfigGroupName();
|
||||
this.group = cloneUtils.cloneMap(settings.getColumnConfigGroupMap());
|
||||
this.currGroupName = settings.getCurrColumnConfigGroupName();
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.intellij.util.ExceptionUtil;
|
|||
import com.sjhy.plugin.entity.Template;
|
||||
import com.sjhy.plugin.entity.TemplateGroup;
|
||||
import com.sjhy.plugin.tool.CloneUtils;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import com.sjhy.plugin.ui.base.BaseGroupPanel;
|
||||
import com.sjhy.plugin.ui.base.BaseItemSelectPanel;
|
||||
import com.sjhy.plugin.ui.base.TemplateEditor;
|
||||
|
@ -51,7 +51,7 @@ public class TemplateSettingPanel implements Configurable {
|
|||
/**
|
||||
* 配置信息
|
||||
*/
|
||||
private ConfigInfo configInfo;
|
||||
private Settings settings;
|
||||
|
||||
/**
|
||||
* 编辑框面板
|
||||
|
@ -95,12 +95,12 @@ public class TemplateSettingPanel implements Configurable {
|
|||
// 项目对象
|
||||
this.project = openProjects.length > 0 ? openProjects[0] : projectManager.getDefaultProject();
|
||||
// 配置服务实例化
|
||||
this.configInfo = ConfigInfo.getInstance();
|
||||
this.settings = Settings.getInstance();
|
||||
// 克隆工具实例化
|
||||
this.cloneUtils = CloneUtils.getInstance();
|
||||
// 克隆对象
|
||||
this.currGroupName = this.configInfo.getCurrTemplateGroupName();
|
||||
this.group = this.cloneUtils.cloneMap(this.configInfo.getTemplateGroupMap());
|
||||
this.currGroupName = this.settings.getCurrTemplateGroupName();
|
||||
this.group = this.cloneUtils.cloneMap(this.settings.getTemplateGroupMap());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,7 +144,7 @@ public class TemplateSettingPanel implements Configurable {
|
|||
protected void deleteGroup(String name) {
|
||||
// 删除分组
|
||||
group.remove(name);
|
||||
currGroupName = ConfigInfo.DEFAULT_NAME;
|
||||
currGroupName = Settings.DEFAULT_NAME;
|
||||
baseGroupPanel.reset(new ArrayList<>(group.keySet()), currGroupName);
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ public class TemplateSettingPanel implements Configurable {
|
|||
*/
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return !configInfo.getTemplateGroupMap().equals(group) || !configInfo.getCurrTemplateGroupName().equals(currGroupName);
|
||||
return !settings.getTemplateGroupMap().equals(group) || !settings.getCurrTemplateGroupName().equals(currGroupName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -251,8 +251,8 @@ public class TemplateSettingPanel implements Configurable {
|
|||
*/
|
||||
@Override
|
||||
public void apply() {
|
||||
configInfo.setTemplateGroupMap(group);
|
||||
configInfo.setCurrTemplateGroupName(currGroupName);
|
||||
settings.setTemplateGroupMap(group);
|
||||
settings.setCurrTemplateGroupName(currGroupName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,8 +265,8 @@ public class TemplateSettingPanel implements Configurable {
|
|||
return;
|
||||
}
|
||||
// 防止对象篡改,需要进行克隆
|
||||
this.group = cloneUtils.cloneMap(configInfo.getTemplateGroupMap());
|
||||
this.currGroupName = configInfo.getCurrTemplateGroupName();
|
||||
this.group = cloneUtils.cloneMap(settings.getTemplateGroupMap());
|
||||
this.currGroupName = settings.getCurrTemplateGroupName();
|
||||
// 重置元素选择面板
|
||||
baseGroupPanel.reset(new ArrayList<>(group.keySet()), currGroupName);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.sjhy.plugin.entity.TypeMapper;
|
|||
import com.sjhy.plugin.entity.TypeMapperGroup;
|
||||
import com.sjhy.plugin.entity.TypeMapperModel;
|
||||
import com.sjhy.plugin.tool.CloneUtils;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import com.sjhy.plugin.tool.StringUtils;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -74,17 +74,17 @@ public class TypeMapperSetting implements Configurable {
|
|||
/**
|
||||
* 全局配置服务
|
||||
*/
|
||||
private ConfigInfo configInfo;
|
||||
private Settings settings;
|
||||
/**
|
||||
* 克隆工具类
|
||||
*/
|
||||
private CloneUtils cloneUtils = CloneUtils.getInstance();
|
||||
|
||||
|
||||
public TypeMapperSetting(ConfigInfo configInfo) {
|
||||
this.configInfo = configInfo;
|
||||
this.typeMapperGroupMap = cloneUtils.cloneMap(configInfo.getTypeMapperGroupMap());
|
||||
this.currGroupName = configInfo.getCurrTypeMapperGroupName();
|
||||
public TypeMapperSetting(Settings settings) {
|
||||
this.settings = settings;
|
||||
this.typeMapperGroupMap = cloneUtils.cloneMap(settings.getTypeMapperGroupMap());
|
||||
this.currGroupName = settings.getCurrTypeMapperGroupName();
|
||||
//添加类型
|
||||
addButton.addActionListener(e -> typeMapperModel.addRow(new TypeMapper("demoColumn", "java.lang.Object")));
|
||||
|
||||
|
@ -146,12 +146,12 @@ public class TypeMapperSetting implements Configurable {
|
|||
//删除分组
|
||||
deleteButton.addActionListener(e -> {
|
||||
if (MessageDialogBuilder.yesNo(MsgValue.TITLE_INFO, "Confirm Delete Group " + typeMapperComboBox.getSelectedItem() + "?").isYes()) {
|
||||
if (ConfigInfo.DEFAULT_NAME.equals(currGroupName)) {
|
||||
if (Settings.DEFAULT_NAME.equals(currGroupName)) {
|
||||
Messages.showWarningDialog("Can't Delete Default Group!", MsgValue.TITLE_INFO);
|
||||
return;
|
||||
}
|
||||
typeMapperGroupMap.remove(currGroupName);
|
||||
currGroupName = ConfigInfo.DEFAULT_NAME;
|
||||
currGroupName = Settings.DEFAULT_NAME;
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
@ -198,19 +198,19 @@ public class TypeMapperSetting implements Configurable {
|
|||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return !typeMapperGroupMap.equals(configInfo.getTypeMapperGroupMap()) || !currGroupName.equals(configInfo.getCurrTypeMapperGroupName());
|
||||
return !typeMapperGroupMap.equals(settings.getTypeMapperGroupMap()) || !currGroupName.equals(settings.getCurrTypeMapperGroupName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
configInfo.setCurrTypeMapperGroupName(currGroupName);
|
||||
configInfo.setTypeMapperGroupMap(typeMapperGroupMap);
|
||||
settings.setCurrTypeMapperGroupName(currGroupName);
|
||||
settings.setTypeMapperGroupMap(typeMapperGroupMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.typeMapperGroupMap = cloneUtils.cloneMap(configInfo.getTypeMapperGroupMap());
|
||||
this.currGroupName = configInfo.getCurrTypeMapperGroupName();
|
||||
this.typeMapperGroupMap = cloneUtils.cloneMap(settings.getTypeMapperGroupMap());
|
||||
this.currGroupName = settings.getCurrTypeMapperGroupName();
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.intellij.openapi.ui.Messages;
|
|||
import com.intellij.ui.CollectionComboBoxModel;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.sjhy.plugin.constants.MsgValue;
|
||||
import com.sjhy.plugin.tool.ConfigInfo;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import com.sjhy.plugin.tool.StringUtils;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -191,7 +191,7 @@ public abstract class BaseGroupPanel extends JPanel {
|
|||
public void actionPerformed(AnActionEvent e) {
|
||||
String groupName = (String) comboBox.getSelectedItem();
|
||||
// 默认分组不允许删除
|
||||
if (Objects.equals(groupName, ConfigInfo.DEFAULT_NAME)) {
|
||||
if (Objects.equals(groupName, Settings.DEFAULT_NAME)) {
|
||||
return;
|
||||
}
|
||||
// 确认删除?
|
||||
|
@ -202,7 +202,7 @@ public abstract class BaseGroupPanel extends JPanel {
|
|||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(!Objects.equals(comboBox.getSelectedItem(), ConfigInfo.DEFAULT_NAME));
|
||||
e.getPresentation().setEnabled(!Objects.equals(comboBox.getSelectedItem(), Settings.DEFAULT_NAME));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
<extensions defaultExtensionNs="com.intellij">
|
||||
<!-- Add your extensions here -->
|
||||
<!--实例化配置信息服务-->
|
||||
<applicationService serviceImplementation="com.sjhy.plugin.tool.ConfigInfo"/>
|
||||
<applicationService serviceImplementation="com.sjhy.plugin.config.Settings"/>
|
||||
<!--系统设置面板-->
|
||||
<applicationConfigurable dynamic="true" instance="com.sjhy.plugin.ui.MainSetting"/>
|
||||
|
||||
|
|
|
@ -3,47 +3,19 @@
|
|||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div>说明文档:</div>
|
||||
<pre>
|
||||
属性
|
||||
$packageName 选择的包名 java.lang.String
|
||||
$author 设置中的作者 java.lang.String
|
||||
$encode 设置的编码 java.lang.String
|
||||
$modulePath 选中的module路径 java.lang.String
|
||||
$projectPath 项目绝对路径 java.lang.String
|
||||
对象
|
||||
$tableInfo 表对象
|
||||
obj 表原始对象 com.intellij.database.model.DasTable
|
||||
name 表名(转换后的首字母大写)java.lang.String
|
||||
comment 表注释 java.lang.String
|
||||
fullColumn 所有列 java.util.List<ColumnInfo>
|
||||
pkColumn 主键列 java.util.List<ColumnInfo>
|
||||
otherColumn 其他列 java.util.List<ColumnInfo>,除主键以外的列
|
||||
savePackageName 保存的包名 java.lang.String
|
||||
savePath 保存路径 java.lang.String
|
||||
saveModelName 保存的model名称 java.lang.String
|
||||
columnInfo 列对象
|
||||
obj 列原始对象 com.intellij.database.model.DasColumn
|
||||
name 列名(首字母小写) java.lang.String
|
||||
comment 列注释 java.lang.String
|
||||
type 列类型(类型全名) java.lang.String
|
||||
ext 附加字段(Map类型) java.lang.Map<java.lang.String, java.lang.Object>
|
||||
$tableInfoList 所有选中的表
|
||||
$importList 所有需要导入的包集合 java.util.Set<java.lang.String>
|
||||
回调
|
||||
&callback
|
||||
setFileName(String) 设置文件储存名字
|
||||
setSavePath(String) 设置文件储存路径,默认使用选中路径
|
||||
工具
|
||||
$tool
|
||||
firstUpperCase(String) 首字母大写方法
|
||||
firstLowerCase(String) 首字母小写方法
|
||||
getClsNameByFullName(String) 通过包全名获取类名
|
||||
getJavaName(String) 将下划线分割字符串转驼峰命名(属性名)
|
||||
getClassName(String) 将下划线分割字符串转驼峰命名(类名)
|
||||
append(... Object) 多个数据进行拼接
|
||||
$time
|
||||
currTime(String) 获取当前时间,指定时间格式(默认:yyyy-MM-dd HH:mm:ss)
|
||||
</pre>
|
||||
<h4>说明文档:</h4>
|
||||
<p>
|
||||
不仅仅是简单的全局变量,完全的自由发挥。<br>
|
||||
<span style="color: #ffbc17; background: gray">注意:</span>全局变量具有优先处理权限,会影响到模板中的任意同名变量,<br>
|
||||
<span style="color: red">所以在模板中一定不要定义与全局变量同名的变量。</span>
|
||||
</p>
|
||||
<h4>使用方式:</h4>
|
||||
<p>
|
||||
使用全局变量时,直接在模板中当普通变量引入即可。<br>
|
||||
</p>
|
||||
<h4>作用:</h4>
|
||||
<p>
|
||||
通常用于定义宏,初始化操作,定义字符串变量,等等。
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -3,19 +3,47 @@
|
|||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<h4>说明文档:</h4>
|
||||
<p>
|
||||
不仅仅是简单的全局变量,完全的自由发挥。<br>
|
||||
<span style="color: #ffbc17; background: gray">注意:</span>全局变量具有优先处理权限,会影响到模板中的任意同名变量,<br>
|
||||
<span style="color: red">所以在模板中一定不要定义与全局变量同名的变量。</span>
|
||||
</p>
|
||||
<h4>使用方式:</h4>
|
||||
<p>
|
||||
使用全局变量时,直接在模板中当普通变量引入即可。<br>
|
||||
</p>
|
||||
<h4>作用:</h4>
|
||||
<p>
|
||||
通常用于定义宏,初始化操作,定义字符串变量,等等。
|
||||
</p>
|
||||
<div>说明文档:</div>
|
||||
<pre>
|
||||
属性
|
||||
$packageName 选择的包名 java.lang.String
|
||||
$author 设置中的作者 java.lang.String
|
||||
$encode 设置的编码 java.lang.String
|
||||
$modulePath 选中的module路径 java.lang.String
|
||||
$projectPath 项目绝对路径 java.lang.String
|
||||
对象
|
||||
$tableInfo 表对象
|
||||
obj 表原始对象 com.intellij.database.model.DasTable
|
||||
name 表名(转换后的首字母大写)java.lang.String
|
||||
comment 表注释 java.lang.String
|
||||
fullColumn 所有列 java.util.List<ColumnInfo>
|
||||
pkColumn 主键列 java.util.List<ColumnInfo>
|
||||
otherColumn 其他列 java.util.List<ColumnInfo>,除主键以外的列
|
||||
savePackageName 保存的包名 java.lang.String
|
||||
savePath 保存路径 java.lang.String
|
||||
saveModelName 保存的model名称 java.lang.String
|
||||
columnInfo 列对象
|
||||
obj 列原始对象 com.intellij.database.model.DasColumn
|
||||
name 列名(首字母小写) java.lang.String
|
||||
comment 列注释 java.lang.String
|
||||
type 列类型(类型全名) java.lang.String
|
||||
ext 附加字段(Map类型) java.lang.Map<java.lang.String, java.lang.Object>
|
||||
$tableInfoList 所有选中的表
|
||||
$importList 所有需要导入的包集合 java.util.Set<java.lang.String>
|
||||
回调
|
||||
&callback
|
||||
setFileName(String) 设置文件储存名字
|
||||
setSavePath(String) 设置文件储存路径,默认使用选中路径
|
||||
工具
|
||||
$tool
|
||||
firstUpperCase(String) 首字母大写方法
|
||||
firstLowerCase(String) 首字母小写方法
|
||||
getClsNameByFullName(String) 通过包全名获取类名
|
||||
getJavaName(String) 将下划线分割字符串转驼峰命名(属性名)
|
||||
getClassName(String) 将下划线分割字符串转驼峰命名(类名)
|
||||
append(... Object) 多个数据进行拼接
|
||||
$time
|
||||
currTime(String) 获取当前时间,指定时间格式(默认:yyyy-MM-dd HH:mm:ss)
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,9 +1,4 @@
|
|||
#*
|
||||
不仅仅是简单的全局变量,完全的自由发挥,下面给出一些例子。需要的请自行扩展。
|
||||
注意:全局变量有优先处理权限,会影响到模板的任意同名变量,
|
||||
所以在模板中一定不要定义与全局变量同名的变量。
|
||||
*#
|
||||
##定义区域(Velocity宏定义)
|
||||
##(Velocity宏定义)
|
||||
|
||||
##定义设置表名后缀的宏定义,调用方式:#setTableSuffix("Test")
|
||||
#macro(setTableSuffix $suffix)
|
||||
|
|
Loading…
Reference in New Issue