mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 21:59:20 +01:00
Added ellipses, improved error Panel, fixed a previous NPE bug
This commit is contained in:
@@ -109,7 +109,7 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib
|
||||
table.setFillsViewportHeight(true);
|
||||
// table.setBorder();
|
||||
table.setDefaultRenderer(Contribution.class, new StatusRendere());
|
||||
table.setRowHeight(30);
|
||||
table.setRowHeight(40);
|
||||
table.setRowMargin(6);
|
||||
table.getColumnModel().setColumnMargin(-1);
|
||||
table.getColumnModel().getColumn(0).setMaxWidth(60);
|
||||
@@ -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 = "<html><body><b>" + contribution.getName() + "</b>";
|
||||
if (sentence == null) {
|
||||
label.setText(name + "</body></html>");
|
||||
} 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) + " ...</body></html>");
|
||||
}
|
||||
if (!contribution.isCompatible(Base.getRevision())) {
|
||||
label.setForeground(Color.LIGHT_GRAY);
|
||||
}
|
||||
name.setText("<html><body><b>" + contribution.getName() + "</b> - "
|
||||
+ contribution.getSentence() + "</body></html>");
|
||||
int textHeight = table.getFontMetrics(table.getFont().deriveFont(Font.BOLD)).getHeight() + 4;
|
||||
|
||||
GroupLayout layout = new GroupLayout(label);
|
||||
layout.setAutoCreateGaps(true);
|
||||
layout.setHorizontalGroup(layout.createSequentialGroup()
|
||||
.addComponent(name));
|
||||
layout.setVerticalGroup(layout
|
||||
.createSequentialGroup()
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
|
||||
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(name, 0,
|
||||
textHeight,
|
||||
textHeight)
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
|
||||
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE));
|
||||
if (table.isRowSelected(row)) {
|
||||
label.setBackground(Color.BLUE);
|
||||
name.setOpaque(false);
|
||||
}
|
||||
label.setOpaque(true);
|
||||
label.setLayout(layout);
|
||||
} else {
|
||||
label = new JLabel(
|
||||
contribution.isSpecial() ? Toolkit
|
||||
.getLibIcon("icons/pde-16.png") : null);
|
||||
contribution.isSpecial() ? Toolkit
|
||||
.getLibIcon("icons/pde-16.png") : null);
|
||||
StringBuilder name = new StringBuilder("");
|
||||
String authorList = contribution.getAuthorList();
|
||||
if (authorList != null) {
|
||||
|
||||
@@ -486,6 +486,9 @@ public class ContributionListing {
|
||||
|
||||
String getLatestVersion(Contribution contribution) {
|
||||
Contribution newestContrib = getAvailableContribution(contribution);
|
||||
if(newestContrib == null){
|
||||
return null;
|
||||
}
|
||||
String latestVersion = newestContrib.getPrettyVersion();
|
||||
if (latestVersion != null && !latestVersion.isEmpty()) {
|
||||
if (latestVersion.toLowerCase().startsWith("build")) // For Python mode
|
||||
|
||||
@@ -262,12 +262,14 @@ public class ContributionTab {
|
||||
layout.setAutoCreateGaps(true);
|
||||
layout.setAutoCreateContainerGaps(true);
|
||||
errorPanel.setLayout(layout);
|
||||
errorPanel.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, Color.BLACK));
|
||||
errorMessage = new JTextPane();
|
||||
errorMessage.setEditable(false);
|
||||
errorMessage.setText("Could not connect to the Processing server. "
|
||||
+ "Contributions cannot be installed or updated without an Internet connection. "
|
||||
+ "Please verify your network connection again, then try connecting again.");
|
||||
errorMessage.setMaximumSize(new Dimension(450, 50));
|
||||
errorMessage.setContentType("text/html");
|
||||
errorMessage.setText("<html><body>Could not connect to the Processing server.<br>"
|
||||
+ "Contributions cannot be installed or updated without an Internet connection.<br>"
|
||||
+ "Please verify your network connection again, then try connecting again.</body></html>");
|
||||
errorMessage.setMaximumSize(new Dimension(550, 50));
|
||||
errorMessage.setOpaque(false);
|
||||
|
||||
StyledDocument doc = errorMessage.getStyledDocument();
|
||||
@@ -306,13 +308,13 @@ public class ContributionTab {
|
||||
.addComponent(tryAgainButton, statusPanel.BUTTON_WIDTH,
|
||||
statusPanel.BUTTON_WIDTH,
|
||||
statusPanel.BUTTON_WIDTH))
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED,
|
||||
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED,
|
||||
GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(closeButton));
|
||||
layout.setVerticalGroup(layout
|
||||
.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup().addComponent(errorMessage)
|
||||
.addComponent(closeButton)).addComponent(tryAgainButton));
|
||||
.addComponent(closeButton)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(tryAgainButton));
|
||||
errorPanel.setBackground(Color.PINK);
|
||||
errorPanel.validate();
|
||||
}
|
||||
|
||||
@@ -184,8 +184,10 @@ class StatusPanel extends JPanel {
|
||||
}
|
||||
|
||||
void clear() {
|
||||
label.setText(null);
|
||||
label.repaint();
|
||||
if (label != null) {
|
||||
label.setText(null);
|
||||
label.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void update(ContributionPanel panel) {
|
||||
|
||||
Reference in New Issue
Block a user