/**
  * Enables/disables left border {@link #BORDER_SIZE_PX} width for certain editors.
  *
  * @param editors editors to enable/disable border
  * @param enable whether border should be enabled
  */
 private static void configureLeftBorder(
     final boolean enable, @NotNull final EditorEx... editors) {
   for (final EditorEx editor : editors) {
     final Color backgroundColor =
         editor.getBackgroundColor(); // Border have the same color console background has
     final int thickness = enable ? BORDER_SIZE_PX : 0;
     final Border border = BorderFactory.createMatteBorder(0, thickness, 0, 0, backgroundColor);
     editor.getComponent().setBorder(border);
   }
 }
Example #2
0
 @Nullable
 private Color getBgColorForFragmentContainingInlines(@NotNull EditorEx editor) {
   TextAttributes originalAttrs = getTextAttributes(editor.getColorsScheme());
   if (originalAttrs == null) {
     return null;
   }
   Color fg = originalAttrs.getBackgroundColor();
   if (fg == null) {
     return null;
   }
   Color bg = editor.getBackgroundColor();
   return getMiddleColor(fg, bg, MIDDLE_COLOR_FACTOR);
 }
  public static EditorFragmentComponent createEditorFragmentComponent(
      Editor editor, int startLine, int endLine, boolean showFolding, boolean showGutter) {
    final EditorEx editorEx = (EditorEx) editor;
    final Color old = editorEx.getBackgroundColor();
    Color backColor = getBackgroundColor(editor);
    editorEx.setBackgroundColor(backColor);
    EditorFragmentComponent fragmentComponent =
        new EditorFragmentComponent(editorEx, startLine, endLine, showFolding, showGutter);
    fragmentComponent.setBackground(backColor);

    editorEx.setBackgroundColor(old);
    return fragmentComponent;
  }
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean selected, boolean focused, int row, int column) {
    RendererComponent panel = getEditorPanel(table);
    EditorEx editor = panel.getEditor();
    editor.getColorsScheme().setEditorFontSize(table.getFont().getSize());

    editor
        .getColorsScheme()
        .setColor(EditorColors.SELECTION_BACKGROUND_COLOR, table.getSelectionBackground());
    editor
        .getColorsScheme()
        .setColor(EditorColors.SELECTION_FOREGROUND_COLOR, table.getSelectionForeground());
    editor.setBackgroundColor(selected ? table.getSelectionBackground() : table.getBackground());
    panel.setSelected(!Comparing.equal(editor.getBackgroundColor(), table.getBackground()));

    panel.setBorder(
        null); // prevents double border painting when ExtendedItemRendererComponentWrapper is used

    customizeEditor(editor, table, value, selected, row, column);
    return panel;
  }
  private Color[] toColorsForEditor(Color[] baseColors) {
    final Color tagBackground = myEditor.getBackgroundColor();

    if (tagBackground == null) {
      return baseColors;
    }

    final Color[] resultColors = new Color[baseColors.length];
    // todo: make configurable
    final double transparency =
        WebEditorOptions.getInstance().getTagTreeHighlightingOpacity() * 0.01;

    for (int i = 0; i < resultColors.length; i++) {
      final Color color = baseColors[i];

      final Color color1 =
          color != null
              ? XmlTagTreeHighlightingUtil.makeTransparent(color, tagBackground, transparency)
              : null;
      resultColors[i] = color1;
    }

    return resultColors;
  }