List of usage examples for com.intellij.openapi.actionSystem IdeActions ACTION_SHOW_ERROR_DESCRIPTION
String ACTION_SHOW_ERROR_DESCRIPTION
To view the source code for com.intellij.openapi.actionSystem IdeActions ACTION_SHOW_ERROR_DESCRIPTION.
Click Source Link
From source file:com.intellij.codeInsight.daemon.impl.actions.ShowErrorDescriptionAction.java
License:Apache License
private static void changeState() { if (Comparing.strEqual(ActionManagerEx.getInstanceEx().getPrevPreformedActionId(), IdeActions.ACTION_SHOW_ERROR_DESCRIPTION)) { shouldShowDescription = descriptionShown; } else {//from w ww . ja v a2 s . co m shouldShowDescription = false; descriptionShown = true; } }
From source file:com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.java
License:Apache License
public LocalInspectionsPass(@NotNull PsiFile file, @Nullable Document document, int startOffset, int endOffset, @NotNull TextRange priorityRange, boolean ignoreSuppressed, @NotNull HighlightInfoProcessor highlightInfoProcessor) { super(file.getProject(), document, PRESENTABLE_NAME, file, null, new TextRange(startOffset, endOffset), true, highlightInfoProcessor); myStartOffset = startOffset;//from ww w.java 2s .c o m myEndOffset = endOffset; myPriorityRange = priorityRange; myIgnoreSuppressed = ignoreSuppressed; setId(Pass.LOCAL_INSPECTIONS); final KeymapManager keymapManager = KeymapManager.getInstance(); if (keymapManager != null) { final Keymap keymap = keymapManager.getActiveKeymap(); myShortcutText = keymap == null ? "" : "(" + KeymapUtil .getShortcutsText(keymap.getShortcuts(IdeActions.ACTION_SHOW_ERROR_DESCRIPTION)) + ")"; } else { myShortcutText = ""; } InspectionProfileWrapper profileToUse = InspectionProjectProfileManagerImpl.getInstanceImpl(myProject) .getProfileWrapper(); Function<InspectionProfileWrapper, InspectionProfileWrapper> custom = file .getUserData(InspectionProfileWrapper.CUSTOMIZATION_KEY); if (custom != null) { profileToUse = custom.fun(profileToUse); } myProfileWrapper = profileToUse; assert myProfileWrapper != null; mySeverityRegistrar = ((SeverityProvider) myProfileWrapper.getInspectionProfile().getProfileManager()) .getSeverityRegistrar(); // initial guess setProgressLimit(300 * 2); }
From source file:com.intellij.codeInsight.hint.LineTooltipRenderer.java
License:Apache License
@Override public LightweightHint show(@NotNull final Editor editor, @NotNull final Point p, final boolean alignToRight, @NotNull final TooltipGroup group, @NotNull final HintHint hintHint) { if (myText == null) return null; //setup text/* w w w. ja va 2 s . c o m*/ myText = myText.replaceAll(String.valueOf(UIUtil.MNEMONIC), ""); final boolean expanded = myCurrentWidth > 0 && dressDescription(editor); final HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl(); final JComponent contentComponent = editor.getContentComponent(); final JComponent editorComponent = editor.getComponent(); if (!editorComponent.isShowing()) return null; final JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane(); final JEditorPane pane = IdeTooltipManager.initPane(new Html(myText).setKeepFont(true), hintHint, layeredPane); hintHint.setContentActive(isActiveHtml(myText)); if (!hintHint.isAwtTooltip()) { correctLocation(editor, pane, p, alignToRight, expanded, myCurrentWidth); } final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane); scrollPane.setBorder(null); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setOpaque(hintHint.isOpaqueAllowed()); scrollPane.getViewport().setOpaque(hintHint.isOpaqueAllowed()); scrollPane.setBackground(hintHint.getTextBackground()); scrollPane.getViewport().setBackground(hintHint.getTextBackground()); scrollPane.setViewportBorder(null); final Ref<AnAction> actionRef = new Ref<AnAction>(); final LightweightHint hint = new LightweightHint(scrollPane) { @Override public void hide() { onHide(pane); super.hide(); final AnAction action = actionRef.get(); if (action != null) { action.unregisterCustomShortcutSet(contentComponent); } } }; actionRef.set(new AnAction() { // an action to expand description when tooltip was shown after mouse move; need to unregister from editor component { registerCustomShortcutSet(new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap() .getShortcuts(IdeActions.ACTION_SHOW_ERROR_DESCRIPTION)), contentComponent); } @Override public void actionPerformed(final AnActionEvent e) { expand(hint, editor, p, pane, alignToRight, group, hintHint); } }); pane.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(final HyperlinkEvent e) { myActiveLink = true; if (e.getEventType() == HyperlinkEvent.EventType.EXITED) { myActiveLink = false; return; } if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { final URL url = e.getURL(); if (url != null) { BrowserUtil.browse(url); hint.hide(); return; } final String description = e.getDescription(); if (description != null && handle(description, editor)) { hint.hide(); return; } if (!expanded) { expand(hint, editor, p, pane, alignToRight, group, hintHint); } else { stripDescription(); hint.hide(); TooltipController.getInstance().showTooltip(editor, new Point(p.x - 3, p.y - 3), createRenderer(myText, 0), false, group, hintHint); } } } }); // This listener makes hint transparent for mouse events. It means that hint is closed // by MousePressed and this MousePressed goes into the underlying editor component. pane.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(final MouseEvent e) { if (!myActiveLink) { MouseEvent newMouseEvent = SwingUtilities.convertMouseEvent(e.getComponent(), e, contentComponent); hint.hide(); contentComponent.dispatchEvent(newMouseEvent); } } @Override public void mouseExited(final MouseEvent e) { if (!expanded) { hint.hide(); } } }); hintManager.showEditorHint(hint, editor, p, HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_OTHER_HINT | HintManager.HIDE_BY_SCROLLING, 0, false, hintHint); return hint; }