public SimpleTextAttributes applyHighlighters( @NotNull Component rendererComponent, int row, int column, String text, boolean hasFocus, final boolean selected) { VcsLogHighlighter.VcsCommitStyle style = getStyle(row, column, text, hasFocus, selected); assert style.getBackground() != null && style.getForeground() != null && style.getTextStyle() != null; rendererComponent.setBackground(style.getBackground()); rendererComponent.setForeground(style.getForeground()); switch (style.getTextStyle()) { case BOLD: return SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES; case ITALIC: return SimpleTextAttributes.REGULAR_ITALIC_ATTRIBUTES; default: } return SimpleTextAttributes.REGULAR_ATTRIBUTES; }
private int calcMaxContentColumnWidth(int columnIndex, int maxRowsToCheck) { int maxWidth = 0; for (int row = 0; row < maxRowsToCheck; row++) { TableCellRenderer renderer = getCellRenderer(row, columnIndex); Component comp = prepareRenderer(renderer, row, columnIndex); maxWidth = Math.max(comp.getPreferredSize().width, maxWidth); } return maxWidth + UIUtil.DEFAULT_HGAP; }
@Override public void mouseMoved(MouseEvent e) { Component component = e.getComponent(); if (component != null) { if (getRootColumnOrNull(e) != null) { component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { component.setCursor(null); } } }
public void applyHighlighters(@NotNull Component rendererComponent, int row, boolean selected) { boolean fgUpdated = false; for (VcsLogHighlighter highlighter : myHighlighters) { Color color = highlighter.getForeground(myDataPack.getGraphFacade().getCommitAtRow(row), selected); if (color != null) { rendererComponent.setForeground(color); fgUpdated = true; } } if (!fgUpdated) { // reset highlighting if no-one wants to change it rendererComponent.setForeground(UIUtil.getTableForeground(selected)); } }
private VcsLogHighlighter.VcsCommitStyle getStyle( int row, int column, String text, boolean hasFocus, final boolean selected) { Component dummyRendererComponent = myDummyRenderer.getTableCellRendererComponent(this, text, selected, hasFocus, row, column); VisibleGraph<Integer> visibleGraph = getVisibleGraph(); if (row < 0 || row >= visibleGraph.getVisibleCommitCount()) { LOG.error( "Visible graph has " + visibleGraph.getVisibleCommitCount() + " commits, yet we want row " + row); return VcsCommitStyleFactory.createStyle( dummyRendererComponent.getForeground(), dummyRendererComponent.getBackground(), VcsLogHighlighter.TextStyle.NORMAL); } final RowInfo<Integer> rowInfo = visibleGraph.getRowInfo(row); VcsLogHighlighter.VcsCommitStyle defaultStyle = VcsCommitStyleFactory.createStyle( rowInfo.getRowType() == RowType.UNMATCHED ? JBColor.GRAY : dummyRendererComponent.getForeground(), dummyRendererComponent.getBackground(), VcsLogHighlighter.TextStyle.NORMAL); List<VcsLogHighlighter.VcsCommitStyle> styles = ContainerUtil.map( myHighlighters, new Function<VcsLogHighlighter, VcsLogHighlighter.VcsCommitStyle>() { @Override public VcsLogHighlighter.VcsCommitStyle fun(VcsLogHighlighter highlighter) { return highlighter.getStyle(rowInfo.getCommit(), selected); } }); return VcsCommitStyleFactory.combine(ContainerUtil.append(styles, defaultStyle)); }