mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
purge the updateColors() calls
This commit is contained in:
@@ -29,7 +29,7 @@ import javax.swing.JProgressBar;
|
||||
|
||||
// I suspect this code can mostly be replaced with built-in Swing functions.
|
||||
// This code seems like it's adapted from old example code found on the web.
|
||||
// https://github.com/processing/processing/issues/3176
|
||||
// https://github.com/processing/processing4/issues/351
|
||||
|
||||
abstract class ContribProgressBar extends ContribProgressMonitor {
|
||||
JProgressBar progressBar;
|
||||
|
||||
@@ -24,7 +24,7 @@ package processing.app.contrib;
|
||||
|
||||
// I suspect this code can mostly be replaced with built-in Swing functions.
|
||||
// This code seems like it's adapted from old example code found on the web.
|
||||
// https://github.com/processing/processing/issues/3176
|
||||
// https://github.com/processing/processing4/issues/351
|
||||
|
||||
public abstract class ContribProgressMonitor {
|
||||
static final int UNKNOWN = -1;
|
||||
|
||||
@@ -241,8 +241,7 @@ abstract public class Contribution {
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the contribution is a starred/recommended contribution,
|
||||
* or is by the Processing Foundation.
|
||||
* Returns true if the contrib is from the Processing Foundation.
|
||||
*/
|
||||
boolean isSpecial() {
|
||||
if (authors != null &&
|
||||
|
||||
@@ -326,6 +326,9 @@ public class ContributionListing {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Each ContributionTab will add themselves as a ChangeListener
|
||||
*/
|
||||
protected void addListener(ChangeListener listener) {
|
||||
/*
|
||||
for (Contribution contrib : allContributions) {
|
||||
|
||||
@@ -176,7 +176,6 @@ public class ContributionTab extends JPanel {
|
||||
category = null;
|
||||
}
|
||||
filterLibraries(category, filterField.filters);
|
||||
contributionListPanel.updateColors();
|
||||
});
|
||||
|
||||
filterField = new FilterField();
|
||||
@@ -390,8 +389,6 @@ public class ContributionTab extends JPanel {
|
||||
filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a\\x3a]", " ");
|
||||
filters = Arrays.asList(filter.split(" "));
|
||||
filterLibraries(category, filters);
|
||||
|
||||
contributionListPanel.updateColors();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.awt.Dimension;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
|
||||
import processing.app.*;
|
||||
@@ -37,7 +36,7 @@ import processing.app.ui.Toolkit;
|
||||
* Vestigial class that was formerly a detail panel, but since 3.x
|
||||
* has only been used to track install/remove state information.
|
||||
*/
|
||||
class DetailPanel extends JPanel {
|
||||
class DetailPanel {
|
||||
private final ListPanel listPanel;
|
||||
private final ContributionListing contribListing = ContributionListing.getInstance();
|
||||
|
||||
|
||||
@@ -24,15 +24,12 @@ package processing.app.contrib;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.RowSorter.SortKey;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Platform;
|
||||
import processing.app.Util;
|
||||
import processing.app.ui.Toolkit;
|
||||
|
||||
@@ -561,17 +558,17 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
|
||||
// Thread: EDT
|
||||
public void contributionAdded(final Contribution contribution) {
|
||||
|
||||
if (!panelByContribution.containsKey(contribution)) {
|
||||
// long t1 = System.currentTimeMillis();
|
||||
new Exception().printStackTrace(System.out);
|
||||
long t1 = System.currentTimeMillis();
|
||||
DetailPanel newPanel = new DetailPanel(this);
|
||||
panelByContribution.put(contribution, newPanel);
|
||||
newPanel.setContrib(contribution);
|
||||
add(newPanel);
|
||||
// add(newPanel);
|
||||
model.fireTableDataChanged();
|
||||
// long t2 = System.currentTimeMillis();
|
||||
updateColors(); // XXX this is the place
|
||||
// long t3 = System.currentTimeMillis();
|
||||
// System.out.println("ListPanel.contributionAdded() " + (t2-t1) + " " + (t3-t2) + " " + contribution.getTypeName() + " " + contribution.getName());
|
||||
long t2 = System.currentTimeMillis();
|
||||
System.out.println("ListPanel.contributionAdded() " + (t2-t1) + " " + contribution.getTypeName() + " " + contribution.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -580,11 +577,9 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
public void contributionRemoved(final Contribution contribution) {
|
||||
DetailPanel panel = panelByContribution.get(contribution);
|
||||
if (panel != null) {
|
||||
remove(panel);
|
||||
panelByContribution.remove(contribution);
|
||||
}
|
||||
model.fireTableDataChanged();
|
||||
updateColors();
|
||||
updateUI();
|
||||
}
|
||||
|
||||
@@ -628,7 +623,7 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
// }
|
||||
// contributionPanel.setSelected(true);
|
||||
|
||||
updateColors();
|
||||
// updateColors();
|
||||
requestFocusInWindow();
|
||||
}
|
||||
}
|
||||
@@ -639,48 +634,6 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
}
|
||||
|
||||
|
||||
// Thread: EDT
|
||||
/**
|
||||
* Updates the colors of all library panels that are visible.
|
||||
*/
|
||||
protected void updateColors() {
|
||||
int count = 0;
|
||||
for (Entry<Contribution, DetailPanel> entry : panelByContribution.entrySet()) {
|
||||
DetailPanel panel = entry.getValue();
|
||||
Border border = BorderFactory.createEmptyBorder(1, 1, 1, 1);
|
||||
|
||||
if (panel.isVisible()) {
|
||||
boolean oddRow = count % 2 == 1;
|
||||
Color bgColor = null;
|
||||
Color fgColor = UIManager.getColor("List.foreground");
|
||||
|
||||
//if (panel.isSelected()) {
|
||||
//if (getSelectedPanel() == panel) {
|
||||
if (selectedPanel == panel) {
|
||||
bgColor = UIManager.getColor("List.selectionBackground");
|
||||
fgColor = UIManager.getColor("List.selectionForeground");
|
||||
border = UIManager.getBorder("List.focusCellHighlightBorder");
|
||||
} else if (Platform.isMacOS()) {
|
||||
border = oddRow
|
||||
? UIManager.getBorder("List.oddRowBackgroundPainter")
|
||||
: UIManager.getBorder("List.evenRowBackgroundPainter");
|
||||
} else {
|
||||
bgColor = oddRow ?
|
||||
new Color(219, 224, 229) :
|
||||
new Color(241, 241, 241);
|
||||
}
|
||||
|
||||
panel.setForeground(fgColor);
|
||||
if (bgColor != null) {
|
||||
panel.setBackground(bgColor);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
panel.setBorder(border);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredScrollableViewportSize() {
|
||||
return getPreferredSize();
|
||||
@@ -722,9 +675,11 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
int bottomOfScrollArea = visibleRect.y + visibleRect.height;
|
||||
|
||||
for (Component c : getComponents()) {
|
||||
if (!(c.isVisible() && c instanceof DetailPanel)) {
|
||||
continue;
|
||||
}
|
||||
// "if not a visible DetailPanel"
|
||||
// (will never be true, b/c DetailPanel never visible)
|
||||
// if (!(c.isVisible() && c instanceof DetailPanel)) {
|
||||
// continue;
|
||||
// }
|
||||
Dimension d = c.getPreferredSize();
|
||||
|
||||
int nextHeight = height + d.height;
|
||||
@@ -745,7 +700,6 @@ implements Scrollable, ContributionListing.ChangeListener {
|
||||
lastHeight = height;
|
||||
height = nextHeight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user