mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
sorting out contrib progress bar
This commit is contained in:
@@ -36,7 +36,6 @@ import javax.swing.event.DocumentListener;
|
||||
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,9 +54,6 @@ public class ContributionTab extends JPanel {
|
||||
StatusPanel statusPanel;
|
||||
FilterField filterField;
|
||||
|
||||
boolean inited;
|
||||
|
||||
// JLabel categoryLabel;
|
||||
JLabel loaderLabel;
|
||||
|
||||
JPanel errorPanel;
|
||||
@@ -82,8 +78,10 @@ public class ContributionTab extends JPanel {
|
||||
|
||||
filter = contrib -> contrib.getType() == contribType;
|
||||
|
||||
statusPanel = new StatusPanel(this);
|
||||
listPanel = new ListPanel(this, filter, false);
|
||||
// TODO init is after listPanel is created because it calls updateTheme()
|
||||
// which needs it, but yuck, too messy [fry 220504]
|
||||
statusPanel = new StatusPanel(this);
|
||||
|
||||
ContributionListing.getInstance().addListPanel(listPanel);
|
||||
}
|
||||
@@ -547,17 +545,6 @@ 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");
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
*/
|
||||
package processing.app.contrib;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
@@ -31,6 +32,7 @@ import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JTextPane;
|
||||
import javax.swing.LayoutStyle;
|
||||
import javax.swing.SwingConstants;
|
||||
@@ -40,6 +42,7 @@ import javax.swing.text.html.HTMLDocument;
|
||||
import processing.app.Language;
|
||||
import processing.app.Util;
|
||||
import processing.app.laf.PdeButtonUI;
|
||||
import processing.app.laf.PdeProgressBarUI;
|
||||
import processing.app.ui.Theme;
|
||||
import processing.app.ui.Toolkit;
|
||||
import processing.app.Base;
|
||||
@@ -62,7 +65,7 @@ class StatusPanel extends JPanel {
|
||||
|
||||
JTextPane label;
|
||||
JButton installButton;
|
||||
JPanel progressPanel;
|
||||
JProgressBar progressBar;
|
||||
JLabel updateLabel;
|
||||
JButton updateButton;
|
||||
JButton removeButton;
|
||||
@@ -110,9 +113,28 @@ class StatusPanel extends JPanel {
|
||||
currentDetail.install();
|
||||
updateDetail(currentDetail);
|
||||
});
|
||||
progressPanel = new JPanel();
|
||||
progressPanel.setLayout(new BorderLayout());
|
||||
progressPanel.setOpaque(false);
|
||||
|
||||
progressBar = new JProgressBar();
|
||||
/*
|
||||
progressBar = new JProgressBar() {
|
||||
@Override
|
||||
public void setBackground(Color c) {
|
||||
new Exception("setting bg to " + c).printStackTrace(System.out);
|
||||
super.setBackground(c);
|
||||
}
|
||||
};
|
||||
*/
|
||||
progressBar.setStringPainted(true);
|
||||
progressBar.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
//progressBar.setOpaque(true);
|
||||
|
||||
resetProgressBar();
|
||||
|
||||
final int high = progressBar.getPreferredSize().height;
|
||||
Dimension dim = new Dimension(BUTTON_WIDTH, high);
|
||||
progressBar.setPreferredSize(dim);
|
||||
progressBar.setMaximumSize(dim);
|
||||
progressBar.setMinimumSize(dim);
|
||||
|
||||
updateLabel = new JLabel(" ");
|
||||
// updateLabel.setFont(buttonFont);
|
||||
@@ -162,7 +184,7 @@ class StatusPanel extends JPanel {
|
||||
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER)
|
||||
.addComponent(installButton,
|
||||
BUTTON_WIDTH, BUTTON_WIDTH, BUTTON_WIDTH)
|
||||
.addComponent(progressPanel)
|
||||
.addComponent(progressBar)
|
||||
.addComponent(updateLabel,
|
||||
BUTTON_WIDTH, BUTTON_WIDTH, BUTTON_WIDTH)
|
||||
.addComponent(updateButton)
|
||||
@@ -176,14 +198,14 @@ class StatusPanel extends JPanel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(installButton)
|
||||
.addGroup(layout.createParallelGroup()
|
||||
.addComponent(progressPanel)
|
||||
.addComponent(progressBar)
|
||||
.addComponent(updateLabel))
|
||||
.addComponent(updateButton).addComponent(removeButton)));
|
||||
|
||||
layout.linkSize(SwingConstants.HORIZONTAL,
|
||||
installButton, progressPanel, updateButton, removeButton);
|
||||
installButton, progressBar, updateButton, removeButton);
|
||||
|
||||
progressPanel.setVisible(false);
|
||||
progressBar.setVisible(false);
|
||||
|
||||
installButton.setEnabled(false);
|
||||
updateButton.setEnabled(false);
|
||||
@@ -197,6 +219,16 @@ class StatusPanel extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
protected void resetProgressBar() {
|
||||
// TODO is this overkill for a reset? is this really only being used
|
||||
// when we mean to call setVisible(false)? [fry 220311]
|
||||
progressBar.setString(Language.text("contrib.progress.starting"));
|
||||
progressBar.setIndeterminate(false);
|
||||
progressBar.setValue(0);
|
||||
progressBar.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
protected void updateTheme() {
|
||||
setBackground(Theme.getColor("manager.panel.background.color"));
|
||||
|
||||
@@ -234,6 +266,12 @@ class StatusPanel extends JPanel {
|
||||
currentDetail.updateTheme();
|
||||
}
|
||||
|
||||
if (progressBar.getUI() instanceof PdeProgressBarUI) {
|
||||
((PdeProgressBarUI) progressBar.getUI()).updateTheme();
|
||||
} else {
|
||||
progressBar.setUI(new PdeProgressBarUI("manager.progress"));
|
||||
}
|
||||
|
||||
/*
|
||||
if (installButton.getUI() instanceof PdeButtonUI) {
|
||||
((PdeButtonUI) installButton.getUI()).updateTheme();
|
||||
@@ -419,16 +457,19 @@ class StatusPanel extends JPanel {
|
||||
|
||||
removeButton.setEnabled(contrib.isInstalled() && !detail.removeInProgress);
|
||||
|
||||
progressPanel.removeAll();
|
||||
progressPanel.add(detail.getProgressBar());
|
||||
|
||||
if (detail.updateInProgress || detail.installInProgress || detail.removeInProgress) {
|
||||
progressPanel.setVisible(true);
|
||||
// progressBar.setUI(new PdeProgressBarUI("manager.progress"));
|
||||
// System.out.println(progressBar.getUI());
|
||||
// ((PdeProgressBarUI) progressBar.getUI()).updateTheme();
|
||||
progressBar.setVisible(true);
|
||||
// System.out.println(progressBar.getUI());
|
||||
// System.out.println("progress bar bg: " + progressBar.getBackground());
|
||||
updateLabel.setVisible(false);
|
||||
} else {
|
||||
progressPanel.setVisible(false);
|
||||
progressBar.setVisible(false);
|
||||
updateLabel.setVisible(true);
|
||||
}
|
||||
detail.setProgressBar(progressBar);
|
||||
// progressPanel.repaint(); // needed? [fry 220504]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
*/
|
||||
package processing.app.contrib;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.AbstractQueue;
|
||||
@@ -77,6 +75,12 @@ class StatusPanelDetail {
|
||||
}
|
||||
|
||||
|
||||
protected void setProgressBar(JProgressBar progressBar) {
|
||||
this.progressBar = progressBar;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
protected JProgressBar getProgressBar() {
|
||||
if (progressBar == null) {
|
||||
initProgressBar();
|
||||
@@ -113,6 +117,7 @@ class StatusPanelDetail {
|
||||
progressBar.setValue(0);
|
||||
progressBar.setVisible(false);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
private void installContribution(AvailableContribution info) {
|
||||
@@ -125,7 +130,7 @@ class StatusPanelDetail {
|
||||
|
||||
|
||||
private void finishInstall(boolean error) {
|
||||
resetProgressBar();
|
||||
statusPanel.resetProgressBar();
|
||||
|
||||
if (error) {
|
||||
statusPanel.setErrorMessage(Language.text("contrib.download_error"));
|
||||
@@ -210,7 +215,7 @@ class StatusPanelDetail {
|
||||
ContribProgress progress = new ContribProgress(progressBar) {
|
||||
@Override
|
||||
public void finishedAction() {
|
||||
resetProgressBar();
|
||||
statusPanel.resetProgressBar();
|
||||
AvailableContribution ad =
|
||||
contribListing.getAvailableContribution(contrib);
|
||||
// install the new version of the Mode (or Tool)
|
||||
@@ -219,7 +224,7 @@ class StatusPanelDetail {
|
||||
|
||||
@Override
|
||||
public void cancelAction() {
|
||||
resetProgressBar();
|
||||
statusPanel.resetProgressBar();
|
||||
//clearStatusMessage();
|
||||
statusPanel.clearMessage();
|
||||
updateInProgress = false;
|
||||
@@ -251,13 +256,13 @@ class StatusPanelDetail {
|
||||
ContribProgress progress = new ContribProgress(progressBar) {
|
||||
@Override
|
||||
public void finishedAction() {
|
||||
resetProgressBar();
|
||||
statusPanel.resetProgressBar();
|
||||
removeInProgress = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelAction() {
|
||||
resetProgressBar();
|
||||
statusPanel.resetProgressBar();
|
||||
removeInProgress = false;
|
||||
}
|
||||
};
|
||||
@@ -269,12 +274,12 @@ class StatusPanelDetail {
|
||||
protected void updateTheme() {
|
||||
if (progressBar != null) {
|
||||
if (progressBar.getUI() instanceof PdeProgressBarUI) {
|
||||
System.out.println("updating theme for progress bar");
|
||||
// System.out.println("updating theme for progress bar");
|
||||
((PdeProgressBarUI) progressBar.getUI()).updateTheme();
|
||||
} else {
|
||||
System.out.println("setting ui for progress bar");
|
||||
// System.out.println("setting ui for progress bar");
|
||||
progressBar.setUI(new PdeProgressBarUI("manager.progress"));
|
||||
System.out.println("fore " + progressBar.getForeground());
|
||||
// System.out.println("fore " + progressBar.getForeground());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,13 @@ public class PdeProgressBarUI extends BasicProgressBarUI {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The "selectionForeground" is the color of the text when it is painted
|
||||
* over a filled area of the progress bar.
|
||||
|
||||
@@ -36,26 +36,31 @@ X icons for contrib manager list entries (green/orange PNGs won't do)
|
||||
X remove ability to rearrange columns in contrib manager
|
||||
X why tf this is the default is beyond me
|
||||
X remove extra space between prefs lines
|
||||
X style the popup menu for Mode using the theme
|
||||
_ Export to Application fonts are too tiny
|
||||
_ font for stack trace dialogs is too small (and wrong)
|
||||
|
||||
|
||||
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
|
||||
X override flatlaf for components (search, buttons, dropdown menu) in manager
|
||||
X popup menu coloring (contribs)
|
||||
X progress bar in contrib manager
|
||||
X need monochrome icon for foundation
|
||||
X remove JProgressBar from ContributionTab/UpdateContributionTab
|
||||
X StatusPanelDetail creates its own, which is the one used
|
||||
_ still need to work to prevent multiple from colliding
|
||||
_ (i.e. get rid of ContribProgress class)
|
||||
_ after download, list item doesn't update to show installed
|
||||
_ stays stuck with the download icon
|
||||
_ stays stuck with the downloading icon
|
||||
_ remove dorky loading.gif (used in ContributionTab and UpdateContributionTab)
|
||||
_ should be a better way to implement this
|
||||
_ override flatlaf for components (search, buttons, dropdown menu) in manager
|
||||
_ popup menu coloring (contribs and editor)
|
||||
_ progress bar in contrib manager
|
||||
_ remove ManagerFrame constants for NORMAL_PLAIN, SMALL_PLAIN, etc
|
||||
_ these should be read from theme.txt instead
|
||||
_ or not used at all: the defaults from ui.font and FlatLaf should do
|
||||
|
||||
design/manager/waiting
|
||||
X need monochrome icon for foundation
|
||||
_ do we need other color states for list item icons
|
||||
_ update lib/theme.txt to clean up current Frankenstein status
|
||||
_ just replace with the blue default once that's updated
|
||||
|
||||
Reference in New Issue
Block a user