private void setColumnPreferredSize() { for (int i = 0; i < getColumnCount(); i++) { TableColumn column = getColumnModel().getColumn(i); if (i == AbstractVcsLogTableModel.ROOT_COLUMN) { // thin stripe or nothing int rootWidth = myUI.getColorManager().isMultipleRoots() ? ROOT_INDICATOR_WIDTH : 0; // 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); } else if (i == AbstractVcsLogTableModel .COMMIT_COLUMN) { // let commit message occupy as much as possible column.setPreferredWidth(Short.MAX_VALUE); } else if (i == AbstractVcsLogTableModel.AUTHOR_COLUMN) { // detect author with the longest name // to avoid querying the last row (it would lead to full graph loading) int maxRowsToCheck = Math.min(MAX_ROWS_TO_CALC_WIDTH, getRowCount() - MAX_ROWS_TO_CALC_OFFSET); if (maxRowsToCheck < 0) { // but if the log is small, check all of them maxRowsToCheck = getRowCount(); } int contentWidth = calcMaxContentColumnWidth(i, maxRowsToCheck); column.setMinWidth(Math.min(contentWidth, MAX_DEFAULT_AUTHOR_COLUMN_WIDTH)); column.setWidth(column.getMinWidth()); } else if (i == AbstractVcsLogTableModel.DATE_COLUMN) { // all dates have nearly equal sizes Font tableFont = UIManager.getFont("Table.font"); column.setMinWidth( getFontMetrics(tableFont) .stringWidth("mm" + DateFormatUtil.formatDateTime(new Date()))); column.setWidth(column.getMinWidth()); } } }
private void layoutPanel() { if (myUsagePreviewPanel != null) { Disposer.dispose(myUsagePreviewPanel); } removeAll(); JScrollPane pane = ScrollPaneFactory.createScrollPane(myTree); if (isPreview()) { pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.RIGHT)); boolean vertical = myToolWindow.getAnchor() == ToolWindowAnchor.LEFT || myToolWindow.getAnchor() == ToolWindowAnchor.RIGHT; Splitter splitter = new Splitter( vertical, UsageViewSettings.getInstance().PREVIEW_USAGES_SPLITTER_PROPORTIONS); splitter.setFirstComponent(pane); myUsagePreviewPanel = new UsagePreviewPanel(myProject, new UsageViewPresentation()); myUsagePreviewPanel.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); Disposer.register(this, myUsagePreviewPanel); splitter.setSecondComponent(myUsagePreviewPanel); add(splitter, BorderLayout.CENTER); } else { pane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); add(pane, BorderLayout.CENTER); } add(createToolbar().getComponent(), BorderLayout.WEST); myTree.getParent().setBackground(UIManager.getColor("Tree.background")); revalidate(); }
private boolean setColumnPreferredSize() { boolean sizeCalculated = false; Font tableFont = UIManager.getFont("Table.font"); for (int i = 0; i < getColumnCount(); i++) { TableColumn column = getColumnModel().getColumn(i); if (i == GraphTableModel.ROOT_COLUMN) { // thin stripe, or root name, or nothing setRootColumnSize(column); } else if (i == GraphTableModel.COMMIT_COLUMN) { // let commit message occupy as much as possible column.setPreferredWidth(Short.MAX_VALUE); } else if (i == GraphTableModel.AUTHOR_COLUMN) { // detect author with the longest name // to avoid querying the last row (it would lead to full graph loading) int maxRowsToCheck = Math.min(MAX_ROWS_TO_CALC_WIDTH, getRowCount() - MAX_ROWS_TO_CALC_OFFSET); if (maxRowsToCheck < 0) { // but if the log is small, check all of them maxRowsToCheck = getRowCount(); } int maxWidth = 0; for (int row = 0; row < maxRowsToCheck; row++) { String value = getModel().getValueAt(row, i).toString(); maxWidth = Math.max(getFontMetrics(tableFont).stringWidth(value), maxWidth); if (!value.isEmpty()) sizeCalculated = true; } column.setMinWidth( Math.min(maxWidth + UIUtil.DEFAULT_HGAP, MAX_DEFAULT_AUTHOR_COLUMN_WIDTH)); column.setWidth(column.getMinWidth()); } else if (i == GraphTableModel.DATE_COLUMN) { // all dates have nearly equal sizes column.setMinWidth( getFontMetrics(tableFont) .stringWidth("mm" + DateFormatUtil.formatDateTime(new Date()))); column.setWidth(column.getMinWidth()); } } return sizeCalculated; }
private int calculateMaxRootWidth() { int width = 0; for (VirtualFile file : myLogDataHolder.getRoots()) { Font tableFont = UIManager.getFont("Table.font"); width = Math.max(getFontMetrics(tableFont).stringWidth(file.getName() + " "), width); } return width; }
@Override protected void paintComponent(Graphics g) { setFont(UIManager.getFont("Table.font")); g.setColor(myColor); int width = getWidth(); if (isNarrow) { g.fillRect(0, 0, width - ROOT_INDICATOR_WHITE_WIDTH, myUi.getTable().getRowHeight()); g.setColor(myBorderColor); g.fillRect( width - ROOT_INDICATOR_WHITE_WIDTH, 0, ROOT_INDICATOR_WHITE_WIDTH, myUi.getTable().getRowHeight()); } else { g.fillRect(0, 0, width, myUi.getTable().getRowHeight()); } super.paintComponent(g); }
@NotNull @Override public BalloonBuilder createDialogBalloonBuilder(@NotNull JComponent content, String title) { final BalloonPopupBuilderImpl builder = new BalloonPopupBuilderImpl(myStorage, content); final Color bg = UIManager.getColor("Panel.background"); final Color borderOriginal = Color.darkGray; final Color border = ColorUtil.toAlpha(borderOriginal, 75); builder .setDialogMode(true) .setTitle(title) .setAnimationCycle(200) .setFillColor(bg) .setBorderColor(border) .setHideOnClickOutside(false) .setHideOnKeyOutside(false) .setHideOnAction(false) .setCloseButtonEnabled(true) .setShadow(true); return builder; }
private void doPaint(Graphics g) { GraphicsUtil.setupAntialiasing(g); final boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText()); final Dimension size = getSize(); if (isSmallVariant()) { final Graphics2D g2 = (Graphics2D) g; g2.setColor(UIUtil.getControlColor()); final int w = getWidth(); final int h = getHeight(); if (getModel().isArmed() && getModel().isPressed()) { g2.setPaint( new GradientPaint( 0, 0, UIUtil.getControlColor(), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.8))); } else { g2.setPaint( new GradientPaint( 0, 0, ColorUtil.shift(UIUtil.getControlColor(), 1.1), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.9))); } g2.fillRect(2, 0, w - 2, h); GraphicsUtil.setupAntialiasing(g2); if (!myMouseInside) { g2.setPaint( new GradientPaint( 0, 0, UIUtil.getBorderColor(), 0, h, UIUtil.getBorderColor().darker())); // g2.setColor(UIUtil.getBorderColor()); } else { g2.setPaint( new GradientPaint( 0, 0, UIUtil.getBorderColor().darker(), 0, h, UIUtil.getBorderColor().darker().darker())); } g2.drawRect(2, 0, w - 3, h - 1); final Icon icon = getIcon(); int x = 7; if (icon != null) { icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2); x += icon.getIconWidth() + 3; } if (!StringUtil.isEmpty(getText())) { final Font font = getFont(); g2.setFont(font); g2.setColor(UIManager.getColor("Panel.foreground")); g2.drawString(getText(), x, (size.height + font.getSize()) / 2 - 1); } } else { super.paintComponent(g); } final Insets insets = super.getInsets(); final Icon icon = isEnabled() ? ARROW_ICON : DISABLED_ARROW_ICON; final int x; if (isEmpty) { x = (size.width - icon.getIconWidth()) / 2; } else { if (isSmallVariant()) { x = size.width - icon.getIconWidth() - insets.right + 1; } else { x = size.width - icon.getIconWidth() - insets.right + (UIUtil.isUnderNimbusLookAndFeel() ? -3 : 2); } } if (UIUtil.isUnderDarcula()) { g.setXORMode(new Color(208, 188, 159)); } icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2); g.setPaintMode(); }