Skip to content

Commit

Permalink
Moved console toolbar to the right, added clear action
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Jul 20, 2024
1 parent d318eca commit 7551ad0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
28 changes: 23 additions & 5 deletions src/main/java/rife/bld/idea/console/BldConsoleViewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected void setAutoScrollMode(boolean state) {
scroll_pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
message_panel.add(console.getComponent(), BorderLayout.CENTER);

add(createToolbarPanel(), BorderLayout.WEST);
add(createToolbarPanel(), BorderLayout.EAST);

add(message_panel, BorderLayout.CENTER);

Expand Down Expand Up @@ -120,17 +120,35 @@ public void update(AnActionEvent event) {
}
}

private JPanel createToolbarPanel() {
var action = new StopAction();
private static class ClearAction extends DumbAwareAction {
public ClearAction() {
super(IdeBundle.message("terminal.action.ClearBuffer.text"), null, AllIcons.Actions.GC);
}

@Override
public void actionPerformed(AnActionEvent e) {
var project = e.getProject();
if (project != null) {
BldConsoleManager.getConsole(project).clear();
}
}

@Override
public @NotNull ActionUpdateThread getActionUpdateThread() {
return ActionUpdateThread.BGT;
}
}

private JPanel createToolbarPanel() {
var group = new DefaultActionGroup();
group.add(action);
group.add(new StopAction());
group.add(new ClearAction());

var toolbar_panel = new JPanel(new BorderLayout());
var action_manager = ActionManager.getInstance();
var left_toolbar = action_manager.createActionToolbar(BldConstants.BLD_CONSOLE_TOOLBAR, group, false);
left_toolbar.setTargetComponent(this);
toolbar_panel.add(left_toolbar.getComponent(), BorderLayout.WEST);
toolbar_panel.add(left_toolbar.getComponent(), BorderLayout.EAST);

return toolbar_panel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import icons.BldIcons;
import org.jetbrains.annotations.NotNull;
import rife.bld.idea.execution.BldExecution;
import rife.bld.idea.utils.BldBundle;
Expand Down

0 comments on commit 7551ad0

Please sign in to comment.