@RequiredReadAction public MyInfo(@Nonnull final PsiElement element, final Color color, final ElementColorProvider colorProvider) { super(element, element.getTextRange(), new ColorIcon(JBUI.scaleFontSize(12), color), Pass.UPDATE_ALL, FunctionUtil.nullConstant(), new GutterIconNavigationHandler<PsiElement>() { @Override @RequiredDispatchThread public void navigate(MouseEvent e, PsiElement elt) { if (!elt.isWritable()) return; final Editor editor = PsiUtilBase.findEditor(element); assert editor != null; final Color c = ColorChooser.chooseColor(editor.getComponent(), "Choose Color", color, true); if (c != null) { WriteAction.run(() -> colorProvider.setColorTo(element, c)); } } }, GutterIconRenderer.Alignment.LEFT); myColor = color; }
@Override public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) { for (ElementColorProvider colorProvider : myExtensions) { final Color color = colorProvider.getColorFrom(element); if (color != null) { MyInfo info = new MyInfo(element, color, colorProvider); NavigateAction.setNavigateAction(info, "Choose color", null); return info; } } return null; }
public MyInfo(@NotNull final PsiElement element, final Color color, final ElementColorProvider colorProvider) { super(element, element.getTextRange(), new ColorIcon(12, color), Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), new GutterIconNavigationHandler<PsiElement>() { @Override public void navigate(MouseEvent e, PsiElement elt) { if (!elt.isWritable()) return; final Editor editor = PsiUtilBase.findEditor(element); assert editor != null; final Color c = ColorChooser.chooseColor(editor.getComponent(), "Choose Color", color, true); if (c != null) { AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(ColorLineMarkerProvider.class); try { colorProvider.setColorTo(element, c); } finally { token.finish(); } } } }, GutterIconRenderer.Alignment.LEFT); myColor = color; }
@Override public LineMarkerInfo getLineMarkerInfo(@NotNull PsiElement element) { for (ElementColorProvider colorProvider : myExtensions) { final Color color = colorProvider.getColorFrom(element); if (color != null) { return new MyInfo(element, color, colorProvider); } } return null; }
public MyInfo(@NotNull final PsiElement element, final Color color, final ElementColorProvider colorProvider) { super(element, element.getTextRange(), new ColorIcon(12, color), Pass.UPDATE_ALL, FunctionUtil.<Object, String>nullConstant(), new GutterIconNavigationHandler<PsiElement>() { @Override public void navigate(MouseEvent e, PsiElement elt) { if (!elt.isWritable()) return; final Editor editor = PsiUtilBase.findEditor(element); assert editor != null; final Color c = ColorChooser.chooseColor(editor.getComponent(), "Choose color", color, true); if (c != null) { AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(ColorLineMarkerProvider.class); try { colorProvider.setColorTo(element, c); } finally { token.finish(); } } } }, GutterIconRenderer.Alignment.LEFT); myColor = color; }
@RequiredReadAction @Override public LineMarkerInfo getLineMarkerInfo(@Nonnull PsiElement element) { for (ElementColorProvider colorProvider : myExtensions) { final Color color = colorProvider.getColorFrom(element); if (color != null) { MyInfo info = new MyInfo(element, color, colorProvider); NavigateAction.setNavigateAction(info, "Choose color", null); return info; } } return null; }