-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an action to open the dev tools for the JCEF preview
- Loading branch information
Showing
5 changed files
with
83 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/org/asciidoc/intellij/actions/OpenDevtoolsAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.asciidoc.intellij.actions; | ||
|
||
import com.intellij.openapi.actionSystem.AnActionEvent; | ||
import org.asciidoc.intellij.actions.asciidoc.AsciiDocAction; | ||
import org.asciidoc.intellij.editor.AsciiDocHtmlPanel; | ||
import org.asciidoc.intellij.editor.AsciiDocSplitEditor; | ||
import org.asciidoc.intellij.editor.jcef.AsciiDocJCEFHtmlPanel; | ||
import org.asciidoc.intellij.ui.SplitFileEditor; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class OpenDevtoolsAction extends AsciiDocAction { | ||
@Override | ||
public void actionPerformed(@NotNull AnActionEvent event) { | ||
SplitFileEditor<?, ?> fileEditor = AsciiDocActionUtil.findSplitEditor(event); | ||
if (fileEditor instanceof AsciiDocSplitEditor) { | ||
AsciiDocHtmlPanel panel = ((AsciiDocSplitEditor) fileEditor).getSecondEditor().getPanel(); | ||
if (panel instanceof AsciiDocJCEFHtmlPanel) { | ||
((AsciiDocJCEFHtmlPanel) panel).openDevtools(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void update(@NotNull AnActionEvent event) { | ||
boolean visible = false; | ||
SplitFileEditor<?, ?> fileEditor = AsciiDocActionUtil.findSplitEditor(event); | ||
if (fileEditor instanceof AsciiDocSplitEditor) { | ||
AsciiDocHtmlPanel panel = ((AsciiDocSplitEditor) fileEditor).getSecondEditor().getPanel(); | ||
if (panel instanceof AsciiDocJCEFHtmlPanel) { | ||
visible = true; | ||
} | ||
} | ||
event.getPresentation().setVisible(visible); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters