This repository has been archived by the owner on Feb 4, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from d-wojciechowski/dev
Release 0.7.1
- Loading branch information
Showing
24 changed files
with
267 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/pl/dwojciechowski/execution/RemoteCommandConfigType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package pl.dwojciechowski.execution | ||
|
||
import com.intellij.execution.configurations.ConfigurationFactory | ||
import com.intellij.execution.configurations.ConfigurationTypeBase | ||
import pl.dwojciechowski.execution.command.RemoteCommandFactory | ||
import pl.dwojciechowski.ui.PluginIcons | ||
|
||
class RemoteCommandConfigType : ConfigurationTypeBase( | ||
id = "PLMCompanion.RemoteCommand", | ||
displayName = "Remote Command", | ||
description = "Remote Command execution configuration", | ||
icon = PluginIcons.PLUGIN | ||
) { | ||
|
||
override fun getConfigurationFactories(): Array<ConfigurationFactory> { | ||
return arrayOf(RemoteCommandFactory(this)) | ||
} | ||
|
||
} |
5 changes: 2 additions & 3 deletions
5
...owski/run/factory/RemoteCommandFactory.kt → ...execution/command/RemoteCommandFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/kotlin/pl/dwojciechowski/execution/command/RemoteCommandProcessHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package pl.dwojciechowski.execution.command | ||
|
||
import com.intellij.execution.Executor | ||
import com.intellij.execution.process.NopProcessHandler | ||
import com.intellij.execution.runners.ExecutionEnvironment | ||
import com.intellij.openapi.application.ApplicationManager | ||
import pl.dwojciechowski.model.CommandBean | ||
import pl.dwojciechowski.service.IdeControlService | ||
import pl.dwojciechowski.service.RemoteService | ||
import java.time.LocalTime | ||
|
||
class RemoteCommandProcessHandler( | ||
environment: ExecutionEnvironment, | ||
private val executor: Executor? | ||
) : NopProcessHandler() { | ||
|
||
private val remoteServiceManager = RemoteService.getInstance(environment.project) | ||
private val ideControlService = IdeControlService.getInstance(environment.project) | ||
private val runProfile = environment.runProfile as RemoteCommandRunConfig | ||
|
||
private val command = CommandBean(runProfile.settings.command, runProfile.settings.command, LocalTime.now()) | ||
|
||
override fun destroyProcess() { | ||
super.destroyProcess() | ||
switchToSelectedTab() | ||
} | ||
|
||
override fun startNotify() { | ||
super.startNotify() | ||
ApplicationManager.getApplication().invokeLater { | ||
executeCommand() | ||
} | ||
} | ||
|
||
private fun executeCommand() { | ||
if (runProfile.settings.async.not()) { | ||
ideControlService.switchToCommandTab() | ||
remoteServiceManager.executeStreaming(command) { | ||
destroyProcess() | ||
} | ||
} else { | ||
remoteServiceManager.executeStreaming(command) | ||
destroyProcess() | ||
} | ||
} | ||
|
||
private fun switchToSelectedTab() { | ||
ideControlService.getToolWindow(executor?.toolWindowId) | ||
?.let { toolWindow -> | ||
toolWindow.contentManager.selectedContent?.let { | ||
toolWindow.contentManager.removeContent(it, true) | ||
ideControlService.switchToCommandTab() | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/pl/dwojciechowski/execution/command/RemoteCommandSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package pl.dwojciechowski.execution.command | ||
|
||
data class RemoteCommandSettings( | ||
var command: String = "", | ||
var async: Boolean = true | ||
) : Cloneable { | ||
|
||
companion object { | ||
const val TAG = "RemoteCommandSettings" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/kotlin/pl/dwojciechowski/execution/command/RemoteCommandState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package pl.dwojciechowski.execution.command | ||
|
||
import com.intellij.execution.DefaultExecutionResult | ||
import com.intellij.execution.ExecutionException | ||
import com.intellij.execution.ExecutionResult | ||
import com.intellij.execution.Executor | ||
import com.intellij.execution.configurations.RunProfileState | ||
import com.intellij.execution.runners.ExecutionEnvironment | ||
import com.intellij.execution.runners.ProgramRunner | ||
|
||
class RemoteCommandState(private val environment: ExecutionEnvironment) : RunProfileState { | ||
|
||
private val runProfile = environment.runProfile as RemoteCommandRunConfig | ||
|
||
override fun execute(executor: Executor?, runner: ProgramRunner<*>): ExecutionResult? { | ||
if (runProfile.settings.command.isEmpty()) { | ||
throw ExecutionException("Could not execute command, no command provided") | ||
} | ||
return DefaultExecutionResult(RemoteCommandProcessHandler(environment, executor)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/main/kotlin/pl/dwojciechowski/run/RemoteCommandConfigurationType.kt
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
src/main/kotlin/pl/dwojciechowski/run/state/RemoteCommandState.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.