Java 类com.intellij.openapi.editor.ElementColorProvider 实例源码

项目:consulo    文件:ColorLineMarkerProvider.java   
@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;
}
项目:intellij-ce-playground    文件:ColorLineMarkerProvider.java   
@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;
}
项目:intellij-ce-playground    文件:ColorLineMarkerProvider.java   
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;
}
项目:tools-idea    文件:ColorLineMarkerProvider.java   
@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;
}
项目:tools-idea    文件:ColorLineMarkerProvider.java   
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;
}
项目:consulo    文件:ColorLineMarkerProvider.java   
@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;
}