Skip to content

settings page improvements #504

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

Merged
merged 5 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import com.intellij.ui.dsl.builder.bindText
import com.intellij.ui.dsl.builder.columns
import com.intellij.ui.dsl.builder.panel
import com.intellij.ui.layout.ComponentPredicate
import com.jetbrains.cidr.cpp.cmake.workspace.CMakeWorkspace
import com.jetbrains.cidr.cpp.execution.CMakeAppRunConfiguration
import kotlin.reflect.KMutableProperty0
import org.utbot.cpp.clion.plugin.UTBot
import org.utbot.cpp.clion.plugin.listeners.UTBotSettingsChangedListener
Expand All @@ -33,9 +35,12 @@ import org.utbot.cpp.clion.plugin.utils.addValidation
import org.utbot.cpp.clion.plugin.utils.commandLineEditor
import org.utbot.cpp.clion.plugin.utils.isLookLikeUnixPath
import org.utbot.cpp.clion.plugin.utils.isValidHostName
import org.utbot.cpp.clion.plugin.utils.nioPath
import org.utbot.cpp.clion.plugin.utils.projectLifetimeDisposable
import org.utbot.cpp.clion.plugin.utils.stripLeadingSlashes
import java.awt.Dimension
import java.awt.event.ItemEvent
import java.io.File

class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
"Project Settings to Generate Tests"
Expand Down Expand Up @@ -108,7 +113,7 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
).bindIntValue(projectIndependentSettings::port).applyToComponent {
portComponent = this
}
}.rowComment(UTBot.message("deployment.utbot.port.description"))
}

row(UTBot.message("settings.project.serverName")) {
textField().bindText(projectIndependentSettings::serverName).applyToComponent {
Expand All @@ -118,7 +123,7 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
UTBot.message("validation.invalid.host")
) { it.text.isValidHostName() }
)
}.rowComment(UTBot.message("deployment.utbot.host.description"))
}

row(UTBot.message("settings.project.remotePath")) {
textField().bindText(settings::remotePath).columns(COLUMNS_LARGE).validateInput(
Expand All @@ -130,26 +135,25 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(

private fun Panel.createPathsSettings() {
row(UTBot.message("settings.project.buildDir")) {
val validator: (JBTextField) -> Boolean = {
it.text.isNotEmpty()
}
textField().bindText(settings::buildDirRelativePath).columns(COLUMNS_LARGE)
.validateInput(ValidationCondition(UTBot.message("validation.not.empty")) { it.text.isNotEmpty() })
}.rowComment(UTBot.message("paths.buildDirectory.description"))

row(UTBot.message("settings.project.target")) {
textField().bindText(
getter = {
settings.uiTargetPath
},
setter = {}
).columns(COLUMNS_LARGE).enabled(false)
}.rowComment(UTBot.message("paths.target.description"))
.validateInput(ValidationCondition(UTBot.message("validation.not.empty")) {
it.text.stripLeadingSlashes().isNotEmpty()
})
.validateInput(ValidationCondition(UTBot.message("validation.different.from.cmake.build.dir")) { jTextField ->
val buildDirRelative = jTextField.text.stripLeadingSlashes()
val cmakeBuildDirectories: List<File>? =
CMakeAppRunConfiguration.getSelectedRunConfiguration(myProject)
?.cMakeTarget?.buildConfigurations?.map {
it.configurationGenerationDir
}
cmakeBuildDirectories?.all { it.toPath() != myProject.nioPath.resolve(buildDirRelative) } ?: true
})
}.contextHelp(UTBot.message("paths.buildDirectory.description"))

row(UTBot.message("settings.project.testsDir")) {
textField().bindText(settings::testDirRelativePath).columns(COLUMNS_LARGE)
.validateInput(ValidationCondition(UTBot.message("validation.not.empty")) { it.text.isNotEmpty() })
}.rowComment(UTBot.message("paths.testsDir.description"))
}.contextHelp(UTBot.message("paths.testsDir.description"))

row {
val pane = UTBotProjectViewPaneForSettings(myProject)
Expand All @@ -169,32 +173,34 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
{ settings.cmakeOptions },
{ settings.cmakeOptions = it }
)
}.rowComment(UTBot.message("paths.cmakeOptions.description"))
}
}

private fun Panel.createGeneratorSettings() {
data class CheckBoxInfo(
val boolProperty: KMutableProperty0<Boolean>,
val title: String,
val description: String
val description: String? = null
) {
fun add(panel: Panel) {
panel.row {
checkBox(title).bindSelected(boolProperty)
}.rowComment(description)
}.apply {
description?.let {
rowComment(it)
}
}
}
}

val checkBoxes = listOf(
CheckBoxInfo(
settings::useStubs,
UTBot.message("stubs.useStubs.title"),
UTBot.message("stubs.useStubs.description")
),
CheckBoxInfo(
settings::verbose,
UTBot.message("testsGeneration.verboseFormatting.title"),
UTBot.message("testsGeneration.verboseFormatting.description")
),
CheckBoxInfo(
settings::useDeterministicSearcher,
Expand All @@ -204,7 +210,6 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
CheckBoxInfo(
settings::generateForStaticFunctions,
UTBot.message("testsGeneration.generateForStaticFunctions.title"),
UTBot.message("testsGeneration.generateForStaticFunctions.description")
)
)
checkBoxes.forEach {
Expand All @@ -218,7 +223,7 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
).bindIntValue(settings::timeoutPerFunction).applyToComponent {
maximumSize = TEXT_FIELD_MAX_SIZE
}
}.rowComment(UTBot.message("advanced.timeoutPerFunction.description"))
}

row(UTBot.message("advanced.timeoutPerTest.title")) {
spinner(
Expand All @@ -227,7 +232,7 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable(
).bindIntValue(settings::timeoutPerTest).applyToComponent {
maximumSize = TEXT_FIELD_MAX_SIZE
}
}.rowComment(UTBot.message("advanced.timeoutPerTest.description"))
}
}

override fun isModified(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class UTBotProjectStoredSettings(val project: Project) : PersistentStateComponen
var useStubs: Boolean = true,
var useDeterministicSearcher: Boolean = false,
var verbose: Boolean = false,
var timeoutPerFunction: Int = 0,
var timeoutPerFunction: Int = 30,
var timeoutPerTest: Int = 0,
var isPluginEnabled: Boolean = false
) {
Expand Down
11 changes: 6 additions & 5 deletions clion-plugin/src/main/resources/messages/UTBot.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ settings.project.target.wrong.conversion=Possibly wrong target path. Could not c
settings.project.testsDir=Tests directory:
settings.project.testsDir.wrong=Wrong relative path to tests directory
settings.project.sourcePaths.wrong.conversion=Possibly wrong source path. Could not create relative path from remote path or this path
settings.project.remotePath=Path to project on remote machine
settings.project.serverName=Server host name
settings.project.port=Server port
settings.project.cmakeOptions=Cmake options
settings.project.remotePath=Path to project on remote machine:
settings.project.serverName=Server host name:
settings.project.port=Server port:
settings.project.cmakeOptions=Cmake options:
settings.enabled.title=Plugin enabled:
actions.reconnect=Reconnect to Server
requests.assertion.description.progress=Generating for assertion...
Expand All @@ -37,7 +37,7 @@ paths.buildDirectory.description=Relative path to build directory with compile_c
paths.target.description=Path to target which is passed to UTBot. You can select targets in UTBot targets tool window
paths.cmakeOptions.description=Options passed to CMake command. <a href=https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#cmake-options>Learn more</a>
paths.testsDir.description=Relative path to directory in which tests will be generated. <a href=https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#tests-directory>Learn more</a>
paths.sourceDirectories.description=Mark/unmark directory as source by double-clicking or using actions from context menu. You can also unmark or mark directories in UTBot project view pane. <a href=https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#source-directories>Learn more</a>
paths.sourceDirectories.description=Mark/unmark directory as source by using actions from context menu. You can also unmark or mark directories in UTBot project view pane. <a href=https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#source-directories>Learn more</a>
testsGeneration.verboseFormatting.description=If set to true, tests will be formatted in more detailed form. <a href=https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#verbose-formatting>Learn more</a>
testsGeneration.verboseFormatting.title=Use verbose mode
testsGeneration.generateForStaticFunctions.title=Generate for static functions
Expand Down Expand Up @@ -103,6 +103,7 @@ show.settings.text=Go to Settings
validation.not.empty=Please fill in this field
validation.not.unix.path=This path must be an absolute unix path!
validation.invalid.host=Invalid host name
validation.different.from.cmake.build.dir=Must be different from CMake build directory
toolwindow.targets.displayName=Targets
toolwindow.logs.displayName=Logs
actions.verbose.menu.enabled=Verbose Mode: On
Expand Down