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.
Merge pull request #93 from onriv/feat/external_infoview_search
working on external infoview search, adding search text field
- Loading branch information
Showing
11 changed files
with
207 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package lean4ij.actions | ||
|
||
import com.intellij.icons.AllIcons | ||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.components.service | ||
import kotlinx.coroutines.launch | ||
import lean4ij.infoview.external.JcefInfoviewService | ||
import lean4ij.util.leanProjectScope | ||
|
||
class FindInExternalInfoview : AnAction() { | ||
|
||
init { | ||
templatePresentation.icon = AllIcons.Actions.Find | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val project = e.project ?: return | ||
val jcefInfoviewService = project.service<JcefInfoviewService>() | ||
jcefInfoviewService.searchTextField.isVisible = !jcefInfoviewService.searchTextField.isVisible | ||
if (!jcefInfoviewService.searchTextField.isVisible) { | ||
project.leanProjectScope.launch { | ||
jcefInfoviewService.searchTextFlow.send("") | ||
} | ||
return | ||
} | ||
project.leanProjectScope.launch { | ||
jcefInfoviewService.searchTextFlow.send(jcefInfoviewService.searchTextField.text) | ||
} | ||
|
||
} | ||
|
||
override fun getActionUpdateThread(): ActionUpdateThread { | ||
return ActionUpdateThread.BGT; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/lean4ij/actions/RestartInternalInfoview.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,32 @@ | ||
package lean4ij.actions | ||
|
||
import com.intellij.icons.AllIcons | ||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.fileEditor.FileEditorManager | ||
import lean4ij.infoview.LeanInfoviewService | ||
import lean4ij.project.LeanProjectService | ||
|
||
class RestartInternalInfoview : AnAction() { | ||
|
||
override fun getActionUpdateThread(): ActionUpdateThread { | ||
return ActionUpdateThread.BGT | ||
} | ||
|
||
init { | ||
templatePresentation.icon = AllIcons.Actions.Restart | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val project = e.project?:return | ||
FileEditorManager.getInstance(project).selectedTextEditor?.let { editor -> | ||
// TODO here in fact message up two things: | ||
// one is recreating a new editor for removing old editor's bug | ||
// the other is updating infoview manually | ||
project.service<LeanInfoviewService>().toolWindow?.restartEditor() | ||
project.service<LeanProjectService>().updateInfoviewFor(editor, true) | ||
} | ||
} | ||
} |
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
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/lean4ij/actions/ToggleAutomaticallyRefreshInternalInfoview.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,39 @@ | ||
package lean4ij.actions | ||
|
||
import com.intellij.icons.AllIcons | ||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.util.IconLoader | ||
import lean4ij.infoview.LeanInfoviewService | ||
import javax.swing.Icon | ||
|
||
/** | ||
* TODO maybe add some buttons/actions for stop/start/toggle automatically refreshing the infoview | ||
* which turn it into a manual mode | ||
*/ | ||
class ToggleAutomaticallyRefreshInternalInfoview : AnAction() { | ||
|
||
private val onIcon: Icon = IconLoader.getIcon("/icons/textAutoGenerate.svg", javaClass) | ||
private val offIcon: Icon = AllIcons.Actions.Suspend | ||
init { | ||
templatePresentation.icon = onIcon | ||
templatePresentation.disabledIcon = offIcon | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val project = e.project?:return | ||
val leanInfoviewService = project.service<LeanInfoviewService>() | ||
leanInfoviewService.automaticallyRefreshInternalInfoview = !leanInfoviewService.automaticallyRefreshInternalInfoview | ||
if (!leanInfoviewService.automaticallyRefreshInternalInfoview) { | ||
e.presentation.isEnabled = false | ||
} else { | ||
e.presentation.isEnabled = true | ||
} | ||
} | ||
|
||
override fun getActionUpdateThread(): ActionUpdateThread { | ||
return ActionUpdateThread.BGT | ||
} | ||
} |
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 |
---|---|---|
|
@@ -239,4 +239,5 @@ class ToggleInfoviewPreferred : AnAction() { | |
e.presentation.isVisible = false | ||
} | ||
} | ||
} | ||
} | ||
|
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
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
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