Merge pull request #2782 from joelmoniz/highlightContribs

Enabled highlighting of contributions with a Processing icon
This commit is contained in:
Ben Fry
2014-08-19 13:36:25 -04:00
3 changed files with 39 additions and 1 deletions

View File

@@ -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.
*/

View File

@@ -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("<html><body><b>");

View File

@@ -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;
}