Search in sources :

Example 6 with MouseWheelEvent

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();
        }
    });
}
Also used : EditorMouseEvent(com.intellij.openapi.editor.event.EditorMouseEvent) MouseEvent(java.awt.event.MouseEvent) MouseWheelEvent(java.awt.event.MouseWheelEvent) MouseAdapter(java.awt.event.MouseAdapter)

Example 7 with MouseWheelEvent

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

Aggregations

MouseWheelEvent (java.awt.event.MouseWheelEvent)7 MouseEvent (java.awt.event.MouseEvent)6 MouseWheelListener (java.awt.event.MouseWheelListener)4 MouseAdapter (java.awt.event.MouseAdapter)3 GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JButton (javax.swing.JButton)2 JLabel (javax.swing.JLabel)2 DarculaLookAndFeelInfo (com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo)1 EditorMouseEvent (com.intellij.openapi.editor.event.EditorMouseEvent)1 com.mxgraph.swing.mxGraphOutline (com.mxgraph.swing.mxGraphOutline)1 BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 Frame (java.awt.Frame)1 Point (java.awt.Point)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1