com.intellij.util.ui.UIUtil Java Examples
The following examples show how to use
com.intellij.util.ui.UIUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TreeUiTest.java From consulo with Apache License 2.0 | 6 votes |
private void buildSiblings(final Node node, final int start, final int end, @Nullable final Runnable eachRunnable, @javax.annotation.Nullable final Runnable endRunnable) throws InvocationTargetException, InterruptedException { UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { for (int i = start; i <= end; i++) { Node eachFile = node.addChild("File " + i); myAutoExpand.add(eachFile.getElement()); eachFile.addChild("message 1 for " + i); eachFile.addChild("message 2 for " + i); if (eachRunnable != null) { eachRunnable.run(); } } if (endRunnable != null) { endRunnable.run(); } } }); }
Example #2
Source File: AbstractGotoSEContributor.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override public JComponent createCustomComponent(@Nonnull Presentation presentation, @Nonnull String place) { JComponent component = new ActionButtonWithText(this, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); UIUtil.putClientProperty(component, MnemonicHelper.MNEMONIC_CHECKER, keyCode -> KeyEvent.getExtendedKeyCodeForChar(TOGGLE) == keyCode || KeyEvent.getExtendedKeyCodeForChar(CHOOSE) == keyCode); MnemonicHelper.registerMnemonicAction(component, CHOOSE); InputMap map = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); int mask = MnemonicHelper.getFocusAcceleratorKeyMask(); map.put(KeyStroke.getKeyStroke(TOGGLE, mask, false), TOGGLE_ACTION_NAME); component.getActionMap().put(TOGGLE_ACTION_NAME, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { // mimic AnAction event invocation to trigger myEverywhereAutoSet=false logic DataContext dataContext = DataManager.getInstance().getDataContext(component); KeyEvent inputEvent = new KeyEvent(component, KeyEvent.KEY_PRESSED, e.getWhen(), MnemonicHelper.getFocusAcceleratorKeyMask(), KeyEvent.getExtendedKeyCodeForChar(TOGGLE), TOGGLE); AnActionEvent event = AnActionEvent.createFromAnAction(ScopeChooserAction.this, inputEvent, ActionPlaces.TOOLBAR, dataContext); ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); actionManager.fireBeforeActionPerformed(ScopeChooserAction.this, dataContext, event); onProjectScopeToggled(); actionManager.fireAfterActionPerformed(ScopeChooserAction.this, dataContext, event); } }); return component; }
Example #3
Source File: NewProjectPanel.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull @Override protected JComponent createLeftComponent(@Nonnull Disposable parentDisposable) { NewModuleContext context = new NewModuleContext(); NewModuleBuilder.EP_NAME.composite().setupContext(context); myTree = new Tree(new AsyncTreeModel(new StructureTreeModel<>(new NewProjectTreeStructure(context), parentDisposable), parentDisposable)); myTree.setFont(UIUtil.getFont(UIUtil.FontSize.BIGGER, null)); myTree.setOpaque(false); myTree.setBackground(SwingUIDecorator.get(SwingUIDecorator::getSidebarColor)); myTree.setRootVisible(false); myTree.setRowHeight(JBUI.scale(24)); TreeUtil.expandAll(myTree); return ScrollPaneFactory.createScrollPane(myTree, true); }
Example #4
Source File: SdkUtil.java From intellij with Apache License 2.0 | 6 votes |
/** * Check if sdk is not null and have path to expected files (android.jar and res/). If it does not * have expected content, this sdk will be removed from jdktable. * * @param sdk sdk to check * @return true if sdk is valid */ public static boolean checkSdkAndRemoveIfInvalid(@Nullable Sdk sdk) { if (sdk == null) { return false; } else if (containsJarAndRes(sdk)) { return true; } else { ProjectJdkTable jdkTable = ProjectJdkTable.getInstance(); logger.info( String.format( "Some classes of Sdk %s is missing. Trying to remove and reinstall it.", sdk.getName())); EventLoggingService.getInstance().logEvent(SdkUtil.class, "Invalid SDK"); Application application = ApplicationManager.getApplication(); if (application.isDispatchThread()) { WriteAction.run(() -> jdkTable.removeJdk(sdk)); } else { UIUtil.invokeAndWaitIfNeeded( (Runnable) () -> WriteAction.run(() -> jdkTable.removeJdk(sdk))); } return false; } }
Example #5
Source File: HideableDecorator.java From consulo with Apache License 2.0 | 6 votes |
private void registerMnemonic() { final int mnemonicIndex = UIUtil.getDisplayMnemonicIndex(getTitle()); if (mnemonicIndex != -1) { myPanel.getActionMap().put("Collapse/Expand on mnemonic", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (myOn) { off(); } else { on(); } } }); final Character mnemonicCharacter = UIUtil.removeMnemonic(getTitle()).toUpperCase().charAt(mnemonicIndex); myPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(mnemonicCharacter, InputEvent.ALT_MASK, false), "Collapse/Expand on mnemonic"); } }
Example #6
Source File: ImageLoader.java From consulo with Apache License 2.0 | 6 votes |
/** * Loads an image of available resolution (1x, 2x, ...) and scales to address the provided scale context. * Then wraps the image with {@link JBHiDPIScaledImage} if necessary. */ @Nullable public static Image loadFromUrl(@Nonnull URL url, final boolean allowFloatScaling, boolean useCache, Supplier<ImageFilter>[] filters, final JBUI.ScaleContext ctx) { // We can't check all 3rd party plugins and convince the authors to add @2x icons. // In IDE-managed HiDPI mode with scale > 1.0 we scale images manually. return ImageDescList.create(url.toString(), null, UIUtil.isUnderDarcula(), allowFloatScaling, ctx).load(ImageConverterChain.create(). withFilter(filters). with(new ImageConverter() { @Override public Image convert(Image source, ImageDesc desc) { if (source != null && desc.type != SVG) { double scale = adjustScaleFactor(allowFloatScaling, ctx.getScale(PIX_SCALE)); if (desc.scale > 1) scale /= desc.scale; // compensate the image original scale source = scaleImage(source, scale); } return source; } }). withHiDPI(ctx), useCache); }
Example #7
Source File: DialogWrapperPeerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override public void update(AnActionEvent e) { Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); e.getPresentation().setEnabled(false); if (focusOwner instanceof JComponent && SpeedSearchBase.hasActiveSpeedSearch((JComponent)focusOwner)) { return; } if (StackingPopupDispatcher.getInstance().isPopupFocused()) return; JTree tree = UIUtil.getParentOfType(JTree.class, focusOwner); JTable table = UIUtil.getParentOfType(JTable.class, focusOwner); if (tree != null || table != null) { if (hasNoEditingTreesOrTablesUpward(focusOwner)) { e.getPresentation().setEnabled(true); } } }
Example #8
Source File: DarculaEditorTabsUI.java From consulo with Apache License 2.0 | 6 votes |
@Override public void doPaintInactiveImpl(Graphics2D g2d, Rectangle effectiveBounds, int x, int y, int w, int h, Color tabColor, int row, int column, boolean vertical) { if (tabColor != null) { g2d.setColor(tabColor); g2d.fillRect(x, y, w, h); } else { g2d.setPaint(UIUtil.getControlColor()); g2d.fillRect(x, y, w, h); } g2d.setColor(Gray._0.withAlpha(10)); g2d.drawRect(x, y, w - 1, h - 1); }
Example #9
Source File: CommanderPanel.java From consulo with Apache License 2.0 | 6 votes |
public final void setActive(final boolean active) { myActive = active; if (active) { myTitlePanel.setBackground(DARK_BLUE); myTitlePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, DARK_BLUE_BRIGHTER, DARK_BLUE_DARKER)); myParentTitle.setForeground(Color.white); } else { final Color color = UIUtil.getPanelBackground(); LOG.assertTrue(color != null); myTitlePanel.setBackground(color); myTitlePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, color.brighter(), color.darker())); myParentTitle.setForeground(JBColor.foreground()); } final int[] selectedIndices = myList.getSelectedIndices(); if (selectedIndices.length == 0 && myList.getModel().getSize() > 0) { myList.setSelectedIndex(0); if (!myList.hasFocus()) { IdeFocusManager.getGlobalInstance().doForceFocusWhenFocusSettlesDown(myList); } } else if (myList.getModel().getSize() > 0) { // need this to generate SelectionChanged events so that listeners, added by Commander, will be notified myList.setSelectedIndices(selectedIndices); } }
Example #10
Source File: TestTreeView.java From consulo with Apache License 2.0 | 6 votes |
private static void paintRowData(Tree tree, String duration, Rectangle bounds, Graphics2D g, boolean isSelected, boolean hasFocus) { final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.setFont(tree.getFont().deriveFont(Font.PLAIN, UIUtil.getFontSize(UIUtil.FontSize.SMALL))); final FontMetrics metrics = tree.getFontMetrics(g.getFont()); int totalWidth = metrics.stringWidth(duration) + 2; int x = bounds.x + bounds.width - totalWidth; g.setColor(isSelected ? UIUtil.getTreeSelectionBackground(hasFocus) : UIUtil.getTreeBackground()); final int leftOffset = 5; g.fillRect(x - leftOffset, bounds.y, totalWidth + leftOffset, bounds.height); g.translate(0, bounds.y - 1); if (isSelected) { if (!hasFocus && UIUtil.isUnderAquaBasedLookAndFeel()) { g.setColor(UIUtil.getTreeForeground()); } else { g.setColor(UIUtil.getTreeSelectionForeground()); } } else { g.setColor(new JBColor(0x808080, 0x808080)); } g.drawString(duration, x, SimpleColoredComponent.getTextBaseLine(tree.getFontMetrics(tree.getFont()), bounds.height) + 1); g.translate(0, -bounds.y + 1); config.restore(); }
Example #11
Source File: DesktopEditorAnalyzeStatusPanel.java From consulo with Apache License 2.0 | 6 votes |
private InspectionPopupManager() { myContent.setOpaque(true); myContent.setBackground(UIUtil.getToolTipBackground()); myPopupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(myContent, null). setCancelOnClickOutside(true). setCancelCallback(() -> analyzerStatus == null || analyzerStatus.getController().canClosePopup()); myAncestorListener = new AncestorListenerAdapter() { @Override public void ancestorMoved(AncestorEvent event) { hidePopup(); } }; myPopupListener = new JBPopupListener() { @Override public void onClosed(@Nonnull LightweightWindowEvent event) { if (analyzerStatus != null) { analyzerStatus.getController().onClosePopup(); } myEditor.getComponent().removeAncestorListener(myAncestorListener); } }; }
Example #12
Source File: MoreAction.java From consulo with Apache License 2.0 | 6 votes |
protected MoreAction(final String name) { myPanel = new JPanel(); final BoxLayout layout = new BoxLayout(myPanel, BoxLayout.X_AXIS); myPanel.setLayout(layout); myLoadMoreBtn = new JButton(name); myLoadMoreBtn.setMargin(new Insets(2, 2, 2, 2)); myLoadMoreBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { MoreAction.this.actionPerformed(null); } }); myPanel.add(myLoadMoreBtn); myLabel = new JLabel("Loading..."); myLabel.setForeground(UIUtil.getInactiveTextColor()); myLabel.setBorder(BorderFactory.createEmptyBorder(1, 3, 1, 1)); myPanel.add(myLabel); }
Example #13
Source File: FlutterPerformanceView.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void updateForEmptyContent(ToolWindow toolWindow) { // There's a possible race here where the tool window gets disposed while we're displaying contents. if (toolWindow.isDisposed()) { return; } toolWindow.setIcon(FlutterIcons.Flutter_13); // Display a 'No running applications' message. final ContentManager contentManager = toolWindow.getContentManager(); final JPanel panel = new JPanel(new BorderLayout()); final JBLabel label = new JBLabel("No running applications", SwingConstants.CENTER); label.setForeground(UIUtil.getLabelDisabledForeground()); panel.add(label, BorderLayout.CENTER); emptyContent = contentManager.getFactory().createContent(panel, null, false); contentManager.addContent(emptyContent); }
Example #14
Source File: ExternalChangesAndRefreshingTest.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void tearDown() throws Exception { if (getName().equals("testRefreshingAsynchronously")) { // this methods waits for another thread to finish, that leads // to deadlock in swing-thread. Therefore we have to run this test // outside of swing-thread UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { try { ExternalChangesAndRefreshingTest.super.tearDown(); } catch (Exception e) { throw new RuntimeException(e); } } }); } else { super.tearDown(); } }
Example #15
Source File: PopupLocationTracker.java From consulo with Apache License 2.0 | 6 votes |
public static boolean canRectangleBeUsed(@Nonnull Component parent, @Nonnull Rectangle desiredScreenBounds, @Nullable ScreenAreaConsumer excludedConsumer) { if (!Registry.is("ide.use.screen.area.tracker", false)) { return true; } Window window = UIUtil.getWindow(parent); if (window != null) { for (ScreenAreaConsumer consumer : ourAreaConsumers) { if (consumer == excludedConsumer) continue; if (window == consumer.getUnderlyingWindow()) { Rectangle area = consumer.getConsumedScreenBounds(); if (area.intersects(desiredScreenBounds)) { return false; } } } } return true; }
Example #16
Source File: MnemonicHelper.java From consulo with Apache License 2.0 | 6 votes |
public static boolean hasMnemonic(@Nullable Component component, int keyCode) { if (component instanceof AbstractButton) { AbstractButton button = (AbstractButton)component; if (button instanceof JBOptionButton) { return ((JBOptionButton)button).isOkToProcessDefaultMnemonics() || button.getMnemonic() == keyCode; } else { return button.getMnemonic() == keyCode; } } if (component instanceof JLabel) { return ((JLabel)component).getDisplayedMnemonic() == keyCode; } IntPredicate checker = UIUtil.getClientProperty(component, MNEMONIC_CHECKER); return checker != null && checker.test(keyCode); }
Example #17
Source File: DiagnosticsTreeCellRenderer.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void appendFragmentsForSpeedSearch(@NotNull JComponent speedSearchEnabledComponent, @NotNull String text, @NotNull SimpleTextAttributes attributes, boolean selected, @NotNull MultiIconSimpleColoredComponent simpleColoredComponent) { final SpeedSearchSupply speedSearch = SpeedSearchSupply.getSupply(speedSearchEnabledComponent); if (speedSearch != null) { final Iterable<TextRange> fragments = speedSearch.matchingFragments(text); if (fragments != null) { final Color fg = attributes.getFgColor(); final Color bg = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground(); final int style = attributes.getStyle(); final SimpleTextAttributes plain = new SimpleTextAttributes(style, fg); final SimpleTextAttributes highlighted = new SimpleTextAttributes(bg, fg, null, style | SimpleTextAttributes.STYLE_SEARCH_MATCH); appendColoredFragments(simpleColoredComponent, text, fragments, plain, highlighted); return; } } simpleColoredComponent.append(text, attributes); }
Example #18
Source File: WrappingAndBracesPanel.java From consulo with Apache License 2.0 | 6 votes |
@Nullable @Override protected JComponent getCustomValueRenderer(@Nonnull String optionName, @Nonnull Object value) { if (CodeStyleSoftMarginsPresentation.OPTION_NAME.equals(optionName)) { JLabel softMarginsLabel = new JLabel(getSoftMarginsString(castToIntList(value))); UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, softMarginsLabel); return softMarginsLabel; } else if ("WRAP_ON_TYPING".equals(optionName)) { if (value.equals(ApplicationBundle.message("wrapping.wrap.on.typing.default"))) { JLabel wrapLabel = new JLabel(MarginOptionsUtil.getDefaultWrapOnTypingText(getSettings())); UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, wrapLabel); return wrapLabel; } } return super.getCustomValueRenderer(optionName, value); }
Example #19
Source File: ActionButtonUI.java From consulo with Apache License 2.0 | 6 votes |
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) { if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return; if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(ALPHA_30); g.drawRoundRect(0, 0, size.width - 2, size.height - 2, 4, 4); } } else { final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift)); ((Graphics2D)g).setStroke(BASIC_STROKE); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.drawRoundRect(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4)); config.restore(); } }
Example #20
Source File: BaseStep.java From consulo with Apache License 2.0 | 5 votes |
public int getMnemonicPos(T value) { final String text = getTextFor(value); int i = text.indexOf("&"); if (i < 0) { i = text.indexOf(UIUtil.MNEMONIC); } return i; }
Example #21
Source File: DesktopStripeButton.java From consulo with Apache License 2.0 | 5 votes |
@Override public void updateUI() { setUI(DesktopStripeButtonUI.createUI(this)); Font font = UIUtil.getLabelFont(UIUtil.FontSize.SMALL); setFont(font); // update text if localize was changed updateText(); }
Example #22
Source File: DaemonTooltipWithActionRenderer.java From consulo with Apache License 2.0 | 5 votes |
private JPanel createActionPanelWithBackground(boolean highlight) { JPanel wrapper; if (highlight) { wrapper = new JPanel(new BorderLayout()) { @Override public void paint(Graphics g) { g.setColor(UIUtil.getToolTipActionBackground()); if (JBPopupFactory.getInstance().getParentBalloonFor(this) == null) { g.fillRect(0, 0, getWidth(), getHeight()); } else { Graphics2D graphics2D = (Graphics2D)g; GraphicsConfig cfg = new GraphicsConfig(g); cfg.setAntialiasing(true); Rectangle bounds = getBounds(); graphics2D.fill(new RoundRectangle2D.Double(1.0, 0.0, bounds.width - 2.5, (bounds.height / 2), 0.0, 0.0)); double arc = BalloonImpl.ARC.get(); RoundRectangle2D.Double d = new RoundRectangle2D.Double(1.0, 0.0, bounds.width - 2.5, (bounds.height - 1), arc, arc); graphics2D.fill(d); cfg.restore(); } super.paint(g); } }; } else { wrapper = new JPanel(new BorderLayout()); } wrapper.setOpaque(false); wrapper.setBorder(JBUI.Borders.empty()); return wrapper; }
Example #23
Source File: Unity3dProjectImportUtil.java From consulo-unity3d with Apache License 2.0 | 5 votes |
private static void importAfterDefines(@Nonnull final Project project, @Nullable final Sdk sdk, final boolean runValidator, @Nonnull ProgressIndicator indicator, @Nullable UnityOpenFilePostHandlerRequest requestor, @Nullable UnitySetDefines setDefines) { try { Collection<String> defines = null; if(setDefines != null) { VirtualFile maybeProjectDir = LocalFileSystem.getInstance().findFileByPath(setDefines.projectPath); if(maybeProjectDir != null && maybeProjectDir.equals(project.getBaseDir())) { defines = new TreeSet<>(Arrays.asList(setDefines.defines)); } } importOrUpdate(project, sdk, null, indicator, defines); } finally { project.putUserData(ourInProgressFlag, null); } if(runValidator) { UnityPluginFileValidator.runValidation(project); } if(requestor != null) { UIUtil.invokeLaterIfNeeded(() -> UnityOpenFilePostHandler.openFile(project, requestor)); } }
Example #24
Source File: FocusManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void delayedApplicationDeactivated(@Nonnull IdeFrame ideFrame) { final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); Component parent = UIUtil.findUltimateParent(owner); if (parent == ideFrame) { myLastFocusedAtDeactivation.put(ideFrame, owner); } }
Example #25
Source File: RemoteFilePanel.java From consulo with Apache License 2.0 | 5 votes |
public void deselectNotify() { UIUtil.invokeLaterIfNeeded(new Runnable() { public void run() { myProgressUpdatesQueue.hideNotify(); if (myFileEditor != null) { myFileEditor.deselectNotify(); } } }); }
Example #26
Source File: DockablePopupManager.java From consulo with Apache License 2.0 | 5 votes |
void restartAutoUpdate(final boolean state) { if (state && myToolWindow != null) { if (myAutoUpdateRequest == null) { myAutoUpdateRequest = this::updateComponent; UIUtil.invokeLaterIfNeeded(() -> IdeEventQueue.getInstance().addIdleListener(myAutoUpdateRequest, 500)); } } else { if (myAutoUpdateRequest != null) { IdeEventQueue.getInstance().removeIdleListener(myAutoUpdateRequest); myAutoUpdateRequest = null; } } }
Example #27
Source File: WindowMouseListener.java From consulo with Apache License 2.0 | 5 votes |
public void removeFrom(Component comp) { if (methodsNotAvailable()) return; comp = UIUtil.getWindow(comp); if (getPeer(comp) != null) { removeMouseListenerMethod.invoke(getPeer(comp), myListener); removeMouseMotionListenerMethod.invoke(getPeer(comp), myListener); } if (comp != null) comp.removeComponentListener(pendingListener); }
Example #28
Source File: ToolbarDecorator.java From consulo with Apache License 2.0 | 5 votes |
private static AnActionButton findButton(JComponent comp, CommonActionsPanel.Buttons type) { final CommonActionsPanel panel = UIUtil.findComponentOfType(comp, CommonActionsPanel.class); if (panel != null) { return panel.getAnActionButton(type); } //noinspection ConstantConditions return null; }
Example #29
Source File: ConsoleViewImpl.java From consulo with Apache License 2.0 | 5 votes |
private void runHeavyFilters(int line1, int endLine) { final int startLine = Math.max(0, line1); final Document document = myEditor.getDocument(); final int startOffset = document.getLineStartOffset(startLine); String text = document.getText(new TextRange(startOffset, document.getLineEndOffset(endLine))); final Document documentCopy = new DocumentImpl(text, true); documentCopy.setReadOnly(true); myJLayeredPane.startUpdating(); final int currentValue = myHeavyUpdateTicket; myHeavyAlarm.addRequest(() -> { if (!myFilters.shouldRunHeavy()) return; try { myFilters.applyHeavyFilter(documentCopy, startOffset, startLine, additionalHighlight -> addFlushRequest(0, new FlushRunnable(true) { @Override public void doRun() { if (myHeavyUpdateTicket != currentValue) return; TextAttributes additionalAttributes = additionalHighlight.getTextAttributes(null); if (additionalAttributes != null) { ResultItem item = additionalHighlight.getResultItems().get(0); myHyperlinks.addHighlighter(item.getHighlightStartOffset(), item.getHighlightEndOffset(), additionalAttributes); } else { myHyperlinks.highlightHyperlinks(additionalHighlight, 0); } } })); } catch (IndexNotReadyException ignore) { } finally { if (myHeavyAlarm.getActiveRequestCount() <= 1) { // only the current request UIUtil.invokeLaterIfNeeded(() -> myJLayeredPane.finishUpdating()); } } }, 0); }
Example #30
Source File: NeovimIntellijComplete.java From neovim-intellij-complete with MIT License | 5 votes |
@NeovimHandler("IntellijComplete") public DeopleteItem[] intellijComplete(final String path, final String bufferContents, final int row, final int col) { LookupElement[] c = mEmbeditorRequestHandler.getCompletionVariants(path, bufferContents, row, col); if (c.length < 0) return null; DeopleteHelper dh = new DeopleteHelper(); UIUtil.invokeAndWaitIfNeeded((Runnable) () -> { for (LookupElement i : c) { if (i instanceof PsiPackage || i instanceof LookupElementBuilder || i.getPsiElement() instanceof PsiPackageImpl) { dh.add(i.getLookupString(), "", ""); continue; } String word = i.getLookupString(); List<String> params = new ArrayList<String>(); String info; String kind = ""; PsiElement psiElement = i.getPsiElement(); if (psiElement == null) { dh.add(word, "", ""); continue; } for (PsiElement e : psiElement.getChildren()) { if (e instanceof PsiParameterList) { for (PsiParameter param : ((PsiParameterList)e).getParameters()) { params.add(param.getTypeElement().getText() + " " + param.getName()); } } else if (e instanceof PsiTypeElement) { kind = e.getText(); } } info = "(" + String.join(", ", params) + ")"; dh.add(word, info, kind); } }); return dh.getItems(); }