diff --git a/src/main/kotlin/org/move/cli/runConfigurations/aptos/CommandConfigurationHandler.kt b/src/main/kotlin/org/move/cli/runConfigurations/aptos/CommandConfigurationHandler.kt index 4c7b18e54..7142ac000 100644 --- a/src/main/kotlin/org/move/cli/runConfigurations/aptos/CommandConfigurationHandler.kt +++ b/src/main/kotlin/org/move/cli/runConfigurations/aptos/CommandConfigurationHandler.kt @@ -56,8 +56,8 @@ abstract class CommandConfigurationHandler { fun generateCommand( moveProject: MoveProject, - profileName: String, - functionCall: FunctionCall + functionCall: FunctionCall, + signerAccount: String?, ): RsResult { val functionId = functionCall.functionId(moveProject) ?: return RsResult.Err("FunctionId is null") @@ -68,13 +68,12 @@ abstract class CommandConfigurationHandler { val commandArguments = listOf( subCommand.split(' '), - listOf("--profile", profileName), + listOf("--profile", signerAccount), listOf("--function-id", functionId), typeParams, params ).flatten() val command = commandArguments.joinToString(" ") - println("Command is $command") return RsResult.Ok(command) } diff --git a/src/main/kotlin/org/move/cli/runConfigurations/aptos/FunctionCallConfigurationEditor.kt b/src/main/kotlin/org/move/cli/runConfigurations/aptos/FunctionCallConfigurationEditor.kt index a87eafe6f..8e8e91f0e 100644 --- a/src/main/kotlin/org/move/cli/runConfigurations/aptos/FunctionCallConfigurationEditor.kt +++ b/src/main/kotlin/org/move/cli/runConfigurations/aptos/FunctionCallConfigurationEditor.kt @@ -9,6 +9,7 @@ import com.intellij.openapi.ui.MessageType import com.intellij.openapi.util.Disposer import com.intellij.ui.JBColor import com.intellij.ui.dsl.builder.* +import com.intellij.xdebugger.impl.ui.TextViewer import org.move.cli.MoveProject import org.move.cli.moveProjectsService import org.move.stdext.RsResult @@ -25,7 +26,7 @@ data class MoveProjectItem(val moveProject: MoveProject) { } class FunctionCallConfigurationEditor( - private val handler: CommandConfigurationHandler, + private val commandHandler: CommandConfigurationHandler, private var moveProject: MoveProject, ) : SettingsEditor() { @@ -37,8 +38,9 @@ class FunctionCallConfigurationEditor( private val projectComboBox: ComboBox = ComboBox() private val accountTextField = JTextField() + private val rawCommandField = TextViewer("", project, true) - private val functionParametersPanel = FunctionParametersPanel(handler, moveProject) + private val functionParametersPanel = FunctionParametersPanel(commandHandler, moveProject) private val errorLabel = JLabel("") @@ -57,6 +59,8 @@ class FunctionCallConfigurationEditor( functionParametersPanel.addFunctionCallListener(object : FunctionParameterPanelListener { override fun functionParametersChanged(functionCall: FunctionCall) { editor.functionCall = functionCall + editor.rawCommandField.text = + commandHandler.generateCommand(moveProject, functionCall, signerAccount).unwrapOrNull() ?: "" } }) functionParametersPanel.setMoveProjectAndCompletionVariants(moveProject) @@ -72,7 +76,7 @@ class FunctionCallConfigurationEditor( return } - val res = handler.parseCommand(moveProject, s.command) + val res = commandHandler.parseCommand(moveProject, s.command) val (profile, functionCall) = when (res) { is RsResult.Ok -> res.ok is RsResult.Err -> { @@ -91,19 +95,8 @@ class FunctionCallConfigurationEditor( override fun applyEditorTo(s: T) { functionParametersPanel.fireChangeEvent() - val moveProject = moveProject - val profile = signerAccount - val functionCall = functionCall - + s.command = rawCommandField.text s.moveProjectFromWorkingDirectory = moveProject - if (profile != null && functionCall != null) { - s.command = - handler.generateCommand(moveProject, profile, functionCall).unwrapOrNull() ?: "" - } else { - s.command = "" - } - - println("Command in applyEditorTo = ${s.command}") } override fun disposeEditor() { @@ -117,8 +110,6 @@ class FunctionCallConfigurationEditor( row { cell(editorPanel) .align(AlignX.FILL + AlignY.FILL) -// .verticalAlign(VerticalAlign.FILL) -// .horizontalAlign(HorizontalAlign.FILL) } } return DumbService.getInstance(project).wrapGently(outerPanel, this) @@ -130,7 +121,6 @@ class FunctionCallConfigurationEditor( row("Project") { cell(projectComboBox) .align(AlignX.FILL) -// .horizontalAlign(HorizontalAlign.FILL) .columns(COLUMNS_LARGE) .whenItemSelectedFromUi { moveProject = it.moveProject @@ -140,7 +130,6 @@ class FunctionCallConfigurationEditor( row("Account") { cell(accountTextField) .align(AlignX.FILL) -// .horizontalAlign(HorizontalAlign.FILL) .whenTextChangedFromUi { signerAccount = it } @@ -149,8 +138,11 @@ class FunctionCallConfigurationEditor( row { cell(functionParametersPanel) .align(AlignX.FILL + AlignY.FILL) -// .verticalAlign(VerticalAlign.FILL) -// .horizontalAlign(HorizontalAlign.FILL) + } + separator() + row("Raw") { + cell(rawCommandField) + .align(AlignX.FILL) } } editorPanel.registerValidators(this) diff --git a/src/main/kotlin/org/move/cli/runConfigurations/aptos/FunctionParametersPanel.kt b/src/main/kotlin/org/move/cli/runConfigurations/aptos/FunctionParametersPanel.kt index cca7983d0..02d0a1650 100644 --- a/src/main/kotlin/org/move/cli/runConfigurations/aptos/FunctionParametersPanel.kt +++ b/src/main/kotlin/org/move/cli/runConfigurations/aptos/FunctionParametersPanel.kt @@ -70,7 +70,7 @@ class FunctionParametersPanel( private lateinit var valueParams: MutableMap private val functionItemField = CompletionTextField(project, "", emptyList()) - private val functionApplyButton = JButton("Select function") + private val functionApplyButton = JButton("Select and refresh UI") private val functionValidator: ComponentValidator diff --git a/src/test/kotlin/org/move/cli/runConfigurations/CommandConfigurationHandlerTest.kt b/src/test/kotlin/org/move/cli/runConfigurations/CommandConfigurationHandlerTest.kt index 55ad12277..eb887e3b3 100644 --- a/src/test/kotlin/org/move/cli/runConfigurations/CommandConfigurationHandlerTest.kt +++ b/src/test/kotlin/org/move/cli/runConfigurations/CommandConfigurationHandlerTest.kt @@ -79,7 +79,7 @@ profiles: check(profile == expectedProfile) { "Unexpected profile $profile" } - val generatedCommand = handler.generateCommand(moveProject, profile, functionCall).unwrap() + val generatedCommand = handler.generateCommand(moveProject, functionCall, profile).unwrap() check(command == generatedCommand) { "Commands are not equal. \n" + "Original: $command\n" +