Skip to content

Commit

Permalink
feat(Graph): 1.09 direction setting | 方向设置
Browse files Browse the repository at this point in the history
  • Loading branch information
LinWanCen committed Jan 17, 2024
1 parent 149c515 commit e3f0485
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## [1.0.0]

- 1.09 direction setting
- 1.08 skip get/set/is(FieldName)
- 1.07 Add Symbol: + public - private # protected ~ package
- S static O Override A abstract C Constructor o open
Expand All @@ -17,6 +18,7 @@

# 中文更新日志

- 1.09 方向设置
- 1.08 跳过 get/set/is 在有同名字段的时候
- 1.07 添加符号:+ 公有 - 私有 # 保护 ~ 包级
- S 静态 O 重写 A 抽象 C 构造 o 可重写
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.github.linwancen.drawgraph
pluginName = draw-graph
pluginRepositoryUrl = https://github.com/LinWanCen/draw-graph
# SemVer format -> https://semver.org
pluginVersion = 1.08
pluginVersion = 1.09

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# Support JCEF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@
</tabbedpane>
</children>
</grid>
<grid id="7c5b3" layout-manager="GridLayoutManager" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="7c5b3" layout-manager="GridLayoutManager" row-count="7" 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>
<tabbedpane title-resource-bundle="messages/DrawGraphBundle" title-key="setting"/>
Expand All @@ -412,36 +412,36 @@
<children>
<component id="37035" class="javax.swing.JTextField" binding="include">
<constraints>
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="3" column="0" row-span="1" col-span="4" 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>
<vspacer id="5f29f">
<constraints>
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="4" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="2f4c5" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DrawGraphBundle" key="include"/>
</properties>
</component>
<component id="c8d16" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DrawGraphBundle" key="exclude"/>
</properties>
</component>
<component id="c30b6" class="javax.swing.JTextField" binding="exclude">
<constraints>
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="5" column="0" row-span="1" col-span="4" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
Expand All @@ -457,7 +457,7 @@
</component>
<hspacer id="b46a1">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="1" row-span="1" col-span="3" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="f2b43" class="javax.swing.JCheckBox" binding="skipGetSetIs" default-binding="true">
Expand All @@ -468,6 +468,19 @@
<text resource-bundle="messages/DrawGraphBundle" key="skipGetSetIs"/>
</properties>
</component>
<hspacer id="26a96">
<constraints>
<grid row="1" 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>
<component id="44e67" class="javax.swing.JCheckBox" binding="lr" default-binding="true">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/DrawGraphBundle" key="LR"/>
</properties>
</component>
</children>
</grid>
</children>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.github.linwancen.plugin.graph.printer.PrinterGraphviz;
import com.github.linwancen.plugin.graph.printer.PrinterMermaid;
import com.github.linwancen.plugin.graph.printer.PrinterPlantuml;
import com.github.linwancen.plugin.graph.settings.DrawGraphAppState;
import com.github.linwancen.plugin.graph.settings.DrawGraphProjectState;
import com.github.linwancen.plugin.graph.ui.webview.Browser;
import com.intellij.openapi.application.ApplicationManager;
Expand All @@ -27,6 +28,7 @@ public class GraphWindow {
public GraphWindow(@NotNull Project project, ToolWindow toolWindow) {
this.project = project;
this.toolWindow = toolWindow;
DrawGraphAppState appState = DrawGraphAppState.of(null);
DrawGraphProjectState projectState = DrawGraphProjectState.of(project);

openDir.addActionListener(e -> InstallMermaid.openDir(project));
Expand All @@ -45,6 +47,12 @@ public GraphWindow(@NotNull Project project, ToolWindow toolWindow) {
RelController.reload(project);
});

lr.setSelected(appState.getLr());
lr.addActionListener(e -> {
appState.setLr(lr.isSelected());
RelController.reload(project);
});

UiUtils.onChange(include, projectState.getInclude(), projectState::setInclude);
UiUtils.onChange(exclude, projectState.getExclude(), projectState::setExclude);
resetSetting.addActionListener(e -> {
Expand Down Expand Up @@ -121,5 +129,6 @@ private void initEvent(JTextArea src, JTextArea html, Browser browser,
private JTextField include;
private JTextField exclude;
private JCheckBox skipGetSetIs;
private JCheckBox lr;
// endregion setting
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.linwancen.plugin.graph.printer

import com.github.linwancen.plugin.common.file.SysPath
import com.github.linwancen.plugin.graph.parser.RelData
import com.github.linwancen.plugin.graph.settings.DrawGraphAppState
import com.github.linwancen.plugin.graph.ui.DrawGraphBundle
import com.intellij.execution.CommandLineUtil
import com.intellij.execution.configurations.GeneralCommandLine
Expand All @@ -22,7 +23,7 @@ class PrinterGraphviz : Printer() {

val sb = StringBuilder(
"""digraph{
rankdir=LR
${if (DrawGraphAppState.of().lr) "rankdir=LR" else ""}
fontname = "Microsoft YaHei,Consolas"
node [shape = "record", style="rounded,filled", fillcolor = "#F1F1F1", fontname = "Microsoft YaHei,Consolas"]
edge [arrowhead = "empty", fontname = "Microsoft YaHei,Consolas"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.linwancen.plugin.graph.printer

import com.github.linwancen.plugin.common.file.SysPath
import com.github.linwancen.plugin.graph.parser.RelData
import com.github.linwancen.plugin.graph.settings.DrawGraphAppState
import com.github.linwancen.plugin.graph.ui.DrawGraphBundle
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.Task
Expand All @@ -16,12 +17,11 @@ import java.util.function.Consumer

class PrinterMermaid : Printer() {

val sb = StringBuilder("graph LR\n\n")
val sb = StringBuilder("graph ${if (DrawGraphAppState.of().lr) "" else "TD"}\n\n")

override fun beforeGroup(groupMap: MutableMap<String, String>) {
sb.append("subgraph ")
label(groupMap, false)
sb.append("direction LR\n")
}

override fun afterGroup(groupMap: MutableMap<String, String>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.linwancen.plugin.graph.printer

import com.github.linwancen.plugin.common.file.SysPath
import com.github.linwancen.plugin.graph.parser.RelData
import com.github.linwancen.plugin.graph.settings.DrawGraphAppState
import com.github.linwancen.plugin.graph.ui.DrawGraphBundle
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.Task
Expand All @@ -24,7 +25,7 @@ class PrinterPlantuml : Printer() {
val sb = StringBuilder("""@startuml
hide empty circle
hide empty members
left to right direction
${if (DrawGraphAppState.of().lr) "left to right direction" else ""}
skinparam shadowing false
skinparam componentStyle rectangle
skinparam defaultTextAlignment center
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.util.regex.Pattern
open class AbstractDrawGraphState {

var skipGetSetIs = true
var lr = true

@Transient
var includePattern = Pattern.compile("")!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.intellij.util.xmlb.XmlSerializerUtil
name = "com.github.linwancen.plugin.graph.settings.DrawGraphAppState",
storages = [Storage("draw-graph-settings/DrawGraphAppState.xml")]
)
class DrawGraphAppState : PersistentStateComponent<DrawGraphAppState?> {
class DrawGraphAppState : PersistentStateComponent<DrawGraphAppState?>, AbstractDrawGraphState() {
override fun getState(): DrawGraphAppState {
return this
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages/DrawGraphBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ graphviz.msg=If open java/pom.xml file but no graph, may be Graphviz is not inst

setting=Setting
skipGetSetIs=skip get/set/is
LR=LR
include=className#memberName include Regexp:
exclude=className#memberName exclude Regexp:
1 change: 1 addition & 0 deletions src/main/resources/messages/DrawGraphBundle_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ graphviz.msg=\u5982\u679C\u6253\u5F00\u4E86 java/pom.xml \u6587\u4EF6\u4F46\u6CA

setting=\u8BBE\u7F6E
skipGetSetIs=\u5FFD\u7565get/set/is
LR=\u5DE6\u53F3
include=\u7C7B#\u65B9\u6CD5 \u5305\u542B \u6B63\u5219\uFF1A
exclude=\u7C7B#\u65B9\u6CD5 \u6392\u9664 \u6B63\u5219\uFF1A

0 comments on commit e3f0485

Please sign in to comment.