Skip to content

Commit

Permalink
增加滚动至底部按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
MemoryZy committed Dec 19, 2024
1 parent 2bb4f74 commit 7acc2fc
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package cn.memoryzy.json.action.toolwindow;

import cn.memoryzy.json.bundle.JsonAssistantBundle;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.actions.ScrollToTheEndToolbarAction;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
import icons.JsonAssistantIcons;
import org.jetbrains.annotations.NotNull;

/**
Expand All @@ -10,8 +14,17 @@
*/
public class ScrollToTheEndAction extends ScrollToTheEndToolbarAction {

public ScrollToTheEndAction(@NotNull Editor editor) {
private final Editor editor;
private final SimpleToolWindowPanel simpleToolWindowPanel;

public ScrollToTheEndAction(@NotNull Editor editor, SimpleToolWindowPanel simpleToolWindowPanel) {
super(editor);
this.editor = editor;
this.simpleToolWindowPanel = simpleToolWindowPanel;
Presentation presentation = getTemplatePresentation();
presentation.setText(JsonAssistantBundle.messageOnSystem("action.scroll.to.end.text"));
presentation.setDescription(JsonAssistantBundle.messageOnSystem("action.scroll.to.end.description"));
presentation.setIcon(JsonAssistantIcons.ToolWindow.SCROLL_DOWN);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ public JComponent createToolbar(SimpleToolWindowPanel simpleToolWindowPanel) {
actionGroup.add(new ClearEditorAction(editor, simpleToolWindowPanel));
actionGroup.add(Separator.create());
actionGroup.add(new ToggleUseSoftWrapsAction(editor, simpleToolWindowPanel));
actionGroup.add(new ScrollToTheEndAction(editor, simpleToolWindowPanel));

ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.TOOLBAR, actionGroup, false);
return toolbar.getComponent();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/icons/JsonAssistantIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public static class ToolWindow {
public static final Icon MAGIC = load("/icons/toolwindow/magic.svg");
public static final Icon EYE_OFF = load("/icons/toolwindow/eye_off.svg");
public static final Icon SOFT_WRAP = load("/icons/toolwindow/softWrap.svg");
public static final Icon SCROLL_DOWN = load("/icons/toolwindow/scrollDown.svg");
}

public static Icon load(String iconPath) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/icons/toolwindow/scrollDown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main/resources/messages/JsonAssistantBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,6 @@ action.close.query.card.text=Close Query View
action.toggle.editor.card.description=Switch the view to the editor (Json Assistant)
action.toggle.softWraps.text=Soft-Wrap
action.toggle.softWraps.description=Toggle using soft wraps in current editor (Json Assistant)
action.scroll.to.end.text=Scroll to End
action.scroll.to.end.description=Scroll to End (Json Assistant)
2 changes: 2 additions & 0 deletions src/main/resources/messages/JsonAssistantBundle_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,6 @@ action.close.query.card.text=\u5173\u95ed\u67e5\u8be2\u89c6\u56fe
action.toggle.editor.card.description=\u5c06\u89c6\u56fe\u5207\u6362\u5230\u7f16\u8f91\u5668 (Json Assistant)
action.toggle.softWraps.text=\u8f6f\u6362\u884c
action.toggle.softWraps.description=\u6587\u5b57\u5728\u4e00\u884c\u5df2\u6ee1\u540e\u8f6c\u5230\u65b0\u884c\uff0c\u4f7f\u6bcf\u884c\u90fd\u53ef\u5728\u89c6\u7a97\u8303\u56f4\u770b\u5230\uff0c\u65e0\u9700\u6c34\u5e73\u6eda\u52a8 (Json Assistant)
action.scroll.to.end.text=\u6eda\u52a8\u81f3\u672b\u5c3e
action.scroll.to.end.description=\u6eda\u52a8\u81f3\u672b\u5c3e (Json Assistant)

0 comments on commit 7acc2fc

Please sign in to comment.