mirror of https://gitee.com/makejava/EasyCode.git
升级到1.2.7版本,并修复已知BUG
This commit is contained in:
parent
66aabeecc4
commit
19a7ddac8f
|
@ -15,7 +15,7 @@ public interface GlobalDict {
|
||||||
/**
|
/**
|
||||||
* 版本号
|
* 版本号
|
||||||
*/
|
*/
|
||||||
String VERSION = "1.2.6";
|
String VERSION = "1.2.7";
|
||||||
/**
|
/**
|
||||||
* 作者名称
|
* 作者名称
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ColumnInfoDTO {
|
||||||
this.comment = DocCommentUtils.getComment(field.getDocComment());
|
this.comment = DocCommentUtils.getComment(field.getDocComment());
|
||||||
this.type = field.getType().getCanonicalText();
|
this.type = field.getType().getCanonicalText();
|
||||||
this.custom = false;
|
this.custom = false;
|
||||||
this.ext = new HashMap<>();
|
this.ext = "{}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ColumnInfoDTO(DasColumn column) {
|
public ColumnInfoDTO(DasColumn column) {
|
||||||
|
@ -38,7 +38,7 @@ public class ColumnInfoDTO {
|
||||||
this.comment = column.getComment();
|
this.comment = column.getComment();
|
||||||
this.type = getJavaType(column.getDataType().toString());
|
this.type = getJavaType(column.getDataType().toString());
|
||||||
this.custom = false;
|
this.custom = false;
|
||||||
this.ext = new HashMap<>();
|
this.ext = "{}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getJavaType(String dbType) {
|
private String getJavaType(String dbType) {
|
||||||
|
@ -74,7 +74,7 @@ public class ColumnInfoDTO {
|
||||||
*/
|
*/
|
||||||
private Boolean custom;
|
private Boolean custom;
|
||||||
/**
|
/**
|
||||||
* 扩展数据
|
* 扩展数据(JSON字符串)
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> ext;
|
private String ext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class TableInfoDTO {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void merge(TableInfoDTO oldData, TableInfoDTO newData) {
|
private static void merge(TableInfoDTO oldData, TableInfoDTO newData) {
|
||||||
if (oldData == null) {
|
if (oldData == null || CollectionUtil.isEmpty(oldData.getFullColumn())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!StringUtils.isEmpty(oldData.getPreName())) {
|
if (!StringUtils.isEmpty(oldData.getPreName())) {
|
||||||
|
@ -88,32 +88,66 @@ public class TableInfoDTO {
|
||||||
if (!StringUtils.isEmpty(oldData.getSaveModelName())) {
|
if (!StringUtils.isEmpty(oldData.getSaveModelName())) {
|
||||||
newData.saveModelName = oldData.getSaveModelName();
|
newData.saveModelName = oldData.getSaveModelName();
|
||||||
}
|
}
|
||||||
if (CollectionUtil.isEmpty(oldData.getFullColumn())) {
|
List<String> allNewColumnNames = newData.getFullColumn().stream().map(ColumnInfoDTO::getName).collect(Collectors.toList());
|
||||||
return;
|
// 列出旧的顺序,并删除已经不存在的列,不包括自定义列
|
||||||
|
List<ColumnInfoDTO> oldSequenceColumn = oldData.getFullColumn().stream()
|
||||||
|
.filter(item -> allNewColumnNames.contains(item.getName()) || Boolean.TRUE.equals(item.getCustom()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 尽可能的保留原始顺序(把自定义列按原始位置插入)
|
||||||
|
Map<String, String> nameMap = new HashMap<>(oldSequenceColumn.size());
|
||||||
|
for (int i = 0; i < oldSequenceColumn.size(); i++) {
|
||||||
|
ColumnInfoDTO columnInfo = oldSequenceColumn.get(i);
|
||||||
|
if (columnInfo.getCustom()) {
|
||||||
|
// 如果原本是自定义列,现在变成了数据库列,则忽略调原本的自定义列
|
||||||
|
if (allNewColumnNames.contains(columnInfo.getName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 获取当前自定义列的前一个名称
|
||||||
|
String beforeName = "";
|
||||||
|
if (i > 0) {
|
||||||
|
beforeName = oldSequenceColumn.get(i - 1).getName();
|
||||||
|
}
|
||||||
|
nameMap.put(beforeName, columnInfo.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 补充自定义列
|
// 将自定义列按顺序插入到新表中
|
||||||
for (ColumnInfoDTO oldColumn : oldData.getFullColumn()) {
|
nameMap.forEach((k, v) -> {
|
||||||
if (!oldColumn.getCustom()) {
|
if (StringUtils.isEmpty(k)) {
|
||||||
|
allNewColumnNames.add(0, v);
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < allNewColumnNames.size(); i++) {
|
||||||
|
if (allNewColumnNames.get(i).equals(k)) {
|
||||||
|
allNewColumnNames.add(i + 1, v);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 按顺序依次重写数据
|
||||||
|
Map<String, ColumnInfoDTO> oldColumnMap = oldData.getFullColumn().stream().collect(Collectors.toMap(ColumnInfoDTO::getName, v -> v));
|
||||||
|
Map<String, ColumnInfoDTO> newColumnMap = newData.getFullColumn().stream().collect(Collectors.toMap(ColumnInfoDTO::getName, v -> v));
|
||||||
|
List<ColumnInfoDTO> tmpList = new ArrayList<>();
|
||||||
|
for (String name : allNewColumnNames) {
|
||||||
|
ColumnInfoDTO newColumnInfo = newColumnMap.get(name);
|
||||||
|
if (newColumnInfo == null) {
|
||||||
|
newColumnInfo = oldColumnMap.get(name);
|
||||||
|
if (newColumnInfo == null) {
|
||||||
|
throw new NullPointerException("找不到列信息");
|
||||||
|
}
|
||||||
|
tmpList.add(newColumnInfo);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
newData.getFullColumn().add(oldColumn);
|
ColumnInfoDTO oldColumnInfo = oldColumnMap.get(name);
|
||||||
}
|
if (oldColumnInfo == null) {
|
||||||
// 保持旧列的顺序
|
tmpList.add(newColumnInfo);
|
||||||
Map<String, ColumnInfoDTO> map = newData.getFullColumn().stream().collect(Collectors.toMap(ColumnInfoDTO::getName, val -> val));
|
continue;
|
||||||
List<ColumnInfoDTO> tmpList = new ArrayList<>();
|
|
||||||
for (ColumnInfoDTO columnInfo : oldData.getFullColumn()) {
|
|
||||||
ColumnInfoDTO newColumn = map.get(columnInfo.getName());
|
|
||||||
if (newColumn != null) {
|
|
||||||
// ext属性转移
|
|
||||||
newColumn.setExt(columnInfo.getExt());
|
|
||||||
tmpList.add(newColumn);
|
|
||||||
}
|
}
|
||||||
}
|
// 需要进行合并操作
|
||||||
// 补充剩余列
|
newColumnInfo.setExt(oldColumnInfo.getExt());
|
||||||
for (ColumnInfoDTO columnInfoDTO : newData.getFullColumn()) {
|
if (StringUtils.isEmpty(newColumnInfo.getComment())) {
|
||||||
if (!tmpList.contains(columnInfoDTO)) {
|
newColumnInfo.setComment(oldColumnInfo.getComment());
|
||||||
tmpList.add(columnInfoDTO);
|
|
||||||
}
|
}
|
||||||
|
tmpList.add(newColumnInfo);
|
||||||
}
|
}
|
||||||
// list数据替换
|
// list数据替换
|
||||||
newData.getFullColumn().clear();
|
newData.getFullColumn().clear();
|
||||||
|
@ -187,6 +221,7 @@ public class TableInfoDTO {
|
||||||
return tableInfo;
|
return tableInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public TableInfo toTableInfo(DbTable dbTable) {
|
public TableInfo toTableInfo(DbTable dbTable) {
|
||||||
TableInfo tableInfo = new TableInfo();
|
TableInfo tableInfo = new TableInfo();
|
||||||
tableInfo.setObj(dbTable);
|
tableInfo.setObj(dbTable);
|
||||||
|
@ -216,7 +251,7 @@ public class TableInfoDTO {
|
||||||
columnInfo.setShortType(split[split.length - 1]);
|
columnInfo.setShortType(split[split.length - 1]);
|
||||||
columnInfo.setComment(dto.getComment());
|
columnInfo.setComment(dto.getComment());
|
||||||
columnInfo.setCustom(dto.getCustom());
|
columnInfo.setCustom(dto.getCustom());
|
||||||
columnInfo.setExt(dto.getExt());
|
columnInfo.setExt(JSON.parse(dto.getExt(), HashMap.class));
|
||||||
tableInfo.getFullColumn().add(columnInfo);
|
tableInfo.getFullColumn().add(columnInfo);
|
||||||
if (columnInfo.getObj() != null && DasUtil.isPrimary(columnInfo.getObj())) {
|
if (columnInfo.getObj() != null && DasUtil.isPrimary(columnInfo.getObj())) {
|
||||||
tableInfo.getPkColumn().add(columnInfo);
|
tableInfo.getPkColumn().add(columnInfo);
|
||||||
|
@ -242,7 +277,7 @@ public class TableInfoDTO {
|
||||||
ColumnInfoDTO columnInfoDTO = new ColumnInfoDTO();
|
ColumnInfoDTO columnInfoDTO = new ColumnInfoDTO();
|
||||||
columnInfoDTO.setName(columnInfo.getName());
|
columnInfoDTO.setName(columnInfo.getName());
|
||||||
columnInfoDTO.setType(columnInfo.getType());
|
columnInfoDTO.setType(columnInfo.getType());
|
||||||
columnInfoDTO.setExt(columnInfo.getExt());
|
columnInfoDTO.setExt(JSON.toJson(columnInfo.getExt()));
|
||||||
columnInfoDTO.setCustom(columnInfo.getCustom());
|
columnInfoDTO.setCustom(columnInfo.getCustom());
|
||||||
columnInfoDTO.setComment(columnInfo.getComment());
|
columnInfoDTO.setComment(columnInfo.getComment());
|
||||||
dto.getFullColumn().add(columnInfoDTO);
|
dto.getFullColumn().add(columnInfoDTO);
|
||||||
|
|
|
@ -21,17 +21,6 @@ import java.util.stream.Stream;
|
||||||
*/
|
*/
|
||||||
public class CellEditorFactory {
|
public class CellEditorFactory {
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建下拉框编辑器
|
|
||||||
*
|
|
||||||
* @param editable 可编辑的
|
|
||||||
* @return {@link TableCellEditor}
|
|
||||||
*/
|
|
||||||
public static TableCellEditor createComboBoxEditor(boolean editable, Class<? extends Enum> enumCls) {
|
|
||||||
Enum[] enumConstants = enumCls.getEnumConstants();
|
|
||||||
return createComboBoxEditor(editable, Stream.of(enumConstants).map(Enum::name).toArray(value -> new String[enumConstants.length]));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建下拉框编辑器
|
* 创建下拉框编辑器
|
||||||
*
|
*
|
||||||
|
@ -42,11 +31,6 @@ public class CellEditorFactory {
|
||||||
public static TableCellEditor createComboBoxEditor(boolean editable, String... items) {
|
public static TableCellEditor createComboBoxEditor(boolean editable, String... items) {
|
||||||
ComboBox<String> comboBox = new ComboBox<>(items);
|
ComboBox<String> comboBox = new ComboBox<>(items);
|
||||||
comboBox.setEditable(editable);
|
comboBox.setEditable(editable);
|
||||||
// 配色
|
|
||||||
if (comboBox.getPopup() != null) {
|
|
||||||
comboBox.getPopup().getList().setBackground(JBColor.WHITE);
|
|
||||||
comboBox.getPopup().getList().setForeground(JBColor.GREEN);
|
|
||||||
}
|
|
||||||
if (!editable) {
|
if (!editable) {
|
||||||
transmitFocusEvent(comboBox);
|
transmitFocusEvent(comboBox);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.sjhy.plugin.ui;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.intellij.openapi.options.Configurable;
|
import com.intellij.openapi.options.Configurable;
|
||||||
|
import com.intellij.openapi.ui.ComboBoxTableRenderer;
|
||||||
import com.sjhy.plugin.dict.GlobalDict;
|
import com.sjhy.plugin.dict.GlobalDict;
|
||||||
import com.sjhy.plugin.dto.SettingsStorageDTO;
|
import com.sjhy.plugin.dto.SettingsStorageDTO;
|
||||||
import com.sjhy.plugin.entity.ColumnConfig;
|
import com.sjhy.plugin.entity.ColumnConfig;
|
||||||
|
@ -15,11 +16,13 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.TableCellEditor;
|
import javax.swing.table.TableCellEditor;
|
||||||
|
import javax.swing.table.TableCellRenderer;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author makejava
|
* @author makejava
|
||||||
|
@ -27,7 +30,7 @@ import java.util.function.Consumer;
|
||||||
* @date 2021/08/10 13:27
|
* @date 2021/08/10 13:27
|
||||||
*/
|
*/
|
||||||
public class ColumnConfigSettingForm implements Configurable, BaseSettings {
|
public class ColumnConfigSettingForm implements Configurable, BaseSettings {
|
||||||
private JPanel mainPanel;
|
private final JPanel mainPanel;
|
||||||
/**
|
/**
|
||||||
* 列配置
|
* 列配置
|
||||||
*/
|
*/
|
||||||
|
@ -51,14 +54,16 @@ public class ColumnConfigSettingForm implements Configurable, BaseSettings {
|
||||||
|
|
||||||
private void initTable() {
|
private void initTable() {
|
||||||
// 第一列,类型
|
// 第一列,类型
|
||||||
TableCellEditor typeEditor = CellEditorFactory.createComboBoxEditor(false, ColumnConfigType.class);
|
String[] columnConfigTypeNames = Stream.of(ColumnConfigType.values()).map(ColumnConfigType::name).toArray(String[]::new);
|
||||||
TableComponent.Column<ColumnConfig> typeColumn = new TableComponent.Column<>("type", item -> item.getType().name(), (entity, val) -> entity.setType(ColumnConfigType.valueOf(val)), typeEditor);
|
TableCellEditor typeEditor = CellEditorFactory.createComboBoxEditor(false, columnConfigTypeNames);
|
||||||
|
TableCellRenderer typeRenderer = new ComboBoxTableRenderer<>(columnConfigTypeNames);
|
||||||
|
TableComponent.Column<ColumnConfig> typeColumn = new TableComponent.Column<>("type", item -> item.getType().name(), (entity, val) -> entity.setType(ColumnConfigType.valueOf(val)), typeEditor, typeRenderer);
|
||||||
// 第二列标题
|
// 第二列标题
|
||||||
TableCellEditor titleEditor = CellEditorFactory.createTextFieldEditor();
|
TableCellEditor titleEditor = CellEditorFactory.createTextFieldEditor();
|
||||||
TableComponent.Column<ColumnConfig> titleColumn = new TableComponent.Column<>("title", ColumnConfig::getTitle, ColumnConfig::setTitle, titleEditor);
|
TableComponent.Column<ColumnConfig> titleColumn = new TableComponent.Column<>("title", ColumnConfig::getTitle, ColumnConfig::setTitle, titleEditor, null);
|
||||||
// 第三列选项
|
// 第三列选项
|
||||||
TableCellEditor selectValueEditor = CellEditorFactory.createTextFieldEditor();
|
TableCellEditor selectValueEditor = CellEditorFactory.createTextFieldEditor();
|
||||||
TableComponent.Column<ColumnConfig> selectValueColumn = new TableComponent.Column<>("selectValue", ColumnConfig::getSelectValue, ColumnConfig::setSelectValue, selectValueEditor);
|
TableComponent.Column<ColumnConfig> selectValueColumn = new TableComponent.Column<>("selectValue", ColumnConfig::getSelectValue, ColumnConfig::setSelectValue, selectValueEditor, null);
|
||||||
List<TableComponent.Column<ColumnConfig>> columns = Arrays.asList(typeColumn, titleColumn, selectValueColumn);
|
List<TableComponent.Column<ColumnConfig>> columns = Arrays.asList(typeColumn, titleColumn, selectValueColumn);
|
||||||
|
|
||||||
// 表格初始化
|
// 表格初始化
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.sjhy.plugin.ui;
|
package com.sjhy.plugin.ui;
|
||||||
|
|
||||||
|
import com.intellij.openapi.ui.ComboBoxTableRenderer;
|
||||||
import com.intellij.openapi.ui.DialogWrapper;
|
import com.intellij.openapi.ui.DialogWrapper;
|
||||||
|
import com.intellij.ui.BooleanTableCellRenderer;
|
||||||
import com.intellij.ui.ToolbarDecorator;
|
import com.intellij.ui.ToolbarDecorator;
|
||||||
import com.intellij.ui.table.JBTable;
|
import com.intellij.ui.table.JBTable;
|
||||||
import com.sjhy.plugin.dict.GlobalDict;
|
import com.sjhy.plugin.dict.GlobalDict;
|
||||||
|
@ -18,6 +20,8 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumn;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表配置窗口
|
* 表配置窗口
|
||||||
|
@ -30,7 +34,7 @@ public class ConfigTableDialog extends DialogWrapper {
|
||||||
/**
|
/**
|
||||||
* 主面板
|
* 主面板
|
||||||
*/
|
*/
|
||||||
private JPanel mainPanel;
|
private final JPanel mainPanel;
|
||||||
/**
|
/**
|
||||||
* 表信息对象
|
* 表信息对象
|
||||||
*/
|
*/
|
||||||
|
@ -52,8 +56,10 @@ public class ConfigTableDialog extends DialogWrapper {
|
||||||
|
|
||||||
// 配置列编辑器
|
// 配置列编辑器
|
||||||
table.getColumn("name").setCellEditor(CellEditorFactory.createTextFieldEditor());
|
table.getColumn("name").setCellEditor(CellEditorFactory.createTextFieldEditor());
|
||||||
table.getColumn("type").setCellEditor(CellEditorFactory.createComboBoxEditor(true, GlobalDict.DEFAULT_JAVA_TYPE_LIST));
|
TableColumn typeColumn = table.getColumn("type");
|
||||||
table.getColumn("type").setMinWidth(120);
|
typeColumn.setCellRenderer(new ComboBoxTableRenderer<>(GlobalDict.DEFAULT_JAVA_TYPE_LIST));
|
||||||
|
typeColumn.setCellEditor(CellEditorFactory.createComboBoxEditor(true, GlobalDict.DEFAULT_JAVA_TYPE_LIST));
|
||||||
|
typeColumn.setMinWidth(120);
|
||||||
table.getColumn("comment").setCellEditor(CellEditorFactory.createTextFieldEditor());
|
table.getColumn("comment").setCellEditor(CellEditorFactory.createTextFieldEditor());
|
||||||
// 其他附加列
|
// 其他附加列
|
||||||
for (ColumnConfig columnConfig : CurrGroupUtils.getCurrColumnConfigGroup().getElementList()) {
|
for (ColumnConfig columnConfig : CurrGroupUtils.getCurrColumnConfigGroup().getElementList()) {
|
||||||
|
@ -66,10 +72,17 @@ public class ConfigTableDialog extends DialogWrapper {
|
||||||
if (StringUtils.isEmpty(columnConfig.getSelectValue())) {
|
if (StringUtils.isEmpty(columnConfig.getSelectValue())) {
|
||||||
column.setCellEditor(CellEditorFactory.createTextFieldEditor());
|
column.setCellEditor(CellEditorFactory.createTextFieldEditor());
|
||||||
} else {
|
} else {
|
||||||
column.setCellEditor(CellEditorFactory.createComboBoxEditor(false, columnConfig.getSelectValue().split(",")));
|
String[] split = columnConfig.getSelectValue().split(",");
|
||||||
|
ArrayList<String> list = new ArrayList<>(Arrays.asList(split));
|
||||||
|
// 添加一个空值作为默认值
|
||||||
|
list.add(0, "");
|
||||||
|
split = list.toArray(new String[0]);
|
||||||
|
column.setCellRenderer(new ComboBoxTableRenderer<>(split));
|
||||||
|
column.setCellEditor(CellEditorFactory.createComboBoxEditor(false, split));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
|
column.setCellRenderer(new BooleanTableCellRenderer());
|
||||||
column.setCellEditor(CellEditorFactory.createBooleanEditor());
|
column.setCellEditor(CellEditorFactory.createBooleanEditor());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.sjhy.plugin.ui;
|
||||||
|
|
||||||
import com.intellij.openapi.options.Configurable;
|
import com.intellij.openapi.options.Configurable;
|
||||||
import com.intellij.openapi.options.ConfigurationException;
|
import com.intellij.openapi.options.ConfigurationException;
|
||||||
|
import com.sjhy.plugin.dict.GlobalDict;
|
||||||
import com.sjhy.plugin.dto.SettingsStorageDTO;
|
import com.sjhy.plugin.dto.SettingsStorageDTO;
|
||||||
import com.sjhy.plugin.service.impl.ClipboardExportImportSettingsServiceImpl;
|
import com.sjhy.plugin.service.impl.ClipboardExportImportSettingsServiceImpl;
|
||||||
import com.sjhy.plugin.service.impl.LocalFileExportImportSettingsServiceImpl;
|
import com.sjhy.plugin.service.impl.LocalFileExportImportSettingsServiceImpl;
|
||||||
|
@ -151,7 +152,7 @@ public class MainSettingForm implements Configurable, Configurable.Composite, Ba
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void loadSettingsStore(SettingsStorageDTO settingsStorage) {
|
public void loadSettingsStore(SettingsStorageDTO settingsStorage) {
|
||||||
this.versionLabel.setText(settingsStorage.getVersion());
|
this.versionLabel.setText(GlobalDict.VERSION);
|
||||||
this.authorEditor.setText(settingsStorage.getAuthor());
|
this.authorEditor.setText(settingsStorage.getAuthor());
|
||||||
this.userSecureEditor.setText(settingsStorage.getUserSecure());
|
this.userSecureEditor.setText(settingsStorage.getUserSecure());
|
||||||
if (StringUtils.isEmpty(settingsStorage.getUserSecure())) {
|
if (StringUtils.isEmpty(settingsStorage.getUserSecure())) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.sjhy.plugin.ui;
|
package com.sjhy.plugin.ui;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.intellij.openapi.ui.ComboBoxTableRenderer;
|
||||||
import com.sjhy.plugin.dict.GlobalDict;
|
import com.sjhy.plugin.dict.GlobalDict;
|
||||||
import com.sjhy.plugin.dto.SettingsStorageDTO;
|
import com.sjhy.plugin.dto.SettingsStorageDTO;
|
||||||
import com.sjhy.plugin.entity.TypeMapper;
|
import com.sjhy.plugin.entity.TypeMapper;
|
||||||
|
@ -14,11 +15,13 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.TableCellEditor;
|
import javax.swing.table.TableCellEditor;
|
||||||
|
import javax.swing.table.TableCellRenderer;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author makejava
|
* @author makejava
|
||||||
|
@ -26,7 +29,7 @@ import java.util.function.Consumer;
|
||||||
* @date 2021/08/07 15:33
|
* @date 2021/08/07 15:33
|
||||||
*/
|
*/
|
||||||
public class TypeMapperSettingForm implements BaseSettings {
|
public class TypeMapperSettingForm implements BaseSettings {
|
||||||
private JPanel mainPanel;
|
private final JPanel mainPanel;
|
||||||
/**
|
/**
|
||||||
* 类型映射配置
|
* 类型映射配置
|
||||||
*/
|
*/
|
||||||
|
@ -50,18 +53,22 @@ public class TypeMapperSettingForm implements BaseSettings {
|
||||||
|
|
||||||
private void initTable() {
|
private void initTable() {
|
||||||
// 第一列仅适用下拉框
|
// 第一列仅适用下拉框
|
||||||
TableCellEditor matchTypeEditor = CellEditorFactory.createComboBoxEditor(false, MatchType.class);
|
String[] matchTypeNames = Stream.of(MatchType.values()).map(MatchType::name).toArray(String[]::new);
|
||||||
|
TableCellEditor matchTypeEditor = CellEditorFactory.createComboBoxEditor(false, matchTypeNames);
|
||||||
|
TableCellRenderer matchTypeRenderer = new ComboBoxTableRenderer<>(matchTypeNames);
|
||||||
TableComponent.Column<TypeMapper> matchTypeColumn = new TableComponent.Column<>("matchType",
|
TableComponent.Column<TypeMapper> matchTypeColumn = new TableComponent.Column<>("matchType",
|
||||||
item -> item.getMatchType() != null ? item.getMatchType().name() : MatchType.REGEX.name(),
|
item -> item.getMatchType() != null ? item.getMatchType().name() : MatchType.REGEX.name(),
|
||||||
(entity, val) -> entity.setMatchType(MatchType.valueOf(val)),
|
(entity, val) -> entity.setMatchType(MatchType.valueOf(val)),
|
||||||
matchTypeEditor
|
matchTypeEditor,
|
||||||
|
matchTypeRenderer
|
||||||
);
|
);
|
||||||
// 第二列监听输入状态,及时修改属性值
|
// 第二列监听输入状态,及时修改属性值
|
||||||
TableCellEditor columnTypeEditor = CellEditorFactory.createTextFieldEditor();
|
TableCellEditor columnTypeEditor = CellEditorFactory.createTextFieldEditor();
|
||||||
TableComponent.Column<TypeMapper> columnTypeColumn = new TableComponent.Column<>("columnType", TypeMapper::getColumnType, TypeMapper::setColumnType, columnTypeEditor);
|
TableComponent.Column<TypeMapper> columnTypeColumn = new TableComponent.Column<>("columnType", TypeMapper::getColumnType, TypeMapper::setColumnType, columnTypeEditor, null);
|
||||||
// 第三列支持下拉框
|
// 第三列支持下拉框
|
||||||
TableCellEditor javaTypeEditor = CellEditorFactory.createComboBoxEditor(true, GlobalDict.DEFAULT_JAVA_TYPE_LIST);
|
TableCellEditor javaTypeEditor = CellEditorFactory.createComboBoxEditor(true, GlobalDict.DEFAULT_JAVA_TYPE_LIST);
|
||||||
TableComponent.Column<TypeMapper> javaTypeColumn = new TableComponent.Column<>("javaType", TypeMapper::getJavaType, TypeMapper::setJavaType, javaTypeEditor);
|
TableCellRenderer javaTypeRenderer = new ComboBoxTableRenderer<>(GlobalDict.DEFAULT_JAVA_TYPE_LIST);
|
||||||
|
TableComponent.Column<TypeMapper> javaTypeColumn = new TableComponent.Column<>("javaType", TypeMapper::getJavaType, TypeMapper::setJavaType, javaTypeEditor, javaTypeRenderer);
|
||||||
List<TableComponent.Column<TypeMapper>> columns = Arrays.asList(matchTypeColumn, columnTypeColumn, javaTypeColumn);
|
List<TableComponent.Column<TypeMapper>> columns = Arrays.asList(matchTypeColumn, columnTypeColumn, javaTypeColumn);
|
||||||
// 表格初始化
|
// 表格初始化
|
||||||
this.tableComponent = new TableComponent<>(columns, this.currTypeMapperGroup.getElementList(), TypeMapper.class);
|
this.tableComponent = new TableComponent<>(columns, this.currTypeMapperGroup.getElementList(), TypeMapper.class);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import lombok.NonNull;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import javax.swing.table.TableCellEditor;
|
import javax.swing.table.TableCellEditor;
|
||||||
|
import javax.swing.table.TableCellRenderer;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
@ -68,6 +69,9 @@ public class TableComponent<T extends AbstractItem<T>> extends DefaultTableModel
|
||||||
this.table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
this.table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||||
// 指定编辑器
|
// 指定编辑器
|
||||||
for (Column<T> column : this.columns) {
|
for (Column<T> column : this.columns) {
|
||||||
|
if (column.renderer != null) {
|
||||||
|
this.table.getColumn(column.name).setCellRenderer(column.renderer);
|
||||||
|
}
|
||||||
if (column.editor != null) {
|
if (column.editor != null) {
|
||||||
this.table.getColumn(column.name).setCellEditor(column.editor);
|
this.table.getColumn(column.name).setCellEditor(column.editor);
|
||||||
}
|
}
|
||||||
|
@ -157,5 +161,9 @@ public class TableComponent<T extends AbstractItem<T>> extends DefaultTableModel
|
||||||
* 列编辑器
|
* 列编辑器
|
||||||
*/
|
*/
|
||||||
private TableCellEditor editor;
|
private TableCellEditor editor;
|
||||||
|
/**
|
||||||
|
* 列展示器
|
||||||
|
*/
|
||||||
|
private TableCellRenderer renderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<idea-plugin>
|
<idea-plugin>
|
||||||
<id>com.sjhy.plugin.easycode</id>
|
<id>com.sjhy.plugin.easycode</id>
|
||||||
<name>Easy Code</name>
|
<name>EasyCode</name>
|
||||||
<vendor email="1353036300@qq.com" url="http://www.shujuhaiyang.com">Easy Code Office Website</vendor>
|
<vendor email="1353036300@qq.com" url="http://www.shujuhaiyang.com">Easy Code Office Website</vendor>
|
||||||
|
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
|
@ -20,6 +20,19 @@
|
||||||
|
|
||||||
|
|
||||||
<change-notes><![CDATA[
|
<change-notes><![CDATA[
|
||||||
|
<p>1.2.7-java.RELEASE</p>
|
||||||
|
<ul>
|
||||||
|
<li>1.Fix extended attribute save loss</li>
|
||||||
|
<li>2.Fix the problem that the order of newly added fields in the table cannot be consistent</li>
|
||||||
|
<li>3.Optimize UI</li>
|
||||||
|
<li>4.Optimize module selection, support module name search</li>
|
||||||
|
<li>5.Optimize cleanup table configuration function</li>
|
||||||
|
</ul>
|
||||||
|
<ul>
|
||||||
|
<li>1.修复扩展属性保存丢失问题</li>
|
||||||
|
<li>2.修复表新增字段后顺序无法保持一致问题</li>
|
||||||
|
<li>3.优化UI界面</li>
|
||||||
|
</ul>
|
||||||
<p>1.2.6-java.RELEASE</p>
|
<p>1.2.6-java.RELEASE</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>1.Fix the problem of exported Chinese garbled code</li>
|
<li>1.Fix the problem of exported Chinese garbled code</li>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -14,6 +14,7 @@
|
||||||
对象
|
对象
|
||||||
$tableInfo 表对象
|
$tableInfo 表对象
|
||||||
obj 表原始对象 com.intellij.database.model.DasTable
|
obj 表原始对象 com.intellij.database.model.DasTable
|
||||||
|
preName 表前缀 java.lang.String
|
||||||
name 表名(转换后的首字母大写)java.lang.String
|
name 表名(转换后的首字母大写)java.lang.String
|
||||||
comment 表注释 java.lang.String
|
comment 表注释 java.lang.String
|
||||||
fullColumn 所有列 java.util.List<ColumnInfo>
|
fullColumn 所有列 java.util.List<ColumnInfo>
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
$generateService
|
$generateService
|
||||||
run(String, Map<String,Object>) 代码生成服务,参数1:模板名称,参数2:附加参数。
|
run(String, Map<String,Object>) 代码生成服务,参数1:模板名称,参数2:附加参数。
|
||||||
$dasUtil Database提供的工具类,具体可方法请查看源码,适用于高端玩家
|
$dasUtil Database提供的工具类,具体可方法请查看源码,适用于高端玩家
|
||||||
|
$dasUtil.
|
||||||
$dbUtil Database提供的工具类,具体可方法请查看源码,适用于高端玩家
|
$dbUtil Database提供的工具类,具体可方法请查看源码,适用于高端玩家
|
||||||
</pre>
|
</pre>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue