Search in sources :

Example 6 with DarculaLookAndFeelInfo

use of com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo in project intellij-community by JetBrains.

the class IpnbJfxUtils method createHtmlPanel.

public static JComponent createHtmlPanel(@NotNull final String source, int width) {
    final JFXPanel javafxPanel = new JFXPanel() {

        @Override
        protected void processMouseWheelEvent(MouseWheelEvent e) {
            final Container parent = getParent();
            final MouseEvent parentEvent = SwingUtilities.convertMouseEvent(this, e, parent);
            parent.dispatchEvent(parentEvent);
        }
    };
    javafxPanel.setBackground(IpnbEditorUtil.getBackground());
    Platform.runLater(() -> {
        final WebView webView = new WebView();
        webView.setContextMenuEnabled(false);
        webView.setOnDragDetected(event -> {
        });
        final WebEngine engine = webView.getEngine();
        initHyperlinkListener(engine);
        final boolean hasMath = source.contains("$");
        if (hasMath) {
            engine.setOnStatusChanged(event -> adjustHeight(webView, javafxPanel, source));
        } else {
            engine.getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
                if (newValue == Worker.State.SUCCEEDED) {
                    adjustHeight(webView, javafxPanel, source);
                }
            });
        }
        final BorderPane pane = new BorderPane(webView);
        final String prefix;
        if (hasMath) {
            prefix = String.format(ourMathJaxPrefix, width - 500, EditorColorsManager.getInstance().getGlobalScheme().getEditorFontSize());
        } else {
            prefix = String.format(ourPrefix, width - 500);
        }
        final String content = prefix + convertToHtml(source) + ourPostfix;
        engine.loadContent(content);
        final Scene scene = new Scene(pane, 0, 0);
        javafxPanel.setScene(scene);
        updateLaf(LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo, engine, javafxPanel);
    });
    return javafxPanel;
}
Also used : JFXPanel(javafx.embed.swing.JFXPanel) BorderPane(javafx.scene.layout.BorderPane) MouseEvent(java.awt.event.MouseEvent) MouseWheelEvent(java.awt.event.MouseWheelEvent) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) WebEngine(javafx.scene.web.WebEngine)

Example 7 with DarculaLookAndFeelInfo

use of com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo in project intellij-plugins by StepicOrg.

the class StudyBrowserWindow method initComponents.

private void initComponents() {
    Platform.runLater(() -> {
        pane = new StackPane();
        webComponent = new WebView();
        engine = webComponent.getEngine();
        pane.getChildren().add(webComponent);
        initHyperlinkListener();
        initConsoleListener();
        Scene scene = new Scene(pane);
        panel.setScene(scene);
        panel.setVisible(true);
        updateLaf(LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo);
    });
    add(panel, BorderLayout.CENTER);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
}
Also used : DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) WebView(javafx.scene.web.WebView) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 8 with DarculaLookAndFeelInfo

use of com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo in project intellij-plugins by StepicOrg.

the class StudyToolWindow method setText.

private void setText(@Nullable StepNode stepNode) {
    if (stepNode == null) {
        setEmptyText();
        rightPanel.setVisible(false);
        return;
    }
    browserWindow.showLoadAnimation();
    StepType stepType = stepNode.getType();
    if (stepType != VIDEO && stepType != CODE) {
        SwingUtilities.invokeLater(() -> rightPanel.setVisible(false));
    }
    boolean isTheory = stepType == VIDEO || stepType == TEXT;
    postView(stepNode, isTheory);
    StepHelper stepHelper = null;
    switch(stepType) {
        case UNKNOWN:
            stepHelper = new StepHelper(project, stepNode);
            break;
        case CODE:
            stepHelper = new CodeQuizHelper(project, stepNode);
            updateLanguageBox(stepNode);
            break;
        case TEXT:
            stepHelper = new TextTheoryHelper(project, stepNode);
            break;
        case VIDEO:
            stepHelper = new VideoTheoryHelper(project, stepNode);
            break;
        case CHOICE:
            stepHelper = new ChoiceQuizHelper(project, stepNode);
            break;
        case STRING:
            stepHelper = new StringQuizHelper(project, stepNode);
            break;
        case SORTING:
            stepHelper = new SortingQuizHelper(project, stepNode);
            break;
        case MATCHING:
            stepHelper = new MatchingQuizHelper(project, stepNode);
            break;
        case NUMBER:
            stepHelper = new NumberQuizHelper(project, stepNode);
            break;
        case DATASET:
            stepHelper = new DatasetQuizHelper(project, stepNode);
            break;
        case TABLE:
            stepHelper = new TableQuizHelper(project, stepNode);
            break;
        case FILL_BLANKS:
            stepHelper = new QuizHelper(project, stepNode);
            break;
        case MATH:
            stepHelper = new QuizHelper(project, stepNode);
            break;
        case FREE_ANSWER:
            stepHelper = new FreeAnswerQuizHelper(project, stepNode);
            break;
    }
    HashMap<String, Object> params = new HashMap<>();
    params.put("stepNode", stepHelper);
    params.put("darcula", LafManager.getInstance().getCurrentLookAndFeel() instanceof DarculaLookAndFeelInfo);
    browserWindow.loadContent("quiz/" + stepHelper.getType(), params);
}
Also used : CodeQuizHelper(org.stepik.core.courseFormat.stepHelpers.CodeQuizHelper) TableQuizHelper(org.stepik.core.courseFormat.stepHelpers.TableQuizHelper) HashMap(java.util.HashMap) StepType(org.stepik.core.courseFormat.StepType) DarculaLookAndFeelInfo(com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo) TextTheoryHelper(org.stepik.core.courseFormat.stepHelpers.TextTheoryHelper) StringQuizHelper(org.stepik.core.courseFormat.stepHelpers.StringQuizHelper) VideoTheoryHelper(org.stepik.core.courseFormat.stepHelpers.VideoTheoryHelper) SortingQuizHelper(org.stepik.core.courseFormat.stepHelpers.SortingQuizHelper) ChoiceQuizHelper(org.stepik.core.courseFormat.stepHelpers.ChoiceQuizHelper) StringQuizHelper(org.stepik.core.courseFormat.stepHelpers.StringQuizHelper) QuizHelper(org.stepik.core.courseFormat.stepHelpers.QuizHelper) DatasetQuizHelper(org.stepik.core.courseFormat.stepHelpers.DatasetQuizHelper) TableQuizHelper(org.stepik.core.courseFormat.stepHelpers.TableQuizHelper) MatchingQuizHelper(org.stepik.core.courseFormat.stepHelpers.MatchingQuizHelper) FreeAnswerQuizHelper(org.stepik.core.courseFormat.stepHelpers.FreeAnswerQuizHelper) SortingQuizHelper(org.stepik.core.courseFormat.stepHelpers.SortingQuizHelper) NumberQuizHelper(org.stepik.core.courseFormat.stepHelpers.NumberQuizHelper) CodeQuizHelper(org.stepik.core.courseFormat.stepHelpers.CodeQuizHelper) MatchingQuizHelper(org.stepik.core.courseFormat.stepHelpers.MatchingQuizHelper) NumberQuizHelper(org.stepik.core.courseFormat.stepHelpers.NumberQuizHelper) DatasetQuizHelper(org.stepik.core.courseFormat.stepHelpers.DatasetQuizHelper) StepHelper(org.stepik.core.courseFormat.stepHelpers.StepHelper) FreeAnswerQuizHelper(org.stepik.core.courseFormat.stepHelpers.FreeAnswerQuizHelper) ChoiceQuizHelper(org.stepik.core.courseFormat.stepHelpers.ChoiceQuizHelper)

Aggregations

DarculaLookAndFeelInfo (com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo)8 Scene (javafx.scene.Scene)3 WebView (javafx.scene.web.WebView)3 LafManagerImpl (com.intellij.ide.ui.laf.LafManagerImpl)2 EditorColorsScheme (com.intellij.openapi.editor.colors.EditorColorsScheme)2 HashMap (java.util.HashMap)2 StackPane (javafx.scene.layout.StackPane)2 LafManager (com.intellij.ide.ui.LafManager)1 DarculaInstaller (com.intellij.ide.ui.laf.darcula.DarculaInstaller)1 ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)1 KeymapManagerImpl (com.intellij.openapi.keymap.impl.KeymapManagerImpl)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Project (com.intellij.openapi.project.Project)1 DialogWrapper (com.intellij.openapi.ui.DialogWrapper)1 MouseEvent (java.awt.event.MouseEvent)1 MouseWheelEvent (java.awt.event.MouseWheelEvent)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 JFXPanel (javafx.embed.swing.JFXPanel)1