Skip to content

Commit

Permalink
base dialog ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ellizio committed Mar 15, 2024
1 parent fb6c700 commit cabeb11
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.jetbrains.rider.plugins.odatacliui

import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.ui.DialogWrapper
import com.intellij.ui.dsl.builder.AlignX
import com.intellij.ui.dsl.builder.panel
import javax.swing.JComponent

class CliDialog : DialogWrapper(false) {
init {
title = "OData Cli UI"
init()
}

override fun createCenterPanel(): JComponent {
return panel {
groupRowsRange("Information") {
row("OData Cli Version:") {
label("todo")
.comment("Not installed? Follow <a href='https://learn.microsoft.com/en-us/odata/odatacli/getting-started#install'>instruction</a>")
}
}
groupRowsRange("Arguments") {
row("--metadata-uri") {
textFieldWithBrowseButton(fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFileDescriptor("xml"))
.align(AlignX.FILL)
.comment("The URI of the metadata document. The value must be set to a valid service document URI or a local file path")
}
row("--custom-headers") {
textField()
.align(AlignX.FILL)
.comment("Headers that will get sent along with the request when fetching the metadata document from the service. Format: Header1:HeaderValue, Header2:HeaderValue")
}
row("--proxy") {
textField()
.align(AlignX.FILL)
.comment("Proxy settings. Format: domain\\\\user:password@SERVER:PORT")
}
row("--file-name") {
textField()
.align(AlignX.FILL)
.comment("The name of the generated file. If not provided, then the default name 'Reference.cs' is used")
}
row("--namespace-prefix") {
textField()
.align(AlignX.FILL)
.comment("The namespace of the client code generated. Example: NorthWindService.Client or it could be a name related to the OData endpoint that you are generating code for")
}
row("--excluded-operation-imports") {
textField()
.align(AlignX.FILL)
.comment("Comma-separated list of the names of operation imports to exclude from the generated code. Example: ExcludedOperationImport1, ExcludedOperationImport2")
}
row("--excluded-bound-operations") {
textField()
.align(AlignX.FILL)
.comment("Comma-separated list of the names of bound operations to exclude from the generated code. Example: BoundOperation1, BoundOperation2")
}
row("--excluded-schema-types") {
textField()
.align(AlignX.FILL)
.comment("Comma-separated list of the names of entity types to exclude from the generated code. Example: EntityType1, EntityType2, EntityType3")
}
row {
checkBox("--upper-camel-case")
.align(AlignX.FILL)
.comment("Transforms names (class and property names) to upper camel-case so that to better conform with C# naming conventions")
}
row {
checkBox("--internal")
.align(AlignX.FILL)
.comment("Applies the internal class modifier on generated classes instead of public thereby making them invisible outside the assembly")
}
row {
checkBox("--multiple-files")
.align(AlignX.FILL)
.comment("Split the generated classes into separate files instead of generating all the code in a single file")
}
row {
checkBox("--ignore-unexpected-elements")
.align(AlignX.FILL)
.comment("This flag indicates whether to ignore unexpected elements and attributes in the metadata document and generate the client code if any")
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.jetbrains.rider.plugins.odatacliui

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.rd.util.launchOnUi
import com.intellij.openapi.rd.util.lifetime
import com.jetbrains.rider.plugins.odatacliui.extensions.entityForAction
import com.jetbrains.rider.projectView.workspace.isProject
import com.jetbrains.rider.projectView.workspace.isWebReferenceFolder

class OpenCliDialogAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
project.lifetime.launchOnUi {
val dialog = CliDialog()
dialog.show()
}
}

override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

override fun update(e: AnActionEvent) {
val entity = e.entityForAction
e.presentation.isVisible = entity.isWebReferenceFolder() || entity.isProject()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.jetbrains.rider.plugins.odatacliui.extensions

import com.intellij.openapi.actionSystem.AnActionEvent
import com.jetbrains.rider.projectView.ProjectEntityView
import com.jetbrains.rider.projectView.actions.getProjectElementForAction
import com.jetbrains.rider.projectView.workspace.ProjectModelEntity

val AnActionEvent.entityForAction: ProjectModelEntity
get() = (dataContext.getProjectElementForAction() as ProjectEntityView).entity
9 changes: 8 additions & 1 deletion src/rider/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<id>com.jetbrains.rider.plugins.odatacliui</id>
<name>ODataCliUi</name>
<version>_PLACEHOLDER_</version>
<vendor url="https://project-url">Author</vendor>
<vendor url="https://project-url">ellizio</vendor>
<idea-version since-build="_PLACEHOLDER_" until-build="_PLACEHOLDER_" />
<depends>com.intellij.modules.rider</depends>

Expand All @@ -12,4 +12,11 @@
]]>
</description>

<actions>
<action class="com.jetbrains.rider.plugins.odatacliui.OpenCliDialogAction" id="odatacliui.OpenCliDialogAction" text="OData Reference...">
<add-to-group group-id="SolutionViewAddGroup.SpecialSection" anchor="after" relative-to-action="AddWebReferenceAction" />
<add-to-group group-id="SolutionExplorerPopupMenuForReferenceFolder" anchor="after" relative-to-action="AddWebReferenceAction" />
</action>
</actions>

</idea-plugin>

0 comments on commit cabeb11

Please sign in to comment.