concrete 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +32 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +87 -0
- data/concrete/basic_inline_editor.js +73 -0
- data/concrete/clipboard.js +72 -0
- data/concrete/concrete.js +58 -0
- data/concrete/constraint_checker.js +297 -0
- data/concrete/editor.js +964 -0
- data/concrete/element_extension.js +68 -0
- data/concrete/external_identifier_provider.js +112 -0
- data/concrete/helper.js +63 -0
- data/concrete/identifier_provider.js +168 -0
- data/concrete/inline_editor.js +55 -0
- data/concrete/metamodel_provider.js +171 -0
- data/concrete/model_interface.js +429 -0
- data/concrete/scroller.js +106 -0
- data/concrete/selector.js +302 -0
- data/concrete/template_provider.js +141 -0
- data/concrete/ui/abstract_dialog.js +80 -0
- data/concrete/ui/concrete_ui.js +28 -0
- data/concrete/ui/create_module_dialog.js +55 -0
- data/concrete/ui/images/close.png +0 -0
- data/concrete/ui/images/document-new.png +0 -0
- data/concrete/ui/images/document-save.png +0 -0
- data/concrete/ui/images/edit-find-replace.png +0 -0
- data/concrete/ui/images/emblem-symbolic-link.png +0 -0
- data/concrete/ui/images/help-browser.png +0 -0
- data/concrete/ui/images/minus_11px.png +0 -0
- data/concrete/ui/images/plus_11px.png +0 -0
- data/concrete/ui/images/preferences-system.png +0 -0
- data/concrete/ui/images/process-stop.png +0 -0
- data/concrete/ui/images/system-search.png +0 -0
- data/concrete/ui/layout_manager.js +54 -0
- data/concrete/ui/module_browser.js +88 -0
- data/concrete/ui/module_editor.js +217 -0
- data/concrete/ui/open_element_dialog.js +90 -0
- data/concrete/ui/preferences_dialog.js +75 -0
- data/concrete/ui/proceed_dialog.js +52 -0
- data/concrete/ui/search_replace_dialog.js +323 -0
- data/concrete/ui/style.css +296 -0
- data/concrete/ui/toolbar.js +74 -0
- data/concrete/ui/workbench.js +165 -0
- data/doc/concrete_developers_guide.html +1054 -0
- data/doc/concrete_developers_guide.txt +502 -0
- data/doc/concrete_users_guide.html +694 -0
- data/doc/concrete_users_guide.txt +223 -0
- data/example/formula_editor/example_data/example1.json +11 -0
- data/example/formula_editor/formula_editor.html +83 -0
- data/example/formula_editor/sqrt_horz.png +0 -0
- data/example/formula_editor/sqrt_vert.png +0 -0
- data/example/formula_editor/style.css +31 -0
- data/example/metamodel_editor/edit.rb +54 -0
- data/example/metamodel_editor/example_data/formula_metamodel.json +18 -0
- data/example/metamodel_editor/example_data/meta_metamodel.json +22 -0
- data/example/metamodel_editor/example_data/statemachine_metamodel.json +32 -0
- data/example/metamodel_editor/metamodel_editor.html +120 -0
- data/example/metamodel_editor/metamodel_editor2.html +135 -0
- data/example/metamodel_editor/metamodel_editor3.html +151 -0
- data/example/metamodel_editor/style.css +8 -0
- data/example/metamodel_editor/style2.css +19 -0
- data/example/metamodel_editor/style3.css +35 -0
- data/example/minimal_editor/minimal_editor.html +43 -0
- data/example/statemachine_editor/example_data/example1.json +11 -0
- data/example/statemachine_editor/state_background.png +0 -0
- data/example/statemachine_editor/statemachine_editor0.html +55 -0
- data/example/statemachine_editor/statemachine_editor1.html +62 -0
- data/example/statemachine_editor/statemachine_editor2.html +103 -0
- data/example/statemachine_editor/style0.css +8 -0
- data/example/statemachine_editor/style1.css +32 -0
- data/example/statemachine_editor/style2.css +43 -0
- data/example/themes/cobalt.css +176 -0
- data/example/themes/dialog-error.png +0 -0
- data/example/themes/dialog-information.png +0 -0
- data/example/themes/dialog-warning.png +0 -0
- data/example/themes/dots_12px.png +0 -0
- data/example/themes/fold_button_dots_when_hidden.css +18 -0
- data/example/themes/fold_button_plus_minus.css +21 -0
- data/example/themes/fold_button_plus_when_hidden.css +18 -0
- data/example/themes/light_blue.css +177 -0
- data/example/themes/minus_11px.png +0 -0
- data/example/themes/minus_13px.png +0 -0
- data/example/themes/minus_9px.png +0 -0
- data/example/themes/plus_11px.png +0 -0
- data/example/themes/plus_13px.png +0 -0
- data/example/themes/plus_9px.png +0 -0
- data/example/themes/white.css +177 -0
- data/lib/concrete/concrete_syntax_provider.rb +63 -0
- data/lib/concrete/config.rb +36 -0
- data/lib/concrete/file_cache_map.rb +88 -0
- data/lib/concrete/index_builder.rb +108 -0
- data/lib/concrete/metamodel/concrete_mmm.rb +45 -0
- data/lib/concrete/metamodel/ecore_to_concrete.rb +80 -0
- data/lib/concrete/server.rb +92 -0
- data/lib/concrete/util/logger.rb +24 -0
- data/lib/concrete/util/string_writer.rb +17 -0
- data/lib/concrete/working_set.rb +41 -0
- data/rakefile +33 -0
- data/redist/prototype.js +4320 -0
- data/redist/scriptaculous/builder.js +136 -0
- data/redist/scriptaculous/controls.js +991 -0
- data/redist/scriptaculous/dragdrop.js +975 -0
- data/redist/scriptaculous/effects.js +1130 -0
- data/redist/scriptaculous/scriptaculous.js +60 -0
- data/redist/scriptaculous/slider.js +275 -0
- data/redist/scriptaculous/sound.js +55 -0
- data/redist/scriptaculous/unittest.js +568 -0
- data/test/concrete_test.rb +5 -0
- data/test/file_cache_map_test.rb +90 -0
- data/test/file_cache_map_test/testdir/fileA +1 -0
- data/test/index_builder_test.rb +68 -0
- data/test/index_builder_test/ecore_index.js +85 -0
- data/test/index_builder_test/ecore_index_expected.js +85 -0
- data/test/integration/external_elements_test.html +114 -0
- data/test/metamodel_test.rb +40 -0
- data/test/metamodel_test/concrete_mmm_expected.js +19 -0
- data/test/metamodel_test/concrete_mmm_generated.js +19 -0
- data/test/metamodel_test/concrete_mmm_regenerated.js +19 -0
- data/test/unit/external_identifier_provider_test.html +138 -0
- data/test/unit/identifier_provider_test.html +269 -0
- data/test/unit/metamodel_provider_test.html +318 -0
- data/test/unit/model_interface_test.html +257 -0
- data/test/unit/template_provider_test.html +171 -0
- data/test/unit/test.css +90 -0
- data/test/working_set_test.rb +54 -0
- data/test/working_set_test/file1.txt +0 -0
- data/test/working_set_test/file2 +0 -0
- data/test/working_set_test/subdir/file3.xml +0 -0
- metadata +201 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
[{"_class": "Datatype", "name": "String"},
|
2
|
+
{"_class": "Class", "name": "Statemachine", "features": [
|
3
|
+
{"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"},
|
4
|
+
{"_class": "Feature", "name": "variables", "kind": "containment", "type": "Variable"},
|
5
|
+
{"_class": "Feature", "name": "triggers", "kind": "containment", "type": "Trigger"},
|
6
|
+
{"_class": "Feature", "name": "states", "kind": "containment", "type": "State"}]},
|
7
|
+
{"_class": "Class", "name": "Variable", "features":
|
8
|
+
{"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"}},
|
9
|
+
{"_class": "Class", "name": "Trigger", "features":
|
10
|
+
{"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"}},
|
11
|
+
{"_class": "Class", "name": "State", "abstract": true, "features": [
|
12
|
+
{"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"},
|
13
|
+
{"_class": "Feature", "name": "transitions", "kind": "containment", "upperLimit": -1, "type": "Transition"}]},
|
14
|
+
{"_class": "Class", "name": "SimpleState", "superTypes": "State"},
|
15
|
+
{"_class": "Class", "name": "CompositeState", "superTypes": "State", "features":
|
16
|
+
{"_class": "Feature", "name": "subStates", "kind": "containment", "upperLimit": -1, "type": "State"}},
|
17
|
+
{"_class": "Class", "name": "Transition", "features": [
|
18
|
+
{"_class": "Feature", "name": "target", "kind": "reference", "lowerLimit": 1, "upperLimit": 1, "type": "State"},
|
19
|
+
{"_class": "Feature", "name": "trigger", "kind": "reference", "upperLimit": -1, "type": "Trigger"},
|
20
|
+
{"_class": "Feature", "name": "condition", "kind": "containment", "upperLimit": 1, "type": "Expression"}]},
|
21
|
+
{"_class": "Class", "name": "Expression"},
|
22
|
+
{"_class": "Class", "name": "AndExpression", "superTypes": "Expression", "features": [
|
23
|
+
{"_class": "Feature", "name": "expr1", "kind": "containment", "lowerLimit": 1, "upperLimit": -1, "type": "Expression"},
|
24
|
+
{"_class": "Feature", "name": "expr2", "kind": "containment", "lowerLimit": 1, "upperLimit": -1, "type": "Expression"}]},
|
25
|
+
{"_class": "Class", "name": "OrExpression", "superTypes": "Expression", "features": [
|
26
|
+
{"_class": "Feature", "name": "expr1", "kind": "containment", "lowerLimit": 1, "upperLimit": -1, "type": "Expression"},
|
27
|
+
{"_class": "Feature", "name": "expr2", "kind": "containment", "lowerLimit": 1, "upperLimit": -1, "type": "Expression"}]},
|
28
|
+
{"_class": "Class", "name": "NotExpression", "superTypes": "Expression", "features":
|
29
|
+
{"_class": "Feature", "name": "expr", "kind": "containment", "lowerLimit": 1, "upperLimit": -1, "type": "Expression"}},
|
30
|
+
{"_class": "Class", "name": "VarRef", "superTypes": "Expression", "features":
|
31
|
+
{"_class": "Feature", "name": "variable", "kind": "reference", "lowerLimit": 1, "upperLimit": 1, "type": "Variable"}}]
|
32
|
+
|
@@ -0,0 +1,120 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<link rel="stylesheet" href="../../example/themes/cobalt.css" type="text/css" />
|
4
|
+
<link rel="stylesheet" href="../../example/themes/fold_button_dots_when_hidden.css" type="text/css" />
|
5
|
+
<link rel="stylesheet" href="../../example/metamodel_editor/style.css" type="text/css" />
|
6
|
+
<script src="../../redist/prototype.js" type="text/javascript"></script>
|
7
|
+
<script src="../../redist/scriptaculous/scriptaculous.js" type="text/javascript"></script>
|
8
|
+
<script src="../../concrete/concrete.js" type="text/javascript"></script>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="templates1" style="display: none">
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div id="metamodel1" style="display: none">
|
15
|
+
[
|
16
|
+
{"_class": "Datatype", "name": "String"},
|
17
|
+
{"_class": "Datatype", "name": "Integer"},
|
18
|
+
{"_class": "Datatype", "name": "Boolean"},
|
19
|
+
{"_class": "Enum", "name": "FeatureKindType", "literals": ["attribute", "reference", "containment"]},
|
20
|
+
{"_class": "Class", "name": "Classifier", "abstract": true, "features": {"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"}},
|
21
|
+
{"_class": "Class", "name": "Datatype", "superTypes": "Classifier"},
|
22
|
+
{"_class": "Class", "name": "Enum", "superTypes": "Datatype", "features": {"_class": "Feature", "name": "literals", "kind": "attribute", "lowerLimit": 1, "upperLimit": -1, "type": "String"}},
|
23
|
+
{"_class": "Class", "name": "Class", "superTypes": "Classifier", "features": [
|
24
|
+
{"_class": "Feature", "name": "superTypes", "kind": "reference", "upperLimit": -1, "type": "Class"},
|
25
|
+
{"_class": "Feature", "name": "features", "kind": "containment", "upperLimit": -1, "type": "Feature"},
|
26
|
+
{"_class": "Feature", "name": "abstract", "kind": "attribute", "upperLimit": 1, "type": "Boolean"}
|
27
|
+
]},
|
28
|
+
{"_class": "Class", "name": "Feature", "features": [
|
29
|
+
{"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"},
|
30
|
+
{"_class": "Feature", "name": "kind", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "FeatureKindType"},
|
31
|
+
{"_class": "Feature", "name": "lowerLimit", "kind": "attribute", "upperLimit": 1, "type": "Integer"},
|
32
|
+
{"_class": "Feature", "name": "upperLimit", "kind": "attribute", "upperLimit": 1, "type": "Integer"},
|
33
|
+
{"_class": "Feature", "name": "type", "kind": "reference", "lowerLimit": 1, "upperLimit": 1, "type": "Classifier"}
|
34
|
+
]}
|
35
|
+
]
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<div id="model1" style="display: none">
|
39
|
+
<!-- json model here -->
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<div class="ct_editor" id="editor1">
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div id="controlbuttons" style="display: none">
|
46
|
+
<!-- the buttons will only be shown in ajax mode -->
|
47
|
+
<input type="button" style="margin: 10px" value="Save" onclick="saveModel();"/>
|
48
|
+
<input type="button" style="margin: 10px" value="Exit" onclick="exitEditor();"/>
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<br/>
|
52
|
+
<textarea id="clipboard1" style="background-color: white; color: black; border: 1px solid grey" cols="80" rows="10" wrap="off"></textarea>
|
53
|
+
|
54
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
55
|
+
// <![CDATA[
|
56
|
+
var tp = new Concrete.TemplateProvider($("templates1"), {identifierAttribute: "name"});
|
57
|
+
var mp = new Concrete.MetamodelProvider($("metamodel1").textContent.evalJSON());
|
58
|
+
var ip = new Concrete.QualifiedNameBasedIdentifierProvider({nameAttribute: "name", separator: "/", leadingSeparator: false});
|
59
|
+
var cb = new Concrete.Clipboard($("clipboard1"));
|
60
|
+
var ed = new Concrete.Editor($("editor1"), tp, mp, ip, {clipboard: cb,
|
61
|
+
rootClasses: mp.metaclasses.select(function(c) { return ["Class", "Datatype", "Enum"].include(c.name)})});
|
62
|
+
|
63
|
+
// Editor specific constraints
|
64
|
+
|
65
|
+
ed.constraintChecker.addConstraint(new Concrete.ConstraintChecker.FeatureValueConstraint({
|
66
|
+
class: "Datatype", feature: "name",
|
67
|
+
message: "primitive types (Datatype) must be named 'String', 'Integer', 'Float' or 'Boolean'",
|
68
|
+
checker: function(element, value) {
|
69
|
+
return ["String", "Integer", "Float", "Boolean"].include(value);
|
70
|
+
}
|
71
|
+
}));
|
72
|
+
|
73
|
+
ed.constraintChecker.addConstraint(new Concrete.ConstraintChecker.FeatureValueConstraint({
|
74
|
+
class: "Feature", feature: "type",
|
75
|
+
message: "features of kind 'attribute' must only reference primitive types (Datatype or Enum)",
|
76
|
+
checker: function(element, target) {
|
77
|
+
return !element.featureValues("kind").include("attribute") || !target || ["Datatype", "Enum"].include(target.mmClass.name);
|
78
|
+
}
|
79
|
+
}));
|
80
|
+
|
81
|
+
ed.constraintChecker.addConstraint(new Concrete.ConstraintChecker.FeatureValueConstraint({
|
82
|
+
class: "Feature", feature: "type",
|
83
|
+
message: "features of kind 'reference' or 'containment' must only reference classes",
|
84
|
+
checker: function(element, target) {
|
85
|
+
var kind = element.featureValues("kind");
|
86
|
+
return (!kind.include("reference") && !kind.include("containment")) || !target || target.mmClass.name == "Class";
|
87
|
+
}
|
88
|
+
}));
|
89
|
+
|
90
|
+
// load model if present
|
91
|
+
var modelData = $("model1").textContent;
|
92
|
+
if (modelData.isJSON()) {
|
93
|
+
ed.setModel(modelData);
|
94
|
+
$("controlbuttons").show();
|
95
|
+
}
|
96
|
+
|
97
|
+
function saveModel() {
|
98
|
+
new Ajax.Request("/save", {
|
99
|
+
method: 'post',
|
100
|
+
postBody: ed.getModel(),
|
101
|
+
});
|
102
|
+
}
|
103
|
+
|
104
|
+
function exitEditor() {
|
105
|
+
new Ajax.Request("/exit", { onSuccess: function() {$$("body").first().innerHTML = "<p>Editor exited. Close window.</p>"}});
|
106
|
+
}
|
107
|
+
|
108
|
+
Event.observe(window, 'click', function(event) {
|
109
|
+
ed.handleEvent(event);
|
110
|
+
});
|
111
|
+
Event.observe(window, 'keydown', function(event) {
|
112
|
+
ed.handleEvent(event);
|
113
|
+
});
|
114
|
+
Event.observe(window, 'mousemove', function(event) {
|
115
|
+
ed.handleEvent(event);
|
116
|
+
});
|
117
|
+
// ]]>
|
118
|
+
</script>
|
119
|
+
</body>
|
120
|
+
</html>
|
@@ -0,0 +1,135 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<link rel="stylesheet" href="../../example/themes/white.css" type="text/css" />
|
4
|
+
<link rel="stylesheet" href="../../example/themes/fold_button_dots_when_hidden.css" type="text/css" />
|
5
|
+
<link rel="stylesheet" href="../../example/metamodel_editor/style2.css" type="text/css" />
|
6
|
+
<script src="../../redist/prototype.js" type="text/javascript"></script>
|
7
|
+
<script src="../../redist/scriptaculous/scriptaculous.js" type="text/javascript"></script>
|
8
|
+
<script src="../../concrete/concrete.js" type="text/javascript"></script>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="templates1" style="display: none">
|
12
|
+
<div class="ct_element ctc_Class" style="">
|
13
|
+
<div class="ct_reference ctn_superTypes ct_auto_hide" style="text-align: right; text-decoration: italic"><span class="ct_slot"></span></div>
|
14
|
+
<div class="ct_attribute ctn_name" style="text-align: center; font-size: 150%; border-bottom: 1px solid grey"><span class="ct_slot"></span></div>
|
15
|
+
<div class="ct_attribute ctn_abstract ct_always_hide" style="">abstract: <span class="ct_slot"></span></div>
|
16
|
+
<div class="ct_containment ctn_features" style="padding: 5px">
|
17
|
+
<div class="ct_slot"></div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
<div class="ct_element ctc_Feature" style="margin: 0">
|
21
|
+
<span class="ct_attribute ctn_kind ct_always_hide" style=""><span class="ct_slot"></span></span>
|
22
|
+
<span class="ct_attribute ctn_name" style=""><span class="ct_slot"></span></span>:
|
23
|
+
<span class="ct_reference ctn_type" style=""><span class="ct_slot"></span></span>
|
24
|
+
[<span class="ct_attribute ctn_lowerLimit ct_auto_hide" style=""><span class="ct_slot"></span></span>;
|
25
|
+
<span class="ct_attribute ctn_upperLimit ct_auto_hide" style=""><span class="ct_slot"></span></span>]
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div id="metamodel1" style="display: none">
|
30
|
+
[
|
31
|
+
{"_class": "Datatype", "name": "String"},
|
32
|
+
{"_class": "Datatype", "name": "Integer"},
|
33
|
+
{"_class": "Datatype", "name": "Boolean"},
|
34
|
+
{"_class": "Enum", "name": "FeatureKindType", "literals": ["attribute", "reference", "containment"]},
|
35
|
+
{"_class": "Class", "name": "Classifier", "abstract": true, "features": {"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"}},
|
36
|
+
{"_class": "Class", "name": "Datatype", "superTypes": "Classifier"},
|
37
|
+
{"_class": "Class", "name": "Enum", "superTypes": "Datatype", "features": {"_class": "Feature", "name": "literals", "kind": "attribute", "lowerLimit": 1, "upperLimit": -1, "type": "String"}},
|
38
|
+
{"_class": "Class", "name": "Class", "superTypes": "Classifier", "features": [
|
39
|
+
{"_class": "Feature", "name": "superTypes", "kind": "reference", "upperLimit": -1, "type": "Class"},
|
40
|
+
{"_class": "Feature", "name": "features", "kind": "containment", "upperLimit": -1, "type": "Feature"},
|
41
|
+
{"_class": "Feature", "name": "abstract", "kind": "attribute", "upperLimit": 1, "type": "Boolean"}
|
42
|
+
]},
|
43
|
+
{"_class": "Class", "name": "Feature", "features": [
|
44
|
+
{"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"},
|
45
|
+
{"_class": "Feature", "name": "kind", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "FeatureKindType"},
|
46
|
+
{"_class": "Feature", "name": "lowerLimit", "kind": "attribute", "upperLimit": 1, "type": "Integer"},
|
47
|
+
{"_class": "Feature", "name": "upperLimit", "kind": "attribute", "upperLimit": 1, "type": "Integer"},
|
48
|
+
{"_class": "Feature", "name": "type", "kind": "reference", "lowerLimit": 1, "upperLimit": 1, "type": "Classifier"}
|
49
|
+
]}
|
50
|
+
]
|
51
|
+
</div>
|
52
|
+
|
53
|
+
<div id="model1" style="display: none">
|
54
|
+
<!-- json model here -->
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<div class="ct_editor" id="editor1">
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div id="controlbuttons" style="display: none">
|
61
|
+
<!-- the buttons will only be shown in ajax mode -->
|
62
|
+
<input type="button" style="margin: 10px" value="Save" onclick="saveModel();"/>
|
63
|
+
<input type="button" style="margin: 10px" value="Exit" onclick="exitEditor();"/>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<br/>
|
67
|
+
<textarea id="clipboard1" style="background-color: white; color: black; border: 1px solid grey" cols="80" rows="10" wrap="off"></textarea>
|
68
|
+
|
69
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
70
|
+
// <![CDATA[
|
71
|
+
var tp = new Concrete.TemplateProvider($("templates1"), {identifierAttribute: "name"});
|
72
|
+
var mp = new Concrete.MetamodelProvider($("metamodel1").textContent.evalJSON());
|
73
|
+
var ip = new Concrete.QualifiedNameBasedIdentifierProvider({nameAttribute: "name", separator: "/", leadingSeparator: false});
|
74
|
+
var cb = new Concrete.Clipboard($("clipboard1"));
|
75
|
+
var ed = new Concrete.Editor($("editor1"), tp, mp, ip, {clipboard: cb,
|
76
|
+
rootClasses: mp.metaclasses.select(function(c) { return ["Class", "Datatype", "Enum"].include(c.name)})});
|
77
|
+
|
78
|
+
// Editor specific constraints
|
79
|
+
|
80
|
+
ed.constraintChecker.addConstraint(new Concrete.ConstraintChecker.FeatureValueConstraint({
|
81
|
+
class: "Datatype", feature: "name",
|
82
|
+
message: "primitive types (Datatype) must be named 'String', 'Integer', 'Float' or 'Boolean'",
|
83
|
+
checker: function(element, value) {
|
84
|
+
return ["String", "Integer", "Float", "Boolean"].include(value);
|
85
|
+
}
|
86
|
+
}));
|
87
|
+
|
88
|
+
ed.constraintChecker.addConstraint(new Concrete.ConstraintChecker.FeatureValueConstraint({
|
89
|
+
class: "Feature", feature: "type",
|
90
|
+
message: "features of kind 'attribute' must only reference primitive types (Datatype or Enum)",
|
91
|
+
checker: function(element, target) {
|
92
|
+
return !element.featureValues("kind").include("attribute") || !target || ["Datatype", "Enum"].include(target.mmClass.name);
|
93
|
+
}
|
94
|
+
}));
|
95
|
+
|
96
|
+
ed.constraintChecker.addConstraint(new Concrete.ConstraintChecker.FeatureValueConstraint({
|
97
|
+
class: "Feature", feature: "type",
|
98
|
+
message: "features of kind 'reference' or 'containment' must only reference classes",
|
99
|
+
checker: function(element, target) {
|
100
|
+
var kind = element.featureValues("kind");
|
101
|
+
return (!kind.include("reference") && !kind.include("containment")) || !target || target.mmClass.name == "Class";
|
102
|
+
}
|
103
|
+
}));
|
104
|
+
|
105
|
+
// load model if present
|
106
|
+
var modelData = $("model1").textContent;
|
107
|
+
if (modelData.isJSON()) {
|
108
|
+
ed.setModel(modelData);
|
109
|
+
$("controlbuttons").show();
|
110
|
+
}
|
111
|
+
|
112
|
+
function saveModel() {
|
113
|
+
new Ajax.Request("/save", {
|
114
|
+
method: 'post',
|
115
|
+
postBody: ed.getModel(),
|
116
|
+
});
|
117
|
+
}
|
118
|
+
|
119
|
+
function exitEditor() {
|
120
|
+
new Ajax.Request("/exit", { onSuccess: function() {$$("body").first().innerHTML = "<p>Editor exited. Close window.</p>"}});
|
121
|
+
}
|
122
|
+
|
123
|
+
Event.observe(window, 'click', function(event) {
|
124
|
+
ed.handleEvent(event);
|
125
|
+
});
|
126
|
+
Event.observe(window, 'keydown', function(event) {
|
127
|
+
ed.handleEvent(event);
|
128
|
+
});
|
129
|
+
Event.observe(window, 'mousemove', function(event) {
|
130
|
+
ed.handleEvent(event);
|
131
|
+
});
|
132
|
+
// ]]>
|
133
|
+
</script>
|
134
|
+
</body>
|
135
|
+
</html>
|
@@ -0,0 +1,151 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<link rel="stylesheet" href="../../example/themes/white.css" type="text/css" />
|
4
|
+
<link rel="stylesheet" href="../../example/themes/fold_button_dots_when_hidden.css" type="text/css" />
|
5
|
+
<link rel="stylesheet" href="../../example/metamodel_editor/style3.css" type="text/css" />
|
6
|
+
<script src="../../redist/prototype.js" type="text/javascript"></script>
|
7
|
+
<script src="../../redist/scriptaculous/scriptaculous.js" type="text/javascript"></script>
|
8
|
+
<script src="../../concrete/concrete.js" type="text/javascript"></script>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="templates1" style="display: none">
|
12
|
+
<div class="ct_element ctc_Class">
|
13
|
+
<span class="ct_handle ct_class_name">Class</span>
|
14
|
+
<span class="ct_attribute ctn_name ct_identifier_attribute">
|
15
|
+
<span class="ct_feature_name">name: </span><span class="ct_slot"></span>
|
16
|
+
</span>
|
17
|
+
<span class="ct_reference ctn_superTypes ct_auto_hide">
|
18
|
+
<span class="ct_feature_name">superTypes: </span><span class="ct_slot"></span>
|
19
|
+
</span>
|
20
|
+
<span class="ct_attribute ctn_abstract ct_auto_hide">
|
21
|
+
<span class="ct_feature_name">abstract: </span><span class="ct_slot"></span>
|
22
|
+
</span>
|
23
|
+
<div class="ct_containment ctn_features ct_auto_hide">
|
24
|
+
<span class="ct_feature_name">features: </span>
|
25
|
+
<table>
|
26
|
+
<thead>
|
27
|
+
<tr><td>Name</td><td>Kind</td><td>Lower Limit</td><td>Upper Limit</td><td>Type</td></tr>
|
28
|
+
</thead>
|
29
|
+
<tbody class="ct_slot">
|
30
|
+
</tbody>
|
31
|
+
</table>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
<table> <!-- dummy table to make valid template dom -->
|
35
|
+
<tr class="ct_element ctc_Feature">
|
36
|
+
<td class="ct_attribute ctn_name"><span class="ct_slot"></span></td>
|
37
|
+
<td class="ct_attribute ctn_kind"><span class="ct_slot"></span></td>
|
38
|
+
<td class="ct_attribute ctn_lowerLimit"><span class="ct_slot"></span></td>
|
39
|
+
<td class="ct_attribute ctn_upperLimit"><span class="ct_slot"></span></td>
|
40
|
+
<td class="ct_reference ctn_type"><span class="ct_slot"></span></td>
|
41
|
+
</tr>
|
42
|
+
</table>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div id="metamodel1" style="display: none">
|
46
|
+
[
|
47
|
+
{"_class": "Datatype", "name": "String"},
|
48
|
+
{"_class": "Datatype", "name": "Integer"},
|
49
|
+
{"_class": "Datatype", "name": "Boolean"},
|
50
|
+
{"_class": "Enum", "name": "FeatureKindType", "literals": ["attribute", "reference", "containment"]},
|
51
|
+
{"_class": "Class", "name": "Classifier", "abstract": true, "features": {"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"}},
|
52
|
+
{"_class": "Class", "name": "Datatype", "superTypes": "Classifier"},
|
53
|
+
{"_class": "Class", "name": "Enum", "superTypes": "Datatype", "features": {"_class": "Feature", "name": "literals", "kind": "attribute", "lowerLimit": 1, "upperLimit": -1, "type": "String"}},
|
54
|
+
{"_class": "Class", "name": "Class", "superTypes": "Classifier", "features": [
|
55
|
+
{"_class": "Feature", "name": "superTypes", "kind": "reference", "upperLimit": -1, "type": "Class"},
|
56
|
+
{"_class": "Feature", "name": "features", "kind": "containment", "upperLimit": -1, "type": "Feature"},
|
57
|
+
{"_class": "Feature", "name": "abstract", "kind": "attribute", "upperLimit": 1, "type": "Boolean"}
|
58
|
+
]},
|
59
|
+
{"_class": "Class", "name": "Feature", "features": [
|
60
|
+
{"_class": "Feature", "name": "name", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "String"},
|
61
|
+
{"_class": "Feature", "name": "kind", "kind": "attribute", "lowerLimit": 1, "upperLimit": 1, "type": "FeatureKindType"},
|
62
|
+
{"_class": "Feature", "name": "lowerLimit", "kind": "attribute", "upperLimit": 1, "type": "Integer"},
|
63
|
+
{"_class": "Feature", "name": "upperLimit", "kind": "attribute", "upperLimit": 1, "type": "Integer"},
|
64
|
+
{"_class": "Feature", "name": "type", "kind": "reference", "lowerLimit": 1, "upperLimit": 1, "type": "Classifier"} ]}
|
65
|
+
]
|
66
|
+
</div>
|
67
|
+
|
68
|
+
<div id="model1" style="display: none">
|
69
|
+
<!-- json model here -->
|
70
|
+
</div>
|
71
|
+
|
72
|
+
<div class="ct_editor" id="editor1">
|
73
|
+
</div>
|
74
|
+
|
75
|
+
<div id="controlbuttons" style="display: none">
|
76
|
+
<!-- the buttons will only be shown in ajax mode -->
|
77
|
+
<input type="button" style="margin: 10px" value="Save" onclick="saveModel();"/>
|
78
|
+
<input type="button" style="margin: 10px" value="Exit" onclick="exitEditor();"/>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<br/>
|
82
|
+
<textarea id="clipboard1" style="background-color: white; color: black; border: 1px solid grey" cols="80" rows="10" wrap="off"></textarea>
|
83
|
+
|
84
|
+
<script type="text/javascript" language="javascript" charset="utf-8">
|
85
|
+
// <![CDATA[
|
86
|
+
var tp = new Concrete.TemplateProvider($("templates1"), {identifierAttribute: "name"});
|
87
|
+
var mp = new Concrete.MetamodelProvider($("metamodel1").textContent.evalJSON());
|
88
|
+
var ip = new Concrete.QualifiedNameBasedIdentifierProvider({nameAttribute: "name", separator: "/", leadingSeparator: false});
|
89
|
+
var cb = new Concrete.Clipboard($("clipboard1"));
|
90
|
+
var ed = new Concrete.Editor($("editor1"), tp, mp, ip, {clipboard: cb,
|
91
|
+
rootClasses: mp.metaclasses.select(function(c) { return ["Class", "Datatype", "Enum"].include(c.name)}),
|
92
|
+
selector: new Concrete.Selector({cursorEdgeOnly: false})});
|
93
|
+
|
94
|
+
// Editor specific constraints
|
95
|
+
|
96
|
+
ed.constraintChecker.addConstraint(new Concrete.ConstraintChecker.FeatureValueConstraint({
|
97
|
+
class: "Datatype", feature: "name",
|
98
|
+
message: "primitive types (Datatype) must be named 'String', 'Integer', 'Float' or 'Boolean'",
|
99
|
+
checker: function(element, value) {
|
100
|
+
return ["String", "Integer", "Float", "Boolean"].include(value);
|
101
|
+
}
|
102
|
+
}));
|
103
|
+
|
104
|
+
ed.constraintChecker.addConstraint(new Concrete.ConstraintChecker.FeatureValueConstraint({
|
105
|
+
class: "Feature", feature: "type",
|
106
|
+
message: "features of kind 'attribute' must only reference primitive types (Datatype or Enum)",
|
107
|
+
checker: function(element, target) {
|
108
|
+
return !element.featureValues("kind").include("attribute") || !target || ["Datatype", "Enum"].include(target.mmClass.name);
|
109
|
+
}
|
110
|
+
}));
|
111
|
+
|
112
|
+
ed.constraintChecker.addConstraint(new Concrete.ConstraintChecker.FeatureValueConstraint({
|
113
|
+
class: "Feature", feature: "type",
|
114
|
+
message: "features of kind 'reference' or 'containment' must only reference classes",
|
115
|
+
checker: function(element, target) {
|
116
|
+
var kind = element.featureValues("kind");
|
117
|
+
return (!kind.include("reference") && !kind.include("containment")) || !target || target.mmClass.name == "Class";
|
118
|
+
}
|
119
|
+
}));
|
120
|
+
|
121
|
+
// load model if present
|
122
|
+
var modelData = $("model1").textContent;
|
123
|
+
if (modelData.isJSON()) {
|
124
|
+
ed.setModel(modelData);
|
125
|
+
$("controlbuttons").show();
|
126
|
+
}
|
127
|
+
|
128
|
+
function saveModel() {
|
129
|
+
new Ajax.Request("/save", {
|
130
|
+
method: 'post',
|
131
|
+
postBody: ed.getModel(),
|
132
|
+
});
|
133
|
+
}
|
134
|
+
|
135
|
+
function exitEditor() {
|
136
|
+
new Ajax.Request("/exit", { onSuccess: function() {$$("body").first().innerHTML = "<p>Editor exited. Close window.</p>"}});
|
137
|
+
}
|
138
|
+
|
139
|
+
Event.observe(window, 'click', function(event) {
|
140
|
+
ed.handleEvent(event);
|
141
|
+
});
|
142
|
+
Event.observe(window, 'keydown', function(event) {
|
143
|
+
ed.handleEvent(event);
|
144
|
+
});
|
145
|
+
Event.observe(window, 'mousemove', function(event) {
|
146
|
+
ed.handleEvent(event);
|
147
|
+
});
|
148
|
+
// ]]>
|
149
|
+
</script>
|
150
|
+
</body>
|
151
|
+
</html>
|