From 8a9b5d62e752a9bbda800dfd44411c38e7cc6746 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 29 Jul 2024 19:37:53 -0700 Subject: [PATCH] Added Scroll to Top/End actions to the console --- .../console/BldConsoleActionScrollEnd.java | 32 +++++++++++++++++++ .../console/BldConsoleActionScrollTop.java | 32 +++++++++++++++++++ .../bld/idea/console/BldConsoleViewPanel.java | 2 ++ 3 files changed, 66 insertions(+) create mode 100644 src/main/java/rife/bld/idea/console/BldConsoleActionScrollEnd.java create mode 100644 src/main/java/rife/bld/idea/console/BldConsoleActionScrollTop.java diff --git a/src/main/java/rife/bld/idea/console/BldConsoleActionScrollEnd.java b/src/main/java/rife/bld/idea/console/BldConsoleActionScrollEnd.java new file mode 100644 index 0000000..1066cea --- /dev/null +++ b/src/main/java/rife/bld/idea/console/BldConsoleActionScrollEnd.java @@ -0,0 +1,32 @@ +/* + * Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)) + * Licensed under the Apache License, Version 2.0 (the "License") + */ +package rife.bld.idea.console; + +import com.intellij.icons.AllIcons; +import com.intellij.idea.ActionsBundle; +import com.intellij.openapi.actionSystem.ActionUpdateThread; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.project.DumbAwareAction; +import org.jetbrains.annotations.NotNull; + +class BldConsoleActionScrollEnd extends DumbAwareAction { + public BldConsoleActionScrollEnd() { + super(ActionsBundle.message("action.EditorConsoleScrollToTheEnd.text"), null, + AllIcons.RunConfigurations.Scroll_down); + } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + + @Override + public void actionPerformed(AnActionEvent e) { + var project = e.getProject(); + if (project != null) { + BldConsoleManager.getConsole(project).requestScrollingToEnd(); + } + } +} diff --git a/src/main/java/rife/bld/idea/console/BldConsoleActionScrollTop.java b/src/main/java/rife/bld/idea/console/BldConsoleActionScrollTop.java new file mode 100644 index 0000000..e24fc86 --- /dev/null +++ b/src/main/java/rife/bld/idea/console/BldConsoleActionScrollTop.java @@ -0,0 +1,32 @@ +/* + * Copyright 2024 Erik C. Thauvin (https://erik.thauvin.net/)) + * Licensed under the Apache License, Version 2.0 (the "License") + */ +package rife.bld.idea.console; + +import com.intellij.icons.AllIcons; +import com.intellij.idea.ActionsBundle; +import com.intellij.openapi.actionSystem.ActionUpdateThread; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.project.DumbAwareAction; +import org.jetbrains.annotations.NotNull; + +class BldConsoleActionScrollTop extends DumbAwareAction { + public BldConsoleActionScrollTop() { + super(ActionsBundle.message("action.EditorScrollTop.text"), null, + AllIcons.RunConfigurations.Scroll_up); + } + + @Override + public @NotNull ActionUpdateThread getActionUpdateThread() { + return ActionUpdateThread.BGT; + } + + @Override + public void actionPerformed(AnActionEvent e) { + var project = e.getProject(); + if (project != null) { + BldConsoleManager.getConsole(project).scrollTo(0); + } + } +} diff --git a/src/main/java/rife/bld/idea/console/BldConsoleViewPanel.java b/src/main/java/rife/bld/idea/console/BldConsoleViewPanel.java index ff40c3d..0fea0a0 100644 --- a/src/main/java/rife/bld/idea/console/BldConsoleViewPanel.java +++ b/src/main/java/rife/bld/idea/console/BldConsoleViewPanel.java @@ -87,6 +87,8 @@ public void setRowHeight(int i) { private JPanel createToolbarPanel() { var group = new DefaultActionGroup(); group.add(new BldConsoleActionStop()); + group.add(new BldConsoleActionScrollTop()); + group.add(new BldConsoleActionScrollEnd()); group.add(new BldConsoleActionClear()); var toolbar_panel = new JPanel(new BorderLayout());