mirror of https://gitee.com/makejava/EasyCode.git
commit
fffb3aa341
68
build.gradle
68
build.gradle
|
@ -6,75 +6,41 @@ buildscript {
|
||||||
maven { url 'https://dl.bintray.com/jetbrains/intellij-plugin-service' }
|
maven { url 'https://dl.bintray.com/jetbrains/intellij-plugin-service' }
|
||||||
maven { url 'https://dl.bintray.com/jetbrains/intellij-third-party-dependencies/' }
|
maven { url 'https://dl.bintray.com/jetbrains/intellij-third-party-dependencies/' }
|
||||||
}
|
}
|
||||||
// https://github.com/JetBrains/gradle-intellij-plugin/ 关注开发插件版本
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.6.5"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//2.1 插件配置
|
|
||||||
// 这两个插件是必备
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.jetbrains.intellij' version '0.6.5'
|
id 'org.jetbrains.intellij' version '0.7.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
group 'com.sjhy'
|
group 'com.sjhy'
|
||||||
version '1.2.5-java.RELEASE'
|
version '1.2.6.RELEASE'
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
compileJava.options.encoding = "UTF-8"
|
||||||
|
compileTestJava.options.encoding = "UTF-8"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://www.jetbrains.org/intellij/sdk/docs/tutorials/build_system/prerequisites.html
|
|
||||||
// https://plugins.jetbrains.com/docs/intellij/gradle-guide.html 官网gradle构建教程
|
|
||||||
|
|
||||||
intellij {
|
|
||||||
// 插件名称
|
|
||||||
pluginName 'EasyCode'
|
|
||||||
// 沙箱目录位置,用于保存IDEA的设置,默认在build文件下面,防止clean,放在根目录下。
|
|
||||||
sandboxDirectory = "${rootProject.rootDir}/idea-sandbox"
|
|
||||||
// 开发环境运行时使用的版本
|
|
||||||
version '2020.1.2'
|
|
||||||
// 社区版
|
|
||||||
// type 'IC'
|
|
||||||
// 企业版
|
|
||||||
type 'IU'
|
|
||||||
// 各种IDEA版本去这里找
|
|
||||||
// https://www.jetbrains.com/intellij-repository/releases
|
|
||||||
// 依赖的插件
|
|
||||||
plugins = ['java', 'DatabaseTools']
|
|
||||||
//Disables updating since-build attribute in plugin.xml
|
|
||||||
updateSinceUntilBuild false
|
|
||||||
downloadSources = true
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// jackson工具
|
|
||||||
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.6'
|
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.6'
|
||||||
// guava工具
|
|
||||||
// compile 'com.google.guava:guava:29.0-jre'
|
|
||||||
// velocity支持
|
|
||||||
// compile 'org.apache.velocity:velocity:1.7'
|
|
||||||
// groovy支持
|
|
||||||
// compile 'org.codehaus.groovy:groovy:3.0.2'
|
|
||||||
// beetl支持
|
|
||||||
// compile 'com.ibeetl:beetl:3.3.0.RELEASE'
|
|
||||||
// freemarker支持
|
|
||||||
// compile 'org.freemarker:freemarker:2.3.30'
|
|
||||||
// lombok 支持
|
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.2'
|
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.2'
|
|
||||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.2'
|
|
||||||
// 测试用例
|
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
|
// lombok
|
||||||
|
compileOnly 'org.projectlombok:lombok:1.18.12'
|
||||||
|
annotationProcessor 'org.projectlombok:lombok:1.18.12'
|
||||||
|
testCompileOnly 'org.projectlombok:lombok:1.18.12'
|
||||||
|
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
// See https://github.com/JetBrains/gradle-intellij-plugin/
|
||||||
options.encoding = "UTF-8"
|
intellij {
|
||||||
|
version = 'IU-2020.1.2'
|
||||||
|
plugins = ['java', 'DatabaseTools']
|
||||||
|
updateSinceUntilBuild = false
|
||||||
|
downloadSources = true
|
||||||
|
sandboxDirectory = "${rootProject.rootDir}/idea-sandbox"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -1,6 +1,5 @@
|
||||||
#Tue Jul 17 15:13:01 CST 2018
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://downloads.gradle-dn.com/distributions/gradle-6.9-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import com.google.common.collect.Lists;
|
||||||
import com.intellij.openapi.actionSystem.AnAction;
|
import com.intellij.openapi.actionSystem.AnAction;
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||||
|
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||||
|
import com.intellij.openapi.module.Module;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
import com.intellij.psi.PsiClass;
|
import com.intellij.psi.PsiClass;
|
||||||
|
@ -74,5 +76,23 @@ public class EasyCodeEntityAction extends AnAction {
|
||||||
return psiClassList;
|
return psiClassList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(@NotNull AnActionEvent event) {
|
||||||
|
// 不存在模块不展示:选择多个模块
|
||||||
|
Project project = event.getData(CommonDataKeys.PROJECT);
|
||||||
|
Module module = event.getData(LangDataKeys.MODULE);
|
||||||
|
if (project == null || module == null) {
|
||||||
|
event.getPresentation().setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 非java的文件不显示
|
||||||
|
VirtualFile file = event.getDataContext().getData(CommonDataKeys.VIRTUAL_FILE);
|
||||||
|
if (file != null && !file.isDirectory() && !"java".equals(file.getExtension())) {
|
||||||
|
event.getPresentation().setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public interface GlobalDict {
|
||||||
/**
|
/**
|
||||||
* 版本号
|
* 版本号
|
||||||
*/
|
*/
|
||||||
String VERSION = "1.2.4";
|
String VERSION = "1.2.6";
|
||||||
/**
|
/**
|
||||||
* 作者名称
|
* 作者名称
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -95,12 +95,11 @@ public class TableInfoSettingsDTO {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DbTable dbTable = tableInfo.getObj();
|
DbTable dbTable = tableInfo.getObj();
|
||||||
PsiClass psiClass = tableInfo.getPsiClassObj();
|
|
||||||
String key;
|
String key;
|
||||||
if (dbTable != null) {
|
if (dbTable != null) {
|
||||||
key = generateKey(dbTable);
|
key = generateKey(dbTable);
|
||||||
} else if (psiClass != null) {
|
} else if (tableInfo.getPsiClassObj() != null) {
|
||||||
key = generateKey(psiClass);
|
key = generateKey((PsiClass) tableInfo.getPsiClassObj());
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.sjhy.plugin.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.intellij.database.psi.DbTable;
|
import com.intellij.database.psi.DbTable;
|
||||||
import com.intellij.psi.PsiClass;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -24,9 +23,11 @@ public class TableInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 原始对象(从实体生成)
|
* 原始对象(从实体生成)
|
||||||
|
*
|
||||||
|
* Note: 实际类型是com.intellij.psi.PsiClass,为了避免velocity反射出现ClassNotFound,写为Object类型
|
||||||
*/
|
*/
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private PsiClass psiClassObj;
|
private Object psiClassObj;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表名(首字母大写)
|
* 表名(首字母大写)
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class ClipboardExportImportSettingsServiceImpl implements ExportImportSet
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exportConfig(SettingsStorageDTO settingsStorage) {
|
public void exportConfig(SettingsStorageDTO settingsStorage) {
|
||||||
String json = JSON.toJson(settingsStorage);
|
String json = JSON.toJsonByFormat(settingsStorage);
|
||||||
CopyPasteManager.getInstance().setContents(new TextTransferable(json));
|
CopyPasteManager.getInstance().setContents(new TextTransferable(json));
|
||||||
Messages.showInfoMessage("Config info success write to clipboard!", GlobalDict.TITLE_INFO);
|
Messages.showInfoMessage("Config info success write to clipboard!", GlobalDict.TITLE_INFO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.intellij.openapi.module.Module;
|
||||||
import com.intellij.openapi.module.ModuleManager;
|
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.psi.PsiClass;
|
||||||
import com.intellij.util.ReflectionUtil;
|
import com.intellij.util.ReflectionUtil;
|
||||||
import com.sjhy.plugin.dict.GlobalDict;
|
import com.sjhy.plugin.dict.GlobalDict;
|
||||||
import com.sjhy.plugin.dto.GenerateOptions;
|
import com.sjhy.plugin.dto.GenerateOptions;
|
||||||
|
@ -80,7 +81,8 @@ public class CodeGenerateServiceImpl implements CodeGenerateService {
|
||||||
if (selectedTableInfo.getObj() != null) {
|
if (selectedTableInfo.getObj() != null) {
|
||||||
Messages.showInfoMessage(selectedTableInfo.getObj().getName() + "表配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO);
|
Messages.showInfoMessage(selectedTableInfo.getObj().getName() + "表配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO);
|
||||||
} else if (selectedTableInfo.getPsiClassObj() != null) {
|
} else if (selectedTableInfo.getPsiClassObj() != null) {
|
||||||
Messages.showInfoMessage(selectedTableInfo.getPsiClassObj().getName() + "类配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO);
|
PsiClass psiClassObj = (PsiClass) selectedTableInfo.getPsiClassObj();
|
||||||
|
Messages.showInfoMessage(psiClassObj.getName() + "类配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO);
|
||||||
} else {
|
} else {
|
||||||
Messages.showInfoMessage("配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO);
|
Messages.showInfoMessage("配置信息不正确,请尝试重新配置", GlobalDict.TITLE_INFO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地文件导入导出设置服务实现
|
* 本地文件导入导出设置服务实现
|
||||||
|
@ -52,7 +53,7 @@ public class LocalFileExportImportSettingsServiceImpl implements ExportImportSet
|
||||||
FileUtil.createIfDoesntExist(file);
|
FileUtil.createIfDoesntExist(file);
|
||||||
WriteCommandAction.runWriteCommandAction(ProjectUtils.getCurrProject(), () -> {
|
WriteCommandAction.runWriteCommandAction(ProjectUtils.getCurrProject(), () -> {
|
||||||
try {
|
try {
|
||||||
byte[] bytes = JSON.toJson(settingsStorage).getBytes();
|
byte[] bytes = JSON.toJsonByFormat(settingsStorage).getBytes(StandardCharsets.UTF_8);
|
||||||
VirtualFile virtualFile = VfsUtil.findFileByIoFile(file, true);
|
VirtualFile virtualFile = VfsUtil.findFileByIoFile(file, true);
|
||||||
if (virtualFile != null) {
|
if (virtualFile != null) {
|
||||||
virtualFile.setBinaryContent(bytes);
|
virtualFile.setBinaryContent(bytes);
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<idea-plugin>
|
||||||
|
|
||||||
|
<actions>
|
||||||
|
<!-- 实体类生成代码 -->
|
||||||
|
<action id="com.sjhy.plugin.actions.EasyCodeEntityAction"
|
||||||
|
class="com.sjhy.plugin.actions.EasyCodeEntityAction" text="EasyCode...">
|
||||||
|
<add-to-group group-id="GenerateGroup" anchor="last"/>
|
||||||
|
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
|
||||||
|
</action>
|
||||||
|
</actions>
|
||||||
|
|
||||||
|
</idea-plugin>
|
|
@ -234,8 +234,7 @@
|
||||||
<depends>com.intellij.modules.lang</depends>
|
<depends>com.intellij.modules.lang</depends>
|
||||||
<!--必须依赖Database Tool插件-->
|
<!--必须依赖Database Tool插件-->
|
||||||
<depends>com.intellij.database</depends>
|
<depends>com.intellij.database</depends>
|
||||||
<!--必须依赖Java环境-->
|
<depends optional="true" config-file="easycode-java.xml">com.intellij.modules.java</depends>
|
||||||
<depends>com.intellij.modules.java</depends>
|
|
||||||
|
|
||||||
<application-components>
|
<application-components>
|
||||||
<!--<component>-->
|
<!--<component>-->
|
||||||
|
@ -262,12 +261,6 @@
|
||||||
<!--生成代码菜单-->
|
<!--生成代码菜单-->
|
||||||
<add-to-group group-id="DatabaseViewPopupMenu" anchor="first"/>
|
<add-to-group group-id="DatabaseViewPopupMenu" anchor="first"/>
|
||||||
</group>
|
</group>
|
||||||
<!-- 实体类生成代码 -->
|
|
||||||
<action id="com.sjhy.plugin.actions.EasyCodeEntityAction"
|
|
||||||
class="com.sjhy.plugin.actions.EasyCodeEntityAction" text="EasyCode...">
|
|
||||||
<add-to-group group-id="GenerateGroup" anchor="last"/>
|
|
||||||
<add-to-group group-id="ProjectViewPopupMenu" anchor="last"/>
|
|
||||||
</action>
|
|
||||||
</actions>
|
</actions>
|
||||||
|
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
|
Loading…
Reference in New Issue