diff --git a/app/src/processing/app/contrib/ContributionListPanel.java b/app/src/processing/app/contrib/ContributionListPanel.java index 5618c3a9c..3c267c9ac 100644 --- a/app/src/processing/app/contrib/ContributionListPanel.java +++ b/app/src/processing/app/contrib/ContributionListPanel.java @@ -271,40 +271,38 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib label.setOpaque(true); // return table.getDefaultRenderer(Icon.class).getTableCellRendererComponent(table, icon, isSelected, false, row, column); } else if (column == 1) { - //TODO add ellipses, currently the height of JTextPane = height of font + 4 - JTextPane name = new JTextPane(); - name.setContentType("text/html"); - name.setEditable(false); - if(!contribution.isCompatible(Base.getRevision())){ - name.setForeground(Color.LIGHT_GRAY); + // Generating ellipses based on fontMetrics + FontMetrics fontMetrics = table.getFontMetrics(table.getFont()); + int colSize = table.getColumnModel().getColumn(1).getWidth(); + String sentence = contribution.getSentence(); + int currentWidth = table.getFontMetrics(table.getFont().deriveFont(Font.BOLD)).stringWidth(contribution.getName()); + int ellipsesWidth = fontMetrics.stringWidth(" ..."); + String name = "
" + contribution.getName() + ""; + if (sentence == null) { + label.setText(name + ""); + } else { + sentence = " - " + sentence; + currentWidth += ellipsesWidth; + int i = 0; + for (i = 0; i < sentence.length(); i++) { + currentWidth += fontMetrics.charWidth(sentence.charAt(i)); + if (currentWidth >= colSize) { + break; + } + } + label.setText(name + sentence.substring(0, i) + " ...