Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit f2af7ef

Browse files
committed
add: 添加全选按钮
1 parent b74ca80 commit f2af7ef

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

Plugin/src/com/ciy/plugin/ShowInputDialogAction.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ class ShowInputDialogAction : AnAction() {
3434
*/
3535
@JvmStatic
3636
val generateSourceCodeErrorList = ArrayList<Throwable>()
37+
38+
@JvmStatic
39+
val urlConstantClassName = "URLConstant"
40+
41+
@JvmStatic
42+
val apiSeriviceClassName = "ApiService"
3743
}
3844

3945
/**
@@ -90,11 +96,9 @@ class ShowInputDialogAction : AnAction() {
9096
fun generateSourceCode(rootDir: File, packName: String, apiInfoList: List<ApiInfoBean>) {
9197
propertyMap.clear()
9298
// 生成 URLConstant.kt
93-
val urlConstantClassName = "URLConstant"
9499
val urlConstantFile = URLConstantGenerate.createURLConstant(urlConstantClassName, rootDir, packName, apiInfoList)
95100
urlConstantFile.writeTo(rootDir)
96101
// 生成ApiService.kt
97-
val apiSeriviceClassName = "ApiService"
98102
val apiServiceFile = ApiServiceGenerate.createApiService(apiSeriviceClassName, rootDir, packName, urlConstantFile, apiInfoList)
99103
apiServiceFile.writeTo(rootDir)
100104
}

Plugin/src/com/ciy/plugin/ui/SelectApiDialog.form

+11-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<properties/>
99
<border type="none"/>
1010
<children>
11-
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
11+
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
1212
<margin top="0" left="0" bottom="0" right="0"/>
1313
<constraints>
1414
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -24,7 +24,7 @@
2424
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1">
2525
<margin top="0" left="0" bottom="0" right="0"/>
2626
<constraints>
27-
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
27+
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
2828
</constraints>
2929
<properties/>
3030
<border type="none"/>
@@ -58,12 +58,20 @@
5858
</component>
5959
<component id="d5917" class="javax.swing.JButton" binding="btnReverse">
6060
<constraints>
61-
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
61+
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
6262
</constraints>
6363
<properties>
6464
<text value="反选"/>
6565
</properties>
6666
</component>
67+
<component id="6c46e" class="javax.swing.JButton" binding="btnSelectAll">
68+
<constraints>
69+
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
70+
</constraints>
71+
<properties>
72+
<text value="全选"/>
73+
</properties>
74+
</component>
6775
</children>
6876
</grid>
6977
<grid id="e3588" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">

Plugin/src/com/ciy/plugin/ui/SelectApiDialog.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.ciy.plugin.ui;
22

33
import com.ciy.plugin.Constants;
4+
import com.ciy.plugin.ShowInputDialogAction;
45
import com.ciy.plugin.modle.*;
56
import com.google.gson.Gson;
67
import com.google.gson.reflect.TypeToken;
@@ -39,6 +40,7 @@ public class SelectApiDialog extends JDialog {
3940
private JTextField tfPack;
4041
private JLabel lbTitle;
4142
private JButton btnReverse;
43+
private JButton btnSelectAll;
4244
private Project project;
4345
private ProjectInfoBean projectInfo;
4446
private SelectApiDialogListener listener;
@@ -76,7 +78,7 @@ public void actionPerformed(ActionEvent e) {
7678
}
7779
});
7880

79-
btnReverse.addActionListener(new AbstractAction() {
81+
btnReverse.addActionListener(new ActionListener() {
8082
@Override
8183
public void actionPerformed(ActionEvent e) {
8284
apiList.stream().forEach(it -> {
@@ -86,6 +88,16 @@ public void actionPerformed(ActionEvent e) {
8688
}
8789
});
8890

91+
btnSelectAll.addActionListener(new ActionListener() {
92+
@Override
93+
public void actionPerformed(ActionEvent e) {
94+
apiList.stream().forEach(it -> {
95+
it.setSelect(true);
96+
});
97+
refreshListData();
98+
}
99+
});
100+
89101
tfPack.addActionListener(new AbstractAction() {
90102
@Override
91103
public void actionPerformed(ActionEvent e) {
@@ -183,7 +195,8 @@ private void readSelectApi() {
183195
Module selectModule = moduleList.get(cbModule.getSelectedIndex());
184196
if (selectModule != null) {
185197
String pack = tfPack.getText().replace(".", "/");
186-
VirtualFile apiServiceFile = selectModule.getModuleFile().getParent().findFileByRelativePath("src/main/java/" + pack + "/URLConstant.kt");
198+
VirtualFile apiServiceFile = selectModule.getModuleFile().getParent().findFileByRelativePath("src/main/java/" +
199+
pack + "/" + ShowInputDialogAction.Companion.getUrlConstantClassName() + ".kt");
187200
if (apiServiceFile != null && apiServiceFile.exists()) {
188201
// URLConstant 存在读取里面的url
189202
try {
@@ -213,7 +226,7 @@ private void readSelectApi() {
213226
} else {
214227
// URLConstant 不存在则全选
215228
apiList.forEach(it -> {
216-
it.setSelect(true);
229+
it.setSelect(false);
217230
});
218231
}
219232
refreshListData();

0 commit comments

Comments
 (0)