diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b77dd0..911e9ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.2.0] +- Added missing odata-cli options +- Fixed tabs validation + ## [1.1.0] - odata-cli 0.3.1 support - UI improvements and fixes diff --git a/README.md b/README.md index 4fda33b..3a184ab 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,23 @@ --- + ## Installation 1. Install plugin from [Marketplace](https://plugins.jetbrains.com/plugin/24117-odata-cli-ui) or download from [Releases page](https://github.com/ellizio/odata-cli-ui/releases) and install manually 2. Install the latest version of the OData CLI tool with the command `dotnet tool install -g Microsoft.OData.Cli` + +## Compatibility + +| Plugin version | odata-cli version | +|----------------|-------------------| +| 1.2.0 | 0.3.1, 0.3.0 | +| 1.1.0 | 0.3.1, 0.3.0 | +| 1.0.1 | 0.2.1 | +| 1.0.0 | 0.2.1 | + + ## Usage ![](/img/step1.png) @@ -22,7 +34,8 @@ ![](/img/step3.png) ![](/img/step4.png) + ## Additional References -- [Changelog](https://github.com/ellizio/odata-cli-ui/blob/master/CHANGELOG.md) +- [Changelog](CHANGELOG.md) - [OData CLI](https://learn.microsoft.com/en-us/odata/odatacli/getting-started) diff --git a/build.gradle b/build.gradle index 47db2f7..6f01eb0 100644 --- a/build.gradle +++ b/build.gradle @@ -212,7 +212,10 @@ runPluginVerifier { "RD-2024.1", "RD-2024.1.1", "RD-2024.1.2", - "RD-2024.1.3" + "RD-2024.1.3", + "RD-2024.1.4", + "RD-2024.1.5", + "RD-2024.1.6" ] } diff --git a/gradle.properties b/gradle.properties index e73ca56..7943777 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ DotnetPluginId=ReSharperPlugin.ODataCliUi DotnetSolution=ReSharperPlugin.ODataCliUi.sln RiderPluginId=ru.ellizio.odatacliui -PluginVersion=1.1.0-2024.1 +PluginVersion=1.2.0-2024.1 BuildConfiguration=Debug diff --git a/src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/BaseDialog.kt b/src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/BaseDialog.kt new file mode 100644 index 0000000..e904f94 --- /dev/null +++ b/src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/BaseDialog.kt @@ -0,0 +1,19 @@ +package ru.ellizio.odatacliui.dialogs + +import com.intellij.openapi.ui.DialogPanel +import com.intellij.openapi.ui.DialogWrapper +import java.awt.Container + +abstract class BaseDialog(canBeParent: Boolean) : DialogWrapper(canBeParent) { + private val panelsStates: MutableMap = mutableMapOf() + + protected fun registerPanelValidators(panel: DialogPanel) { + if (panelsStates.put(panel, true) != null) + throw Exception("Panel validators are already registered") + + panel.registerValidators(disposable) { validations -> + panelsStates[panel] = validations.all { it.value.okEnabled } + isOKActionEnabled = panelsStates.all { it.value } + } + } +} \ No newline at end of file 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 9c1dac7..ff308f3 100644 --- a/src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/CliDialog.kt +++ b/src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/CliDialog.kt @@ -2,7 +2,6 @@ package ru.ellizio.odatacliui.dialogs import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory import com.intellij.openapi.ui.DialogPanel -import com.intellij.openapi.ui.DialogWrapper import com.intellij.ui.components.JBTabbedPane import com.intellij.ui.dsl.builder.* import ru.ellizio.odatacliui.Constants @@ -13,7 +12,7 @@ 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) { +class CliDialog(private val model: CliDialogModel) : BaseDialog(false) { private lateinit var generationTabPanel: DialogPanel private lateinit var requestTabPanel: DialogPanel @@ -76,6 +75,8 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) { row { cell(tabbedPane) }.resizableRow() + }.apply { + registerPanelValidators(this) } } @@ -117,10 +118,16 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) { .bindText(model.excludedSchemaTypes) } row { - checkBox("--internal") + checkBox("--enable-internal") .align(AlignX.FILL) - .comment(UiBundle.text("cli.internal.comment"), Int.MAX_VALUE) - .bindSelected(model.internal) + .comment(UiBundle.text("cli.enable-internal.comment"), Int.MAX_VALUE) + .bindSelected(model.enableInternal) + } + row { + checkBox("--omit-versioning-info") + .align(AlignX.FILL) + .comment(UiBundle.text("cli.omit-versioning-info.comment"), Int.MAX_VALUE) + .bindSelected(model.omitVersioningInfo) } row { checkBox("--multiple-files") @@ -134,6 +141,12 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) { .comment(UiBundle.text("cli.ignore-unexpected-elements.comment"), Int.MAX_VALUE) .bindSelected(model.ignoreUnexpectedElements) } + row { + checkBox("--enable-tracking") + .align(AlignX.FILL) + .comment(UiBundle.text("cli.enable-tracking.comment"), Int.MAX_VALUE) + .bindSelected(model.enableTracking) + } row { checkBox("--upper-camel-case") .align(AlignX.FILL) @@ -141,7 +154,7 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) { .bindSelected(model.upperCamelCase) } }.apply { - registerValidators(disposable) + registerPanelValidators(this) generationTabPanel = this } @@ -163,7 +176,7 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) { .validationOnApply(CliDialogValidators.proxyValidator()) } }.apply { - registerValidators(disposable) + registerPanelValidators(this) requestTabPanel = this } } \ No newline at end of file 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 2acbc82..2e42e43 100644 --- a/src/rider/main/kotlin/ru/ellizio/odatacliui/models/CliDialogModel.kt +++ b/src/rider/main/kotlin/ru/ellizio/odatacliui/models/CliDialogModel.kt @@ -40,9 +40,11 @@ class CliDialogModel(project: Project, private val actionMetadata: ActionMetadat val excludedOperationImports = MutableProperty("") val excludedBoundOperations = MutableProperty("") val excludedSchemaTypes = MutableProperty("") - val internal = MutableProperty(false) + val enableInternal = MutableProperty(false) + val omitVersioningInfo = MutableProperty(false) val multipleFiles = MutableProperty(false) val ignoreUnexpectedElements = MutableProperty(false) + val enableTracking = MutableProperty(false) val upperCamelCase = MutableProperty(true) val customHeaders = MutableProperty("") @@ -65,10 +67,12 @@ class CliDialogModel(project: Project, private val actionMetadata: ActionMetadat .withParameter("--excluded-operation-imports", excludedOperationImports.get()) .withParameter("--excluded-bound-operations", excludedBoundOperations.get()) .withParameter("--excluded-schema-types", excludedSchemaTypes.get()) - .withFlag("--upper-camel-case", upperCamelCase.get()) - .withFlag("--internal", internal.get()) + .withFlag("--enable-internal", enableInternal.get()) + .withFlag("--omit-versioning-info", omitVersioningInfo.get()) .withFlag("--multiple-files", multipleFiles.get()) .withFlag("--ignore-unexpected-elements", ignoreUnexpectedElements.get()) + .withFlag("--enable-tracking", enableTracking.get()) + .withFlag("--upper-camel-case", upperCamelCase.get()) .withParameter("--outputdir", getOutputDirectory()) .build() 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 index f157e1f..37254a3 100644 --- a/src/rider/main/kotlin/ru/ellizio/odatacliui/models/validators/CliDialogValidators.kt +++ b/src/rider/main/kotlin/ru/ellizio/odatacliui/models/validators/CliDialogValidators.kt @@ -7,6 +7,7 @@ import javax.swing.JTextField object CliDialogValidators { private val serviceNameRegex = Regex("^[0-9a-zA-Z_\\-. ]+\$") + private val namespacePrefixRegex = Regex("^[a-zA-Z]\\w*(\\.[a-zA-Z]\\w*)*\$") private val proxyRegex = Regex("^(\\w+\\\\\\w+(:\\w+)?@)?\\w+:\\d+\$") fun serviceNameValidator(): ValidationInfoBuilder.(JTextField) -> ValidationInfo? = { @@ -30,14 +31,14 @@ object CliDialogValidators { } fun namespacePrefixValidator(): ValidationInfoBuilder.(JTextField) -> ValidationInfo? = { - if (it.text.contains(' ')) - error("Namespace prefix must not contain spaces") + if (it.text.isNotEmpty() && !namespacePrefixRegex.matches(it.text)) + error("Namespace prefix must be in a valid format") else null } fun proxyValidator(): ValidationInfoBuilder.(JTextField) -> ValidationInfo? = { - if (!proxyRegex.matches(it.text)) + if (it.text.isNotEmpty() && !proxyRegex.matches(it.text)) error("Proxy must be in a valid format") else null diff --git a/src/rider/main/resources/UiBundle.properties b/src/rider/main/resources/UiBundle.properties index a11e576..aff2d93 100644 --- a/src/rider/main/resources/UiBundle.properties +++ b/src/rider/main/resources/UiBundle.properties @@ -20,9 +20,11 @@ cli.excluded-bound-operations.empty-text=Example: BoundOperation1, BoundOperatio cli.excluded-bound-operations.comment=Comma-separated list of the names of bound operations to exclude from the generated code cli.excluded-schema-types.empty-text=Example: EntityType1, EntityType2, EntityType3 cli.excluded-schema-types.comment=Comma-separated list of the names of entity types to exclude from the generated code -cli.internal.comment=Applies the internal class modifier on generated classes instead of public thereby making them invisible outside the assembly +cli.enable-internal.comment=Applies the internal class modifier on generated classes instead of public thereby making them invisible outside the assembly +cli.omit-versioning-info.comment=Omit runtime version and code generation timestamp from the generated files cli.multiple-files.comment=Split the generated classes into separate files instead of generating all the code in a single file cli.ignore-unexpected-elements.comment=This flag indicates whether to ignore unexpected elements and attributes in the metadata document and generate the client code if any +cli.enable-tracking.comment=Enable entity and property tracking 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