[Java] move ScrollToEnd Action of Compilation Charts to intellij.java.compiler.charts.xml

IDEA-353070

GitOrigin-RevId: b31bd27e96b9e2e74c64d7873d423418a0dab19b
This commit is contained in:
Georgii Ustinov
2024-09-18 06:25:24 +00:00
committed by intellij-monorepo-bot
parent cc61ed361e
commit 1533c62747
5 changed files with 12 additions and 17 deletions
@@ -20,6 +20,8 @@
icon="AllIcons.Graph.ZoomOut" use-shortcut-of="CollapseAll"/>
<action id="CompilationChartsZoomInAction" class="com.intellij.java.compiler.charts.ui.ActionPanel$ZoomInAction"
icon="AllIcons.Graph.ZoomIn" use-shortcut-of="ExpandAll"/>
<action id="CompilationChartsScrollToEndAction" class="com.intellij.java.compiler.charts.ui.ActionPanel$ScrollToEndAction"
icon="AllIcons.Actions.Forward"/>
</group>
</actions>
</idea-plugin>
@@ -7,8 +7,8 @@ charts.test.type=Test
charts.memory.type=Memory
charts.cpu.type=CPU
charts.search.results={0} results
charts.scroll.to.end.action.title=Scroll to End
charts.scroll.to.end.action.description=Scrolls to end in compilation charts
action.CompilationChartsScrollToEndAction.text=Scroll to End
action.CompilationChartsScrollToEndAction.description=Scrolls to end in compilation charts
action.CompilationChartsZoomInAction.text=Zoom In Compilation Charts
action.CompilationChartsZoomInAction.description=Increases zoom of compilation charts
action.CompilationChartsZoomOutAction.text=Zoom Out Compilation Charts
@@ -19,9 +19,6 @@ class CompilationChartsViewModel(val lifetime: Lifetime) {
val statistics: Statistics = Statistics()
val cpuMemory: RdProperty<CpuMemoryStatisticsType> = RdProperty(CpuMemoryStatisticsType.MEMORY)
val filter: RdProperty<Filter> = RdProperty(Filter())
val scrollToEndEvent: RdProperty<ScrollToEndEvent> = RdProperty(ScrollToEndEvent())
fun requestScrollToEnd() = scrollToEndEvent.set(ScrollToEndEvent())
fun started(values: List<StartTarget>) {
values.forEach { value ->
@@ -112,8 +109,6 @@ class CompilationChartsViewModel(val lifetime: Lifetime) {
}
}
class ScrollToEndEvent
enum class CpuMemoryStatisticsType {
CPU {
override fun max(statistics: Statistics): Long = 100
@@ -109,7 +109,6 @@ class ActionPanel(private val project: Project, private val vm: CompilationChart
val actionGroup = ActionManager.getInstance().getAction("CompilationChartsActionGroup") as? DefaultActionGroup
if (actionGroup != null) {
actionGroup.addAction(CompilationChartsStatsActionHolder(vm), Constraints.FIRST)
actionGroup.addAction(ScrollToEndAction(vm), Constraints.LAST)
val toolbar = ActionManager.getInstance().createActionToolbar(COMPILATION_CHARTS_TOOLBAR_NAME, actionGroup, true).apply {
targetComponent = this@ActionPanel
}
@@ -139,11 +138,10 @@ class ActionPanel(private val project: Project, private val vm: CompilationChart
}
}
private class ScrollToEndAction(private val vm: CompilationChartsViewModel) : DumbAwareAction(
CompilationChartsBundle.message("charts.scroll.to.end.action.title"),
CompilationChartsBundle.message("charts.scroll.to.end.action.description"),
AllIcons.Actions.Forward) {
override fun actionPerformed(e: AnActionEvent) = vm.requestScrollToEnd()
internal class ScrollToEndAction : CompilationChartsActionBase() {
override fun actionPerformed(e: AnActionEvent) {
e.getData(COMPILATION_CHARTS_VIEW_KEY)?.scrollToEnd()
}
}
internal abstract class CompilationChartsActionBase: DumbAwareAction() {
@@ -82,16 +82,16 @@ class CompilationChartsView(project: Project, private val vm: CompilationChartsV
diagrams.cpuMemory = filter
diagrams.smartDraw(true, false)
}
vm.scrollToEndEvent.advise(vm.lifetime) { _ ->
rightAdhesionScrollBarListener.scrollToEnd()
}
}
override fun uiDataSnapshot(sink: DataSink) {
sink[COMPILATION_CHARTS_VIEW_KEY] = this
}
internal fun scrollToEnd() {
rightAdhesionScrollBarListener.scrollToEnd()
}
internal fun zoom(zoomType: ZoomEvent) {
when (zoomType) {
ZoomEvent.IN -> rightAdhesionScrollBarListener.increase()