mirror of https://gitee.com/makejava/EasyCode.git
UI优化,部分完成,临时提交
This commit is contained in:
parent
3ffb11cc57
commit
61916b04a5
|
@ -9,6 +9,7 @@ import com.intellij.util.ExceptionUtil;
|
|||
import com.intellij.util.xmlb.XmlSerializerUtil;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import com.sjhy.plugin.entity.*;
|
||||
import com.sjhy.plugin.enums.ColumnConfigType;
|
||||
import lombok.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.sjhy.plugin.dict;
|
||||
|
||||
/**
|
||||
* 全局字典
|
||||
*
|
||||
* @author makejava
|
||||
* @version 1.0.0
|
||||
* @date 2021/08/07 11:41
|
||||
*/
|
||||
public interface GlobalDict {
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
String VERSION = "1.2.4";
|
||||
/**
|
||||
* 作者名称
|
||||
*/
|
||||
String AUTHOR = "makejava";
|
||||
/**
|
||||
* 默认分组名称
|
||||
*/
|
||||
String DEFAULT_GROUP_NAME = "Default";
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.sjhy.plugin.dto;
|
||||
|
||||
import com.sjhy.plugin.dict.GlobalDict;
|
||||
import com.sjhy.plugin.entity.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 设置储存传输对象
|
||||
*
|
||||
* @author makejava
|
||||
* @version 1.0.0
|
||||
* @date 2021/08/07 11:35
|
||||
*/
|
||||
@Data
|
||||
public class SettingsStorageDTO {
|
||||
/**
|
||||
* 返回默认值,不使用静态常量,防止默认值别篡改
|
||||
*
|
||||
* @return 储存对象
|
||||
*/
|
||||
public static SettingsStorageDTO defaultVal() {
|
||||
SettingsStorageDTO storage = new SettingsStorageDTO();
|
||||
storage.author = GlobalDict.AUTHOR;
|
||||
storage.version = GlobalDict.VERSION;
|
||||
storage.userSecure = "";
|
||||
// 默认分组名称
|
||||
storage.currTypeMapperGroupName = GlobalDict.DEFAULT_GROUP_NAME;
|
||||
storage.currTemplateGroupName = GlobalDict.DEFAULT_GROUP_NAME;
|
||||
storage.currColumnConfigGroupName = GlobalDict.DEFAULT_GROUP_NAME;
|
||||
storage.currGlobalConfigGroupName = GlobalDict.DEFAULT_GROUP_NAME;
|
||||
// 默认配置信息
|
||||
storage.typeMapperGroupMap = new HashMap<>(16);
|
||||
TypeMapperGroup typeMapperGroup = new TypeMapperGroup();
|
||||
typeMapperGroup.setName(GlobalDict.DEFAULT_GROUP_NAME);
|
||||
typeMapperGroup.setElementList(Arrays.asList(new TypeMapper("varchar", "java.lang.String"), new TypeMapper("varchar\\(\\)", "java.lang.String")));
|
||||
storage.typeMapperGroupMap.put(GlobalDict.DEFAULT_GROUP_NAME, typeMapperGroup);
|
||||
return storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置为默认值
|
||||
*/
|
||||
public void resetDefaultVal() {
|
||||
SettingsStorageDTO defaultVal = defaultVal();
|
||||
this.setAuthor(defaultVal.getAuthor());
|
||||
this.setVersion(defaultVal.getVersion());
|
||||
this.setCurrColumnConfigGroupName(defaultVal.getCurrColumnConfigGroupName());
|
||||
this.setCurrTemplateGroupName(defaultVal.getCurrTemplateGroupName());
|
||||
this.setCurrGlobalConfigGroupName(defaultVal.getCurrGlobalConfigGroupName());
|
||||
this.setCurrTypeMapperGroupName(defaultVal.getCurrTypeMapperGroupName());
|
||||
this.setGlobalConfigGroupMap(defaultVal.getGlobalConfigGroupMap());
|
||||
this.setColumnConfigGroupMap(defaultVal.getColumnConfigGroupMap());
|
||||
this.setTypeMapperGroupMap(defaultVal.getTypeMapperGroupMap());
|
||||
this.setTemplateGroupMap(defaultVal.getTemplateGroupMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
private String author;
|
||||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* 用户密钥
|
||||
*/
|
||||
private String userSecure;
|
||||
/**
|
||||
* 当前类型映射组名
|
||||
*/
|
||||
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;
|
||||
|
||||
public TypeMapperGroup currentTypeMapperGroup() {
|
||||
return typeMapperGroupMap.get(currColumnConfigGroupName);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.sjhy.plugin.entity;
|
||||
|
||||
import com.sjhy.plugin.enums.ColumnConfigType;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.sjhy.plugin.entity;
|
||||
|
||||
import com.sjhy.plugin.enums.MatchType;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
@ -13,6 +14,10 @@ import lombok.NoArgsConstructor;
|
|||
@Data
|
||||
@NoArgsConstructor
|
||||
public class TypeMapper {
|
||||
/**
|
||||
* 匹配类型
|
||||
*/
|
||||
private MatchType matchType;
|
||||
/**
|
||||
* 列类型
|
||||
*/
|
||||
|
@ -23,6 +28,7 @@ public class TypeMapper {
|
|||
private String javaType;
|
||||
|
||||
public TypeMapper(String columnType, String javaType) {
|
||||
this.matchType = MatchType.REGEX;
|
||||
this.columnType = columnType;
|
||||
this.javaType = javaType;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.sjhy.plugin.entity;
|
||||
|
||||
import com.intellij.util.ui.EditableModel;
|
||||
import com.sjhy.plugin.comm.AbstractTableModel;
|
||||
import com.sjhy.plugin.enums.MatchType;
|
||||
|
||||
/**
|
||||
* 类型隐射模型
|
||||
|
@ -9,23 +11,40 @@ import com.sjhy.plugin.comm.AbstractTableModel;
|
|||
* @version 1.0.0
|
||||
* @since 2018/07/17 13:10
|
||||
*/
|
||||
public class TypeMapperModel extends AbstractTableModel<TypeMapper> {
|
||||
public class TypeMapperModel extends AbstractTableModel<TypeMapper> implements EditableModel {
|
||||
@Override
|
||||
protected String[] initColumnName() {
|
||||
return new String[]{"columnType", "javaType"};
|
||||
return new String[]{"matchType", "columnType", "javaType"};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object[] toObj(TypeMapper entity) {
|
||||
return new Object[]{entity.getColumnType(), entity.getJavaType()};
|
||||
return new Object[]{entity.getMatchType() != null ? entity.getMatchType().name() : MatchType.REGEX.name(), entity.getColumnType(), entity.getJavaType()};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setVal(TypeMapper obj, int columnIndex, Object val) {
|
||||
if (columnIndex==0){
|
||||
if (columnIndex == 0) {
|
||||
obj.setMatchType(MatchType.valueOf((String) val));
|
||||
} else if (columnIndex == 1) {
|
||||
obj.setColumnType((String) val);
|
||||
}else{
|
||||
} else {
|
||||
obj.setJavaType((String) val);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRow() {
|
||||
addRow(new TypeMapper("demo", "java.lang.String"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exchangeRows(int oldIndex, int newIndex) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExchangeRows(int oldIndex, int newIndex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.sjhy.plugin.entity;
|
||||
package com.sjhy.plugin.enums;
|
||||
|
||||
/**
|
||||
* 列配置类型
|
|
@ -0,0 +1,17 @@
|
|||
package com.sjhy.plugin.enums;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
* @version 1.0.0
|
||||
* @date 2021/08/07 17:47
|
||||
*/
|
||||
public enum MatchType {
|
||||
/**
|
||||
* 正常的
|
||||
*/
|
||||
ORDINARY,
|
||||
/**
|
||||
* 正则表达式
|
||||
*/
|
||||
REGEX,
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.sjhy.plugin.service;
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.sjhy.plugin.dto.SettingsStorageDTO;
|
||||
import com.sjhy.plugin.service.impl.SettingsStorageServiceImpl;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
* @version 1.0.0
|
||||
* @date 2021/08/07 11:55
|
||||
*/
|
||||
public interface SettingsStorageService extends PersistentStateComponent<SettingsStorageDTO> {
|
||||
/**
|
||||
* 获取实例
|
||||
*
|
||||
* @return {@link SettingsStorageService}
|
||||
*/
|
||||
static SettingsStorageService getInstance() {
|
||||
return ServiceManager.getService(SettingsStorageServiceImpl.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设置存储
|
||||
*
|
||||
* @return {@link SettingsStorageDTO}
|
||||
*/
|
||||
static SettingsStorageDTO getSettingsStorage() {
|
||||
return getInstance().getState();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.sjhy.plugin.service.impl;
|
||||
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.sjhy.plugin.dto.SettingsStorageDTO;
|
||||
import com.sjhy.plugin.service.SettingsStorageService;
|
||||
import lombok.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* 设置储存服务实现
|
||||
*
|
||||
* @author makejava
|
||||
* @version 1.0.0
|
||||
* @date 2021/08/07 11:32
|
||||
*/
|
||||
@Data
|
||||
@State(name = "EasyCodeSetting", storages = @Storage("easy-code-setting2.xml"))
|
||||
public class SettingsStorageServiceImpl implements SettingsStorageService {
|
||||
|
||||
private SettingsStorageDTO settingsStorage = SettingsStorageDTO.defaultVal();
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*
|
||||
* @return 配置对象
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public SettingsStorageDTO getState() {
|
||||
return settingsStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载配置
|
||||
*
|
||||
* @param state 配置对象
|
||||
*/
|
||||
@Override
|
||||
public void loadState(@NotNull SettingsStorageDTO state) {
|
||||
this.settingsStorage = state;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import com.intellij.ui.BooleanTableCellEditor;
|
|||
import com.intellij.util.ui.ComboBoxCellEditor;
|
||||
import com.sjhy.plugin.constants.MsgValue;
|
||||
import com.sjhy.plugin.entity.*;
|
||||
import com.sjhy.plugin.enums.ColumnConfigType;
|
||||
import com.sjhy.plugin.service.TableInfoService;
|
||||
import com.sjhy.plugin.tool.CacheDataUtils;
|
||||
import com.sjhy.plugin.tool.CurrGroupUtils;
|
||||
|
|
|
@ -332,7 +332,7 @@ public class MainSetting implements Configurable, Configurable.Composite {
|
|||
@Override
|
||||
public Configurable[] getConfigurables() {
|
||||
Configurable[] result = new Configurable[4];
|
||||
result[0] = new TypeMapperSetting(settings);
|
||||
result[0] = new TypeMapperSetting();
|
||||
result[1] = new TemplateSettingPanel();
|
||||
result[2] = new TableSettingPanel();
|
||||
result[3] = new GlobalConfigSettingPanel();
|
||||
|
|
|
@ -0,0 +1,224 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.sjhy.plugin.ui.MainSettingForm">
|
||||
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="631" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="4bc04" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="3" vgap="3">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="ba62e" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="当前版本:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e7dac" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="作者名称:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="584c" class="javax.swing.JLabel" binding="versionLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="4" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="1.0.0"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3ce2" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="用户密钥:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="878f1" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="30"/>
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="ae3" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="actions/intentionBulb.png"/>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="37e85" class="javax.swing.JTextField" binding="userSecureEditor">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="759d0" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="30"/>
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="acf47" class="javax.swing.JTextField" binding="authorEditor">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="b4580" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<icon value="actions/intentionBulb.png"/>
|
||||
<text value=""/>
|
||||
<toolTipText value="用于指定生成的Java文件中的作者名称"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="478bb" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="120"/>
|
||||
<constraints>
|
||||
<grid row="1" column="2" row-span="2" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="de737" class="javax.swing.JButton" binding="resetBtn">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="重置默认设置"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="8e29" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="2" vgap="1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="d6546" class="javax.swing.JButton" binding="pushBtn">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="提交"/>
|
||||
<toolTipText value="提交配置至云端"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c6e6e" class="javax.swing.JButton" binding="pullBtn">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="获取"/>
|
||||
<toolTipText value="从云端获取配置"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="e5223" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="20" left="65" bottom="20" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="ab656" class="javax.swing.JButton" binding="exportByNetBtn">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="导出至云端"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b2c2" class="javax.swing.JButton" binding="importByNetBtn">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="从云端导入"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="480b5" class="javax.swing.JButton" binding="exportByFileBtn">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="导出至本地"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b3eb0" class="javax.swing.JButton" binding="importByFileBtn">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="从本地导入"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="275bf" class="javax.swing.JButton" binding="exportByClipboardBtn">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="导出至剪切板"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4a868" class="javax.swing.JButton" binding="importByClipboardBtn">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="从剪切板导入"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="18803">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="3" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<vspacer id="c82a">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
|
@ -0,0 +1,135 @@
|
|||
package com.sjhy.plugin.ui;
|
||||
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.sjhy.plugin.dto.SettingsStorageDTO;
|
||||
import com.sjhy.plugin.service.SettingsStorageService;
|
||||
import com.sjhy.plugin.tool.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
* @version 1.0.0
|
||||
* @date 2021/08/07 09:22
|
||||
*/
|
||||
public class MainSettingForm implements Configurable, Configurable.Composite {
|
||||
/**
|
||||
* 设置储存传输对象
|
||||
*/
|
||||
private SettingsStorageDTO settingsStorage;
|
||||
private JLabel versionLabel;
|
||||
private JButton resetBtn;
|
||||
private JButton pushBtn;
|
||||
private JButton pullBtn;
|
||||
private JButton exportByNetBtn;
|
||||
private JButton importByNetBtn;
|
||||
private JButton exportByFileBtn;
|
||||
private JButton importByFileBtn;
|
||||
private JButton exportByClipboardBtn;
|
||||
private JButton importByClipboardBtn;
|
||||
private JPanel mainPanel;
|
||||
private JTextField userSecureEditor;
|
||||
private JTextField authorEditor;
|
||||
|
||||
public MainSettingForm() {
|
||||
}
|
||||
|
||||
private void loadStorageValue() {
|
||||
this.versionLabel.setText(this.settingsStorage.getVersion());
|
||||
this.authorEditor.setText(this.settingsStorage.getAuthor());
|
||||
this.userSecureEditor.setText(this.settingsStorage.getUserSecure());
|
||||
if (StringUtils.isEmpty(this.settingsStorage.getUserSecure())) {
|
||||
this.pullBtn.setEnabled(false);
|
||||
this.pushBtn.setEnabled(false);
|
||||
} else {
|
||||
this.pullBtn.setEnabled(true);
|
||||
this.pushBtn.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
this.resetBtn.addActionListener(e -> JBPopupFactory.getInstance()
|
||||
.createConfirmation("确认恢复默认设置,所有Default分组配置将被重置?", () -> {
|
||||
// 重置默认值后重新加载配置
|
||||
settingsStorage.resetDefaultVal();
|
||||
this.loadStorageValue();
|
||||
}, 0)
|
||||
.showInFocusCenter()
|
||||
);
|
||||
|
||||
this.userSecureEditor.addCaretListener(e -> {
|
||||
String userSecure = this.userSecureEditor.getText();
|
||||
if (StringUtils.isEmpty(userSecure)) {
|
||||
this.pullBtn.setEnabled(false);
|
||||
this.pushBtn.setEnabled(false);
|
||||
} else {
|
||||
this.pullBtn.setEnabled(true);
|
||||
this.pushBtn.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "EasyCode";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getHelpTopic() {
|
||||
return getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Configurable[] getConfigurables() {
|
||||
Configurable[] result = new Configurable[]{
|
||||
new TypeMapperSettingForm(),
|
||||
// new TemplateSettingPanel(),
|
||||
// new TableSettingPanel(),
|
||||
// new GlobalConfigSettingPanel()
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable JComponent createComponent() {
|
||||
this.settingsStorage = SettingsStorageService.getSettingsStorage();
|
||||
// 加载储存数据
|
||||
this.loadStorageValue();
|
||||
// 初始化事件
|
||||
this.initEvent();
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
if (!Objects.equals(this.authorEditor.getText(), settingsStorage.getAuthor())) {
|
||||
return true;
|
||||
}
|
||||
if (!Objects.equals(this.userSecureEditor.getText(), settingsStorage.getUserSecure())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.loadStorageValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
String author = this.authorEditor.getText();
|
||||
if (StringUtils.isEmpty(author)) {
|
||||
throw new ConfigurationException("作者名称不能为空");
|
||||
}
|
||||
this.settingsStorage.setAuthor(author);
|
||||
String userSecure = this.userSecureEditor.getText();
|
||||
this.settingsStorage.setUserSecure(userSecure);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||
import com.intellij.openapi.options.Configurable;
|
||||
import com.sjhy.plugin.entity.ColumnConfig;
|
||||
import com.sjhy.plugin.entity.ColumnConfigGroup;
|
||||
import com.sjhy.plugin.entity.ColumnConfigType;
|
||||
import com.sjhy.plugin.enums.ColumnConfigType;
|
||||
import com.sjhy.plugin.tool.CloneUtils;
|
||||
import com.sjhy.plugin.config.Settings;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
|
|
|
@ -78,8 +78,8 @@ public class TypeMapperSetting implements Configurable {
|
|||
private Settings settings;
|
||||
|
||||
|
||||
public TypeMapperSetting(Settings settings) {
|
||||
this.settings = settings;
|
||||
public TypeMapperSetting() {
|
||||
this.settings = Settings.getInstance();
|
||||
this.typeMapperGroupMap = CloneUtils.cloneByJson(settings.getTypeMapperGroupMap(), new TypeReference<Map<String, TypeMapperGroup>>() {});
|
||||
this.currGroupName = settings.getCurrTypeMapperGroupName();
|
||||
//添加类型
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.sjhy.plugin.ui.TypeMapperSettingForm">
|
||||
<grid id="27dc6" binding="mainPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="line"/>
|
||||
<children>
|
||||
<grid id="4186a" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints border-constraint="North"/>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="90249" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Group Name:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="30d98">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<grid id="b788" binding="groupOperatorPanel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="b7ffd" class="javax.swing.JComboBox" binding="groupComboBox">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
|
@ -0,0 +1,96 @@
|
|||
package com.sjhy.plugin.ui;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.sjhy.plugin.entity.TypeMapperModel;
|
||||
import com.sjhy.plugin.enums.MatchType;
|
||||
import com.sjhy.plugin.service.SettingsStorageService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
* @version 1.0.0
|
||||
* @date 2021/08/07 15:33
|
||||
*/
|
||||
public class TypeMapperSettingForm implements Configurable {
|
||||
private JPanel mainPanel;
|
||||
private JComboBox groupComboBox;
|
||||
private JPanel groupOperatorPanel;
|
||||
/**
|
||||
* 表格
|
||||
*/
|
||||
private JBTable table;
|
||||
|
||||
private void initPanel() {
|
||||
TypeMapperModel typeMapperModel = new TypeMapperModel();
|
||||
typeMapperModel.init(SettingsStorageService.getSettingsStorage().currentTypeMapperGroup().getElementList());
|
||||
table = new JBTable(typeMapperModel);
|
||||
ComboBox<String> comboField = new ComboBox<>(Stream.of(MatchType.values()).map(Enum::name).toArray(value -> new String[2]), 20);
|
||||
if (comboField.getPopup() != null) {
|
||||
comboField.getPopup().getList().setBackground(JBColor.MAGENTA);
|
||||
}
|
||||
DefaultCellEditor cellEditor = new DefaultCellEditor(comboField);
|
||||
table.getColumn("matchType").setCellEditor(cellEditor);
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(table);
|
||||
// 表格初始化
|
||||
this.mainPanel.add(decorator.createPanel(), BorderLayout.CENTER);
|
||||
// 分组操作
|
||||
DefaultActionGroup groupAction = new DefaultActionGroup(Arrays.asList(new AnAction(AllIcons.Actions.Copy) {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
|
||||
}
|
||||
}, new AnAction(AllIcons.General.Remove) {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
|
||||
}
|
||||
}));
|
||||
ActionToolbar groupActionToolbar = ActionManager.getInstance().createActionToolbar("Group Toolbar", groupAction, true);
|
||||
this.groupOperatorPanel.add(groupActionToolbar.getComponent());
|
||||
}
|
||||
|
||||
private void loadStorageValue() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Type Mapper";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getHelpTopic() {
|
||||
return getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable JComponent createComponent() {
|
||||
this.initPanel();
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() throws ConfigurationException {
|
||||
|
||||
}
|
||||
}
|
|
@ -227,11 +227,13 @@
|
|||
<!-- Add your extensions here -->
|
||||
<!--实例化配置信息服务-->
|
||||
<applicationService serviceImplementation="com.sjhy.plugin.config.Settings"/>
|
||||
<applicationService serviceImplementation="com.sjhy.plugin.service.impl.SettingsStorageServiceImpl"/>
|
||||
<!--项目服务-->
|
||||
<projectService serviceInterface="com.sjhy.plugin.service.TableInfoService" serviceImplementation="com.sjhy.plugin.service.impl.TableInfoServiceImpl"/>
|
||||
<projectService serviceInterface="com.sjhy.plugin.service.CodeGenerateService" serviceImplementation="com.sjhy.plugin.service.impl.CodeGenerateServiceImpl"/>
|
||||
<!--系统设置面板-->
|
||||
<applicationConfigurable dynamic="true" instance="com.sjhy.plugin.ui.MainSetting"/>
|
||||
<!--<applicationConfigurable dynamic="true" instance="com.sjhy.plugin.ui.MainSetting"/>-->
|
||||
<applicationConfigurable dynamic="true" instance="com.sjhy.plugin.ui.MainSettingForm"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
|
|
Loading…
Reference in New Issue