untangling the story of the progress bar in the contribs manager

This commit is contained in:
Ben Fry
2022-05-04 20:39:34 -04:00
parent 619e271612
commit e2be62b4dc
5 changed files with 58 additions and 16 deletions

View File

@@ -33,10 +33,10 @@ import javax.swing.border.EmptyBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.formdev.flatlaf.ui.FlatComboBoxUI;
import processing.app.Base;
import processing.app.Library;
import processing.app.laf.PdeComboBoxUI;
import processing.app.laf.PdeProgressBarUI;
import processing.app.ui.Editor;
import processing.app.ui.Theme;
import processing.app.ui.Toolkit;
@@ -55,6 +55,8 @@ public class ContributionTab extends JPanel {
StatusPanel statusPanel;
FilterField filterField;
boolean inited;
// JLabel categoryLabel;
JLabel loaderLabel;
@@ -65,7 +67,7 @@ public class ContributionTab extends JPanel {
String category;
JProgressBar progressBar;
//protected JProgressBar progressBar; // TODO this is not actually used?
public ContributionTab(ManagerFrame dialog) {
@@ -116,9 +118,10 @@ public class ContributionTab extends JPanel {
protected void setLayout() {
if (progressBar == null) {
progressBar = new JProgressBar();
progressBar.setVisible(false);
if (loaderLabel == null) {
// if (progressBar == null) {
// progressBar = new JProgressBar();
// progressBar.setVisible(false);
createComponents();
buildErrorPanel();
@@ -544,6 +547,17 @@ public class ContributionTab extends JPanel {
categoryChooser.setUI(new PdeComboBoxUI("manager.categories"));
}
/*
if (progressBar != null) {
if (progressBar.getUI() instanceof PdeProgressBarUI) {
System.out.println("setting theme for progress bar");
((PdeProgressBarUI) progressBar.getUI()).updateTheme();
} else {
progressBar.setUI(new PdeProgressBarUI("manager.progress"));
}
}
*/
/*
textColor = Theme.getColor("manager.list.search.text.color");
placeholderColor = Theme.getColor("manager.list.search.placeholder.color");

View File

@@ -228,6 +228,12 @@ class StatusPanel extends JPanel {
updateButtonTheme(updateButton, "update");
updateButtonTheme(removeButton, "remove");
StatusPanelDetail currentDetail =
contributionTab.listPanel.getSelectedDetail();
if (currentDetail != null) {
currentDetail.updateTheme();
}
/*
if (installButton.getUI() instanceof PdeButtonUI) {
((PdeButtonUI) installButton.getUI()).updateTheme();
@@ -423,6 +429,6 @@ class StatusPanel extends JPanel {
progressPanel.setVisible(false);
updateLabel.setVisible(true);
}
progressPanel.repaint();
// progressPanel.repaint(); // needed? [fry 220504]
}
}

View File

@@ -31,6 +31,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import javax.swing.JProgressBar;
import processing.app.*;
import processing.app.laf.PdeProgressBarUI;
import processing.app.ui.Toolkit;
@@ -55,6 +56,9 @@ class StatusPanelDetail {
StatusPanelDetail(Base base, StatusPanel statusPanel) {
this.base = base;
this.statusPanel = statusPanel;
// initProgressBar();
// updateTheme();
}
@@ -84,11 +88,12 @@ class StatusPanelDetail {
protected void initProgressBar() {
progressBar = new JProgressBar();
progressBar.setInheritsPopupMenu(true);
// progressBar.setInheritsPopupMenu(true);
progressBar.setStringPainted(true);
progressBar.setFont(ManagerFrame.NORMAL_PLAIN);
// progressBar.setFont(ManagerFrame.NORMAL_PLAIN);
progressBar.setAlignmentX(Component.CENTER_ALIGNMENT);
progressBar.setOpaque(false);
// progressBar.setOpaque(false);
progressBar.setOpaque(true);
resetProgressBar();
@@ -196,9 +201,9 @@ class StatusPanelDetail {
// For the special "Updates" tab in the manager, there are no progress
// bars, so if that's what we're doing, this will create a dummy bar.
// TODO Not a good workaround [fry 220312]
if (progressBar == null) {
initProgressBar();
}
// if (progressBar == null) {
// initProgressBar();
// }
progressBar.setVisible(true);
progressBar.setIndeterminate(true);
@@ -261,6 +266,20 @@ class StatusPanelDetail {
}
protected void updateTheme() {
if (progressBar != null) {
if (progressBar.getUI() instanceof PdeProgressBarUI) {
System.out.println("updating theme for progress bar");
((PdeProgressBarUI) progressBar.getUI()).updateTheme();
} else {
System.out.println("setting ui for progress bar");
progressBar.setUI(new PdeProgressBarUI("manager.progress"));
System.out.println("fore " + progressBar.getForeground());
}
}
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

View File

@@ -24,7 +24,7 @@ import java.awt.Color;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
//import javax.swing.JProgressBar;
import processing.app.ui.Toolkit;
@@ -52,9 +52,10 @@ public class UpdateContributionTab extends ContributionTab {
@Override
protected void setLayout() {
if (progressBar == null) {
progressBar = new JProgressBar();
progressBar.setVisible(false);
if (loaderLabel == null) {
// if (progressBar == null) {
// progressBar = new JProgressBar();
// progressBar.setVisible(false);
buildErrorPanel();

View File

@@ -42,6 +42,8 @@ _ Export to Application fonts are too tiny
design/manager
X set color of the sort order icon in the ListPanel table header
X also the color of the text?
_ remove JProgressBar from ContributionTab/UpdateContributionTab
_ StatusPanelDetail creates its own, which is the one used
_ after download, list item doesn't update to show installed
_ stays stuck with the download icon
_ remove dorky loading.gif (used in ContributionTab and UpdateContributionTab)