mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
cleaning this up but balking at refactoring
This commit is contained in:
@@ -316,6 +316,27 @@ abstract public class Contribution {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function that creates a StringList of the compatible Modes
|
||||
* for this Contribution.
|
||||
*/
|
||||
static StringList parseModeList(StringDict properties) {
|
||||
String unparsedModes = properties.get(MODES_PROPERTY);
|
||||
|
||||
// Workaround for 3.0 alpha/beta bug for 3.0b2
|
||||
if ("null".equals(unparsedModes)) {
|
||||
properties.remove(MODES_PROPERTY);
|
||||
unparsedModes = null;
|
||||
}
|
||||
|
||||
StringList outgoing = new StringList();
|
||||
if (unparsedModes != null) {
|
||||
outgoing.append(PApplet.trim(PApplet.split(unparsedModes, ',')));
|
||||
}
|
||||
return outgoing;
|
||||
}
|
||||
|
||||
|
||||
static private String translateCategory(String cat) {
|
||||
// Converts Other to other, I/O to i_o, Video & Vision to video_vision
|
||||
String cleaned = cat.replaceAll("[\\W]+", "_").toLowerCase();
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.Map;
|
||||
|
||||
import processing.app.Base;
|
||||
import processing.app.Mode;
|
||||
import processing.core.PApplet;
|
||||
import processing.data.StringDict;
|
||||
import processing.data.StringList;
|
||||
import static processing.app.contrib.ContributionType.EXAMPLES;
|
||||
@@ -31,34 +30,17 @@ public class ExamplesContribution extends LocalContribution {
|
||||
}
|
||||
|
||||
|
||||
static private StringList parseModeList(StringDict properties) {
|
||||
String unparsedModes = properties.get(MODES_PROPERTY);
|
||||
|
||||
// Workaround for 3.0 alpha/beta bug for 3.0b2
|
||||
if ("null".equals(unparsedModes)) {
|
||||
properties.remove(MODES_PROPERTY);
|
||||
unparsedModes = null;
|
||||
}
|
||||
|
||||
StringList outgoing = new StringList();
|
||||
if (unparsedModes != null) {
|
||||
outgoing.append(PApplet.trim(PApplet.split(unparsedModes, ',')));
|
||||
}
|
||||
return outgoing;
|
||||
static public boolean isCompatible(Base base, StringDict props) {
|
||||
return isCompatible(base.getActiveEditor().getMode(), props);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function to determine whether or not the example present in the
|
||||
* exampleLocation directory is compatible with the current mode.
|
||||
*
|
||||
* @param base
|
||||
* @param props
|
||||
* @return true if the example is compatible with the mode of the currently
|
||||
* active editor
|
||||
* @return true if compatible with the Mode of the currently active editor
|
||||
*/
|
||||
static public boolean isCompatible(Base base, StringDict props) {
|
||||
Mode mode = base.getActiveEditor().getMode();
|
||||
static public boolean isCompatible(Mode mode, StringDict props) {
|
||||
String currentIdentifier = mode.getIdentifier();
|
||||
StringList compatibleList = parseModeList(props);
|
||||
if (compatibleList.size() == 0) {
|
||||
@@ -69,12 +51,7 @@ public class ExamplesContribution extends LocalContribution {
|
||||
// if no Mode specified, assume compatible everywhere
|
||||
return true;
|
||||
}
|
||||
for (String c : compatibleList) {
|
||||
if (c.equals(currentIdentifier)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return compatibleList.hasValue(currentIdentifier);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user