Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea plugin #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public enum EngineFileType implements Serializable {
/**
* MD
*/
MD(".md", "documentation_md", "Markdown文件");
MD(".md", "documentation_md", "Markdown文件"),
/**
* EXCEL
*/
XSL(".xls","documentation_xsl","Excel文件");

/**
* 文件后缀
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ public void optimizeData(DataModel dataModel) {
columns.forEach(BeanUtils::beanAttributeValueEscapeXml);
});
}
if (config.getEngineConfig().getFileType().equals(EngineFileType.XSL)) {
//escape xml
beanAttributeValueReplaceBlank(dataModel);
//columns
tables.forEach(i -> {
//table escape xml
beanAttributeValueReplaceBlank(i);
List<ColumnModel> columns = i.getColumns();
//columns escape xml
columns.forEach(BeanUtils::beanAttributeValueReplaceBlank);
});
}
//if file type is markdown
if (config.getEngineConfig().getFileType().equals(EngineFileType.MD)) {
//escape xml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Microsoft Office User</Author>
<LastAuthor>Microsoft Office User</LastAuthor>
<Created>2020-11-15T08:36:40Z</Created>
<LastSaved>2020-11-15T08:46:38Z</LastSaved>
<Version>16.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>16120</WindowHeight>
<WindowWidth>28240</WindowWidth>
<WindowTopX>280</WindowTopX>
<WindowTopY>460</WindowTopY>
<ActiveSheet>1</ActiveSheet>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Center"/>
<Borders/>
<Font ss:FontName="等线" x:CharSet="134" ss:Size="12" ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<#list tables><#items as t>
<Worksheet ss:Name="${t.tableName!''}(${t.remarks!''})">
<Table ss:ExpandedColumnCount="9" ss:ExpandedRowCount="${t.columns?size+6}" x:FullColumns="1"
x:FullRows="1" ss:DefaultColumnWidth="65" ss:DefaultRowHeight="16">
<Row>
<Cell><PhoneticText xmlns="urn:schemas-microsoft-com:office:excel">xu</PhoneticText><Data
ss:Type="String">序号</Data></Cell>
<Cell><Data ss:Type="String">名称</Data></Cell>
<Cell><PhoneticText xmlns="urn:schemas-microsoft-com:office:excel">shu</PhoneticText><Data
ss:Type="String">数据类型</Data></Cell>
<Cell><PhoneticText xmlns="urn:schemas-microsoft-com:office:excel">chang</PhoneticText><Data
ss:Type="String">长度</Data></Cell>
<Cell><PhoneticText xmlns="urn:schemas-microsoft-com:office:excel">shu'z</PhoneticText><Data
ss:Type="String">小数值</Data></Cell>
<Cell><PhoneticText xmlns="urn:schemas-microsoft-com:office:excel">yun</PhoneticText><Data
ss:Type="String">允许空值</Data></Cell>
<Cell><PhoneticText xmlns="urn:schemas-microsoft-com:office:excel">zhu</PhoneticText><Data
ss:Type="String">主键</Data></Cell>
<Cell><PhoneticText xmlns="urn:schemas-microsoft-com:office:excel">mo'ren</PhoneticText><Data
ss:Type="String">默认值</Data></Cell>
<Cell><PhoneticText xmlns="urn:schemas-microsoft-com:office:excel">shuo</PhoneticText><Data
ss:Type="String">说明</Data></Cell>
</Row>
<#list t.columns>
<#items as c>
<Row>
<Cell><Data ss:Type="Number">${c?index+1}</Data></Cell>
<Cell><Data ss:Type="String">${c.columnName!''}</Data></Cell>
<Cell><Data ss:Type="String">${c.typeName!''}</Data></Cell>
<Cell><Data ss:Type="Number">${c.columnSize!''}</Data></Cell>
<Cell><Data ss:Type="Number">${c.decimalDigits!'0'}</Data></Cell>
<Cell><Data ss:Type="String"> ${c.nullable!''}</Data></Cell>
<Cell><Data ss:Type="String">${c.primaryKey!''}</Data></Cell>
<Cell><Data ss:Type="String"> ${c.columnDef!''}</Data></Cell>
<Cell><Data ss:Type="String">${c.remarks!''}</Data></Cell>
</Row>
</#items>
</#list>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Selected/>
<#-- <Print>-->
<#-- <ValidPrinterInfo/>-->
<#-- <PaperSizeIndex>9</PaperSizeIndex>-->
<#-- <VerticalResolution>0</VerticalResolution>-->
<#-- </Print>-->
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>1</ActiveRow>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>

</#items>
</#list>
</Workbook>
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void build() throws IOException {
//打开目录
.openOutputDir(true)
//文件类型
.fileType(EngineFileType.HTML)
.fileType(EngineFileType.XSL)
//生成模板实现
.produceType(EngineTemplateType.freemarker).build();

Expand Down
3 changes: 3 additions & 0 deletions screw-idea-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/screw-idea-plugin.iml
/out
.idea
31 changes: 31 additions & 0 deletions screw-idea-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
该项目根据[screw][screw]由来,核心代码没改动,旨在通过 idea 插件快速创建数据库文档,只需简单配置数据库连接信息即可使用

# 使用方法
1. 安装screw插件
2. Tools(或者编辑界面右键) --> Screw --> 选择对应数据库 --> 配置数据库信息 --> 确定 --> 选择文件路径
3. 生成失败可以查看Event log 查看原因

# 插件截图
![plugin][plugin]

![effect][effect]

# 文档截图

**html截图**

![html][html]

**word截图**
![word][word]

**markdown截图**
![markdown][markdown]

[screw]:https://github.com/pingfangushi/screw
[plugin]: https://ftp.bmp.ovh/imgs/2020/08/e263d024bf46b9b1.png
[effect]: https://ftp.bmp.ovh/imgs/2020/08/549f41f00a874188.png
[html]: https://images.gitee.com/uploads/images/2020/0622/161414_74cd0b68_1407605.png
[word]: https://images.gitee.com/uploads/images/2020/0625/200946_1dc0717f_1407605.png
[markdown]: https://images.gitee.com/uploads/images/2020/0625/214749_7b15d8bd_1407605.png

Binary file added screw-idea-plugin/lib/HikariCP-3.4.5.jar
Binary file not shown.
Binary file added screw-idea-plugin/lib/freemarker-2.3.30.jar
Binary file not shown.
Binary file not shown.
Binary file added screw-idea-plugin/lib/mssql-jdbc-8.2.1.jre8.jar
Binary file not shown.
Binary file not shown.
Binary file added screw-idea-plugin/lib/ojdbc8-19.3.0.0.jar
Binary file not shown.
Binary file added screw-idea-plugin/lib/postgresql-42.2.11.jar
Binary file not shown.
Binary file added screw-idea-plugin/lib/screw-core-1.0.5.jar
Binary file not shown.
48 changes: 48 additions & 0 deletions screw-idea-plugin/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<idea-plugin>
<id>cn.smallbun.screw.idea.action</id>
<name>Screw</name>
<version>1.0</version>
<vendor url="https://github.com/yuanwenjian/screw-idea-plugin" >yuanwj</vendor>

<description><![CDATA[
<p>简洁好用的数据库表结构文档生成器</p>
<br/>
<a href="https://github.com/yuanwenjian/screw-idea-plugin">GitHub</a>
<br/>

<p><b>特点:</b></p>
<ul>
<li>简洁、轻量、设计良好</li>
<li>多数据库支持</li>
<li>多种格式文档</li>
<li>多种格式文档</li>
<li>灵活扩展</li>
<li>支持自定义模板</li>
</ul>
]]></description>

<change-notes><![CDATA[
<p>首次提交</p>
]]></change-notes>

<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="173.0"/>

<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<depends>com.intellij.modules.platform</depends>

<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
</extensions>

<actions>
<!-- Add your actions here -->
<action id="cn.smallbun.screw.idea.action" class="cn.smallbun.screw.idea.action.ScrewAction" text="Screw"
description="文档生成插件" icon="/META-INF/screw.png">
<add-to-group group-id="ToolsMenu" anchor="last"/>
<add-to-group group-id="EditorPopupMenu" anchor="last"/>
</action>
</actions>

</idea-plugin>
Binary file added screw-idea-plugin/resources/META-INF/screw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screw-idea-plugin/screw-idea-plugin.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main.java.cn.smallbun.screw.idea.action;

import cn.smallbun.screw.idea.wrapper.ScrewWrapper;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.Project;

public class ScrewAction extends AnAction {

@Override
public void actionPerformed(AnActionEvent e) {
// TODO: insert action logic here
Project project = e.getProject();
ScrewWrapper screwWrapper = new ScrewWrapper(project);
screwWrapper.setResizable(true);
screwWrapper.showAndGet();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main.java.cn.smallbun.screw.idea.model;

public class ConfigStatement {
public static DataSourceConfig dataSourceConfig;

public static DataSourceConfig getDataSourceConfig() {
return dataSourceConfig;
}

public static void setDataSourceConfig(DataSourceConfig dataSourceConfig) {
ConfigStatement.dataSourceConfig = dataSourceConfig;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package main.java.cn.smallbun.screw.idea.model;

import cn.smallbun.screw.core.engine.EngineFileType;

import java.util.List;

public class DataSourceConfig {

private String url;

private String driver;

private String userName;

private String password;

private EngineFileType engineFileType;

private String fileName;

private String filePath;

private Boolean isOpen = false;

//忽略表
private List<String> ignoreTable;

//忽略表前缀
private List<String> ignorePrefix;

//忽略表后缀
private List<String> ignoreSuffix;

private String desc;

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public String getDriver() {
return driver;
}

public void setDriver(String driver) {
this.driver = driver;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public EngineFileType getEngineFileType() {
return engineFileType;
}

public void setEngineFileType(EngineFileType engineFileType) {
this.engineFileType = engineFileType;
}

public String getFileName() {
return fileName;
}

public void setFileName(String fileName) {
this.fileName = fileName;
}

public String getFilePath() {
return filePath;
}

public void setFilePath(String filePath) {
this.filePath = filePath;
}

public Boolean getOpen() {
return isOpen;
}

public void setOpen(Boolean open) {
isOpen = open;
}

public List<String> getIgnoreTable() {
return ignoreTable;
}

public void setIgnoreTable(List<String> ignoreTable) {
this.ignoreTable = ignoreTable;
}

public List<String> getIgnorePrefix() {
return ignorePrefix;
}

public void setIgnorePrefix(List<String> ignorePrefix) {
this.ignorePrefix = ignorePrefix;
}

public List<String> getIgnoreSuffix() {
return ignoreSuffix;
}

public void setIgnoreSuffix(List<String> ignoreSuffix) {
this.ignoreSuffix = ignoreSuffix;
}

public String getDesc() {
return desc;
}

public void setDesc(String desc) {
this.desc = desc;
}
}
Loading