mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 02:20:45 +01:00
Merge pull request #2782 from joelmoniz/highlightContribs
Enabled highlighting of contributions with a Processing icon
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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>");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user