-
Notifications
You must be signed in to change notification settings - Fork 46
OK action is enabled if all members are deselected #168 #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -704,7 +715,7 @@ class GenerateTestsDialogWindow(val model: GenerateTestsModel) : DialogWrapper(m | |||
testSourceFolderField.childComponent.addActionListener { event -> | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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):