diff --git a/app/src/processing/app/contrib/ContributionListing.java b/app/src/processing/app/contrib/ContributionListing.java index 8f2b272eb..c8b3084d2 100644 --- a/app/src/processing/app/contrib/ContributionListing.java +++ b/app/src/processing/app/contrib/ContributionListing.java @@ -52,7 +52,7 @@ public class ContributionListing { Map> librariesByCategory; Map librariesByImportHeader; // TODO: Every contribution is getting added twice - // and nothing is replaced ever. + // and nothing is replaced ever. Set allContributions; boolean listDownloaded; boolean listDownloadFailed; @@ -67,7 +67,6 @@ public class ContributionListing { allContributions = new LinkedHashSet<>(); downloadingListingLock = new ReentrantLock(); - //listingFile = Base.getSettingsFile("contributions.txt"); listingFile = Base.getSettingsFile(LOCAL_FILENAME); boolean writable = listingFile.setWritable(true, false); if (writable && listingFile.exists()) { @@ -100,8 +99,8 @@ public class ContributionListing { /** - * Adds the installed libraries to the listing of libraries, replacing any - * pre-existing libraries by the same name as one in the list. + * Adds the installed libraries to the listing of libraries, replacing + * any pre-existing libraries by the same name as one in the list. */ protected void updateInstalledList(List installed) { for (Contribution contribution : installed) { diff --git a/app/src/processing/app/contrib/ContributionTab.java b/app/src/processing/app/contrib/ContributionTab.java index 015989003..457f23045 100644 --- a/app/src/processing/app/contrib/ContributionTab.java +++ b/app/src/processing/app/contrib/ContributionTab.java @@ -82,7 +82,8 @@ public class ContributionTab extends JPanel { // long t4 = System.currentTimeMillis(); contributionListPanel = new ListPanel(this, filter, false); // long t5 = System.currentTimeMillis(); - contribListing.addListener(contributionListPanel); // TODO optimize: this line is taking all of the time + // TODO optimize: this line is taking all of the time + contribListing.addListener(contributionListPanel); // long t6 = System.currentTimeMillis(); // System.out.println("ContributionTab. " + (t4-t1) + " " + (t5-t4) + " " + (t6-t5)); } diff --git a/app/src/processing/app/contrib/DetailPanel.java b/app/src/processing/app/contrib/DetailPanel.java index 636dc0e4a..b1fd5ca3c 100644 --- a/app/src/processing/app/contrib/DetailPanel.java +++ b/app/src/processing/app/contrib/DetailPanel.java @@ -32,7 +32,6 @@ import java.text.DateFormat; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.HyperlinkEvent; -import javax.swing.text.Document; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; @@ -136,12 +135,12 @@ class DetailPanel extends JPanel { setExpandListener(this, new MouseAdapter() { public void mousePressed(MouseEvent e) { - if (contrib.isCompatible(Base.getRevision())) { - listPanel.setSelectedPanel(DetailPanel.this); - } else { - setErrorMessage(contrib.getName() + - " cannot be used with this version of Processing"); - } + if (contrib.isCompatible(Base.getRevision())) { + listPanel.setSelectedPanel(DetailPanel.this); + } else { + setErrorMessage(contrib.getName() + + " cannot be used with this version of Processing"); + } } }); } @@ -152,6 +151,7 @@ class DetailPanel extends JPanel { * when the library panel is not clicked. */ private void addPaneComponents() { + System.out.println("DetailPanel.addPaneComponents()"); setLayout(new BorderLayout()); descriptionPane = new JTextPane(); @@ -165,8 +165,8 @@ class DetailPanel extends JPanel { // HTMLEditorKit kit = new HTMLEditorKit(); HTMLEditorKit kit = Toolkit.createHtmlEditorKit(); StyleSheet stylesheet = new StyleSheet(); - stylesheet.addRule(getBodyStyle()); - stylesheet.addRule("a { color: #000000; text-decoration:underline; text-decoration-style: dotted; }"); + stylesheet.addRule(StatusPanel.getBodyStyle()); +// stylesheet.addRule("a { color: #000000; text-decoration:underline; text-decoration-style: dotted; }"); kit.setStyleSheet(stylesheet); HTMLDocument hd = (HTMLDocument) kit.createDefaultDocument(); descriptionPane.setEditorKit(kit); @@ -293,20 +293,6 @@ class DetailPanel extends JPanel { } - static String getBodyStyle() { - return "body { " + - " margin: 0; " + - " padding: 0;" + - " font-family: " + Toolkit.getSansFontName() + ", Helvetica, Arial, sans-serif;" + - " font-size: 11px;" + -// " font-size: 100%;" + -// " font-size: 0.95em; " + -// "}"; - "}" + - "a { color: #444; text-decoration: none; }"; - } - - private void reorganizePaneComponents() { BorderLayout layout = (BorderLayout) this.getLayout(); remove(layout.getLayoutComponent(BorderLayout.SOUTH)); @@ -406,6 +392,8 @@ class DetailPanel extends JPanel { public void setContribution(Contribution contrib) { +// System.out.println("DetailPanel.setContribution " + contrib.name); + new Exception("DetailPanel.setContribution " + contrib.name).printStackTrace(System.out); this.contrib = contrib; if (contrib.isSpecial()) { diff --git a/app/src/processing/app/contrib/ListPanel.java b/app/src/processing/app/contrib/ListPanel.java index 34992d632..c4d5adedf 100644 --- a/app/src/processing/app/contrib/ListPanel.java +++ b/app/src/processing/app/contrib/ListPanel.java @@ -39,7 +39,7 @@ import processing.app.ui.Toolkit; // The "Scrollable" implementation and its methods here take care of preventing // the scrolling area from running exceptionally slowly. Not sure why they're -// necessary in the first place, however; seems like odd behavior. +// necessary in the first place, however. Is that hiding a bigger problem? // It also allows the description text in the panels to wrap properly. public class ListPanel extends JPanel @@ -66,10 +66,10 @@ implements Scrollable, ContributionListing.ChangeListener { static final Color SELECTION_COLOR = new Color(0xffe0fffd); static final SectionHeaderContribution[] sections = { - new SectionHeaderContribution(ContributionType.LIBRARY), - new SectionHeaderContribution(ContributionType.MODE), - new SectionHeaderContribution(ContributionType.TOOL), - new SectionHeaderContribution(ContributionType.EXAMPLES) + new SectionHeaderContribution(ContributionType.LIBRARY), + new SectionHeaderContribution(ContributionType.MODE), + new SectionHeaderContribution(ContributionType.TOOL), + new SectionHeaderContribution(ContributionType.EXAMPLES) }; diff --git a/app/src/processing/app/contrib/ManagerFrame.java b/app/src/processing/app/contrib/ManagerFrame.java index 684182c50..955c4b0c5 100644 --- a/app/src/processing/app/contrib/ManagerFrame.java +++ b/app/src/processing/app/contrib/ManagerFrame.java @@ -63,7 +63,6 @@ public class ManagerFrame { public ManagerFrame(Base base) { this.base = base; -// long t1 = System.currentTimeMillis(); final int smallSize = Toolkit.zoom(12); final int normalSize = Toolkit.zoom(14); SMALL_PLAIN = Toolkit.getSansFont(smallSize, Font.PLAIN); @@ -73,19 +72,21 @@ public class ManagerFrame { // TODO Optimize these inits... unfortunately it needs to run on the EDT, // and Swing is a piece of s*t, so it's gonna be slow with lots of contribs. - // All the time is being used up between t2 and t3. // In particular, load everything and then fire the update events. // Also, don't pull all the colors over and over again. -// long t2 = System.currentTimeMillis(); + long t1 = System.currentTimeMillis(); librariesTab = new ContributionTab(this, ContributionType.LIBRARY); + long t2 = System.currentTimeMillis(); modesTab = new ContributionTab(this, ContributionType.MODE); + long t3 = System.currentTimeMillis(); toolsTab = new ContributionTab(this, ContributionType.TOOL); + long t4 = System.currentTimeMillis(); examplesTab = new ContributionTab(this, ContributionType.EXAMPLES); -// long t3 = System.currentTimeMillis(); + long t5 = System.currentTimeMillis(); updatesTab = new UpdateContributionTab(this); + long t6 = System.currentTimeMillis(); -// long t4 = System.currentTimeMillis(); -// System.out.println("ManagerFrame. " + (t2-t1) + " " + (t3-t2) + " " + (t4-t3)); + System.out.println("ManagerFrame. " + (t2-t1) + " " + (t3-t2) + " " + (t4-t3) + " " + (t5-t4) + " " + (t6-t5)); } diff --git a/app/src/processing/app/contrib/StatusPanel.java b/app/src/processing/app/contrib/StatusPanel.java index 28b190998..41d4a83d3 100644 --- a/app/src/processing/app/contrib/StatusPanel.java +++ b/app/src/processing/app/contrib/StatusPanel.java @@ -64,11 +64,7 @@ class StatusPanel extends JPanel { // private String bodyRule; - /** Needed by ContributionListPanel */ - public StatusPanel() { } - - - public StatusPanel(final ContributionTab contributionTab, int width) { + public StatusPanel(final ContributionTab contributionTab) { this.contributionTab = contributionTab; if (foundationIcon == null) { @@ -78,6 +74,11 @@ class StatusPanel extends JPanel { removeIcon = Toolkit.getLibIconX("manager/remove"); buttonFont = ManagerFrame.NORMAL_PLAIN; } + } + + + public StatusPanel(final ContributionTab contributionTab, int width) { + this(contributionTab); setBackground(new Color(0xebebeb)); @@ -224,12 +225,27 @@ class StatusPanel extends JPanel { } + static String getBodyStyle() { + return "body { " + + " margin: 0; " + + " padding: 0;" + + " font-family: " + Toolkit.getSansFontName() + ", Helvetica, Arial, sans-serif;" + + " font-size: 11px;" + +// " font-size: 100%;" + +// " font-size: 0.95em; " + +// "}"; + "}" + + "a { color: #444; text-decoration: none; }"; + } + + public void update(DetailPanel panel) { + System.out.println("rebuilding status panel for " + panel.getContrib().name); progressPanel.removeAll(); iconLabel.setIcon(panel.getContrib().isSpecial() ? foundationIcon : null); label.setText(panel.description); - ((HTMLDocument)label.getDocument()).getStyleSheet().addRule(DetailPanel.getBodyStyle()); + ((HTMLDocument)label.getDocument()).getStyleSheet().addRule(getBodyStyle()); //((HTMLDocument)label.getDocument()).getStyleSheet().addRule("a { color: black; text-decoration:underline; text-decoration-style: dotted; }"); //((HTMLDocument)label.getDocument()).getStyleSheet().addRule("a { color: black; text-decoration:underline dotted; }"); // ((HTMLDocument)label.getDocument()).getStyleSheet().addRule("a { color: #666; text-decoration: none; }"); diff --git a/app/src/processing/app/contrib/UpdateContributionTab.java b/app/src/processing/app/contrib/UpdateContributionTab.java index a3de07f38..54d8d00c2 100644 --- a/app/src/processing/app/contrib/UpdateContributionTab.java +++ b/app/src/processing/app/contrib/UpdateContributionTab.java @@ -27,7 +27,7 @@ public class UpdateContributionTab extends ContributionTab { contributionListPanel = new UpdateListPanel(this, filter); // contributionListPanel.setBorder(new EmptyBorder(8, 8, 8, 8)); - statusPanel = new UpdateStatusPanel(this, 650); + statusPanel = new UpdateStatusPanel(this); contribListing = ContributionListing.getInstance(); contribListing.addListener(contributionListPanel); } diff --git a/app/src/processing/app/contrib/UpdateStatusPanel.java b/app/src/processing/app/contrib/UpdateStatusPanel.java index f91db9fbd..5c591e240 100644 --- a/app/src/processing/app/contrib/UpdateStatusPanel.java +++ b/app/src/processing/app/contrib/UpdateStatusPanel.java @@ -21,8 +21,6 @@ package processing.app.contrib; import java.awt.Color; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import javax.swing.GroupLayout; import javax.swing.LayoutStyle; @@ -33,22 +31,16 @@ import processing.app.ui.Toolkit; public class UpdateStatusPanel extends StatusPanel { - public UpdateStatusPanel(UpdateContributionTab tab, int width) { - super(); - this.contributionTab = tab; + public UpdateStatusPanel(UpdateContributionTab tab) { + super(tab); - updateButton = Toolkit.createIconButton("Update All", "manager/update"); + updateButton = Toolkit.createIconButton("Update All", updateIcon); updateButton.setFont(ManagerFrame.NORMAL_PLAIN); updateButton.setHorizontalAlignment(SwingConstants.LEFT); updateButton.setVisible(true); updateButton.setEnabled(false); - updateButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - contributionTab.updateAll(); - } - }); + updateButton.addActionListener(e -> contributionTab.updateAll()); setBackground(new Color(0xebebeb)); layout = new GroupLayout(this); setLayout(layout);