From 424f50b1febeb79ff2127944f237766e8668a641 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Mon, 28 Jul 2014 00:10:03 +0400 Subject: [PATCH 1/5] Done with GUI changes for Show Compatible Contributions --- .../app/contrib/ContributionManagerDialog.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index 66dc442f3..865676f41 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -226,6 +226,22 @@ public class ContributionManagerDialog { // filterPanel.add(Box.createHorizontalGlue()); filterField = new FilterField(); filterPanel.add(filterField); + + filterPanel.add(Box.createHorizontalStrut(5)); + + String compatibleContribType = title.substring(0, title.indexOf(" ")) + .equalsIgnoreCase("Library") ? "Libraries" : (title.substring(0, title + .indexOf(" ")) + "s"); + + JCheckBox compatibleContrib = new JCheckBox("Show Only Compatible " + compatibleContribType); + compatibleContrib.addItemListener(new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent arg0) { + System.out.println("Here"); + } + }); + filterPanel.add(compatibleContrib); // filterPanel.add(Box.createHorizontalGlue()); // } //filterPanel.setBorder(new EmptyBorder(13, 13, 13, 13)); From 93b311078330d133ddfa07517e7f526276cbf26e Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Mon, 28 Jul 2014 03:04:22 +0400 Subject: [PATCH 2/5] Added a compatibleVersions field to properties,contrib And the appropriate parsing of the field --- .../app/contrib/AvailableContribution.java | 21 ++++- .../processing/app/contrib/Contribution.java | 84 ++++++++++++++++++- .../contrib/ContributionManagerDialog.java | 2 +- .../app/contrib/LocalContribution.java | 13 ++- 4 files changed, 116 insertions(+), 4 deletions(-) diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index 39b1cb1b0..457c9f61b 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -1,4 +1,4 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* Part of the Processing project - http://processing.org @@ -61,6 +61,12 @@ class AvailableContribution extends Contribution { } catch (NumberFormatException e) { lastUpdated = 0; } + try { + compatibleVersions = parseCompatibleVersions(params.get("compatibleVersions")); + } + catch (NumberFormatException nfe) { + compatibleVersions = null; + } } @@ -287,6 +293,18 @@ class AvailableContribution extends Contribution { // System.err // .println("Please contact the author to fix it according to the guidelines."); } + + String compatibleVersions = properties.get("compatibleVersions"); + if (compatibleVersions != null && !compatibleVersions.isEmpty()) { + try { + parseCompatibleVersions(compatibleVersions); + } + catch (NumberFormatException nfe) { + compatibleVersions = getCompatibleVersionsStr(); + } + } + else + compatibleVersions = getCompatibleVersionsStr(); if (propFile.delete() && propFile.createNewFile() && propFile.setWritable(true)) { PrintWriter writer = PApplet.createWriter(propFile); @@ -300,6 +318,7 @@ class AvailableContribution extends Contribution { writer.println("version=" + version); writer.println("prettyVersion=" + prettyVersion); writer.println("lastUpdated=" + lastUpdated); + writer.println("compatibleVersions=" + compatibleVersions); if (getType() == ContributionType.EXAMPLES_PACKAGE) { writer.println("compatibleModesList=" + compatibleContribsList); } diff --git a/app/src/processing/app/contrib/Contribution.java b/app/src/processing/app/contrib/Contribution.java index 451ab7d4e..010d5db55 100644 --- a/app/src/processing/app/contrib/Contribution.java +++ b/app/src/processing/app/contrib/Contribution.java @@ -24,8 +24,11 @@ package processing.app.contrib; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; +import java.util.TreeMap; import processing.app.Language; +import processing.app.Base; import processing.core.PApplet; @@ -44,7 +47,8 @@ abstract public class Contribution { protected String paragraph; // protected int version; // 102 protected String prettyVersion; // "1.0.2" - protected long lastUpdated; // 1402805757 + protected long lastUpdated; // 1402805757 + protected TreeMap compatibleVersions; // 216,220,226-229 // "Sound" @@ -129,6 +133,42 @@ abstract public class Contribution { } + public String getCompatibleVersionsStr() { + if (compatibleVersions == null) + return ""; + StringBuilder sb = new StringBuilder(); + sb.append(""); + for (Map.Entry range : compatibleVersions.entrySet()) { + if (range.getKey() == range.getValue()) { + sb.append(range.getKey()); + sb.append(","); + } + else { + sb.append(range.getKey()); + sb.append("-"); + sb.append(range.getValue()); + } + } + sb.deleteCharAt(sb.length()-1); // delete last comma + return sb.toString(); + } + + + public TreeMap getCompatibleVersions() { + return compatibleVersions; + } + + + public boolean isCompatible(int versionNum) { + if (compatibleVersions != null) { + if (compatibleVersions.ceilingEntry(versionNum) != null + && versionNum <= compatibleVersions.ceilingEntry(versionNum).getValue()) + return true; + } + return false; + } + + abstract public ContributionType getType(); @@ -195,4 +235,46 @@ abstract public class Contribution { } return outgoing; } + + + /** + * @param compVerStr + *
A string consisting of a comma separated list of numbers. + * Ranges may be indicated by hyphens between 2 numbers. Open ranges + * may be indicated by leaving the right side of the last hyphen + * blank. + *
   For example, "222,225,227-229,230-" + * is valid. + * @return A TreeMap consisting of integer-integer key-value pairs that + * represent ranges for which the contribution has been + * tested.
   The example above would return a + * TreeMap with the pairs + * <222,222>, <225,225>, <227,229>, + *
   <230,(present_release_number)>. + */ + static TreeMap parseCompatibleVersions(String compVerStr) + throws NumberFormatException { + if (compVerStr == null || compVerStr.equals("")) + return null; + String[] ranges = compVerStr.split(","); + TreeMap compatibleTM = new TreeMap(); + for (String range : ranges) { + range = range.trim(); + if (range.indexOf("-") != -1) { + int key = Integer.parseInt(range.substring(0, range.indexOf("-")) + .trim()); + int value; + if (((range.indexOf("-") + 1) >= range.length()) + || range.substring(range.indexOf("-") + 1).trim().isEmpty()) { + value = Base.getRevision(); + } + else + value = Integer.parseInt(range.substring(range.indexOf("-") + 1) + .trim()); + compatibleTM.put(key, value); + } else + compatibleTM.put(Integer.parseInt(range), Integer.parseInt(range)); + } + return compatibleTM; + } } diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index 865676f41..7b5ea93ab 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -238,7 +238,7 @@ public class ContributionManagerDialog { @Override public void itemStateChanged(ItemEvent arg0) { - System.out.println("Here"); + System.out.println(Base.getRevision()); } }); filterPanel.add(compatibleContrib); diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 1cedbd652..892cecfb3 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -74,17 +74,28 @@ public abstract class LocalContribution extends Contribution { System.err.println("The version number for the “" + name + "” library is not set properly."); System.err.println("Please contact the library author to fix it according to the guidelines."); } + prettyVersion = properties.get("prettyVersion"); + try { lastUpdated = Long.parseLong(properties.get("lastUpdated")); } catch (NumberFormatException e) { lastUpdated = 0; - // Better comment these out till all contribs have a lastUpdated // System.err.println("The last updated timestamp for the “" + name + "” library is not set properly."); // System.err.println("Please contact the library author to fix it according to the guidelines."); } + try { + compatibleVersions = parseCompatibleVersions(properties.get("compatibleVersions")); + } + catch (NumberFormatException nfe) { + compatibleVersions = null; + System.err + .println("The format of the compatibleVersions field is incorrect for " + + name); + } + } else { Base.log("No properties file at " + propertiesFile.getAbsolutePath()); // We'll need this to be set at a minimum. From 62cb88de6655c3a4965e1c634525dc08d156b812 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Mon, 28 Jul 2014 21:09:08 +0400 Subject: [PATCH 3/5] Finished work on Showing only compatible contribs --- .../processing/app/contrib/Contribution.java | 10 +++++----- .../app/contrib/ContributionListing.java | 18 ++++++++++++++++++ .../contrib/ContributionManagerDialog.java | 19 +++++++++++++++---- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/app/src/processing/app/contrib/Contribution.java b/app/src/processing/app/contrib/Contribution.java index 010d5db55..cd0879a09 100644 --- a/app/src/processing/app/contrib/Contribution.java +++ b/app/src/processing/app/contrib/Contribution.java @@ -137,9 +137,8 @@ abstract public class Contribution { if (compatibleVersions == null) return ""; StringBuilder sb = new StringBuilder(); - sb.append(""); for (Map.Entry range : compatibleVersions.entrySet()) { - if (range.getKey() == range.getValue()) { + if (range.getKey().equals(range.getValue())) { sb.append(range.getKey()); sb.append(","); } @@ -147,6 +146,7 @@ abstract public class Contribution { sb.append(range.getKey()); sb.append("-"); sb.append(range.getValue()); + sb.append(","); } } sb.deleteCharAt(sb.length()-1); // delete last comma @@ -161,9 +161,9 @@ abstract public class Contribution { public boolean isCompatible(int versionNum) { if (compatibleVersions != null) { - if (compatibleVersions.ceilingEntry(versionNum) != null - && versionNum <= compatibleVersions.ceilingEntry(versionNum).getValue()) - return true; + if (compatibleVersions.floorEntry(versionNum) != null + && versionNum <= compatibleVersions.floorEntry(versionNum).getValue()) { + return true; } } return false; } diff --git a/app/src/processing/app/contrib/ContributionListing.java b/app/src/processing/app/contrib/ContributionListing.java index e2f172075..f44b6a51f 100644 --- a/app/src/processing/app/contrib/ContributionListing.java +++ b/app/src/processing/app/contrib/ContributionListing.java @@ -308,6 +308,24 @@ public class ContributionListing { } + protected List getCompatibleContributionList(List filteredLibraries, boolean filter) { + ArrayList filteredList = + new ArrayList(filteredLibraries); + + if (!filter) + return filteredList; + + Iterator it = filteredList.iterator(); + while (it.hasNext()) { + Contribution libInfo = it.next(); + if (!libInfo.isCompatible(Base.getRevision())) { + it.remove(); + } + } + return filteredList; + } + + private void notifyRemove(Contribution contribution) { for (ContributionChangeListener listener : listeners) { listener.contributionRemoved(contribution); diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index 7b5ea93ab..78bb6004a 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -57,6 +57,7 @@ public class ContributionManagerDialog { // the calling editor, so updates can be applied Editor editor; String category; + boolean isCompatibilityFilter; ContributionListing contribListing; @@ -217,7 +218,7 @@ public class ContributionManagerDialog { if (ContributionManagerDialog.ANY_CATEGORY.equals(category)) { category = null; } - filterLibraries(category, filterField.filters); + filterLibraries(category, filterField.filters, isCompatibilityFilter); contributionListPanel.updateColors(); } }); @@ -233,12 +234,14 @@ public class ContributionManagerDialog { .equalsIgnoreCase("Library") ? "Libraries" : (title.substring(0, title .indexOf(" ")) + "s"); - JCheckBox compatibleContrib = new JCheckBox("Show Only Compatible " + compatibleContribType); + final JCheckBox compatibleContrib = new JCheckBox("Show Only Compatible " + compatibleContribType); compatibleContrib.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { - System.out.println(Base.getRevision()); + isCompatibilityFilter = compatibleContrib.isSelected(); + filterLibraries(category, filterField.filters, isCompatibilityFilter); + contributionListPanel.updateColors(); } }); filterPanel.add(compatibleContrib); @@ -403,6 +406,14 @@ public class ContributionManagerDialog { contributionListPanel.filterLibraries(filteredLibraries); } + + protected void filterLibraries(String category, List filters, boolean isCompatibilityFilter) { + List filteredLibraries = + contribListing.getFilteredLibraryList(category, filters); + filteredLibraries = contribListing.getCompatibleContributionList(filteredLibraries, isCompatibilityFilter); + contributionListPanel.filterLibraries(filteredLibraries); + } + protected void updateContributionListing() { if (editor != null) { @@ -539,7 +550,7 @@ public class ContributionManagerDialog { // Replace anything but 0-9, a-z, or : with a space filter = filter.replaceAll("[^\\x30-\\x39^\\x61-\\x7a^\\x3a]", " "); filters = Arrays.asList(filter.split(" ")); - filterLibraries(category, filters); + filterLibraries(category, filters, isCompatibilityFilter); contributionListPanel.updateColors(); } From b2268dcb4d6fb83e7849fdcbe78dc480380b4bba Mon Sep 17 00:00:00 2001 From: Joel Moniz Date: Wed, 13 Aug 2014 14:09:15 +0530 Subject: [PATCH 4/5] Replaced compatibleVersions field with mix/maxRevision fields --- .../app/contrib/AvailableContribution.java | 46 ++++++---- .../processing/app/contrib/Contribution.java | 85 +++---------------- .../contrib/ContributionManagerDialog.java | 11 ++- .../app/contrib/LocalContribution.java | 18 ++-- 4 files changed, 57 insertions(+), 103 deletions(-) diff --git a/app/src/processing/app/contrib/AvailableContribution.java b/app/src/processing/app/contrib/AvailableContribution.java index 457c9f61b..1ef5d092e 100644 --- a/app/src/processing/app/contrib/AvailableContribution.java +++ b/app/src/processing/app/contrib/AvailableContribution.java @@ -49,11 +49,14 @@ class AvailableContribution extends Contribution { url = params.get("url"); sentence = params.get("sentence"); paragraph = params.get("paragraph"); + String versionStr = params.get("version"); if (versionStr != null) { version = PApplet.parseInt(versionStr, 0); } + prettyVersion = params.get("prettyVersion"); + String lastUpdatedStr = params.get("lastUpdated"); if (lastUpdatedStr != null) try { @@ -61,11 +64,15 @@ class AvailableContribution extends Contribution { } catch (NumberFormatException e) { lastUpdated = 0; } - try { - compatibleVersions = parseCompatibleVersions(params.get("compatibleVersions")); + + String minRev = params.get("minRevision"); + if (minRev != null) { + minRevision = PApplet.parseInt(minRev, 0); } - catch (NumberFormatException nfe) { - compatibleVersions = null; + + String maxRev = params.get("maxRevision"); + if (maxRev != null) { + maxRevision = PApplet.parseInt(maxRev, 0); } } @@ -293,18 +300,24 @@ class AvailableContribution extends Contribution { // System.err // .println("Please contact the author to fix it according to the guidelines."); } - - String compatibleVersions = properties.get("compatibleVersions"); - if (compatibleVersions != null && !compatibleVersions.isEmpty()) { - try { - parseCompatibleVersions(compatibleVersions); - } - catch (NumberFormatException nfe) { - compatibleVersions = getCompatibleVersionsStr(); - } + + int minRev; + try { + minRev = Integer.parseInt(properties.get("minRevision")); + } catch (NumberFormatException e) { + minRev = getMinRevision(); + System.err.println("The minimum compatible revision for the “" + name + + "” contribution is not set properly. Assuming minimum revision 0."); } - else - compatibleVersions = getCompatibleVersionsStr(); + + int maxRev; + try { + maxRev = Integer.parseInt(properties.get("maxRevision")); + } catch (NumberFormatException e) { + maxRev = getMaxRevision(); + System.err.println("The maximum compatible revision for the “" + name + + "” contribution is not set properly. Assuming maximum revision INF."); + } if (propFile.delete() && propFile.createNewFile() && propFile.setWritable(true)) { PrintWriter writer = PApplet.createWriter(propFile); @@ -318,7 +331,8 @@ class AvailableContribution extends Contribution { writer.println("version=" + version); writer.println("prettyVersion=" + prettyVersion); writer.println("lastUpdated=" + lastUpdated); - writer.println("compatibleVersions=" + compatibleVersions); + writer.println("minRevision=" + minRev); + writer.println("maxRevision=" + maxRev); if (getType() == ContributionType.EXAMPLES_PACKAGE) { writer.println("compatibleModesList=" + compatibleContribsList); } diff --git a/app/src/processing/app/contrib/Contribution.java b/app/src/processing/app/contrib/Contribution.java index cd0879a09..a9698fad4 100644 --- a/app/src/processing/app/contrib/Contribution.java +++ b/app/src/processing/app/contrib/Contribution.java @@ -24,11 +24,8 @@ package processing.app.contrib; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; -import java.util.TreeMap; import processing.app.Language; -import processing.app.Base; import processing.core.PApplet; @@ -47,8 +44,9 @@ abstract public class Contribution { protected String paragraph; // protected int version; // 102 protected String prettyVersion; // "1.0.2" - protected long lastUpdated; // 1402805757 - protected TreeMap compatibleVersions; // 216,220,226-229 + protected long lastUpdated; // 1402805757 + protected int minRevision; // 0 + protected int maxRevision; // 227 // "Sound" @@ -132,40 +130,19 @@ abstract public class Contribution { return lastUpdated; } - - public String getCompatibleVersionsStr() { - if (compatibleVersions == null) - return ""; - StringBuilder sb = new StringBuilder(); - for (Map.Entry range : compatibleVersions.entrySet()) { - if (range.getKey().equals(range.getValue())) { - sb.append(range.getKey()); - sb.append(","); - } - else { - sb.append(range.getKey()); - sb.append("-"); - sb.append(range.getValue()); - sb.append(","); - } - } - sb.deleteCharAt(sb.length()-1); // delete last comma - return sb.toString(); + // 0 + public int getMinRevision() { + return minRevision; } - - public TreeMap getCompatibleVersions() { - return compatibleVersions; + // 227 + public int getMaxRevision() { + return maxRevision; } public boolean isCompatible(int versionNum) { - if (compatibleVersions != null) { - if (compatibleVersions.floorEntry(versionNum) != null - && versionNum <= compatibleVersions.floorEntry(versionNum).getValue()) { - return true; } - } - return false; + return ((maxRevision == 0 || versionNum < maxRevision) && versionNum > minRevision); } @@ -235,46 +212,4 @@ abstract public class Contribution { } return outgoing; } - - - /** - * @param compVerStr - *
A string consisting of a comma separated list of numbers. - * Ranges may be indicated by hyphens between 2 numbers. Open ranges - * may be indicated by leaving the right side of the last hyphen - * blank. - *
   For example, "222,225,227-229,230-" - * is valid. - * @return A TreeMap consisting of integer-integer key-value pairs that - * represent ranges for which the contribution has been - * tested.
   The example above would return a - * TreeMap with the pairs - * <222,222>, <225,225>, <227,229>, - *
   <230,(present_release_number)>. - */ - static TreeMap parseCompatibleVersions(String compVerStr) - throws NumberFormatException { - if (compVerStr == null || compVerStr.equals("")) - return null; - String[] ranges = compVerStr.split(","); - TreeMap compatibleTM = new TreeMap(); - for (String range : ranges) { - range = range.trim(); - if (range.indexOf("-") != -1) { - int key = Integer.parseInt(range.substring(0, range.indexOf("-")) - .trim()); - int value; - if (((range.indexOf("-") + 1) >= range.length()) - || range.substring(range.indexOf("-") + 1).trim().isEmpty()) { - value = Base.getRevision(); - } - else - value = Integer.parseInt(range.substring(range.indexOf("-") + 1) - .trim()); - compatibleTM.put(key, value); - } else - compatibleTM.put(Integer.parseInt(range), Integer.parseInt(range)); - } - return compatibleTM; - } } diff --git a/app/src/processing/app/contrib/ContributionManagerDialog.java b/app/src/processing/app/contrib/ContributionManagerDialog.java index 78bb6004a..927a88104 100644 --- a/app/src/processing/app/contrib/ContributionManagerDialog.java +++ b/app/src/processing/app/contrib/ContributionManagerDialog.java @@ -57,6 +57,7 @@ public class ContributionManagerDialog { // the calling editor, so updates can be applied Editor editor; String category; + String compatibleContribType; boolean isCompatibilityFilter; ContributionListing contribListing; @@ -65,6 +66,7 @@ public class ContributionManagerDialog { if (type == null) { title = Language.text("contrib.manager_title.update"); filter = ContributionType.createUpdateFilter(); + compatibleContribType = "Updates"; } else { if (type == ContributionType.MODE) title = Language.text("contrib.manager_title.mode"); @@ -74,6 +76,11 @@ public class ContributionManagerDialog { title = Language.text("contrib.manager_title.library"); filter = type.createFilter(); + + if (type == ContributionType.LIBRARY) + compatibleContribType = "Libraries"; + else + compatibleContribType = type.getTitle() + "s"; } contribListing = ContributionListing.getInstance(); contributionListPanel = new ContributionListPanel(this, filter); @@ -229,10 +236,6 @@ public class ContributionManagerDialog { filterPanel.add(filterField); filterPanel.add(Box.createHorizontalStrut(5)); - - String compatibleContribType = title.substring(0, title.indexOf(" ")) - .equalsIgnoreCase("Library") ? "Libraries" : (title.substring(0, title - .indexOf(" ")) + "s"); final JCheckBox compatibleContrib = new JCheckBox("Show Only Compatible " + compatibleContribType); compatibleContrib.addItemListener(new ItemListener() { diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 892cecfb3..5433ced90 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -31,6 +31,7 @@ import java.util.zip.*; import javax.swing.JOptionPane; import processing.app.*; +import processing.core.PApplet; /** @@ -81,19 +82,20 @@ public abstract class LocalContribution extends Contribution { lastUpdated = Long.parseLong(properties.get("lastUpdated")); } catch (NumberFormatException e) { lastUpdated = 0; + // Better comment these out till all contribs have a lastUpdated // System.err.println("The last updated timestamp for the “" + name + "” library is not set properly."); // System.err.println("Please contact the library author to fix it according to the guidelines."); } - - try { - compatibleVersions = parseCompatibleVersions(properties.get("compatibleVersions")); + + String minRev = properties.get("minRevision"); + if (minRev != null) { + minRevision = PApplet.parseInt(minRev, 0); } - catch (NumberFormatException nfe) { - compatibleVersions = null; - System.err - .println("The format of the compatibleVersions field is incorrect for " - + name); + + String maxRev = properties.get("maxRevision"); + if (maxRev != null) { + maxRevision = PApplet.parseInt(maxRev, 0); } } else { From 82838882500322e5cc2f35bb85b0ce6225413c99 Mon Sep 17 00:00:00 2001 From: Joel Moniz Date: Fri, 15 Aug 2014 03:22:28 +0530 Subject: [PATCH 5/5] Incompatible contribs are now blurred out --- .../app/contrib/ContributionPanel.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 66781601d..35c37fdef 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -62,6 +62,9 @@ class ContributionPanel extends JPanel { static public final String BUTTON_CONSTRAINT = "Install/Remvoe Button Panel"; + static public final String INCOMPATIBILITY_BLUR = "This contribution is not compatible with " + + "the current revision of Processing"; + private final ContributionListPanel listPanel; private final ContributionListing contribListing = ContributionListing.getInstance(); @@ -229,7 +232,11 @@ class ContributionPanel extends JPanel { setExpandListener(this, new MouseAdapter() { public void mousePressed(MouseEvent e) { - listPanel.setSelectedPanel(ContributionPanel.this); + if (contrib.isCompatible(Base.getRevision())) + listPanel.setSelectedPanel(ContributionPanel.this); + else + listPanel.contribManager.status.setErrorMessage(contrib.getName() + + " is not compatible with this revision of Processing"); } }); } @@ -512,6 +519,19 @@ class ContributionPanel extends JPanel { } } + + private void blurContributionPanel(Component component) { + component.setFocusable(false); + component.setEnabled(false); + if (component instanceof JComponent) + ((JComponent) component).setToolTipText(INCOMPATIBILITY_BLUR); + if (component instanceof Container) { + for (Component child : ((Container) component).getComponents()) { + blurContributionPanel(child); + } + } + } + public void setContribution(Contribution contrib) { this.contrib = contrib; @@ -670,6 +690,9 @@ class ContributionPanel extends JPanel { setComponentPopupMenu(null); } + if (!contrib.isCompatible(Base.getRevision())) { + blurContributionPanel(this); + } } private void installContribution(AvailableContribution info) {