diff --git a/src/main/java/com/darksheep/sheepnote/ui/swing/toolWindow/NoteListToolWindowFactory.java b/src/main/java/com/darksheep/sheepnote/ui/swing/toolWindow/NoteListToolWindowFactory.java index 864d39c..6747664 100644 --- a/src/main/java/com/darksheep/sheepnote/ui/swing/toolWindow/NoteListToolWindowFactory.java +++ b/src/main/java/com/darksheep/sheepnote/ui/swing/toolWindow/NoteListToolWindowFactory.java @@ -7,6 +7,7 @@ import com.darksheep.sheepnote.ui.swing.editor.utils.EditorHelper; import com.darksheep.sheepnote.ui.swing.toolWindow.divider.CustomSplitPaneUI; import com.darksheep.sheepnote.ui.web.brower.JBCefBrowserSingleton; +import com.darksheep.sheepnote.ui.web.container.BrowserPanel; import com.darksheep.sheepnote.utils.LocalHtmlHelper; import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -96,12 +97,16 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo Content mainContent = contentFactory.createContent(mainPanel, "NoteList", false); // 第二个 Content,包含 FlowchartPanel - Content flowchartContent = contentFactory.createContent(flowchartPanel, "NoteFlowchart", false); + Content flowchartContent = contentFactory.createContent(jbCefBrowser.getComponent(), "NoteFlowchart", false); + + //第三个 浏览器 + Content browserContent = contentFactory.createContent(new BrowserPanel(), "Browser", false); toolWindow.getContentManager().addContent(mainContent); toolWindow.getContentManager().addContent(flowchartContent); + toolWindow.getContentManager().addContent(browserContent); toolWindow.getContentManager().setSelectedContent(mainContent); } @NotNull diff --git a/src/main/java/com/darksheep/sheepnote/ui/web/container/BrowserPanel.java b/src/main/java/com/darksheep/sheepnote/ui/web/container/BrowserPanel.java new file mode 100644 index 0000000..9dcd4dd --- /dev/null +++ b/src/main/java/com/darksheep/sheepnote/ui/web/container/BrowserPanel.java @@ -0,0 +1,31 @@ +package com.darksheep.sheepnote.ui.web.container; + +import com.darksheep.sheepnote.ui.web.container.actions.GBackAction; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.ActionPlaces; +import com.intellij.openapi.actionSystem.ActionToolbar; +import com.intellij.openapi.actionSystem.DefaultActionGroup; +import com.intellij.openapi.ui.SimpleToolWindowPanel; +import com.intellij.ui.jcef.JBCefBrowser; + +public class BrowserPanel extends SimpleToolWindowPanel { + + private JBCefBrowser jbCefBrowser; + + public BrowserPanel() { + super(true, true); + jbCefBrowser = new JBCefBrowser("bing.com"); + ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.CONTEXT_TOOLBAR, buildToolbar(), true); + setContent(jbCefBrowser.getComponent()); + setToolbar(actionToolbar.getComponent()); + + } + private DefaultActionGroup buildToolbar() { + DefaultActionGroup toolbar = new DefaultActionGroup(); + GBackAction backButton = new GBackAction(jbCefBrowser, AllIcons.Actions.Back); + toolbar.add(backButton); + return toolbar; + } + +} diff --git a/src/main/java/com/darksheep/sheepnote/ui/web/container/actions/GBackAction.java b/src/main/java/com/darksheep/sheepnote/ui/web/container/actions/GBackAction.java new file mode 100644 index 0000000..f1e1327 --- /dev/null +++ b/src/main/java/com/darksheep/sheepnote/ui/web/container/actions/GBackAction.java @@ -0,0 +1,31 @@ +package com.darksheep.sheepnote.ui.web.container.actions; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.project.DumbAware; +import com.intellij.ui.jcef.JBCefBrowser; + +import javax.swing.*; + +public class GBackAction extends AnAction implements DumbAware { + private JBCefBrowser jbCefBrowser; + + public GBackAction(JBCefBrowser jbCefBrowser, Icon icon) { + super(icon); + this.jbCefBrowser = jbCefBrowser; + } + + @Override + public void update(AnActionEvent e) { + if (!jbCefBrowser.getCefBrowser().canGoBack()) { + e.getPresentation().setEnabled(false); + return; + } + super.update(e); + } + + @Override + public void actionPerformed(AnActionEvent e) { + jbCefBrowser.getCefBrowser().canGoBack(); + } +}