From 0e6827d25383e195cfbf4dd4b1fa3e00a4ab31c9 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sat, 26 Jul 2014 17:37:30 +0400 Subject: [PATCH 1/3] Added isSpecial() to check if contrib is to be highlighted --- app/src/processing/app/contrib/Contribution.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/contrib/Contribution.java b/app/src/processing/app/contrib/Contribution.java index 451ab7d4e..92f21d155 100644 --- a/app/src/processing/app/contrib/Contribution.java +++ b/app/src/processing/app/contrib/Contribution.java @@ -30,9 +30,10 @@ import processing.core.PApplet; abstract public class Contribution { + static final String SPECIAL_CATEGORY_NAME = "Starred"; static final List validCategories = Arrays.asList("3D", "Animation", "Data", "Geometry", "GUI", "Hardware", - "I/O", "Math", "Simulation", "Sound", "Typography", + "I/O", "Math", "Simulation", "Sound", SPECIAL_CATEGORY_NAME, "Typography", "Utilities", "Video & Vision", "Other"); //protected String category; // "Sound" @@ -165,6 +166,19 @@ abstract public class Contribution { } + /** + * Returns true if the contribution is a starred/recommended contribution, or + * is by the Processing Foundation. + * + * @return + */ + boolean isSpecial() { + if (authorList.indexOf("The Processing Foundation") != -1 || categories.contains(SPECIAL_CATEGORY_NAME)) + return true; + return false; + } + + /** * @return a single element list with "Unknown" as the category. */ From 624fc14ace3d1eeb24ea9c5619fa54e7f0da2011 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Mon, 4 Aug 2014 02:19:37 +0530 Subject: [PATCH 2/3] Implemented GUI changes related to highlighting contribs --- app/src/processing/app/contrib/ContributionPanel.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/processing/app/contrib/ContributionPanel.java b/app/src/processing/app/contrib/ContributionPanel.java index 68434f2bc..bc25a10ed 100644 --- a/app/src/processing/app/contrib/ContributionPanel.java +++ b/app/src/processing/app/contrib/ContributionPanel.java @@ -42,6 +42,7 @@ import javax.swing.text.html.StyleSheet; import processing.app.Base; import processing.app.Editor; +import processing.app.Toolkit; import processing.app.Language; @@ -515,6 +516,16 @@ class ContributionPanel extends JPanel { public void setContribution(Contribution contrib) { this.contrib = contrib; + + + if (contrib.isSpecial()) { + ImageIcon processingIcon = new ImageIcon(Toolkit.getLibImage("icons/pde-" + + "48" + ".png")); + JLabel iconLabel = new JLabel(processingIcon); + iconLabel.setBorder(new EmptyBorder(4, 7, 7, 7)); + iconLabel.setVerticalAlignment(SwingConstants.TOP); + add(iconLabel, BorderLayout.WEST); + } // StringBuilder nameText = new StringBuilder(); // nameText.append(""); From 30124cdd0e06f46569242a207575b0afbb123a44 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sun, 3 Aug 2014 23:51:03 +0530 Subject: [PATCH 3/3] Added validation to check if the contrib is actually starred --- .../processing/app/contrib/LocalContribution.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/processing/app/contrib/LocalContribution.java b/app/src/processing/app/contrib/LocalContribution.java index 1cedbd652..099514c76 100644 --- a/app/src/processing/app/contrib/LocalContribution.java +++ b/app/src/processing/app/contrib/LocalContribution.java @@ -91,6 +91,19 @@ public abstract class LocalContribution extends Contribution { name = folder.getName(); categories = defaultCategory(); } + + if (categories.contains(SPECIAL_CATEGORY_NAME)) + validateSpecial(); + } + + + private void validateSpecial() { + for (AvailableContribution available : ContributionListing.getInstance().advertisedContributions) + if (available.getName().equals(name)) { + if (!available.isSpecial()) + categories.remove(SPECIAL_CATEGORY_NAME); + } + return; }