diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 89d7fb31e..7f2cf3ab8 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -113,6 +113,9 @@ public class Base { private List coreTools; private List contribTools; + /** Current tally of available updates (used for new Editor windows). */ + private int updatesAvailable = 0; + // Used by handleOpen(), this saves the chooser to remember the directory. // Doesn't appear to be necessary with the AWT native file dialog. // https://github.com/processing/processing/pull/2366 @@ -700,17 +703,21 @@ public class Base { } - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + public void tallyUpdatesAvailable() { + Set installed = getInstalledContribs(); + ContributionListing listing = ContributionListing.getInstance(); + int newCount = 0; + for (Contribution contrib : installed) { + if (listing.hasUpdates(contrib)) { + newCount++; + } + } + updatesAvailable = newCount; - private int updatesAvailable = 0; - - - public void setUpdatesAvailable(int n) { - updatesAvailable = n; synchronized (editors) { - for (Editor e : editors) { - e.setUpdatesAvailable(n); + for (Editor editor : editors) { + editor.setUpdatesAvailable(updatesAvailable); } } } diff --git a/app/src/processing/app/contrib/ContributionListing.java b/app/src/processing/app/contrib/ContributionListing.java index 580aef16f..d08b6360f 100644 --- a/app/src/processing/app/contrib/ContributionListing.java +++ b/app/src/processing/app/contrib/ContributionListing.java @@ -29,7 +29,6 @@ import java.util.*; import java.util.concurrent.locks.ReentrantLock; import processing.app.Base; -import processing.app.Library; import processing.app.UpdateCheck; import processing.app.Util; import processing.core.PApplet; @@ -98,23 +97,23 @@ 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. - */ - protected void updateInstalledList(Set installed) { - for (Contribution contribution : installed) { - Contribution existingContribution = getContribution(contribution); - if (existingContribution != null) { - if (existingContribution != contribution) { - // don't replace contrib with itself - replaceContribution(existingContribution, contribution); - } - } else { - addContribution(contribution); - } - } - } +// /** +// * 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(Set installed) { +// for (Contribution contribution : installed) { +// Contribution existingContribution = getContribution(contribution); +// if (existingContribution != null) { +// if (existingContribution != contribution) { +// // don't replace contrib with itself +// replaceContribution(existingContribution, contribution); +// } +// } else { +// addContribution(contribution); +// } +// } +// } protected void replaceContribution(Contribution oldLib, Contribution newLib) { @@ -164,6 +163,7 @@ public class ContributionListing { } + /* private Contribution getContribution(Contribution contribution) { for (Contribution c : allContributions) { if (c.getName().equals(contribution.getName()) && @@ -173,6 +173,7 @@ public class ContributionListing { } return null; } + */ protected AvailableContribution getAvailableContribution(Contribution info) { @@ -226,7 +227,7 @@ public class ContributionListing { // TODO: run this in SwingWorker done() [jv] EventQueue.invokeAndWait(() -> { setAdvertisedList(listingFile); - base.setUpdatesAvailable(countUpdates(base)); + base.tallyUpdatesAvailable(); }); } catch (InterruptedException e) { e.printStackTrace(); @@ -275,7 +276,7 @@ public class ContributionListing { } - protected boolean hasUpdates(Contribution contrib) { + public boolean hasUpdates(Contribution contrib) { if (contrib.isInstalled()) { Contribution advertised = getAvailableContribution(contrib); if (advertised != null) { @@ -342,13 +343,14 @@ public class ContributionListing { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - /** - * TODO This needs to be called when the listing loads, and also - * the contribs list has been updated (for whatever reason). - * In addition, the caller (presumably Base) should update all - * Editor windows with the correct number of items available. - * @return The number of contributions that have available updates. - */ +// /** +// * TODO This needs to be called when the listing loads, and also +// * the contribs list has been updated (for whatever reason). +// * In addition, the caller (presumably Base) should update all +// * Editor windows with the correct number of items available. +// * @return The number of contributions that have available updates. +// */ + /* public int countUpdates(Base base) { int count = 0; for (ModeContribution mc : base.getContribModes()) { @@ -357,12 +359,16 @@ public class ContributionListing { } } if (base.getActiveEditor() != null) { - for (Library lib : base.getActiveEditor().getMode().contribLibraries) { + Mode activeMode = base.getActiveEditor().getMode(); + for (Library lib : activeMode.contribLibraries) { if (hasUpdates(lib)) { count++; } } - for (Library lib : base.getActiveEditor().getMode().coreLibraries) { + // Changing this from coreLibraries to foundationLibraries for 4.1.2 + // because that's probably what was intended earlier. [fry 230112] + // https://github.com/processing/processing4/commit/3f5451c7371f2d97aa0bac21262a27ea4eeebe67 + for (Library lib : activeMode.foundationLibraries) { if (hasUpdates(lib)) { count++; } @@ -380,6 +386,7 @@ public class ContributionListing { } return count; } + */ /** Used by JavaEditor to auto-import */ diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index 72a4bd202..6ab13a285 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -165,7 +165,8 @@ public class ContributionManager { EventQueue.invokeAndWait(() -> { contribListing.replaceContribution(ad, contribution); base.refreshContribs(contribution.getType()); - base.setUpdatesAvailable(contribListing.countUpdates(base)); + //base.setUpdatesAvailable(contribListing.countUpdates(base)); + base.tallyUpdatesAvailable(); }); } catch (InterruptedException e) { e.printStackTrace(); @@ -248,7 +249,7 @@ public class ContributionManager { EventQueue.invokeAndWait(() -> { contribListing.replaceContribution(ad, contribution); base.refreshContribs(contribution.getType()); - base.setUpdatesAvailable(contribListing.countUpdates(base)); + base.tallyUpdatesAvailable(); }); } catch (InterruptedException e) { e.printStackTrace(); @@ -378,7 +379,7 @@ public class ContributionManager { EventQueue.invokeAndWait(() -> { contribListing.replaceContribution(contrib, contribution); base.refreshContribs(contribution.getType()); - base.setUpdatesAvailable(contribListing.countUpdates(base)); + base.tallyUpdatesAvailable(); }); } catch (InterruptedException e) { e.printStackTrace(); diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index e73874b29..216f6b61c 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -402,7 +402,7 @@ public abstract class LocalContribution extends Contribution { cl.replaceContribution(LocalContribution.this, advertisedVersion); } base.refreshContribs(LocalContribution.this.getType()); - base.setUpdatesAvailable(cl.countUpdates(base)); + base.tallyUpdatesAvailable(); }); } catch (InterruptedException e) { e.printStackTrace(); @@ -426,7 +426,7 @@ public abstract class LocalContribution extends Contribution { cl.replaceContribution(LocalContribution.this, LocalContribution.this); base.refreshContribs(LocalContribution.this.getType()); - base.setUpdatesAvailable(cl.countUpdates(base)); + base.tallyUpdatesAvailable(); }); } catch (InterruptedException e) { e.printStackTrace(); diff --git a/build/shared/lib/manager/loader.gif b/build/shared/lib/manager/loader.gif deleted file mode 100644 index 60cbc6a13..000000000 Binary files a/build/shared/lib/manager/loader.gif and /dev/null differ diff --git a/todo.txt b/todo.txt index 3b3d87abe..f451b77ce 100755 --- a/todo.txt +++ b/todo.txt @@ -21,6 +21,20 @@ X this ship has sailed X something to set min/max versions that are supported by a library o ManagerFrame.makeAndShowTab() o this one looks like it's gonna get called multiple times +o alternating blue/white backgrounds aren't updated after changing filter +o just need to call a repaint() after a filter change? +o check with Casey about coloring for error messages +o test on Windows and Linux +o font size for "Downloading" on progress bar is too large +o but changing the size breaks the vertical centering +o wheel mouse is super jumpy +o something about unit increment in ContributionListPanel +o arrow keys up/down move scroll bar, not selection +o fonts/etc need to be set in one place where they can be edited +o move styling to separate constants that are more accessible +o optimize ContributionTab addListener() call in constructor +X no longer calling addListener() on every single entry, whcih helps +/ but what else might that change be breaking? manager X add foundation libraries to the stats (https://download.processing.org/stats/) @@ -34,12 +48,17 @@ X change base.getModeContribs() to base.getContribModes() for consistency X move contribs -> binary blob out of Base since it doesn't belong there X Mode manager window is empty X https://github.com/processing/processing4/issues/613 +X in ContributionTab, the downloadAndUpdateContributionListing() should actually be downloading +X but in ManagerFrame.showFrame(), it should not, and should just make sure the list is updated +X however, the list can be updated another time, right? after load? only on changes? +X remove dorky loading.gif (used in ContributionTab and UpdateContributionTab) +X should be a better way to implement this +X currently removed, but still need a way to indicate loading +_ updates tab is empty +_ remove Libraries/Tools/etc separators from Updates tab? too confusing/looks like a bug? _ remove rebuildLayout() from ContributionTab? -_ in ContributionTab, the downloadAndUpdateContributionListing() should actually be downloading -_ but in ManagerFrame.showFrame(), it should not, and should just make sure the list is updated -_ however, the list can be updated another time, right? after load? only on changes? _ Cannot invoke "javax.swing.JProgressBar.setVisible(boolean)" because "this.progressBar" is null _ https://github.com/processing/processing4/issues/618 @@ -344,8 +363,8 @@ PDE / Manager (4.x notes) _ get rid of dummy progress bar being created in StatusDetail.update() _ would be good to *add* a progress bar of some kind, but sheesh -_ remove dorky loading.gif (used in ContributionTab and UpdateContributionTab) -_ should be a better way to implement this +_ if contribution listing is still downloading, need to indicate +_ especially when no previous contribs.txt is in the prefs folder _ if no internet available, install buttons disabled, but not clear why broken _ also if update check disabled, user isn't notified that contribs unavailable _ currently no indication that contrib download failed @@ -367,9 +386,6 @@ _ when opening manager, animation runs briefly then freezes _ DetailPanel setContribution() being called 4x for each contrib on startup _ during install of contrib, progress is halting during the install _ probably too much happening on the EDT that should not be -_ optimize ContributionTab addListener() call in constructor -X no longer calling addListener() on every single entry, whcih helps -_ but what else might that change be breaking? _ StatusPanel seems to be recreated entirely _ StatusPanel being reset twice on each click _ is checking for previous, but apparently that's not working @@ -449,17 +465,7 @@ _ "Update 4 items" as a button name _ new libraries not picked up when changing sketchbook location _ make sure contrib manager can run w/o a network connection _ or if a bad document comes through, it can recover -_ alternating blue/white backgrounds aren't updated after changing filter -_ just need to call a repaint() after a filter change? -_ check with Casey about coloring for error messages -_ test on Windows and Linux -_ font size for "Downloading" on progress bar is too large -_ but changing the size breaks the vertical centering -_ wheel mouse is super jumpy -_ something about unit increment in ContributionListPanel -_ arrow keys up/down move scroll bar, not selection -_ fonts/etc need to be set in one place where they can be edited -_ move styling to separate constants that are more accessible + PDE / Preferences