Convert to action pattern to allow multiple actions

This commit is contained in:
Richard Wackerbarth 2015-03-07 10:43:45 -06:00
parent 2f65f5fdc1
commit 0644bdc51c
1 changed files with 15 additions and 5 deletions

View File

@ -351,8 +351,7 @@ public class Compiler implements MessageConsumer {
sketchIsCompiled = false;
// Hook runs at Start of Compilation
if (prefs.containsKey("recipe.hooks.prebuild"))
runRecipe("recipe.hooks.prebuild");
runActions("hooks.prebuild", prefs);
objectFiles = new ArrayList<File>();
@ -422,9 +421,8 @@ public class Compiler implements MessageConsumer {
progressListener.progress(90);
// Hook runs at End of Compilation
if (prefs.containsKey("recipe.hooks.postbuild"))
runRecipe("recipe.hooks.postbuild");
// Hook runs at End of Compilation
runActions("hooks.postbuild", prefs);
return true;
}
@ -1047,6 +1045,18 @@ public class Compiler implements MessageConsumer {
execAsynchronously(cmdArray);
}
void runActions(String recipeClass, PreferencesMap prefs) throws RunnerException, PreferencesMapException {
List<String> patterns = new ArrayList<String>();
for (String key : prefs.keySet()) {
if (key.startsWith("recipe."+recipeClass) && key.endsWith(".pattern"))
patterns.add(key);
}
Collections.sort(patterns);
for (String recipe : patterns) {
runRecipe(recipe);
}
}
void runRecipe(String recipe) throws RunnerException, PreferencesMapException {
PreferencesMap dict = new PreferencesMap(prefs);
dict.put("ide_version", "" + BaseNoGui.REVISION);