use of java.awt.event.MouseWheelEvent in project intellij-community by JetBrains.
the class ConsoleViewImpl method initConsoleEditor.
private void initConsoleEditor() {
myEditor = createConsoleEditor();
registerConsoleEditorActions();
myEditor.getScrollPane().setBorder(null);
MouseAdapter mouseListener = new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
updateStickToEndState(true);
}
@Override
public void mouseDragged(MouseEvent e) {
updateStickToEndState(false);
}
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
updateStickToEndState(false);
}
};
myEditor.getScrollPane().addMouseWheelListener(mouseListener);
myEditor.getScrollPane().getVerticalScrollBar().addMouseListener(mouseListener);
myEditor.getScrollPane().getVerticalScrollBar().addMouseMotionListener(mouseListener);
myHyperlinks = new EditorHyperlinkSupport(myEditor, myProject);
myEditor.getScrollingModel().addVisibleAreaListener(e -> {
Rectangle oldR = e.getOldRectangle();
if (oldR != null && oldR.height <= 0 && e.getNewRectangle().height > 0 && isStickingToEnd()) {
scrollToEnd();
}
});
}
use of java.awt.event.MouseWheelEvent 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;
}
Aggregations