concrete 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/CHANGELOG +32 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +87 -0
  4. data/concrete/basic_inline_editor.js +73 -0
  5. data/concrete/clipboard.js +72 -0
  6. data/concrete/concrete.js +58 -0
  7. data/concrete/constraint_checker.js +297 -0
  8. data/concrete/editor.js +964 -0
  9. data/concrete/element_extension.js +68 -0
  10. data/concrete/external_identifier_provider.js +112 -0
  11. data/concrete/helper.js +63 -0
  12. data/concrete/identifier_provider.js +168 -0
  13. data/concrete/inline_editor.js +55 -0
  14. data/concrete/metamodel_provider.js +171 -0
  15. data/concrete/model_interface.js +429 -0
  16. data/concrete/scroller.js +106 -0
  17. data/concrete/selector.js +302 -0
  18. data/concrete/template_provider.js +141 -0
  19. data/concrete/ui/abstract_dialog.js +80 -0
  20. data/concrete/ui/concrete_ui.js +28 -0
  21. data/concrete/ui/create_module_dialog.js +55 -0
  22. data/concrete/ui/images/close.png +0 -0
  23. data/concrete/ui/images/document-new.png +0 -0
  24. data/concrete/ui/images/document-save.png +0 -0
  25. data/concrete/ui/images/edit-find-replace.png +0 -0
  26. data/concrete/ui/images/emblem-symbolic-link.png +0 -0
  27. data/concrete/ui/images/help-browser.png +0 -0
  28. data/concrete/ui/images/minus_11px.png +0 -0
  29. data/concrete/ui/images/plus_11px.png +0 -0
  30. data/concrete/ui/images/preferences-system.png +0 -0
  31. data/concrete/ui/images/process-stop.png +0 -0
  32. data/concrete/ui/images/system-search.png +0 -0
  33. data/concrete/ui/layout_manager.js +54 -0
  34. data/concrete/ui/module_browser.js +88 -0
  35. data/concrete/ui/module_editor.js +217 -0
  36. data/concrete/ui/open_element_dialog.js +90 -0
  37. data/concrete/ui/preferences_dialog.js +75 -0
  38. data/concrete/ui/proceed_dialog.js +52 -0
  39. data/concrete/ui/search_replace_dialog.js +323 -0
  40. data/concrete/ui/style.css +296 -0
  41. data/concrete/ui/toolbar.js +74 -0
  42. data/concrete/ui/workbench.js +165 -0
  43. data/doc/concrete_developers_guide.html +1054 -0
  44. data/doc/concrete_developers_guide.txt +502 -0
  45. data/doc/concrete_users_guide.html +694 -0
  46. data/doc/concrete_users_guide.txt +223 -0
  47. data/example/formula_editor/example_data/example1.json +11 -0
  48. data/example/formula_editor/formula_editor.html +83 -0
  49. data/example/formula_editor/sqrt_horz.png +0 -0
  50. data/example/formula_editor/sqrt_vert.png +0 -0
  51. data/example/formula_editor/style.css +31 -0
  52. data/example/metamodel_editor/edit.rb +54 -0
  53. data/example/metamodel_editor/example_data/formula_metamodel.json +18 -0
  54. data/example/metamodel_editor/example_data/meta_metamodel.json +22 -0
  55. data/example/metamodel_editor/example_data/statemachine_metamodel.json +32 -0
  56. data/example/metamodel_editor/metamodel_editor.html +120 -0
  57. data/example/metamodel_editor/metamodel_editor2.html +135 -0
  58. data/example/metamodel_editor/metamodel_editor3.html +151 -0
  59. data/example/metamodel_editor/style.css +8 -0
  60. data/example/metamodel_editor/style2.css +19 -0
  61. data/example/metamodel_editor/style3.css +35 -0
  62. data/example/minimal_editor/minimal_editor.html +43 -0
  63. data/example/statemachine_editor/example_data/example1.json +11 -0
  64. data/example/statemachine_editor/state_background.png +0 -0
  65. data/example/statemachine_editor/statemachine_editor0.html +55 -0
  66. data/example/statemachine_editor/statemachine_editor1.html +62 -0
  67. data/example/statemachine_editor/statemachine_editor2.html +103 -0
  68. data/example/statemachine_editor/style0.css +8 -0
  69. data/example/statemachine_editor/style1.css +32 -0
  70. data/example/statemachine_editor/style2.css +43 -0
  71. data/example/themes/cobalt.css +176 -0
  72. data/example/themes/dialog-error.png +0 -0
  73. data/example/themes/dialog-information.png +0 -0
  74. data/example/themes/dialog-warning.png +0 -0
  75. data/example/themes/dots_12px.png +0 -0
  76. data/example/themes/fold_button_dots_when_hidden.css +18 -0
  77. data/example/themes/fold_button_plus_minus.css +21 -0
  78. data/example/themes/fold_button_plus_when_hidden.css +18 -0
  79. data/example/themes/light_blue.css +177 -0
  80. data/example/themes/minus_11px.png +0 -0
  81. data/example/themes/minus_13px.png +0 -0
  82. data/example/themes/minus_9px.png +0 -0
  83. data/example/themes/plus_11px.png +0 -0
  84. data/example/themes/plus_13px.png +0 -0
  85. data/example/themes/plus_9px.png +0 -0
  86. data/example/themes/white.css +177 -0
  87. data/lib/concrete/concrete_syntax_provider.rb +63 -0
  88. data/lib/concrete/config.rb +36 -0
  89. data/lib/concrete/file_cache_map.rb +88 -0
  90. data/lib/concrete/index_builder.rb +108 -0
  91. data/lib/concrete/metamodel/concrete_mmm.rb +45 -0
  92. data/lib/concrete/metamodel/ecore_to_concrete.rb +80 -0
  93. data/lib/concrete/server.rb +92 -0
  94. data/lib/concrete/util/logger.rb +24 -0
  95. data/lib/concrete/util/string_writer.rb +17 -0
  96. data/lib/concrete/working_set.rb +41 -0
  97. data/rakefile +33 -0
  98. data/redist/prototype.js +4320 -0
  99. data/redist/scriptaculous/builder.js +136 -0
  100. data/redist/scriptaculous/controls.js +991 -0
  101. data/redist/scriptaculous/dragdrop.js +975 -0
  102. data/redist/scriptaculous/effects.js +1130 -0
  103. data/redist/scriptaculous/scriptaculous.js +60 -0
  104. data/redist/scriptaculous/slider.js +275 -0
  105. data/redist/scriptaculous/sound.js +55 -0
  106. data/redist/scriptaculous/unittest.js +568 -0
  107. data/test/concrete_test.rb +5 -0
  108. data/test/file_cache_map_test.rb +90 -0
  109. data/test/file_cache_map_test/testdir/fileA +1 -0
  110. data/test/index_builder_test.rb +68 -0
  111. data/test/index_builder_test/ecore_index.js +85 -0
  112. data/test/index_builder_test/ecore_index_expected.js +85 -0
  113. data/test/integration/external_elements_test.html +114 -0
  114. data/test/metamodel_test.rb +40 -0
  115. data/test/metamodel_test/concrete_mmm_expected.js +19 -0
  116. data/test/metamodel_test/concrete_mmm_generated.js +19 -0
  117. data/test/metamodel_test/concrete_mmm_regenerated.js +19 -0
  118. data/test/unit/external_identifier_provider_test.html +138 -0
  119. data/test/unit/identifier_provider_test.html +269 -0
  120. data/test/unit/metamodel_provider_test.html +318 -0
  121. data/test/unit/model_interface_test.html +257 -0
  122. data/test/unit/template_provider_test.html +171 -0
  123. data/test/unit/test.css +90 -0
  124. data/test/working_set_test.rb +54 -0
  125. data/test/working_set_test/file1.txt +0 -0
  126. data/test/working_set_test/file2 +0 -0
  127. data/test/working_set_test/subdir/file3.xml +0 -0
  128. metadata +201 -0
@@ -0,0 +1,223 @@
1
+ = Concrete Users Guide =
2
+
3
+ _Concrete_ is a generic model editor which can be configured for different
4
+ domain specific languages (DSLs). When you use it, you use it for a predefined DSL.
5
+ The DSL describes what the model may look like, both from a content and a visual point of view.
6
+ See the Developers Guide if you want to setup your own DSL.
7
+
8
+ This document describes the usage of the editor, independant of any specific DSL.
9
+
10
+
11
+ == Models ==
12
+
13
+ Models consist of +elements+ which may have attributes, references to other elements and may contain other elements.
14
+
15
+ +Attributes+ can take one or more primitive values. Currently
16
+ primitive values are of type +String+, +Integer+, +Float+, +Boolean+, or custom defined +Enum+ datatypes. +Enum+ types have
17
+ a name and consist of a set of string literals, each of which is a valid instance of the type.
18
+
19
+ +References+ point to one or more other elements. References can not point to or take primitive values.
20
+
21
+ +Containment+ relationships are references with the difference that the contained element is part of the parent element,
22
+ whereas the referenced element normally is not (there may be exceptions). When the parent element is deleted, the contained
23
+ elements are also deleted. When the parent element is collapsed the contained elements are hidden.
24
+
25
+ Attributes, reference and containmend relationships are called _features_ of an element. Features have names,
26
+ although they may not be visible.
27
+
28
+ Attributes and references contain _values_ whereas containment relationships contain _elements_.
29
+
30
+
31
+ == Navigation and Selection ==
32
+
33
+ === Selecting Elements/Values ===
34
+
35
+ For all editing commands described below, at least one element or attribute/reference value needs to be selected.
36
+ Selection can be done with the arrow keys (+Left+, +Right+, +Up+, +Down+), with +Tab+ and +Shift-Tab+ or with the mouse.
37
+
38
+ Selection with the mouse is straightforward, just click the element.
39
+
40
+ Using the key +Tab+ and +Shift-Tab+, the next/previous element/value can be selected with respect to the logical order
41
+ (instead of the graphical order on the screen). If an element has other elements or values inside, +Tab+ will select
42
+ the first child, and so on.
43
+
44
+ In contrast to the tab keys, the arrow keys select with respect to the graphical position on the screen.
45
+ Press one of +Left+, +Right+, +Up+, +Down+, to move the selection in the respective direction.
46
+ When an element has other elements or values inside, the next selected element may be one of these elements.
47
+ In order to know if the next selected element is inside or outside of the current element, you need to be aware of
48
+ the current _cursor_ position. The _cursor_ is a little dot on the border of the selected element/value.
49
+ If the cursor is on the left border and you press +Right+, the next selected element will be inside of the
50
+ current element (given that it has child elements). Otherwise, if you press +Left+, the next selected element
51
+ will be outside, left of the current element (given that there are elements on the left). The same is true for the
52
+ other directions, of course. If the next element would be outside but there are no elements in this direction, the
53
+ parent element will be selected.
54
+
55
+ Hold +Shift+ down shift while moving the selection with any of the methods described above to extend to selection (_multi select_).
56
+
57
+ === Navigating References ===
58
+
59
+ When you move the mouse over a valid reference value while prssing +Ctrl+, the reference target will be highlighted.
60
+ However, you might not see the target if it is outside of the visible area on the screen.
61
+
62
+ You can click the left mouse button on a valid reference value while pressing +Ctrl+ to select the reference target.
63
+ This will automatically scroll to make the target visible.
64
+
65
+ References can also be followed by pressing +Alt-Right+ while a valid reference value is selected. This will select
66
+ the target element and scroll to make it visible. By pressing +Alt-Left+ you can go back the references in reverse order.
67
+
68
+ === Folding ===
69
+
70
+ Elements with containment relationships can be collapsed using +Ctrl-Left+. This will hide the containment relationships
71
+ including the contained elements. In order to expand the element again, press +Ctrl-Right+.
72
+
73
+ You can collapse and expand elements recursively using +Ctrl-Shift-Left+ and +Ctrl-Shift-Right+. This will also
74
+ collapse/expand child elements.
75
+
76
+ In addition to this, empty features may collapse depending on the DSL configuration. This happens when you leave
77
+ the currently selected element (i.e. select another element which is not a child). You can show all hidden featurs
78
+ be pressing +Shift-Return+. This command also expands the current element.
79
+
80
+ All collapsing commands also work with multiple elements selected.
81
+
82
+ Depending on the DSL, folding may also be triggered by clicking on the fold button (e.g. a plus or minus sign).
83
+
84
+
85
+ == Editing ==
86
+
87
+ === Edit Mode ===
88
+
89
+ Whenever you want to actually edit text (e.g. to edit an attribute value or choose an element's type) you need to be in _edit mode_.
90
+ The easiest way to enter edit mode is by just typing text while an element/value is selected. More explicitly you may also
91
+ click the element or value while it is already selected or press +F2+ or +Ctrl-Space+.
92
+
93
+ You can leave edit mode and cancel your edit by pressing +Esc+ or click the mouse somewhere outside of the current edit box.
94
+
95
+ In order to leaave edit mode and actually use your changes, press +Return+, +Tab+ or +Shift-Tab+.
96
+ If an error is detected with your input (e.g. because you entered letters for an Integer value),
97
+ you can not successfully leave edit mode. In this case, either correct your input or cancel edit mode.
98
+
99
+ If a set of completion options is available for the current element/value, a dropdown box will be shown in edit mode
100
+ when you start typing. You can bring up the dropdown box without typing by pressing one of the arrow keys.
101
+
102
+
103
+ === Creating Elements ===
104
+
105
+ Elements can be created on toplevel or as children in a containment relationship. If in either place, there are no
106
+ other elements yet, an empty placeholder element will be shown.
107
+ In this case, select the placeholder, enter edit mode and type the name of the element class to be created.
108
+ Once in edit mode, a dropdown box appears showing possible completion options.
109
+
110
+ If an element should be added to a set of existing elements, select one of the existing ones and press +Return+.
111
+ This will insert a placeholder after the selected element and immediately enter edit mode.
112
+
113
+ When an element is created, all features are shown although they are empty. Depending on the configuration of the
114
+ editor, empty features may be hidden when you select a different element which is not a child. In oder to
115
+ show the hidden features again, press +Shift-Return+.
116
+
117
+ === Changing the Element Type ===
118
+
119
+ When you enter edit mode while an element is selected, the element's type can be changed. When the type changes,
120
+ feature values will be preserved for features which also exist in the new type.
121
+
122
+ === Deleting Elements ===
123
+
124
+ Elements can be deleted by pressing +Del+. This also works if multiple elements are selected.
125
+
126
+ === Editing Attribute Values ===
127
+
128
+ In a newly created element, no attribute values exist. You can create an attribute value by entering edit mode on
129
+ an empty value placeholder. As with elements, pressing +Return+ on a value will insert another value, pressing +Del+ removes the value.
130
+ In case the attribute to be edited is hidden, press +Shift-Return+ to show it.
131
+
132
+ === Editing Reference Values ===
133
+
134
+ Reference values can be edited in the same way as attribute values. The content of a reference value is the identifier
135
+ of the referenced element. Use the dropdown box in edit mode to choose one of the possible target elements.
136
+ Note, that only elements with an identifier can be referenced.
137
+
138
+ === Copy and Paste ===
139
+
140
+ Both element and values can be cut, copied and pasted with +Ctrl-X+, +Ctrl-C+ and +Ctrl-V+ respectively. This also works
141
+ with multiples elements selected. Note however, that you can not paste an attribute or reference value where an element
142
+ is expected and vice versa.
143
+
144
+
145
+ == Hover Information ==
146
+
147
+ Some information is show only when moving the mouse over a model element or value. Make sure to focus the editor first,
148
+ otherwise the hovers will not appear.
149
+
150
+
151
+ === Errors ===
152
+
153
+ The DSL defines constraints on possible models. For example, for some attributes only a single value might be
154
+ allowed, whereas for other attributes you may provide more than one value.
155
+ If a constraint is violated for an element or feature, the element/feature will be marked as erroneous.
156
+ Move the mouse over such an element in order to show the error message in a popup window.
157
+
158
+
159
+ === Model Information ===
160
+
161
+ Depending on the concrete syntax, the feature names might be hidden. When moving the mouse over a model value, the name of the
162
+ feature that value belongs to will be shown. Also for references, the full identifier will be shown.
163
+
164
+
165
+ == Workbench ==
166
+
167
+ Some editors might use the "workbench" functionality which comes with _Concrete_. The workbench features:
168
+
169
+ * a module index view
170
+ * a module editor view
171
+ * following references across modules
172
+ * finding elements based on a index ("open element")
173
+ * search/replace functionality
174
+ * switchable layouts via the preferences dialog
175
+
176
+ Using the workbench should be pretty much self-explanatory. Some of the commands can be invoked using hotkeys which are described
177
+ in the command reference below.
178
+
179
+
180
+ == Command Reference ==
181
+
182
+ .Keyboard
183
+ [frame="topbot",grid="none"]
184
+ |=======================
185
+ | Left, Right, Up, Down | move selection
186
+ | Tab, Shift-Tab | move selection in sequential order, select first child if available, stop editing when in edit mode
187
+ | Shift-Left, Shift-Right, Shift-Up, Shift-Down | extend selection (multi select)
188
+ | Ctrl-A | select all
189
+ | Return | insert new element/value after current element/value, stop editing when in edit mode
190
+ | Del | delete selected element/value(s)
191
+ | start typing, F2, Ctrl-Space | edit selected element/value (enter edit mode)
192
+ | Esc | stop editing when in edit mode
193
+ | Ctrl-C | copy selection to clipboard
194
+ | Ctrl-X | cut selection to clipboard
195
+ | Ctrl-V | insert from clipboard after selected element/value
196
+ | Ctrl-Left | collapse element
197
+ | Ctrl-Shift-Left | collapse element and all child elements
198
+ | Ctrl-Right | expand element
199
+ | Ctrl-Shift-Right | expand element and all child elements
200
+ | Shift-Return | show hidden features (auto-hide features will hide again when selection leaves the element)
201
+ | Alt-Right | select reference target (jump to reference target) if a reference is selected
202
+ | Alt-Left | jump back references in reverse order
203
+ |=======================
204
+
205
+ .Mouse
206
+ [frame="topbot",grid="none"]
207
+ |=======================
208
+ | Left Click | move selection, stop editing when in edit mode
209
+ | Shift-Left Click | extend selection (multi select)
210
+ | Left click already selected element/value | edit selected element/value (enter edit mode)
211
+ | Hover over element/value | show errors if present
212
+ | Ctrl-Hover over reference | highlight reference target
213
+ | Ctrl-Left Click | select reference target (jump to reference target)
214
+ |=======================
215
+
216
+ .Workbench Commands
217
+ [frame="topbot",grid="none"]
218
+ |=======================
219
+ | Ctrl-Shift-S | save model
220
+ | Ctrl-Shift-F | open search/replace dialog
221
+ | Ctrl-Shift-E | open "open element" dialog
222
+ |=======================
223
+
@@ -0,0 +1,11 @@
1
+ [{"_class": "Sqrt", "expr":
2
+ {"_class": "Fraction", "expr1":
3
+ {"_class": "Mult", "expr1":
4
+ {"_class": "Value", "value": "33"}, "expr2":
5
+ {"_class": "Sqrt", "expr":
6
+ {"_class": "Fraction", "expr1":
7
+ {"_class": "Value", "value": "5"}, "expr2":
8
+ {"_class": "Plus", "expr1":
9
+ {"_class": "Value", "value": "100"}, "expr2":
10
+ {"_class": "Value", "value": "7"}}}}}, "expr2":
11
+ {"_class": "Value", "value": "6"}}}]
@@ -0,0 +1,83 @@
1
+ <html>
2
+ <head>
3
+ <link rel="stylesheet" href="../themes/cobalt.css" type="text/css" />
4
+ <link rel="stylesheet" href="style.css" type="text/css" />
5
+ <script src="../../redist/prototype.js" type="text/javascript"></script>
6
+ <script src="../../redist/scriptaculous/scriptaculous.js" type="text/javascript"></script>
7
+ <script src="../../concrete/concrete.js" type="text/javascript"></script>
8
+ </head>
9
+ <body>
10
+ <div id="templates1" style="display: none">
11
+ <div class="ct_element ctc_Fraction" style="display: inline-block">
12
+ <div class="ct_containment ctn_expr1" style="text-align: center; border-bottom: 1px solid white"><span style="display: inline-block; padding: 3px"><span class="ct_slot"></span></span></div>
13
+ <div class="ct_containment ctn_expr2" style="text-align: center"><span style="display: inline-block; padding: 3px"><span class="ct_slot"></span></span></div>
14
+ </div>
15
+ <div class="ct_element ctc_Sqrt" style="display: inline-block">
16
+ <div>
17
+ <div class="ct_containment ctn_expr" style=""><span style="display: inline-block; padding: 3px"><span class="ct_slot"></span></span></div>
18
+ </div>
19
+ </div>
20
+ <div class="ct_element ctc_Mult" style="display: inline-block">
21
+ (<span class="ct_containment ctn_expr1" style="vertical-align: middle"><span class="ct_slot"></span></span>
22
+ <span class="ct_handle" style="vertical-align: middle">*</span>
23
+ <span class="ct_containment ctn_expr2" style="vertical-align: middle"><span class="ct_slot"></span></span>)
24
+ </div>
25
+ <div class="ct_element ctc_Plus" style="display: inline-block">
26
+ (<span class="ct_containment ctn_expr1" style="vertical-align: middle"><span class="ct_slot"></span></span>
27
+ <span class="ct_handle" style="vertical-align: middle">+</span>
28
+ <span class="ct_containment ctn_expr2" style="vertical-align: middle"><span class="ct_slot"></span></span>)
29
+ </div>
30
+ <span class="ct_element ctc_Value">
31
+ <span class="ct_handle">v</span>
32
+ (<span class="ct_attribute ctn_value"><span class="ct_slot"></span></span>)
33
+ </span>
34
+ <span class="ct_element ctc_Neg">
35
+ <span class="ct_handle"></span>
36
+ -(<span class="ct_containment ctn_expr"><span class="ct_slot"></span></span>)
37
+ </span>
38
+ </div>
39
+ <div id="metamodel1" style="display: none">
40
+ [{"_class": "Datatype", "name": "String"},
41
+ {"_class": "Class", "name": "Expression", "abstract": true},
42
+ {"_class": "Class", "name": "Sqrt", "superTypes": "Expression", "features":
43
+ {"_class": "Feature", "name": "expr", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}},
44
+ {"_class": "Class", "name": "Fraction", "superTypes": "Expression", "features": [
45
+ {"_class": "Feature", "name": "expr1", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"},
46
+ {"_class": "Feature", "name": "expr2", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}]},
47
+ {"_class": "Class", "name": "Mult", "superTypes": "Expression", "features": [
48
+ {"_class": "Feature", "name": "expr1", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"},
49
+ {"_class": "Feature", "name": "expr2", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}]},
50
+ {"_class": "Class", "name": "Plus", "superTypes": "Expression", "features": [
51
+ {"_class": "Feature", "name": "expr1", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"},
52
+ {"_class": "Feature", "name": "expr2", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}]},
53
+ {"_class": "Class", "name": "Neg", "superTypes": "Expression", "features":
54
+ {"_class": "Feature", "name": "expr", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}},
55
+ {"_class": "Class", "name": "Value", "superTypes": "Expression", "features":
56
+ {"_class": "Feature", "name": "value", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"}}]
57
+ </div>
58
+ <div class="ct_editor" id="editor1">
59
+ </div>
60
+ <br/>
61
+ <textarea id="clipboard1" style="background-color: white; color: black; border: 1px solid grey" cols="80" rows="10" wrap="off"></textarea>
62
+ </div>
63
+ <script type="text/javascript" language="javascript" charset="utf-8">
64
+ // <![CDATA[
65
+ var tp = new Concrete.TemplateProvider($("templates1"));
66
+ var mp = new Concrete.MetamodelProvider($("metamodel1").textContent.evalJSON());
67
+ var ip = new Concrete.QualifiedNameBasedIdentifierProvider("name");
68
+ var cb = new Concrete.Clipboard($("clipboard1"));
69
+ var ed = new Concrete.Editor($("editor1"), tp, mp, ip, {clipboard: cb});
70
+
71
+ Event.observe(window, 'click', function(event) {
72
+ ed.handleEvent(event)
73
+ });
74
+ Event.observe(window, 'keydown', function(event) {
75
+ ed.handleEvent(event)
76
+ });
77
+ Event.observe(window, 'mousemove', function(event) {
78
+ ed.handleEvent(event);
79
+ });
80
+ // ]]>
81
+ </script>
82
+ </body>
83
+ </html>
@@ -0,0 +1,31 @@
1
+
2
+ /* Metamodel Specific Styles
3
+ *****************************************************************************/
4
+
5
+ /* overwrite indentation of contained elements (default) */
6
+
7
+ .ct_containment {
8
+ padding: 0;
9
+ }
10
+
11
+ .ct_containment .ct_element {
12
+ margin: 0;
13
+ }
14
+
15
+ .ct_containment > .ct_slot > .ct_inline_editor {
16
+ margin: 0;
17
+ }
18
+
19
+ /* use images for the square root */
20
+
21
+ div.ctc_Sqrt {
22
+ padding-left: 19px; background: url(sqrt_vert.png) no-repeat left bottom;
23
+ }
24
+
25
+ div.ctc_Sqrt.ct_selected {
26
+ padding-left: 19px; background: url(sqrt_vert.png) no-repeat left bottom #001120;
27
+ }
28
+
29
+ div.ctc_Sqrt > div {
30
+ background: url(sqrt_horz.png) no-repeat right top;
31
+ }
@@ -0,0 +1,54 @@
1
+ require 'webrick'
2
+
3
+ #
4
+ # Simple ajax interaction with Concrete editor
5
+ #
6
+ # Adapt the path to the browser (Firefox or Chrome) below.
7
+ # Startup the browser before you run this script, otherwise it might hang.
8
+ #
9
+ Browser = "firefox"
10
+ Port = 1234
11
+
12
+ class ConcreteServer
13
+
14
+ def initialize(file)
15
+ @file = file
16
+ @server = WEBrick::HTTPServer.new(:Port => Port)
17
+ @server.mount_proc("/") do |req, res|
18
+ handleRequest(req, res)
19
+ end
20
+ end
21
+
22
+ def start
23
+ @server.start do |sock|
24
+ @server.run(sock)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def handleRequest(req, res)
31
+ if req.path == "/"
32
+ res.body = File.read("metamodel_editor.html").sub("<!-- json model here -->", File.read(@file))
33
+ elsif req.path == "/save"
34
+ File.open(@file, "w") {|f| f.write(req.body)}
35
+ elsif req.path == "/exit"
36
+ @server.shutdown
37
+ elsif req.path == "/favicon.ico"
38
+ # ignore
39
+ else
40
+ res.body = File.read("../.."+req.path)
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ if (ARGV.size == 0)
47
+ puts "Usage: edit.rb <json file>"
48
+ exit
49
+ end
50
+
51
+ # if the browser is not yet running the following line might block
52
+ system "#{Browser} http://localhost:#{Port}/"
53
+ ConcreteServer.new(ARGV[0]).start
54
+
@@ -0,0 +1,18 @@
1
+ [{"_class": "Datatype", "name": "String"},
2
+ {"_class": "Class", "name": "Expression", "abstract": true},
3
+ {"_class": "Class", "name": "Sqrt", "superTypes": "Expression", "features":
4
+ {"_class": "Feature", "name": "expr", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}},
5
+ {"_class": "Class", "name": "Fraction", "superTypes": "Expression", "features": [
6
+ {"_class": "Feature", "name": "expr1", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"},
7
+ {"_class": "Feature", "name": "expr2", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}]},
8
+ {"_class": "Class", "name": "Mult", "superTypes": "Expression", "features": [
9
+ {"_class": "Feature", "name": "expr1", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"},
10
+ {"_class": "Feature", "name": "expr2", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}]},
11
+ {"_class": "Class", "name": "Plus", "superTypes": "Expression", "features": [
12
+ {"_class": "Feature", "name": "expr1", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"},
13
+ {"_class": "Feature", "name": "expr2", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}]},
14
+ {"_class": "Class", "name": "Neg", "superTypes": "Expression", "features":
15
+ {"_class": "Feature", "name": "expr", "kind": "containment", "lowerLimit": 1, "upperLimit": 1, "type": "Expression"}},
16
+ {"_class": "Class", "name": "Value", "superTypes": "Expression", "features":
17
+ {"_class": "Feature", "name": "value", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"}}]
18
+
@@ -0,0 +1,22 @@
1
+ [
2
+ {"_class": "Datatype", "name": "String"},
3
+ {"_class": "Datatype", "name": "Integer"},
4
+ {"_class": "Datatype", "name": "Boolean"},
5
+ {"_class": "Enum", "name": "FeatureKindType", "literals": ["attribute", "reference", "containment"]},
6
+ {"_class": "Class", "name": "Classifier", "abstract": true, "features": {"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"}},
7
+ {"_class": "Class", "name": "Datatype", "superTypes": "Classifier"},
8
+ {"_class": "Class", "name": "Enum", "superTypes": "Datatype", "features": {"_class": "Feature", "name": "literals", "kind": "attribute", "lowerLimit": 1, "upperLimit": -1, "type": "String"}},
9
+ {"_class": "Class", "name": "Class", "superTypes": "Classifier", "features": [
10
+ {"_class": "Feature", "name": "superTypes", "kind": "reference", "upperLimit": -1, "type": "Class"},
11
+ {"_class": "Feature", "name": "features", "kind": "containment", "upperLimit": -1, "type": "Feature"},
12
+ {"_class": "Feature", "name": "abstract", "kind": "attribute", "upperLimit": 1, "type": "Boolean"}
13
+ ]},
14
+ {"_class": "Class", "name": "Feature", "features": [
15
+ {"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"},
16
+ {"_class": "Feature", "name": "kind", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "FeatureKindType"},
17
+ {"_class": "Feature", "name": "lowerLimit", "kind": "attribute", "upperLimit": 1, "type": "Integer"},
18
+ {"_class": "Feature", "name": "upperLimit", "kind": "attribute", "upperLimit": 1, "type": "Integer"},
19
+ {"_class": "Feature", "name": "type", "kind": "reference", "lowerLimit": 1, "upperLimit": 1, "type": "Classifier"}
20
+ ]}
21
+ ]
22
+