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;
}
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);
}
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);
}
Aggregations