优化常量池

This commit is contained in:
makejava 2021-08-13 10:03:01 +08:00
parent a4239d6f02
commit 0362574977
16 changed files with 51 additions and 107 deletions

View File

@ -1,40 +0,0 @@
package com.sjhy.plugin.constants;
/**
* 消息常量值
*
* @author makejava
* @version 1.0.0
* @since 2018/08/02 11:55
*/
public class MsgValue {
/**
* 提示信息
*/
public static final String TITLE_INFO = "EasyCode Title Info";
/**
* 删除分组二次确认信息
*/
public static final String CONFIRM_DELETE_GROUP = "确认删除%s分组";
/**
* 删除二次确认信息
*/
public static final String CONFIRM_DELETE_MESSAGE = "确认删除%s";
/**
* 分组名称标题
*/
public static final String GROUP_NAME_LABEL = "分组名称:";
/**
* 模板名称标题
*/
public static final String ITEM_NAME_LABEL = "新名称:";
/**
* 重置默认设置提示信息
*/
public static final String RESET_DEFAULT_SETTING_MSG = "确认重置默认配置?\n重置默认配置只会还原插件自带分组配置信息不会删除用户新增分组信息。";
}

View File

@ -12,24 +12,4 @@ public class StrState {
* 相对路径常量 * 相对路径常量
*/ */
public static final String RELATIVE_PATH = "./"; public static final String RELATIVE_PATH = "./";
/**
* 类型映射
*/
public static final String TYPE_MAPPER = "typeMapper";
/**
* 全局配置
*/
public static final String GLOBAL_CONFIG = "globalConfig";
/**
* 模板
*/
public static final String TEMPLATE = "template";
/**
* 列配置
*/
public static final String COLUMN_CONFIG = "columnConfig";
} }

View File

@ -8,6 +8,10 @@ package com.sjhy.plugin.dict;
* @date 2021/08/07 11:41 * @date 2021/08/07 11:41
*/ */
public interface GlobalDict { public interface GlobalDict {
/**
* 提示信息
*/
String TITLE_INFO = "EasyCode Title Info";
/** /**
* 版本号 * 版本号
*/ */

View File

@ -6,7 +6,7 @@ import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Messages;
import com.intellij.util.ExceptionUtil; import com.intellij.util.ExceptionUtil;
import com.intellij.util.ui.TextTransferable; import com.intellij.util.ui.TextTransferable;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.dto.SettingsStorageDTO; import com.sjhy.plugin.dto.SettingsStorageDTO;
import com.sjhy.plugin.service.ExportImportSettingsService; import com.sjhy.plugin.service.ExportImportSettingsService;
@ -31,7 +31,7 @@ public class ClipboardExportImportSettingsServiceImpl implements ExportImportSet
try { try {
String json = new ObjectMapper().writeValueAsString(settingsStorage); String json = new ObjectMapper().writeValueAsString(settingsStorage);
CopyPasteManager.getInstance().setContents(new TextTransferable(json)); CopyPasteManager.getInstance().setContents(new TextTransferable(json));
Messages.showInfoMessage("Config info success write to clipboard", MsgValue.TITLE_INFO); Messages.showInfoMessage("Config info success write to clipboard", GlobalDict.TITLE_INFO);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
ExceptionUtil.rethrow(e); ExceptionUtil.rethrow(e);
} }
@ -49,7 +49,7 @@ public class ClipboardExportImportSettingsServiceImpl implements ExportImportSet
return new ObjectMapper().readValue(json, SettingsStorageDTO.class); return new ObjectMapper().readValue(json, SettingsStorageDTO.class);
} catch (IOException e) { } catch (IOException e) {
// 导入失败 // 导入失败
Messages.showWarningDialog("Config info error by clipboard", MsgValue.TITLE_INFO); Messages.showWarningDialog("Config info error by clipboard", GlobalDict.TITLE_INFO);
return null; return null;
} }
} }

View File

@ -8,7 +8,7 @@ import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Messages;
import com.intellij.util.ReflectionUtil; import com.intellij.util.ReflectionUtil;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.dto.SettingsStorageDTO; import com.sjhy.plugin.dto.SettingsStorageDTO;
import com.sjhy.plugin.entity.Callback; import com.sjhy.plugin.entity.Callback;
import com.sjhy.plugin.entity.SaveFile; import com.sjhy.plugin.entity.SaveFile;
@ -77,7 +77,7 @@ public class CodeGenerateServiceImpl implements CodeGenerateService {
} }
// 校验选中表的保存路径是否正确 // 校验选中表的保存路径是否正确
if (StringUtils.isEmpty(selectedTableInfo.getSavePath())) { if (StringUtils.isEmpty(selectedTableInfo.getSavePath())) {
Messages.showInfoMessage(selectedTableInfo.getObj().getName() + "表配置信息不正确,请尝试重新配置", MsgValue.TITLE_INFO); Messages.showInfoMessage(selectedTableInfo.getObj().getName() + "表配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO);
return; return;
} }
// 将未配置的表进行配置覆盖 // 将未配置的表进行配置覆盖

View File

@ -17,7 +17,7 @@ import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileWrapper; import com.intellij.openapi.vfs.VirtualFileWrapper;
import com.intellij.util.ExceptionUtil; import com.intellij.util.ExceptionUtil;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.dto.SettingsStorageDTO; import com.sjhy.plugin.dto.SettingsStorageDTO;
import com.sjhy.plugin.service.ExportImportSettingsService; import com.sjhy.plugin.service.ExportImportSettingsService;
import com.sjhy.plugin.tool.ProjectUtils; import com.sjhy.plugin.tool.ProjectUtils;
@ -90,7 +90,7 @@ public class LocalFileExportImportSettingsServiceImpl implements ExportImportSet
public SettingsStorageDTO importConfig() { public SettingsStorageDTO importConfig() {
VirtualFile virtualFile = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFileDescriptor("json"), ProjectUtils.getCurrProject(), null); VirtualFile virtualFile = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFileDescriptor("json"), ProjectUtils.getCurrProject(), null);
if (virtualFile == null) { if (virtualFile == null) {
Messages.showWarningDialog("config file not found", MsgValue.TITLE_INFO); Messages.showWarningDialog("config file not found", GlobalDict.TITLE_INFO);
return null; return null;
} }
String json = LoadTextUtil.loadText(virtualFile).toString(); String json = LoadTextUtil.loadText(virtualFile).toString();
@ -98,7 +98,7 @@ public class LocalFileExportImportSettingsServiceImpl implements ExportImportSet
return new ObjectMapper().readValue(json, SettingsStorageDTO.class); return new ObjectMapper().readValue(json, SettingsStorageDTO.class);
} catch (IOException e) { } catch (IOException e) {
// 导入失败 // 导入失败
Messages.showWarningDialog("config file error", MsgValue.TITLE_INFO); Messages.showWarningDialog("config file error", GlobalDict.TITLE_INFO);
return null; return null;
} }
} }

View File

@ -6,7 +6,7 @@ import com.intellij.openapi.ui.InputValidator;
import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.NonEmptyInputValidator; import com.intellij.openapi.ui.NonEmptyInputValidator;
import com.intellij.util.ExceptionUtil; import com.intellij.util.ExceptionUtil;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.dto.SettingsStorageDTO; import com.sjhy.plugin.dto.SettingsStorageDTO;
import com.sjhy.plugin.service.ExportImportSettingsService; import com.sjhy.plugin.service.ExportImportSettingsService;
import com.sjhy.plugin.tool.HttpUtils; import com.sjhy.plugin.tool.HttpUtils;
@ -45,7 +45,7 @@ public class NetworkExportImportSettingsServiceImpl implements ExportImportSetti
token = matcher.group(); token = matcher.group();
} }
// 显示token // 显示token
Messages.showInputDialog(ProjectUtils.getCurrProject(), result, MsgValue.TITLE_INFO, AllIcons.General.InformationDialog, token, new NonEmptyInputValidator()); Messages.showInputDialog(ProjectUtils.getCurrProject(), result, GlobalDict.TITLE_INFO, AllIcons.General.InformationDialog, token, new NonEmptyInputValidator());
} }
} }
@ -56,7 +56,7 @@ public class NetworkExportImportSettingsServiceImpl implements ExportImportSetti
*/ */
@Override @Override
public SettingsStorageDTO importConfig() { public SettingsStorageDTO importConfig() {
String token = Messages.showInputDialog("Token:", MsgValue.TITLE_INFO, AllIcons.General.Tip, "", new InputValidator() { String token = Messages.showInputDialog("Token:", GlobalDict.TITLE_INFO, AllIcons.General.Tip, "", new InputValidator() {
@Override @Override
public boolean checkInput(String inputString) { public boolean checkInput(String inputString) {
return !StringUtils.isEmpty(inputString); return !StringUtils.isEmpty(inputString);

View File

@ -18,7 +18,7 @@ import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.javadoc.PsiDocToken; import com.intellij.psi.javadoc.PsiDocToken;
import com.intellij.util.ExceptionUtil; import com.intellij.util.ExceptionUtil;
import com.intellij.util.containers.JBIterable; import com.intellij.util.containers.JBIterable;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.entity.ColumnInfo; import com.sjhy.plugin.entity.ColumnInfo;
import com.sjhy.plugin.entity.SaveFile; import com.sjhy.plugin.entity.SaveFile;
import com.sjhy.plugin.entity.TableInfo; import com.sjhy.plugin.entity.TableInfo;
@ -290,7 +290,7 @@ public class TableInfoServiceImpl implements TableInfoService {
if (!errorCount.contains(typeMapper.getColumnType())) { if (!errorCount.contains(typeMapper.getColumnType())) {
Messages.showWarningDialog( Messages.showWarningDialog(
"类型映射《" + typeMapper.getColumnType() + "》存在语法错误,请及时修正。报错信息:" + e.getMessage(), "类型映射《" + typeMapper.getColumnType() + "》存在语法错误,请及时修正。报错信息:" + e.getMessage(),
MsgValue.TITLE_INFO); GlobalDict.TITLE_INFO);
errorCount.add(typeMapper.getColumnType()); errorCount.add(typeMapper.getColumnType());
} }
} }
@ -370,7 +370,7 @@ public class TableInfoServiceImpl implements TableInfoService {
ExceptionUtil.rethrow(e); ExceptionUtil.rethrow(e);
} }
if (content == null) { if (content == null) {
Messages.showWarningDialog("保存失败JSON序列化错误。", MsgValue.TITLE_INFO); Messages.showWarningDialog("保存失败JSON序列化错误。", GlobalDict.TITLE_INFO);
return; return;
} }
// 获取或创建保存目录 // 获取或创建保存目录
@ -469,14 +469,14 @@ public class TableInfoServiceImpl implements TableInfoService {
} }
Document document = FileDocumentManager.getInstance().getDocument(configJsonFile); Document document = FileDocumentManager.getInstance().getDocument(configJsonFile);
if (document == null) { if (document == null) {
Messages.showInfoMessage(fileName + "转文档对象失败", MsgValue.TITLE_INFO); Messages.showInfoMessage(fileName + "转文档对象失败", GlobalDict.TITLE_INFO);
return null; return null;
} }
// 读取并解析文件 // 读取并解析文件
String json = document.getText(); String json = document.getText();
if (StringUtils.isEmpty(json)) { if (StringUtils.isEmpty(json)) {
Messages.showInfoMessage(fileName + "配置文件文件为空,请尝试手动删除" + configJsonFile.getPath() + "文件!", Messages.showInfoMessage(fileName + "配置文件文件为空,请尝试手动删除" + configJsonFile.getPath() + "文件!",
MsgValue.TITLE_INFO); GlobalDict.TITLE_INFO);
return null; return null;
} }
return parser(json, configJsonFile); return parser(json, configJsonFile);
@ -491,7 +491,7 @@ public class TableInfoServiceImpl implements TableInfoService {
private VirtualFile getEasyCodeConfigDirectory(Project project) { private VirtualFile getEasyCodeConfigDirectory(Project project) {
VirtualFile baseDir = ProjectUtils.getBaseDir(project); VirtualFile baseDir = ProjectUtils.getBaseDir(project);
if (baseDir == null) { if (baseDir == null) {
Messages.showInfoMessage("无法获取项目路径", MsgValue.TITLE_INFO); Messages.showInfoMessage("无法获取项目路径", GlobalDict.TITLE_INFO);
return null; return null;
} }
// 获取.idea路径 // 获取.idea路径
@ -510,7 +510,7 @@ public class TableInfoServiceImpl implements TableInfoService {
ideaDir = tmpDir.findChild(".idea"); ideaDir = tmpDir.findChild(".idea");
} }
if (ideaDir == null) { if (ideaDir == null) {
Messages.showInfoMessage(".idea路径获取失败", MsgValue.TITLE_INFO); Messages.showInfoMessage(".idea路径获取失败", GlobalDict.TITLE_INFO);
String errorMsg = String.format("baseDir:%s, not found .idea child directory", baseDir.getPath()); String errorMsg = String.format("baseDir:%s, not found .idea child directory", baseDir.getPath());
ExceptionUtil.rethrow(new IllegalStateException(errorMsg)); ExceptionUtil.rethrow(new IllegalStateException(errorMsg));
return null; return null;
@ -550,7 +550,7 @@ public class TableInfoServiceImpl implements TableInfoService {
return objectMapper.readValue(str, TableInfo.class); return objectMapper.readValue(str, TableInfo.class);
} catch (IOException e) { } catch (IOException e) {
Messages.showWarningDialog("读取配置失败JSON反序列化异常。请尝试手动删除" + originalFile.getPath() + "文件!", Messages.showWarningDialog("读取配置失败JSON反序列化异常。请尝试手动删除" + originalFile.getPath() + "文件!",
MsgValue.TITLE_INFO); GlobalDict.TITLE_INFO);
ExceptionUtil.rethrow(e); ExceptionUtil.rethrow(e);
} }
return null; return null;

View File

@ -17,7 +17,7 @@ import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager; import com.intellij.psi.PsiManager;
import com.intellij.util.ExceptionUtil; import com.intellij.util.ExceptionUtil;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -66,7 +66,7 @@ public class FileUtils {
try { try {
return VfsUtil.createDirectoryIfMissing(parent, dirName); return VfsUtil.createDirectoryIfMissing(parent, dirName);
} catch (IOException e) { } catch (IOException e) {
Messages.showWarningDialog("目录创建失败:" + dirName, MsgValue.TITLE_INFO); Messages.showWarningDialog("目录创建失败:" + dirName, GlobalDict.TITLE_INFO);
return null; return null;
} }
}); });
@ -91,7 +91,7 @@ public class FileUtils {
} }
return parent.createChildData(new Object(), fileName); return parent.createChildData(new Object(), fileName);
} catch (IOException e) { } catch (IOException e) {
Messages.showWarningDialog("文件创建失败:" + fileName, MsgValue.TITLE_INFO); Messages.showWarningDialog("文件创建失败:" + fileName, GlobalDict.TITLE_INFO);
return null; return null;
} }
}); });

View File

@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.TextNode; import com.fasterxml.jackson.databind.node.TextNode;
import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Messages;
import com.intellij.util.ExceptionUtil; import com.intellij.util.ExceptionUtil;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import org.apache.http.HttpHeaders; import org.apache.http.HttpHeaders;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig; import org.apache.http.client.config.RequestConfig;
@ -96,7 +96,7 @@ public final class HttpUtils {
httpPost.setEntity(new StringEntity(objectMapper.writeValueAsString(param), "utf-8")); httpPost.setEntity(new StringEntity(objectMapper.writeValueAsString(param), "utf-8"));
return handlerRequest(httpPost); return handlerRequest(httpPost);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
Messages.showWarningDialog("JSON解析出错", MsgValue.TITLE_INFO); Messages.showWarningDialog("JSON解析出错", GlobalDict.TITLE_INFO);
ExceptionUtil.rethrow(e); ExceptionUtil.rethrow(e);
} }
return null; return null;
@ -117,7 +117,7 @@ public final class HttpUtils {
CloseableHttpResponse response = HTTP_CLIENT.execute(request); CloseableHttpResponse response = HTTP_CLIENT.execute(request);
String body = EntityUtils.toString(response.getEntity()); String body = EntityUtils.toString(response.getEntity());
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
Messages.showWarningDialog("连接到服务器错误!", MsgValue.TITLE_INFO); Messages.showWarningDialog("连接到服务器错误!", GlobalDict.TITLE_INFO);
return null; return null;
} }
HttpClientUtils.closeQuietly(response); HttpClientUtils.closeQuietly(response);
@ -133,9 +133,9 @@ public final class HttpUtils {
} }
// 获取错误消息 // 获取错误消息
String msg = jsonNode.get("msg").asText(); String msg = jsonNode.get("msg").asText();
Messages.showWarningDialog(msg, MsgValue.TITLE_INFO); Messages.showWarningDialog(msg, GlobalDict.TITLE_INFO);
} catch (IOException e) { } catch (IOException e) {
Messages.showWarningDialog("无法连接到服务器!", MsgValue.TITLE_INFO); Messages.showWarningDialog("无法连接到服务器!", GlobalDict.TITLE_INFO);
ExceptionUtil.rethrow(e); ExceptionUtil.rethrow(e);
} }
return null; return null;

View File

@ -2,7 +2,7 @@ package com.sjhy.plugin.tool;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.UIUtil;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import javax.swing.*; import javax.swing.*;
@ -36,7 +36,7 @@ public class MessageDialogUtils {
public static boolean yesNo(Project project, String msg) { public static boolean yesNo(Project project, String msg) {
Object[] options = new Object[]{"Yes", "No"}; Object[] options = new Object[]{"Yes", "No"};
return JOptionPane.showOptionDialog(null, return JOptionPane.showOptionDialog(null,
msg, MsgValue.TITLE_INFO, msg, GlobalDict.TITLE_INFO,
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
UIUtil.getQuestionIcon(), UIUtil.getQuestionIcon(),
options, options[0]) == 0; options, options[0]) == 0;
@ -52,7 +52,7 @@ public class MessageDialogUtils {
public static int yesNoCancel(Project project, String msg, String yesText, String noText, String cancelText) { public static int yesNoCancel(Project project, String msg, String yesText, String noText, String cancelText) {
Object[] options = new Object[]{yesText, noText, cancelText}; Object[] options = new Object[]{yesText, noText, cancelText};
return JOptionPane.showOptionDialog(null, return JOptionPane.showOptionDialog(null,
msg, MsgValue.TITLE_INFO, msg, GlobalDict.TITLE_INFO,
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
UIUtil.getQuestionIcon(), UIUtil.getQuestionIcon(),
options, options[0]); options, options[0]);

View File

@ -7,7 +7,7 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.VirtualFileManager;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.java.JavaSourceRootType; import org.jetbrains.jps.model.java.JavaSourceRootType;
@ -50,7 +50,7 @@ public final class ModuleUtils {
} }
VirtualFile dir = VirtualFileManager.getInstance().findFileByUrl(String.format("file://%s", modulePath)); VirtualFile dir = VirtualFileManager.getInstance().findFileByUrl(String.format("file://%s", modulePath));
if (dir == null) { if (dir == null) {
Messages.showInfoMessage("无法获取Module路径, path=" + modulePath, MsgValue.TITLE_INFO); Messages.showInfoMessage("无法获取Module路径, path=" + modulePath, GlobalDict.TITLE_INFO);
} }
return dir; return dir;
} }

View File

@ -5,7 +5,7 @@ import com.intellij.openapi.ui.InputValidator;
import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Messages;
import com.intellij.ui.BooleanTableCellEditor; import com.intellij.ui.BooleanTableCellEditor;
import com.intellij.util.ui.ComboBoxCellEditor; import com.intellij.util.ui.ComboBoxCellEditor;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.entity.*; import com.sjhy.plugin.entity.*;
import com.sjhy.plugin.enums.ColumnConfigType; import com.sjhy.plugin.enums.ColumnConfigType;
import com.sjhy.plugin.service.TableInfoService; import com.sjhy.plugin.service.TableInfoService;
@ -175,7 +175,7 @@ public class ConfigTableDialog extends JDialog {
if (column == 0) { if (column == 0) {
for (ColumnInfo info : tableInfo.getFullColumn()) { for (ColumnInfo info : tableInfo.getFullColumn()) {
if (info.getName().equals(val) && !info.getName().equals(columnInfo.getName())) { if (info.getName().equals(val) && !info.getName().equals(columnInfo.getName())) {
Messages.showWarningDialog("Column Name Already exist!", MsgValue.TITLE_INFO); Messages.showWarningDialog("Column Name Already exist!", GlobalDict.TITLE_INFO);
// 输入的名称已经存在时直接还原 // 输入的名称已经存在时直接还原
tableModel.setValueAt(columnInfo.getName(), row, column); tableModel.setValueAt(columnInfo.getName(), row, column);
return; return;

View File

@ -8,7 +8,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ExceptionUtil; import com.intellij.util.ExceptionUtil;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.constants.StrState; import com.sjhy.plugin.constants.StrState;
import com.sjhy.plugin.dto.SettingsStorageDTO; import com.sjhy.plugin.dto.SettingsStorageDTO;
import com.sjhy.plugin.entity.TableInfo; import com.sjhy.plugin.entity.TableInfo;
@ -154,7 +154,7 @@ public class SelectSavePath extends JDialog {
} }
} }
init(); init();
setTitle(MsgValue.TITLE_INFO); setTitle(GlobalDict.TITLE_INFO);
setContentPane(contentPane); setContentPane(contentPane);
setModal(true); setModal(true);
getRootPane().setDefaultButton(buttonOK); getRootPane().setDefaultButton(buttonOK);
@ -209,12 +209,12 @@ public class SelectSavePath extends JDialog {
List<Template> selectTemplateList = getSelectTemplate(); List<Template> selectTemplateList = getSelectTemplate();
// 如果选择的模板是空的 // 如果选择的模板是空的
if (selectTemplateList.isEmpty()) { if (selectTemplateList.isEmpty()) {
Messages.showWarningDialog("Can't Select Template!", MsgValue.TITLE_INFO); Messages.showWarningDialog("Can't Select Template!", GlobalDict.TITLE_INFO);
return; return;
} }
String savePath = pathField.getText(); String savePath = pathField.getText();
if (StringUtils.isEmpty(savePath)) { if (StringUtils.isEmpty(savePath)) {
Messages.showWarningDialog("Can't Select Save Path!", MsgValue.TITLE_INFO); Messages.showWarningDialog("Can't Select Save Path!", GlobalDict.TITLE_INFO);
return; return;
} }
// 针对Linux系统路径做处理 // 针对Linux系统路径做处理
@ -435,7 +435,7 @@ public class SelectSavePath extends JDialog {
Module module = getSelectModule(); Module module = getSelectModule();
VirtualFile baseVirtualFile = ProjectUtils.getBaseDir(project); VirtualFile baseVirtualFile = ProjectUtils.getBaseDir(project);
if (baseVirtualFile == null) { if (baseVirtualFile == null) {
Messages.showWarningDialog("无法获取到项目基本路径!", MsgValue.TITLE_INFO); Messages.showWarningDialog("无法获取到项目基本路径!", GlobalDict.TITLE_INFO);
return ""; return "";
} }
String baseDir = baseVirtualFile.getPath(); String baseDir = baseVirtualFile.getPath();

View File

@ -5,7 +5,7 @@ import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.VerticalFlowLayout; import com.intellij.openapi.ui.VerticalFlowLayout;
import com.intellij.openapi.ui.ex.MultiLineLabel; import com.intellij.openapi.ui.ex.MultiLineLabel;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.dto.SettingsStorageDTO; import com.sjhy.plugin.dto.SettingsStorageDTO;
import com.sjhy.plugin.entity.AbstractGroup; import com.sjhy.plugin.entity.AbstractGroup;
import com.sjhy.plugin.service.ExportImportSettingsService; import com.sjhy.plugin.service.ExportImportSettingsService;
@ -97,14 +97,14 @@ public class ExportImportComponent {
mainPanel.add(globalConfigPanel); mainPanel.add(globalConfigPanel);
// 构建dialog // 构建dialog
DialogBuilder dialogBuilder = new DialogBuilder(ProjectUtils.getCurrProject()); DialogBuilder dialogBuilder = new DialogBuilder(ProjectUtils.getCurrProject());
dialogBuilder.setTitle(MsgValue.TITLE_INFO); dialogBuilder.setTitle(GlobalDict.TITLE_INFO);
dialogBuilder.setNorthPanel(new MultiLineLabel("请选择要导出的配置分组:")); dialogBuilder.setNorthPanel(new MultiLineLabel("请选择要导出的配置分组:"));
dialogBuilder.setCenterPanel(mainPanel); dialogBuilder.setCenterPanel(mainPanel);
dialogBuilder.addActionDescriptor(dialogWrapper -> new AbstractAction("OK") { dialogBuilder.addActionDescriptor(dialogWrapper -> new AbstractAction("OK") {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (!isSelected(typeMapperPanel, templatePanel, columnConfigPanel, globalConfigPanel)) { if (!isSelected(typeMapperPanel, templatePanel, columnConfigPanel, globalConfigPanel)) {
Messages.showWarningDialog("至少选择一个模板组!", MsgValue.TITLE_INFO); Messages.showWarningDialog("至少选择一个模板组!", GlobalDict.TITLE_INFO);
return; return;
} }
// 过滤数据 // 过滤数据
@ -168,7 +168,7 @@ public class ExportImportComponent {
} }
// 构建dialog // 构建dialog
DialogBuilder dialogBuilder = new DialogBuilder(ProjectUtils.getCurrProject()); DialogBuilder dialogBuilder = new DialogBuilder(ProjectUtils.getCurrProject());
dialogBuilder.setTitle(MsgValue.TITLE_INFO); dialogBuilder.setTitle(GlobalDict.TITLE_INFO);
dialogBuilder.setNorthPanel(new MultiLineLabel("请选择重复配置的处理方式:")); dialogBuilder.setNorthPanel(new MultiLineLabel("请选择重复配置的处理方式:"));
dialogBuilder.setCenterPanel(mainPanel); dialogBuilder.setCenterPanel(mainPanel);
dialogBuilder.addActionDescriptor(dialogWrapper -> new AbstractAction("OK") { dialogBuilder.addActionDescriptor(dialogWrapper -> new AbstractAction("OK") {

View File

@ -27,7 +27,7 @@ import com.intellij.ui.components.JBLabel;
import com.intellij.util.ExceptionUtil; import com.intellij.util.ExceptionUtil;
import com.intellij.util.ReflectionUtil; import com.intellij.util.ReflectionUtil;
import com.intellij.util.containers.JBIterable; import com.intellij.util.containers.JBIterable;
import com.sjhy.plugin.constants.MsgValue; import com.sjhy.plugin.dict.GlobalDict;
import com.sjhy.plugin.entity.TableInfo; import com.sjhy.plugin.entity.TableInfo;
import com.sjhy.plugin.entity.Template; import com.sjhy.plugin.entity.Template;
import com.sjhy.plugin.service.CodeGenerateService; import com.sjhy.plugin.service.CodeGenerateService;
@ -105,7 +105,7 @@ public class RealtimeDebugComponent {
} else { } else {
Method method = ReflectionUtil.getMethod(DbPsiFacade.class, "findElement", DasObject.class); Method method = ReflectionUtil.getMethod(DbPsiFacade.class, "findElement", DasObject.class);
if (method == null) { if (method == null) {
Messages.showWarningDialog("findElement method not found", MsgValue.TITLE_INFO); Messages.showWarningDialog("findElement method not found", GlobalDict.TITLE_INFO);
return; return;
} }
try { try {
@ -129,7 +129,7 @@ public class RealtimeDebugComponent {
PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(ProjectUtils.getCurrProject()); PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(ProjectUtils.getCurrProject());
String fileName = editorComponent.getFile().getName(); String fileName = editorComponent.getFile().getName();
FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(fileName); FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(fileName);
PsiFile psiFile = psiFileFactory.createFileFromText(fileName, fileType, code); PsiFile psiFile = psiFileFactory.createFileFromText(fileName, fileType, code, 0, true);
// 标识为模板让velocity跳过语法校验 // 标识为模板让velocity跳过语法校验
psiFile.getViewProvider().putUserData(FileTemplateManager.DEFAULT_TEMPLATE_PROPERTIES, FileTemplateManager.getInstance(ProjectUtils.getCurrProject()).getDefaultProperties()); psiFile.getViewProvider().putUserData(FileTemplateManager.DEFAULT_TEMPLATE_PROPERTIES, FileTemplateManager.getInstance(ProjectUtils.getCurrProject()).getDefaultProperties());
Document document = PsiDocumentManager.getInstance(ProjectUtils.getCurrProject()).getDocument(psiFile); Document document = PsiDocumentManager.getInstance(ProjectUtils.getCurrProject()).getDocument(psiFile);
@ -140,7 +140,7 @@ public class RealtimeDebugComponent {
((EditorEx) editor).setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(ProjectUtils.getCurrProject(), fileName)); ((EditorEx) editor).setHighlighter(EditorHighlighterFactory.getInstance().createEditorHighlighter(ProjectUtils.getCurrProject(), fileName));
// 构建dialog // 构建dialog
DialogBuilder dialogBuilder = new DialogBuilder(ProjectUtils.getCurrProject()); DialogBuilder dialogBuilder = new DialogBuilder(ProjectUtils.getCurrProject());
dialogBuilder.setTitle(MsgValue.TITLE_INFO); dialogBuilder.setTitle(GlobalDict.TITLE_INFO);
JComponent component = editor.getComponent(); JComponent component = editor.getComponent();
component.setPreferredSize(new Dimension(800, 600)); component.setPreferredSize(new Dimension(800, 600));
dialogBuilder.setCenterPanel(component); dialogBuilder.setCenterPanel(component);