generated from JetBrains/intellij-platform-plugin-template
-
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.
MAK-53 IJ: Create custom tasks from tool window (#103)
and also just calling the action
- Loading branch information
Showing
10 changed files
with
345 additions
and
127 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
41 changes: 41 additions & 0 deletions
41
src/main/kotlin/co/makerflow/client/models/AddCustomTask200Response.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,41 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package co.makerflow.client.models | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
/** | ||
* | ||
* | ||
* @param `data` | ||
* @param message | ||
* @param success | ||
*/ | ||
|
||
|
||
data class AddCustomTask200Response( | ||
|
||
@field:JsonProperty("data") | ||
val `data`: CustomTask? = null, | ||
|
||
@field:JsonProperty("message") | ||
val message: kotlin.String? = null, | ||
|
||
@field:JsonProperty("success") | ||
val success: kotlin.Boolean? = null | ||
|
||
) | ||
|
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: 16 additions & 0 deletions
16
src/main/kotlin/co/makerflow/intellijplugin/actions/tasks/AddCustomTaskAction.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,16 @@ | ||
package co.makerflow.intellijplugin.actions.tasks | ||
|
||
import co.makerflow.intellijplugin.dialogs.AddTaskDialog | ||
import com.intellij.icons.AllIcons | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
|
||
class AddCustomTaskAction : AnAction( | ||
"Makerflow: Add Task", | ||
"Add a new task to the Makerflow task list", | ||
AllIcons.Actions.AddList | ||
) { | ||
override fun actionPerformed(e: AnActionEvent) { | ||
AddTaskDialog().showAndGet() | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/co/makerflow/intellijplugin/dialogs/AddTaskDialog.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,63 @@ | ||
package co.makerflow.intellijplugin.dialogs | ||
|
||
import co.makerflow.intellijplugin.services.TasksService | ||
import com.intellij.openapi.application.ApplicationManager | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.observable.properties.PropertyGraph | ||
import com.intellij.openapi.ui.DialogWrapper | ||
import com.intellij.openapi.ui.ValidationInfo | ||
import com.intellij.ui.components.JBTextField | ||
import com.intellij.ui.dsl.builder.Cell | ||
import com.intellij.ui.dsl.builder.bindText | ||
import com.intellij.ui.dsl.builder.panel | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import javax.swing.JComponent | ||
|
||
class AddTaskDialog : DialogWrapper(false) { | ||
|
||
private val propertyGraph = PropertyGraph() | ||
private val taskName = propertyGraph.property("") | ||
private lateinit var taskField: Cell<JBTextField> | ||
|
||
init { | ||
title = "Makerflow: Add Task" | ||
init() | ||
} | ||
|
||
override fun createCenterPanel(): JComponent { | ||
return panel { | ||
row { | ||
textField() | ||
.bindText(taskName) | ||
.apply { taskField = this } | ||
.comment("What do you want to accomplish?") | ||
} | ||
} | ||
} | ||
|
||
override fun getPreferredFocusedComponent(): JComponent = taskField.component | ||
|
||
override fun doValidate(): ValidationInfo? { | ||
if (taskName.get().isBlank()) { | ||
return ValidationInfo("Task cannot be empty", taskField.component) | ||
} | ||
return null | ||
} | ||
|
||
private val addTaskCoroutineScope = CoroutineScope(Dispatchers.IO) | ||
|
||
override fun doOKAction() { | ||
super.doOKAction() | ||
ApplicationManager.getApplication().invokeLater { | ||
addTaskCoroutineScope.launch { | ||
service<TasksService>().addTask(taskName.get())?.let { | ||
// send a message on the message bus so the panel knows to reload | ||
ApplicationManager.getApplication().messageBus.syncPublisher(TasksService.TASKS_ADDED_TOPIC) | ||
.taskAdded(it) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.