修复乱码问题,并修复针对部分版本无法获取module的虚拟文件问题。

This commit is contained in:
makejava 2018-07-19 15:57:52 +08:00
parent 5a19e37707
commit 8670fcb0fc
2 changed files with 13 additions and 6 deletions

View File

@ -119,8 +119,9 @@ public class VelocityUtils {
map.put("packageName", cacheDataUtils.getPackageName());
if (selectModule != null) {
//module绝对路径
//noinspection ConstantConditions
map.put("modulePath", selectModule.getModuleFile().getParent().getPath());
if (selectModule.getModuleFile()!=null) {
map.put("modulePath", selectModule.getModuleFile().getParent().getPath());
}
map.put("moduleName", selectModule.getName());
}
return map;

View File

@ -217,8 +217,12 @@ public class SelectSavePath extends JDialog {
//选择路径
pathChooseButton.addActionListener(e -> {
//将当前选中的model设置为基础路径
//noinspection ConstantConditions
VirtualFile virtualFile = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), cacheDataUtils.getProject(), getSelectModule().getModuleFile().getParent());
VirtualFile path = cacheDataUtils.getProject().getBaseDir();
Module module = getSelectModule();
if (module!=null && module.getModuleFile()!=null) {
path = module.getModuleFile().getParent();
}
VirtualFile virtualFile = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), cacheDataUtils.getProject(), path);
if (virtualFile != null) {
pathField.setText(virtualFile.getPath());
}
@ -259,8 +263,10 @@ public class SelectSavePath extends JDialog {
*/
private String getBasePath() {
Module module = getSelectModule();
//noinspection ConstantConditions
String baseDir = module.getModuleFile().getParent().getPath();
String baseDir = cacheDataUtils.getProject().getBasePath();
if (module!=null && module.getModuleFile()!=null) {
baseDir = module.getModuleFile().getParent().getPath();
}
// 针对Maven项目
File file = new File(baseDir + "/src/main/java");
if (file.exists()) {