优化用户体验,将空module往后移

This commit is contained in:
makejava 2018-09-03 11:06:53 +08:00
parent 072ee3d0c1
commit 3662d104f4
3 changed files with 26 additions and 17 deletions

View File

@ -1,16 +0,0 @@
package com.sjhy.plugin;
import java.io.IOException;
/**
* 临时测试类
*
* @author makejava
* @version 1.0.0
* @since 2018/07/17 13:10
*/
public class Test {
public static void main(String[] args) throws IOException {
}
}

View File

@ -38,4 +38,14 @@ public final class ModuleUtils {
}
return virtualFileList.get(0);
}
/**
* 判断模块是否存在源代码文件夹
*
* @param module 模块对象
* @return 是否存在
*/
public static boolean existsSourcePath(Module module) {
return !CollectionUtil.isEmpty(ModuleRootManager.getInstance(module).getSourceRoots(JavaSourceRootType.SOURCE));
}
}

View File

@ -25,6 +25,7 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
@ -103,6 +104,10 @@ public class SelectSavePath extends JDialog {
* 代码生成服务
*/
private CodeGenerateService codeGenerateService;
/**
* 当前项目中的module
*/
private List<Module> moduleList;
/**
* 构造方法
@ -112,6 +117,16 @@ public class SelectSavePath extends JDialog {
this.tableInfoService = TableInfoService.getInstance(project);
this.codeGenerateService = CodeGenerateService.getInstance(project);
this.templateGroup = CurrGroupUtils.getCurrTemplateGroup();
// 初始化module存在资源路径的排前面
this.moduleList = new LinkedList<>();
for (Module module : ModuleManager.getInstance(project).getModules()) {
// 存在源代码文件夹放前面否则放后面
if (ModuleUtils.existsSourcePath(module)) {
this.moduleList.add(0, module);
} else {
this.moduleList.add(module);
}
}
init();
setContentPane(contentPane);
setModal(true);
@ -222,7 +237,7 @@ public class SelectSavePath extends JDialog {
allCheckBox.addActionListener(e -> checkBoxList.forEach(jCheckBox -> jCheckBox.setSelected(allCheckBox.isSelected())));
//初始化Module选择
for (Module module : ModuleManager.getInstance(project).getModules()) {
for (Module module : this.moduleList) {
moduleComboBox.addItem(module.getName());
}