private boolean expandOrCollapseRoots(@NotNull MouseEvent e) { TableColumn column = getRootColumnOrNull(e); if (column != null) { myUI.setShowRootNames(!myUI.isShowRootNames()); return true; } return false; }
private void setRootColumnSize(TableColumn column) { int rootWidth; if (!myUI.isMultipleRoots()) { rootWidth = 0; } else if (!myUI.isShowRootNames()) { rootWidth = ROOT_INDICATOR_WIDTH; } else { rootWidth = Math.min(calculateMaxRootWidth(), ROOT_NAME_MAX_WIDTH); } // NB: all further instructions and their order are important, otherwise the minimum size which // is less than 15 won't be applied column.setMinWidth(rootWidth); column.setMaxWidth(rootWidth); column.setPreferredWidth(rootWidth); }
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { String text; Color color; if (value instanceof VirtualFile) { VirtualFile root = (VirtualFile) value; int readableRow = ScrollingUtil.getReadableRow(table, Math.round(myUi.getTable().getRowHeight() * 0.5f)); if (row < readableRow) { text = ""; } else if (row == 0 || !value.equals(table.getModel().getValueAt(row - 1, column)) || readableRow == row) { text = root.getName(); } else { text = ""; } color = getRootBackgroundColor(root, myUi.getColorManager()); } else { text = null; color = UIUtil.getTableBackground(isSelected); } myColor = color; Color background = ((VcsLogGraphTable) table) .getStyle(row, column, text, hasFocus, isSelected) .getBackground(); assert background != null; myBorderColor = background; setForeground(UIUtil.getTableForeground(false)); if (myUi.isShowRootNames()) { setText(text); isNarrow = false; } else { setText(""); isNarrow = true; } return this; }
@Override public String getToolTipText(@NotNull MouseEvent event) { int row = rowAtPoint(event.getPoint()); int column = columnAtPoint(event.getPoint()); if (column < 0 || row < 0) { return null; } if (column == GraphTableModel.ROOT_COLUMN) { Object at = getValueAt(row, column); if (at instanceof VirtualFile) { return "<html><b>" + ((VirtualFile) at).getPresentableUrl() + "</b><br/>Click to " + (myUI.isShowRootNames() ? "collapse" : "expand") + "</html>"; } } return null; }