@@ -10,13 +10,11 @@ import com.intellij.openapi.fileEditor.FileEditorManager
1010import com.intellij.openapi.fileEditor.TextEditor
1111import com.intellij.openapi.project.Project
1212import com.intellij.openapi.ui.Messages
13- import com.intellij.openapi.vfs.VirtualFile
1413import com.intellij.psi.PsiClass
1514import com.intellij.psi.PsiDirectory
1615import com.intellij.psi.PsiFile
1716import com.intellij.psi.PsiJavaFile
1817import com.intellij.util.PlatformIcons
19- import com.intellij.vcsUtil.VcsFileUtil
2018import com.longforus.mvpautocodeplus.config.PersistentState
2119import com.longforus.mvpautocodeplus.maker.TemplateMaker
2220import com.longforus.mvpautocodeplus.maker.TemplateParamFactory
@@ -66,79 +64,49 @@ class MainAction : AnAction("main", "auto make mvp code", PlatformIcons.CLASS_IC
6664 Messages .showErrorDialog(" Super View Interface name is null ! $GOTO_SETTING " , " Error" )
6765 return
6866 }
69- if (state.getValue(SUPER_PRESENTER ).isNullOrEmpty()) {
70- Messages .showErrorDialog(" Super Presenter Interface name is null ! $GOTO_SETTING " , " Error" )
71- return
72- }
73- if (state.getValue(SUPER_MODEL ).isNullOrEmpty()) {
74- Messages .showErrorDialog(" Super Model Interface name is null ! $GOTO_SETTING " , " Error" )
75- return
76- }
77-
7867 val contract = getSubDir(dir, CONTRACT )
7968
8069 EnterKeywordDialog .getDialog {
81- val fileArray = arrayListOf<VirtualFile >()
8270 runWriteAction {
8371 if (it.isJava) {
8472 val contractJ = createFile(it.name, CONTRACT_TP_NAME_JAVA , contract, " " ) as PsiJavaFile
85- fileArray.add(contract.virtualFile)
86- if (! it.vImpl.isEmpty() && it.vImpl != IS_NOT_SET ) {
73+ if (! it.vImpl.isEmpty() && ! it.vImpl.startsWith(IS_NOT_SET )) {
8774 val sdV = getSubDir(dir, VIEW )
8875 if (it.isActivity) {
89- createFile(it.name, VIEW_IMPL_TP_ACTIVITY_JAVA , sdV, it.vImpl, contractJ)?.let {
90- fileArray.add(it.virtualFile)
91- }
76+ createFile(it.name, VIEW_IMPL_TP_ACTIVITY_JAVA , sdV, it.vImpl, contractJ)
9277 } else {
93- createFile(it.name, VIEW_IMPL_TP_FRAGMENT_JAVA , sdV, it.vImpl, contractJ)?.let {
94- fileArray.add(it.virtualFile)
95- }
78+ createFile(it.name, VIEW_IMPL_TP_FRAGMENT_JAVA , sdV, it.vImpl, contractJ)
9679 }
9780 }
9881 if (! it.pImpl.isEmpty()) {
9982 val sdP = getSubDir(dir, PRESENTER )
100- createFile(it.name, PRESENTER_IMPL_TP_JAVA , sdP, it.pImpl, contractJ)?.let {
101- fileArray.add(it.virtualFile)
102- }
83+ createFile(it.name, PRESENTER_IMPL_TP_JAVA , sdP, it.pImpl, contractJ)
10384 }
10485 if (! it.mImpl.isEmpty()) {
10586 val sdM = getSubDir(dir, MODEL )
106- createFile(it.name, MODEL_IMPL_TP_JAVA , sdM, it.mImpl, contractJ)?.let {
107- fileArray.add(it.virtualFile)
108- }
87+ createFile(it.name, MODEL_IMPL_TP_JAVA , sdM, it.mImpl, contractJ)
10988 }
11089
11190 } else {
11291 val contractK = createFile(it.name, CONTRACT_TP_NAME_KOTLIN , contract, " " , fileName = getContractName(it.name))
113- if (contractK != null ) {
114- fileArray.add(contractK.virtualFile)
115- }
116- if (! it.vImpl.isEmpty() && it.vImpl != IS_NOT_SET ) {
92+
93+ if (! it.vImpl.isEmpty() && ! it.vImpl.startsWith(IS_NOT_SET )) {
11794 val sdV = getSubDir(dir, VIEW )
11895 if (it.isActivity) {
119- createFile(it.name, VIEW_IMPL_TP_ACTIVITY_KOTLIN , sdV, it.vImpl, contractK, " ${it.name} Activity" )?.let {
120- fileArray.add(it.virtualFile)
121- }
96+ createFile(it.name, VIEW_IMPL_TP_ACTIVITY_KOTLIN , sdV, it.vImpl, contractK, " ${it.name} Activity" )
12297 } else {
123- createFile(it.name, VIEW_IMPL_TP_FRAGMENT_KOTLIN , sdV, it.vImpl, contractK, " ${it.name} Fragment" )?.let {
124- fileArray.add(it.virtualFile)
125- }
98+ createFile(it.name, VIEW_IMPL_TP_FRAGMENT_KOTLIN , sdV, it.vImpl, contractK, " ${it.name} Fragment" )
12699 }
127100 }
128101 if (! it.pImpl.isEmpty()) {
129102 val sdP = getSubDir(dir, PRESENTER )
130- createFile(it.name, PRESENTER_IMPL_TP_KOTLIN , sdP, it.pImpl, contractK, " ${it.name} Presenter" )?.let {
131- fileArray.add(it.virtualFile)
132- }
103+ createFile(it.name, PRESENTER_IMPL_TP_KOTLIN , sdP, it.pImpl, contractK, " ${it.name} Presenter" )
133104 }
134105 if (! it.mImpl.isEmpty()) {
135106 val sdM = getSubDir(dir, MODEL )
136- createFile(it.name, MODEL_IMPL_TP_KOTLIN , sdM, it.mImpl, contractK, " ${it.name} Model" )?.let {
137- fileArray.add(it.virtualFile)
138- }
107+ createFile(it.name, MODEL_IMPL_TP_KOTLIN , sdM, it.mImpl, contractK, " ${it.name} Model" )
139108 }
140109 }
141- VcsFileUtil .addFilesToVcsWithConfirmation(project!! , fileArray)
142110 }
143111
144112 }
0 commit comments