/** * Long operations need to display an hourglass. * * @param comp The <code>JComponent</code> on which to apply the hour glass cursor * @param on If true, we set the cursor on the hourglass */ public static void setCursorOnWait(Component comp, boolean on) { if (on) { if (comp instanceof AbstractEditorPanel) ((AbstractEditorPanel) comp).showWaitCursor(); else comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); } else { if (comp instanceof AbstractEditorPanel) ((AbstractEditorPanel) comp).hideWaitCursor(); else comp.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }
@Override public void mouseMoved(MouseEvent e) { Component component = e.getComponent(); if (component != null) { if (getRootColumnOrNull(e) != null) { component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { component.setCursor(null); } } }
public void uninstall() { for (RangeHighlighter highlighter : myHighlighters) { highlighter.dispose(); } Component internalComponent = myHighlighterView.getContentComponent(); internalComponent.setCursor(myStoredCursor); internalComponent.removeKeyListener(myEditorKeyListener); myHighlighterView.getScrollingModel().removeVisibleAreaListener(myVisibleAreaListener); myFileEditorManager.removeFileEditorManagerListener(myFileEditorManagerListener); }
private void showHint(Info info) { if (myDisposed) return; Component internalComponent = myEditor.getContentComponent(); if (myHighlighter != null) { if (!info.isSimilarTo(myHighlighter.getStoredInfo())) { disposeHighlighter(); } else { // highlighter already set internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); return; } } if (info.isValid(myEditor.getDocument())) { myHighlighter = installHighlighterSet(info, myEditor); String text = info.getInfo(); if (text == null) return; JComponent label = HintUtil.createInformationLabel(text); final LightweightHint hint = new LightweightHint(label); final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl(); Point p = HintManagerImpl.getHintPosition(hint, myEditor, myPosition, HintManager.ABOVE); hintManager.showEditorHint( hint, myEditor, p, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0, false, HintManagerImpl.createHintHint(myEditor, p, hint, HintManager.ABOVE) .setContentActive(false)); } }
private void showHint(Info info) { if (myDisposed || myEditor.isDisposed()) return; Component internalComponent = myEditor.getContentComponent(); if (myHighlighter != null) { if (!info.isSimilarTo(myHighlighter.getStoredInfo())) { disposeHighlighter(); } else { // highlighter already set internalComponent.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); return; } } if (!info.isValid(myEditor.getDocument())) { return; } myHighlighter = installHighlighterSet(info, myEditor); DocInfo docInfo = info.getInfo(); if (docInfo.text == null) return; if (myDocumentationManager.hasActiveDockedDocWindow()) { info.showDocInfo(myDocumentationManager); } HyperlinkListener hyperlinkListener = docInfo.docProvider == null ? null : new QuickDocHyperlinkListener(docInfo.docProvider, info.myElementAtPointer); final Ref<QuickDocInfoPane> quickDocPaneRef = new Ref<QuickDocInfoPane>(); MouseListener mouseListener = new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { QuickDocInfoPane pane = quickDocPaneRef.get(); if (pane != null) { pane.mouseEntered(e); } } @Override public void mouseExited(MouseEvent e) { QuickDocInfoPane pane = quickDocPaneRef.get(); if (pane != null) { pane.mouseExited(e); } } @Override public void mouseClicked(MouseEvent e) { QuickDocInfoPane pane = quickDocPaneRef.get(); if (pane != null) { pane.mouseClicked(e); } } }; Ref<Consumer<String>> newTextConsumerRef = new Ref<Consumer<String>>(); JComponent label = HintUtil.createInformationLabel( docInfo.text, hyperlinkListener, mouseListener, newTextConsumerRef); Consumer<String> newTextConsumer = newTextConsumerRef.get(); QuickDocInfoPane quickDocPane = null; if (docInfo.documentationAnchor != null) { quickDocPane = new QuickDocInfoPane(docInfo.documentationAnchor, info.myElementAtPointer, label); quickDocPaneRef.set(quickDocPane); } JComponent hintContent = quickDocPane == null ? label : quickDocPane; final LightweightHint hint = new LightweightHint(hintContent); myHint = hint; hint.addHintListener( new HintListener() { @Override public void hintHidden(EventObject event) { myHint = null; } }); myDocAlarm.cancelAllRequests(); if (newTextConsumer != null && docInfo.docProvider != null && docInfo.documentationAnchor != null) { fulfillDocInfo( docInfo.text, docInfo.docProvider, info.myElementAtPointer, docInfo.documentationAnchor, newTextConsumer, hint); } showHint(hint); }