diff --git a/src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/CliDialog.kt b/src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/CliDialog.kt
index aec07c9..9c1dac7 100644
--- a/src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/CliDialog.kt
+++ b/src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/CliDialog.kt
@@ -10,6 +10,7 @@ import ru.ellizio.odatacliui.UiBundle
import ru.ellizio.odatacliui.extensions.emptyText
import ru.ellizio.odatacliui.extensions.humanize
import ru.ellizio.odatacliui.models.CliDialogModel
+import ru.ellizio.odatacliui.models.validators.CliDialogValidators
import javax.swing.JComponent
class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) {
@@ -61,16 +62,16 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) {
textField()
.align(AlignX.FILL)
.bindText(model.serviceName)
- .validationOnInput(model.validator.serviceNameValidation())
- .validationOnApply(model.validator.serviceNameValidation())
+ .validationOnInput(CliDialogValidators.serviceNameValidator())
+ .validationOnApply(CliDialogValidators.serviceNameValidator())
}
row(UiBundle.text("cli.metadata-source.row")) {
textFieldWithBrowseButton(fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor("xml"))
.align(AlignX.FILL)
.comment(UiBundle.text("cli.metadata-source.comment"), Int.MAX_VALUE)
.bindText(model.metadataUri)
- .validationOnInput(model.validator.metadataUriValidation())
- .validationOnApply(model.validator.metadataUriValidation())
+ .validationOnInput(CliDialogValidators.metadataUriValidator())
+ .validationOnApply(CliDialogValidators.metadataUriValidator())
}.bottomGap(BottomGap.SMALL)
row {
cell(tabbedPane)
@@ -91,8 +92,8 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) {
.align(AlignX.FILL)
.comment(UiBundle.text("cli.namespace-prefix.comment"))
.bindText(model.namespacePrefix)
- .validationOnInput(model.validator.namespacePrefixValidation())
- .validationOnApply(model.validator.namespacePrefixValidation())
+ .validationOnInput(CliDialogValidators.namespacePrefixValidator())
+ .validationOnApply(CliDialogValidators.namespacePrefixValidator())
}
row("--excluded-operation-imports") {
textField()
@@ -158,6 +159,8 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) {
.emptyText(UiBundle.text("cli.proxy.empty-text"))
.comment(UiBundle.text("cli.proxy.comment"))
.bindText(model.proxy)
+ .validationOnInput(CliDialogValidators.proxyValidator())
+ .validationOnApply(CliDialogValidators.proxyValidator())
}
}.apply {
registerValidators(disposable)
diff --git a/src/rider/main/kotlin/ru/ellizio/odatacliui/models/CliDialogModel.kt b/src/rider/main/kotlin/ru/ellizio/odatacliui/models/CliDialogModel.kt
index d73ac8e..b55c7cd 100644
--- a/src/rider/main/kotlin/ru/ellizio/odatacliui/models/CliDialogModel.kt
+++ b/src/rider/main/kotlin/ru/ellizio/odatacliui/models/CliDialogModel.kt
@@ -7,7 +7,6 @@ import com.jetbrains.rd.ide.model.protocolModel
import com.jetbrains.rider.model.dotNetActiveRuntimeModel
import ru.ellizio.odatacliui.Constants
import ru.ellizio.odatacliui.extensions.dotnetAddPackageCommand
-import ru.ellizio.odatacliui.models.validators.CliDialogModelValidator
import ru.ellizio.odatacliui.terminal.BatchCommandLine
import ru.ellizio.odatacliui.terminal.builders.BatchCommandLineBuilder
import com.jetbrains.rider.projectView.solution
@@ -19,8 +18,6 @@ private const val CONNECTED_SERVICES = "Connected Services"
private const val CSDL_NAME = "OData ServiceCsdl.xml"
class CliDialogModel(project: Project, private val actionMetadata: ActionMetadata) {
- val validator = CliDialogModelValidator()
-
val odataCliTool: DotnetToolDefinition
val dotnetCliPath: String?
diff --git a/src/rider/main/kotlin/ru/ellizio/odatacliui/models/validators/CliDialogModelValidator.kt b/src/rider/main/kotlin/ru/ellizio/odatacliui/models/validators/CliDialogModelValidator.kt
deleted file mode 100644
index dcf2686..0000000
--- a/src/rider/main/kotlin/ru/ellizio/odatacliui/models/validators/CliDialogModelValidator.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-package ru.ellizio.odatacliui.models.validators
-
-import com.intellij.openapi.ui.TextFieldWithBrowseButton
-import com.intellij.openapi.ui.ValidationInfo
-import com.intellij.ui.layout.ValidationInfoBuilder
-import javax.swing.JTextField
-
-class CliDialogModelValidator {
- fun serviceNameValidation(): ValidationInfoBuilder.(JTextField) -> ValidationInfo? = {
- if (it.text.trim().isEmpty())
- error("Service name must not be empty")
- else
- null
- }
-
- fun metadataUriValidation(): ValidationInfoBuilder.(TextFieldWithBrowseButton) -> ValidationInfo? = {
- if (it.text.trim().isEmpty())
- error("Metadata source must not be empty")
- else
- null
- }
-
- fun namespacePrefixValidation(): ValidationInfoBuilder.(JTextField) -> ValidationInfo? = {
- if (it.text.contains(' '))
- error("Namespace prefix must not contain whitespaces")
- else
- null
- }
-}
\ No newline at end of file
diff --git a/src/rider/main/kotlin/ru/ellizio/odatacliui/models/validators/CliDialogValidators.kt b/src/rider/main/kotlin/ru/ellizio/odatacliui/models/validators/CliDialogValidators.kt
new file mode 100644
index 0000000..b5f5ec0
--- /dev/null
+++ b/src/rider/main/kotlin/ru/ellizio/odatacliui/models/validators/CliDialogValidators.kt
@@ -0,0 +1,42 @@
+package ru.ellizio.odatacliui.models.validators
+
+import com.intellij.openapi.ui.TextFieldWithBrowseButton
+import com.intellij.openapi.ui.ValidationInfo
+import com.intellij.ui.layout.ValidationInfoBuilder
+import javax.swing.JTextField
+
+object CliDialogValidators {
+ private val proxyRegex = Regex("^(\\w+\\\\\\w+(:\\w+)?@)?\\w+:\\d+\$")
+
+ fun serviceNameValidator(): ValidationInfoBuilder.(JTextField) -> ValidationInfo? = {
+ if (it.text.isBlank())
+ error("Service name must not be empty")
+ else if (it.text.startsWith(' '))
+ error("Service name must not start with a space")
+ else if (it.text.endsWith(' '))
+ error("Service name must not end with a space")
+ else
+ null
+ }
+
+ fun metadataUriValidator(): ValidationInfoBuilder.(TextFieldWithBrowseButton) -> ValidationInfo? = {
+ if (it.text.isBlank())
+ error("Metadata source must not be empty")
+ else
+ null
+ }
+
+ fun namespacePrefixValidator(): ValidationInfoBuilder.(JTextField) -> ValidationInfo? = {
+ if (it.text.contains(' '))
+ error("Namespace prefix must not contain spaces")
+ else
+ null
+ }
+
+ fun proxyValidator(): ValidationInfoBuilder.(JTextField) -> ValidationInfo? = {
+ if (!proxyRegex.matches(it.text))
+ error("Proxy must be in a valid format")
+ else
+ null
+ }
+}
\ No newline at end of file
diff --git a/src/rider/main/resources/UiBundle.properties b/src/rider/main/resources/UiBundle.properties
index cc817a3..3c35c4c 100644
--- a/src/rider/main/resources/UiBundle.properties
+++ b/src/rider/main/resources/UiBundle.properties
@@ -3,11 +3,11 @@ action.odatacliui.OpenCliDialogAction.text=OData Reference\u2026
# Dialog
cli.tab.generation=Generation Arguments
-cli.tab.request=Generation Arguments
-cli.cli-version.label=OData CLI Version:
+cli.tab.request=Request Arguments
+cli.cli-version.label=OData CLI version:
cli.cli-version.label-value.not-installed=Not installed
cli.cli-version.label-value.global=Global
-cli.cli-version.comment=Not installed? Follow instruction
+cli.cli-version.comment=Not installed? Follow instructions
cli.service-name.row=Service name:
cli.metadata-source.row=Metadata source:
cli.metadata-source.comment=The URI of the metadata document. The value must be set to a valid service document URI or a local file path
@@ -26,7 +26,7 @@ cli.ignore-unexpected-elements.comment=This flag indicates whether to ignore une
cli.upper-camel-case.comment=Transforms names (class and property names) to upper camel-case so that to better conform with C# naming conventions
cli.custom-headers.empty-text=Example: Header1:HeaderValue, Header2:HeaderValue
cli.custom-headers.comment=Headers that will get sent along with the request when fetching the metadata document from the service
-cli.proxy.empty-text=Example: domain\\user:password@SERVER:PORT
+cli.proxy.empty-text=Format: SERVER:PORT or domain\\user@SERVER:PORT or domain\\user:password@SERVER:PORT
cli.proxy.comment=Proxy settings
cli.ok-action-button.tooltip.not-installed=OData CLI not installed