OK action is enabled if all members are deselected #168#238
Conversation
9ae9a68 to
4166ee4
Compare
| import com.intellij.openapi.roots.ExternalLibraryDescriptor | ||
| import com.intellij.openapi.roots.JavaProjectModelModificationService | ||
| import com.intellij.openapi.roots.ModuleRootManager | ||
| import com.intellij.openapi.roots.* |
There was a problem hiding this comment.
We do not use imports with * by some reasons. Correct this setting in your IntelliJ Idea and in the already commited files after that, please.
| val item = (event.source as JComboBox<*>).selectedItem as String | ||
|
|
||
| pathToFile(item)?.let { model.testSourceRoot = it } | ||
| pathToFile(item)?.let { model.testSourceRoot = it } ?: run { model.testSourceRoot = null } |
There was a problem hiding this comment.
It seems to me that you have just mentioned smth like
model.testSourceRoot = pathToFile(item)
utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/GenerateTestsDialogWindow.kt
Show resolved
Hide resolved
| } | ||
| return true | ||
| if (cbSpecifyTestPackage.isSelected) { | ||
| createSelectedPackage(sourceRootAndEntry.first) |
There was a problem hiding this comment.
Such code is not very easy to understand... What is "first"? How to understand that it is actually the testSourceRoot. I would suggest to use something like named tuples or a structure.
There was a problem hiding this comment.
val (a, b) = getAOrb()
| WriteCommandAction.runWriteCommandAction(model.project) { modifiableModel.commit() } | ||
| private fun getRootDirectoryAndContentEntry() : Pair<VirtualFile, ContentEntry>? { | ||
| val testSourceRoot = model.testSourceRoot ?: return null | ||
| if (!testSourceRoot.isDirectory) return null |
There was a problem hiding this comment.
Can't we incapsulate this logic just in one place, for example, in doValidate method?
| if (testSourceRoot == null || !testSourceRoot.isDirectory) { | ||
| return ValidationInfo("Test source root is not configured", testSourceFolderField.childComponent) | ||
| } | ||
| if (getRootDirectoryAndContentEntry() == null) { |
There was a problem hiding this comment.
Actually here you check just it's "second" as "first" is checked in the previous condition.
| override fun doValidate(): ValidationInfo? { | ||
| val testSourceRoot = model.testSourceRoot | ||
| if (testSourceRoot == null || !testSourceRoot.isDirectory) { | ||
| return ValidationInfo("Test source root is not configured", testSourceFolderField.childComponent) |
There was a problem hiding this comment.
Actually we have another validator for it.
After-review improvements
28a8cf4 to
6b9eb8c
Compare
…-if-all-members-are-deselected
…-if-all-members-are-deselected
…-if-all-members-are-deselected
Description
Now OK button is disabled if no members is selected (ticked), better validation and hints were added for:
Fixes #168
Type of Change
How Has This Been Tested?
Manual Scenario
Checklist (remove irrelevant options):