diff --git a/app/src/processing/app/contrib/ContributionListing.java b/app/src/processing/app/contrib/ContributionListing.java index 5b20d86a0..580aef16f 100644 --- a/app/src/processing/app/contrib/ContributionListing.java +++ b/app/src/processing/app/contrib/ContributionListing.java @@ -56,7 +56,7 @@ public class ContributionListing { Set allContributions; boolean listDownloaded; // boolean listDownloadFailed; - ReentrantLock downloadingListingLock; + ReentrantLock downloadingLock; private ContributionListing() { @@ -64,7 +64,7 @@ public class ContributionListing { advertisedContributions = new ArrayList<>(); librariesByImportHeader = new HashMap<>(); allContributions = new LinkedHashSet<>(); - downloadingListingLock = new ReentrantLock(); + downloadingLock = new ReentrantLock(); listingFile = Base.getSettingsFile(LOCAL_FILENAME); if (listingFile.exists()) { @@ -102,7 +102,7 @@ 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(List installed) { + protected void updateInstalledList(Set installed) { for (Contribution contribution : installed) { Contribution existingContribution = getContribution(contribution); if (existingContribution != null) { @@ -203,7 +203,7 @@ public class ContributionListing { // TODO: replace with SwingWorker [jv] new Thread(() -> { - downloadingListingLock.lock(); + downloadingLock.lock(); try { URL url = new URL(LISTING_URL); @@ -247,7 +247,7 @@ public class ContributionListing { progress.setException(e); progress.finished(); } finally { - downloadingListingLock.unlock(); + downloadingLock.unlock(); } }, "Contribution List Downloader").start(); } @@ -276,15 +276,14 @@ public class ContributionListing { protected boolean hasUpdates(Contribution contrib) { - if (!contrib.isInstalled()) { - return false; + if (contrib.isInstalled()) { + Contribution advertised = getAvailableContribution(contrib); + if (advertised != null) { + return (advertised.getVersion() > contrib.getVersion() && + advertised.isCompatible(Base.getRevision())); + } } - Contribution advertised = getAvailableContribution(contrib); - if (advertised == null) { - return false; - } - return (advertised.getVersion() > contrib.getVersion() && - advertised.isCompatible(Base.getRevision())); + return false; } diff --git a/app/src/processing/app/contrib/ContributionManager.java b/app/src/processing/app/contrib/ContributionManager.java index cef1b86c6..72a4bd202 100644 --- a/app/src/processing/app/contrib/ContributionManager.java +++ b/app/src/processing/app/contrib/ContributionManager.java @@ -38,7 +38,8 @@ import processing.data.StringDict; public class ContributionManager { - static ContributionListing listing; + static ManagerFrame managerFrame; + static ContributionListing contribListing; /** @@ -162,9 +163,9 @@ public class ContributionManager { try { // TODO: run this in SwingWorker done() [jv] EventQueue.invokeAndWait(() -> { - listing.replaceContribution(ad, contribution); + contribListing.replaceContribution(ad, contribution); base.refreshContribs(contribution.getType()); - base.setUpdatesAvailable(listing.countUpdates(base)); + base.setUpdatesAvailable(contribListing.countUpdates(base)); }); } catch (InterruptedException e) { e.printStackTrace(); @@ -245,9 +246,9 @@ public class ContributionManager { try { // TODO: run this in SwingWorker done() [jv] EventQueue.invokeAndWait(() -> { - listing.replaceContribution(ad, contribution); + contribListing.replaceContribution(ad, contribution); base.refreshContribs(contribution.getType()); - base.setUpdatesAvailable(listing.countUpdates(base)); + base.setUpdatesAvailable(contribListing.countUpdates(base)); }); } catch (InterruptedException e) { e.printStackTrace(); @@ -375,9 +376,9 @@ public class ContributionManager { if (contribution != null) { try { EventQueue.invokeAndWait(() -> { - listing.replaceContribution(contrib, contribution); + contribListing.replaceContribution(contrib, contribution); base.refreshContribs(contribution.getType()); - base.setUpdatesAvailable(listing.countUpdates(base)); + base.setUpdatesAvailable(contribListing.countUpdates(base)); }); } catch (InterruptedException e) { e.printStackTrace(); @@ -428,7 +429,7 @@ public class ContributionManager { * * @return a file that does not exist yet */ - public static File getUniqueName(File parentFolder, String fileName) { + static public File getUniqueName(File parentFolder, String fileName) { File backupFolderForLib; int i = 1; do { @@ -486,6 +487,7 @@ public class ContributionManager { deleteFlagged(Base.getSketchbookToolsFolder()); installPreviouslyFailed(base, Base.getSketchbookModesFolder()); + updateFlagged(base, Base.getSketchbookModesFolder()); updateFlagged(base, Base.getSketchbookToolsFolder()); @@ -549,11 +551,11 @@ public class ContributionManager { // https://github.com/processing/processing/issues/5823 if (installList != null) { for (File file : installList) { - for (AvailableContribution contrib : listing.advertisedContributions) { + for (AvailableContribution contrib : contribListing.advertisedContributions) { if (file.getName().equals(contrib.getName())) { file.delete(); installOnStartUp(base, contrib); - EventQueue.invokeAndWait(() -> listing.replaceContribution(contrib, contrib)); + EventQueue.invokeAndWait(() -> contribListing.replaceContribution(contrib, contrib)); } } } @@ -635,7 +637,7 @@ public class ContributionManager { } } - for (AvailableContribution contrib : listing.advertisedContributions) { + for (AvailableContribution contrib : contribListing.advertisedContributions) { if (updateContribsNames.contains(contrib.getName())) { updateContribsList.add(contrib); } @@ -643,7 +645,7 @@ public class ContributionManager { for (AvailableContribution contrib : updateContribsList) { installOnStartUp(base, contrib); - listing.replaceContribution(contrib, contrib); + contribListing.replaceContribution(contrib, contrib); } } @@ -680,12 +682,10 @@ public class ContributionManager { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - static ManagerFrame managerFrame; - - static public void init(Base base) throws Exception { // long t1 = System.currentTimeMillis(); - listing = ContributionListing.getInstance(); // Moved here to make sure it runs on EDT [jv 170121] + // Moved here to make sure it runs on EDT [jv 170121] + contribListing = ContributionListing.getInstance(); // long t2 = System.currentTimeMillis(); managerFrame = new ManagerFrame(base); // long t3 = System.currentTimeMillis(); @@ -695,6 +695,14 @@ public class ContributionManager { } + /* + static public void downloadAvailable() { + //ContributionListing cl = ContributionListing.getInstance(); + contribListing.downloadAvailableList(base, new ContribProgress(null)); + } + */ + + static public void updateTheme() { if (managerFrame != null) { managerFrame.updateTheme(); diff --git a/app/src/processing/app/contrib/ContributionTab.java b/app/src/processing/app/contrib/ContributionTab.java index 679e6c496..027b81db7 100644 --- a/app/src/processing/app/contrib/ContributionTab.java +++ b/app/src/processing/app/contrib/ContributionTab.java @@ -52,12 +52,14 @@ public class ContributionTab extends JPanel { StatusPanel statusPanel; FilterField filterField; + /* JLabel loaderLabel; JPanel errorPanel; JTextPane errorMessage; JButton tryAgainButton; JButton closeButton; + */ String category; @@ -68,22 +70,24 @@ public class ContributionTab extends JPanel { this.managerFrame = dialog; this.base = dialog.base; + /* buildErrorPanel(); loaderLabel = new JLabel(Toolkit.getLibIcon("manager/loader.gif")); loaderLabel.setOpaque(false); + */ } public ContributionTab(ManagerFrame frame, ContributionType type) { this(frame); - this.contribType = type; + contribType = type; filter = contrib -> contrib.getType() == contribType; 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] + // TODO StatusPanel 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); @@ -100,18 +104,33 @@ public class ContributionTab extends JPanel { listPanel.updateTheme(); statusPanel.updateTheme(); - closeButton.setIcon(Toolkit.renderIcon("manager/close", Theme.get("manager.error.close.icon.color"), 16)); + //closeButton.setIcon(Toolkit.renderIcon("manager/close", Theme.get("manager.error.close.icon.color"), 16)); } - public void rebuildLayout(boolean error, boolean loading) { + /* + protected void activate() { + System.out.println("activating " + contribType); + //updateContributionListing(); + ContributionListing.getInstance().updateInstalledList(base.getInstalledContribs()); + updateCategoryChooser(); + //rebuildLayout(false, false); + rebuildLayout(); + } + */ + + +// public void rebuildLayout(boolean error, boolean loading) { + public void rebuildLayout() { setLayout(); + /* listPanel.setVisible(!loading); loaderLabel.setVisible(loading); errorPanel.setVisible(error); + */ - listPanel.fireChange(); + listPanel.fireChange(); // wtf, really? every time? [fry 230111] validate(); repaint(); @@ -147,12 +166,14 @@ public class ContributionTab extends JPanel { filterWidth, filterWidth, filterWidth) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE) - .addComponent(categoryChooser, - ManagerFrame.AUTHOR_WIDTH, - ManagerFrame.AUTHOR_WIDTH, - ManagerFrame.AUTHOR_WIDTH) - .addGap(scrollBarWidth)).addComponent(loaderLabel) - .addComponent(listPanel).addComponent(errorPanel) + .addComponent(categoryChooser, + ManagerFrame.AUTHOR_WIDTH, + ManagerFrame.AUTHOR_WIDTH, + ManagerFrame.AUTHOR_WIDTH) + .addGap(scrollBarWidth)) + //.addComponent(loaderLabel) + .addComponent(listPanel) + //.addComponent(errorPanel) .addComponent(statusPanel)); layout.setVerticalGroup(layout @@ -164,11 +185,13 @@ public class ContributionTab extends JPanel { // https://github.com/processing/processing4/issues/520 .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) - .addComponent(loaderLabel) + //.addComponent(loaderLabel) .addComponent(listPanel)) - .addComponent(errorPanel) - .addComponent(statusPanel, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); + //.addComponent(errorPanel) + .addComponent(statusPanel, + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)); layout.linkSize(SwingConstants.VERTICAL, categoryChooser, filterField); // these will occupy space even if not visible @@ -201,6 +224,7 @@ public class ContributionTab extends JPanel { } + /* protected void buildErrorPanel() { errorPanel = new JPanel(); GroupLayout layout = new GroupLayout(errorPanel); @@ -248,6 +272,7 @@ public class ContributionTab extends JPanel { errorPanel.setBackground(Color.PINK); errorPanel.validate(); } + */ private Set listCategories() { @@ -298,6 +323,7 @@ public class ContributionTab extends JPanel { } + /* // TODO Why is this entire set of code only running when Editor // is not null... And what's it doing anyway? Shouldn't it run // on all editors? (The change to getActiveEditor() was made @@ -339,6 +365,7 @@ public class ContributionTab extends JPanel { //listPanel.filterDummy(category); } } + */ public void updateStatusDetail(StatusDetail detail) { @@ -364,7 +391,7 @@ public class ContributionTab extends JPanel { // Color placeholderColor; // Color backgroundColor; - FilterField () { + FilterField() { // super(""); // necessary? // a label that appears above the component when empty and not focused diff --git a/app/src/processing/app/contrib/ManagerFrame.java b/app/src/processing/app/contrib/ManagerFrame.java index 2bcedc888..e5a9fb3f6 100644 --- a/app/src/processing/app/contrib/ManagerFrame.java +++ b/app/src/processing/app/contrib/ManagerFrame.java @@ -91,12 +91,14 @@ public class ManagerFrame { makeFrame(); // done before as downloadAndUpdateContributionListing() // requires the current selected tab - tabs.setPanel(showTab); - //downloadAndUpdateContributionListing(base); - downloadAndUpdateContributionListing(); - } else { - tabs.setPanel(showTab); +// tabs.setPanel(showTab); + //downloadAndUpdateContributionListing(); +// ContributionListing.updateInstalled(base); +// showTab.activate(); +// } else { } + tabs.setPanel(showTab); +// } frame.setVisible(true); // Avoid the search box taking focus and hiding the 'search' text tabs.requestFocusInWindow(); @@ -108,7 +110,10 @@ public class ManagerFrame { frame.setMinimumSize(Toolkit.zoom(750, 500)); tabs = new ManagerTabs(); - rebuildTabLayouts(false, true); + //rebuildTabLayouts(false, true); + for (ContributionTab tab : tabList) { + tab.rebuildLayout(); + } tabs.addPanel(librariesTab, "Libraries"); tabs.addPanel(modesTab, "Modes"); @@ -181,58 +186,33 @@ public class ManagerFrame { } + /* // TODO move this to ContributionTab (this is handled weirdly, period) [fry] //void downloadAndUpdateContributionListing(Base base) { void downloadAndUpdateContributionListing() { //activeTab is required now but should be removed //as there is only one instance of contribListing, and it should be present in this class - final ContributionTab activeTab = getActiveTab(); +// final ContributionTab activeTab = getActiveTab(); + ContributionTab activeTab = (ContributionTab) tabs.getPanel(); - /* - final JProgressBar bar = activeTab.progressBar; - ContribProgress progress = new ContribProgress(bar) { - @Override - public void startTask(String name, int maxValue) { - super.startTask(name, maxValue); - bar.setVisible(true); - bar.setString(null); - } +// activeTab.updateContributionListing(); + ContributionListing.updateInstalled(base); + activeTab.updateCategoryChooser(); - @Override - public void setProgress(int value) { - super.setProgress(value); - bar.setValue(value); - } - - @Override - public void finishedAction() { - bar.setVisible(false); - */ - activeTab.updateContributionListing(); - activeTab.updateCategoryChooser(); - - /* - Exception exception = getException(); - if (exception != null) { - exception.printStackTrace(); - makeAndShowTab(true, false); - } else { - */ - rebuildTabLayouts(false, false); - /* - } - } - }; - ContributionListing.getInstance().downloadAvailableList(base, progress); - */ + //rebuildTabLayouts(false, false); + //activeTab.rebuildLayout(false, false); + activeTab.rebuildLayout(); } + */ + /* protected void rebuildTabLayouts(boolean error, boolean loading) { for (ContributionTab tab : tabList) { tab.rebuildLayout(error, loading); } } + */ protected ContributionTab getTab(ContributionType contributionType) { @@ -249,7 +229,7 @@ public class ManagerFrame { } - ContributionTab getActiveTab() { - return (ContributionTab) tabs.getPanel(); - } +// ContributionTab getActiveTab() { +// return (ContributionTab) tabs.getPanel(); +// } } diff --git a/app/src/processing/app/contrib/UpdateContributionTab.java b/app/src/processing/app/contrib/UpdateContributionTab.java index f104cf4fe..8ef1f7405 100644 --- a/app/src/processing/app/contrib/UpdateContributionTab.java +++ b/app/src/processing/app/contrib/UpdateContributionTab.java @@ -63,19 +63,21 @@ public class UpdateContributionTab extends ContributionTab { setLayout(layout); layout.setHorizontalGroup(layout .createParallelGroup(GroupLayout.Alignment.CENTER) - .addComponent(loaderLabel) + //.addComponent(loaderLabel) .addComponent(listPanel) - .addComponent(errorPanel) + //.addComponent(errorPanel) .addComponent(statusPanel)); layout.setVerticalGroup(layout .createSequentialGroup() .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) - .addComponent(loaderLabel) + //.addComponent(loaderLabel) .addComponent(listPanel)) - .addComponent(errorPanel) - .addComponent(statusPanel, GroupLayout.PREFERRED_SIZE, - GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)); + //.addComponent(errorPanel) + .addComponent(statusPanel, + GroupLayout.PREFERRED_SIZE, + GroupLayout.DEFAULT_SIZE, + GroupLayout.PREFERRED_SIZE)); layout.setHonorsVisibility(listPanel, false); //setBackground(Color.WHITE); diff --git a/todo.txt b/todo.txt index 3da3b4481..3b3d87abe 100755 --- a/todo.txt +++ b/todo.txt @@ -9,6 +9,19 @@ X cannot use @Override and @Deprecated in static mode X https://github.com/processing/processing4/issues/619 X https://github.com/processing/processing4/pull/622 +manager/cleaning +X send info on 'check for updates' so we know about libs/modes/etc? +X how to disclose to users? +X only send for items that are part of the public list +X otherwise we're sending private libraries/installs +X although this won't pick up old libraries not on the new system +o we shouldn't use .properties extension for modes, et al +o because a .properties file is iso8859-1 +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 + manager X add foundation libraries to the stats (https://download.processing.org/stats/) X make foundationLibraries a class var, and then access it when calling download() @@ -19,9 +32,15 @@ X cleaning up methods for initializing various contribs in Base X replace getToolContribs() with getContribTools() for consistency 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 + +_ 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? -_ Mode manager window is empty -_ https://github.com/processing/processing4/issues/613 _ Cannot invoke "javax.swing.JProgressBar.setVisible(boolean)" because "this.progressBar" is null _ https://github.com/processing/processing4/issues/618 @@ -33,8 +52,9 @@ _ should be using Base.getInstalledContribs() instead of rewriting its own _ ManagerFrame.downloadAndUpdateContributionListing() _ should not even be run, because the contribs load on startup _ but ContributionTab.tryAgainButton needs to be able to request re-download -o ManagerFrame.makeAndShowTab() -o this one looks like it's gonna get called multiple times + +_ make note in docs that .properties file *must* be utf-8 (usually iso8859-1) +_ if not it'll make things gross (andre sier flob library) _ make ctrl-g work inside the find window @@ -383,11 +403,10 @@ _ https://github.com/processing/processing/issues/4757 PDE / Manager (3.x notes) -_ vertical centering of the search box in the manager _ “could not move the contribution to the backup folder” message while updating _ problem is that any sketch that uses a library, the lib is stuck as "in use" _ https://github.com/processing/processing/issues/4973 -_ issues with updating modes +_ failed Mode updates leaving around tmp folders (that appear to be legit Modes) _ https://github.com/processing/processing/issues/5424 _ examples window not updating on install _ open examples window @@ -411,19 +430,9 @@ _ looks like ContributionListing.getScrollableUnitIncrement() returns early _ Examples window closes and re-opens during library install/remove _ https://github.com/processing/processing/issues/3304 _ several TODO items listed in ContributionPanel -_ something to set min/max versions that are supported by a library _ ability to cancel a download/install -_ we shouldn't use .properties extension for modes, et al -_ because a .properties file is iso8859-1 -_ make note that .properties file *must* be utf-8 -_ if not it'll make things gross (andre sier flob library) _ why wasn't Library moved to LibraryContribution? _ or that LibraryContribution needs to be a wrapper around it? -_ send info on 'check for updates' so we know about libs/modes/etc? -_ how to disclose to users? -_ only send for items that are part of the public list -_ otherwise we're sending private libraries/installs -_ although this won't pick up old libraries not on the new system _ classpath conflicts.. _ getPackageList.. from Library... maybe others? _ really need to make sure that a weird core.jar isn't being imported