Skip to content

Commit

Permalink
Merge branch 'master' into release/1.2.0-2024.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ellizio committed Aug 16, 2024
2 parents 81f45fb + 3007db5 commit 42f7f80
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,32 @@

---


## 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)
![](/img/step2.png)
![](/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)
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 19 additions & 0 deletions src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/BaseDialog.kt
Original file line number Diff line number Diff line change
@@ -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<Container, Boolean> = 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 }
}
}
}
27 changes: 20 additions & 7 deletions src/rider/main/kotlin/ru/ellizio/odatacliui/dialogs/CliDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -76,6 +75,8 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) {
row {
cell(tabbedPane)
}.resizableRow()
}.apply {
registerPanelValidators(this)
}
}

Expand Down Expand Up @@ -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")
Expand All @@ -134,14 +141,20 @@ 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)
.comment(UiBundle.text("cli.upper-camel-case.comment"), Int.MAX_VALUE)
.bindSelected(model.upperCamelCase)
}
}.apply {
registerValidators(disposable)
registerPanelValidators(this)
generationTabPanel = this
}

Expand All @@ -163,7 +176,7 @@ class CliDialog(private val model: CliDialogModel) : DialogWrapper(false) {
.validationOnApply(CliDialogValidators.proxyValidator())
}
}.apply {
registerValidators(disposable)
registerPanelValidators(this)
requestTabPanel = this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand All @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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? = {
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/rider/main/resources/UiBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42f7f80

Please sign in to comment.