Skip to content
Permalink
Browse files

Implement dictionaries for the blocks language

Change-Id: I48e4168b1a3297cad163c5984599cf62692e869d
  • Loading branch information
data1013 authored and jisqyv committed Oct 31, 2017
1 parent a2cdacc commit f1e1863ff151b95e55819715941c641555ed28b6
Showing with 2,972 additions and 69 deletions.
  1. +6 −0 appinventor/appengine/src/com/google/appinventor/client/Images.java
  2. +12 −0 appinventor/appengine/src/com/google/appinventor/client/OdeMessages.java
  3. +6 −1 appinventor/appengine/src/com/google/appinventor/client/boxes/BlockSelectorBox.java
  4. BIN appinventor/appengine/src/com/google/appinventor/images/dictionaries.png
  5. +7 −0 appinventor/appengine/war/static/css/mit_app_inventor.css
  6. +2 −0 appinventor/blocklyeditor/ploverConfig.js
  7. +1 −0 appinventor/blocklyeditor/src/blockColors.js
  8. +1 −1 appinventor/blocklyeditor/src/blocks/components.js
  9. +483 −0 appinventor/blocklyeditor/src/blocks/dictionaries.js
  10. +2 −0 appinventor/blocklyeditor/src/blocks/text.js
  11. +7 −4 appinventor/blocklyeditor/src/blocks/utilities.js
  12. +23 −0 appinventor/blocklyeditor/src/drawer.js
  13. +3 −0 appinventor/blocklyeditor/src/generators/yail.js
  14. +239 −0 appinventor/blocklyeditor/src/generators/yail/dictionaries.js
  15. +100 −0 appinventor/blocklyeditor/src/msg/en/_messages.js
  16. +2 −1 appinventor/blocklyeditor/src/typeblock.js
  17. +4 −1 appinventor/blocklyeditor/src/versioning.js
  18. +145 −3 appinventor/buildserver/src/com/google/appinventor/buildserver/resources/runtime.scm
  19. +6 −2 appinventor/components/src/com/google/appinventor/components/common/YaVersion.java
  20. +3 −3 appinventor/components/src/com/google/appinventor/components/runtime/CloudDB.java
  21. +4 −4 appinventor/components/src/com/google/appinventor/components/runtime/FirebaseDB.java
  22. +1 −1 appinventor/components/src/com/google/appinventor/components/runtime/Form.java
  23. +2 −2 appinventor/components/src/com/google/appinventor/components/runtime/GameClient.java
  24. +1 −1 appinventor/components/src/com/google/appinventor/components/runtime/TinyDB.java
  25. +1 −1 appinventor/components/src/com/google/appinventor/components/runtime/TinyWebDB.java
  26. +1 −1 appinventor/components/src/com/google/appinventor/components/runtime/util/CloudDBJedisListener.java
  27. +9 −0 appinventor/components/src/com/google/appinventor/components/runtime/util/ErrorMessages.java
  28. +136 −12 appinventor/components/src/com/google/appinventor/components/runtime/util/JsonUtil.java
  29. +572 −0 appinventor/components/src/com/google/appinventor/components/runtime/util/YailDictionary.java
  30. +19 −10 appinventor/components/src/com/google/appinventor/components/runtime/util/YailList.java
  31. +55 −0 appinventor/components/src/com/google/appinventor/components/runtime/util/YailObject.java
  32. +6 −0 appinventor/components/src/com/google/appinventor/components/scripts/ComponentProcessor.java
  33. +12 −19 appinventor/components/tests/com/google/appinventor/components/runtime/util/JsonUtilTest.java
  34. +381 −0 appinventor/components/tests/com/google/appinventor/components/runtime/util/YailDictionaryTest.java
  35. +477 −0 appinventor/docs/html/reference/blocks/dictionaries.html
  36. BIN appinventor/docs/html/reference/blocks/images/builtin.png
  37. BIN appinventor/docs/html/reference/blocks/images/dictionaries/alist-dict-reversability.png
  38. BIN appinventor/docs/html/reference/blocks/images/dictionaries/alist-to-dict.png
  39. BIN appinventor/docs/html/reference/blocks/images/dictionaries/combine-dicts.png
  40. BIN appinventor/docs/html/reference/blocks/images/dictionaries/copy-dict.png
  41. BIN appinventor/docs/html/reference/blocks/images/dictionaries/create-with.png
  42. BIN appinventor/docs/html/reference/blocks/images/dictionaries/delete-value-for-key.png
  43. BIN appinventor/docs/html/reference/blocks/images/dictionaries/dict-to-alist.png
  44. BIN appinventor/docs/html/reference/blocks/images/dictionaries/example-dictionary-blocks.png
  45. BIN appinventor/docs/html/reference/blocks/images/dictionaries/get-keys.png
  46. BIN appinventor/docs/html/reference/blocks/images/dictionaries/get-value-for-key-path-with-index.png
  47. BIN appinventor/docs/html/reference/blocks/images/dictionaries/get-value-for-key-path.png
  48. BIN appinventor/docs/html/reference/blocks/images/dictionaries/get-value-for-key-path2.png
  49. BIN appinventor/docs/html/reference/blocks/images/dictionaries/get-value-for-key.png
  50. BIN appinventor/docs/html/reference/blocks/images/dictionaries/get-value-for-key2.png
  51. BIN appinventor/docs/html/reference/blocks/images/dictionaries/get-values.png
  52. BIN appinventor/docs/html/reference/blocks/images/dictionaries/is-dict.png
  53. BIN appinventor/docs/html/reference/blocks/images/dictionaries/is-key-in.png
  54. BIN appinventor/docs/html/reference/blocks/images/dictionaries/make-a-dictionary.png
  55. BIN appinventor/docs/html/reference/blocks/images/dictionaries/pair.png
  56. BIN appinventor/docs/html/reference/blocks/images/dictionaries/set-value-for-key-path.png
  57. BIN appinventor/docs/html/reference/blocks/images/dictionaries/set-value-for-key.png
  58. BIN appinventor/docs/html/reference/blocks/images/dictionaries/size.png
  59. BIN appinventor/docs/html/reference/blocks/images/dictionaries/walk-all.png
  60. BIN appinventor/docs/html/reference/blocks/images/dictionaries/walk-tree-example.png
  61. BIN appinventor/docs/html/reference/blocks/images/dictionaries/walk-tree-example2.png
  62. BIN appinventor/docs/html/reference/blocks/images/dictionaries/walk-tree-xml.png
  63. BIN appinventor/docs/html/reference/blocks/images/dictionaries/walk-tree.png
  64. +2 −1 appinventor/docs/html/reference/blocks/index.html
  65. +239 −0 appinventor/docs/markdown/reference/blocks/dictionaries.md
  66. BIN appinventor/docs/markdown/reference/blocks/images/builtin.png
  67. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/alist-dict-reversability.png
  68. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/alist-to-dict.png
  69. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/combine-dicts.png
  70. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/copy-dict.png
  71. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/create-with.png
  72. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/delete-value-for-key.png
  73. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/dict-to-alist.png
  74. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/example-dictionary-blocks.png
  75. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/get-keys.png
  76. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/get-value-for-key-path-with-index.png
  77. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/get-value-for-key-path.png
  78. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/get-value-for-key-path2.png
  79. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/get-value-for-key.png
  80. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/get-value-for-key2.png
  81. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/get-values.png
  82. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/is-dict.png
  83. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/is-key-in.png
  84. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/make-a-dictionary.png
  85. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/pair.png
  86. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/set-value-for-key-path.png
  87. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/set-value-for-key.png
  88. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/size.png
  89. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/walk-all.png
  90. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/walk-tree-example.png
  91. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/walk-tree-example2.png
  92. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/walk-tree-xml.png
  93. BIN appinventor/docs/markdown/reference/blocks/images/dictionaries/walk-tree.png
  94. +2 −1 appinventor/docs/markdown/reference/blocks/index.md
@@ -523,6 +523,12 @@
@Source("com/google/appinventor/images/lists.png")
ImageResource lists();

/**
* Built in drawer item: dictionaries
*/
@Source("com/google/appinventor/images/dictionaries.png")
ImageResource dictionaries();

/**
* Built in drawer item: colors
*/
@@ -896,6 +896,10 @@
@Description("Label on built-in-Lists-blocks branch of block selector tree")
String builtinListsLabel();

@DefaultMessage("Dictionaries")
@Description("Label on built-in-Dictionaries-blocks branch of block selector tree")
String builtinDictionariesLabel();

@DefaultMessage("Colors")
@Description("Label on built-in-Colors-blocks branch of block selector tree")
String builtinColorsLabel();
@@ -3133,6 +3137,10 @@ String newerVersionComponentException(String componentType, int srcCompVersion,
@Description("")
String htmlTextParams();

@DefaultMessage("jsonObject")
@Description("")
String jsonObjectParams();

@DefaultMessage("jsonText")
@Description("")
String jsonTextParams();
@@ -4468,6 +4476,10 @@ String newerVersionComponentException(String componentType, int srcCompVersion,
@Description("")
String JsonTextDecodeMethods();

@DefaultMessage("JsonObjectEncode")
@Description("")
String JsonObjectEncodeMethods();

@DefaultMessage("XmlTextDecode")
@Description("")
String xmlTextDecodeMethods();
@@ -76,7 +76,9 @@ public void delete() {
// Starts out not visible. call setVisible(true) to make it visible
private static final BlockSelectorBox INSTANCE = new BlockSelectorBox();

private static final Set<String> BUILTIN_DRAWER_NAMES = new HashSet<String>(Arrays.asList("Control", "Logic", "Math", "Text", "Lists", "Colors", "Variables", "Procedures"));
private static final Set<String> BUILTIN_DRAWER_NAMES = new HashSet<String>(
Arrays.asList("Control", "Logic", "Math", "Text", "Lists", "Dictionaries", "Colors",
"Variables", "Procedures"));

private static final Images images = Ode.getImageBundle();
private static final Map<String, ImageResource> bundledImages = Maps.newHashMap();
@@ -138,6 +140,7 @@ private static void initBundledImages() {
bundledImages.put("Colors", images.colors());
bundledImages.put("Variables", images.variables());
bundledImages.put("Procedures", images.procedures());
bundledImages.put("Dictionaries", images.dictionaries());
}

/**
@@ -199,6 +202,8 @@ private String getBuiltinDrawerNames(String drawerName) {
name = MESSAGES.builtinVariablesLabel();
} else if (drawerName.equals("Procedures")) {
name = MESSAGES.builtinProceduresLabel();
} else if (drawerName.equals("Dictionaries")) {
name = MESSAGES.builtinDictionariesLabel();
} else {
name = drawerName;
}
Binary file not shown.
@@ -347,6 +347,7 @@ h1 { color: white; }
.documentation span.math, .documentation code.math { background-color: #3F71B5; }
.documentation span.text, .documentation code.text { background-color: #B32D5E; }
.documentation span.list, .documentation code.list { background-color: #49A6D4; }
.documentation span.dictionary, .documentation code.dictionary { background-color: #2D1799; }
.documentation span.color, .documentation code.color { background-color: #7D7D7D; }
.documentation span.variable,
.documentation code.variable {
@@ -425,6 +426,12 @@ dt span.list i:after,
.methods dt em.list:before,
.events dt em.list:before
{ background-color: #70b3d8; content: "list"; }
dt.dictionary i:after,
dt span.dictionary i:after,
.properties dt.dictionary em:after,
.methods dt em.dictionary:before,
.events dt em.dictionary:before
{ background-color: #2D1799; content: "dictionary"; }
dt.component i:after,
dt span.component i:after,
.properties dt.component em:after,
@@ -162,6 +162,7 @@
'./src/blocks/lexical-variables.js',
'./src/blocks/colors.js',
'./src/blocks/components.js',
'./src/blocks/dictionaries.js',

//generator files
"./src/generators/yail.js",
@@ -174,6 +175,7 @@
"./src/generators/yail/colors.js",
"./src/generators/yail/variables.js",
"./src/generators/yail/procedures.js",
"./src/generators/yail/dictionaries.js",

// Repl
"./src/replmgr.js",
@@ -21,3 +21,4 @@ Blockly.LIST_CATEGORY_HUE = "#49A6D4"; // [73, 166, 212]
Blockly.COLOR_CATEGORY_HUE = "#7D7D7D"; // [125, 125, 125]
Blockly.VARIABLE_CATEGORY_HUE = "#D05F2D"; // [208, 95, 45]
Blockly.PROCEDURE_CATEGORY_HUE = "#7C5385"; // [124, 83, 133]
Blockly.DICTIONARY_CATEGORY_HUE = "#2D1799"; // [45, 23, 153]
@@ -1335,7 +1335,7 @@ Blockly.Blocks.component_component_block = {

this.appendDummyInput().appendField(this.componentDropDown, Blockly.ComponentBlock.COMPONENT_SELECTOR);
//this.componentDropDown.setValue(this.instanceName);
this.setOutput(true, [this.typeName,"COMPONENT"]);
this.setOutput(true, [this.typeName,"COMPONENT","Key"]);
this.errors = [{name:"checkIfUndefinedBlock"},{name:"checkComponentNotExistsError"}];
},

0 comments on commit f1e1863

Please sign in to comment.
You can’t perform that action at this time.