isidorus-cvs
Threads by month
- ----- 2025 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
June 2009
- 1 participants
- 50 discussions

30 Jun '09
Author: lgiessmann
Date: Tue Jun 30 09:21:53 2009
New Revision: 82
Log:
ajax-client: fixed some info-messages when the client requests something
Modified:
trunk/src/ajax/javascripts/requests.js
trunk/src/rest_interface/set-up-json-interface.lisp
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Tue Jun 30 09:21:53 2009
@@ -89,12 +89,20 @@
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
var timeFun = setAjaxTimeout(TIMEOUT, TYPE_PSIS_URL);
- onLoad("Requesting all type PSIs");
-
+
var url = ALL_PSIS_URL;
+ var message = "Requesting all type PSIs";
if(what && what.types && what.types === true) url = TYPE_PSIS_URL;
- else if(what && what.instances && what.instances === true) url = INSTANCE_PSIS_URL;
- else if(what && what.all && what.all === true) url = ALL_PSIS_URL;
+ else if(what && what.instances && what.instances === true){
+ url = INSTANCE_PSIS_URL;
+ message = "Requesting all instance PSIs";
+ }
+ else if(what && what.all && what.all === true){
+ url = ALL_PSIS_URL;
+ message = "Requesting all PSIs";
+ }
+
+ onLoad(message);
new Ajax.Request(url, {
"method" : "get",
Modified: trunk/src/rest_interface/set-up-json-interface.lisp
==============================================================================
--- trunk/src/rest_interface/set-up-json-interface.lisp (original)
+++ trunk/src/rest_interface/set-up-json-interface.lisp Tue Jun 30 09:21:53 2009
@@ -19,7 +19,7 @@
(defparameter *json-get-type-tmcl-url* "/json/tmcl/type/?$") ;the json url for getting some tmcl information of a topic treated as a type
(defparameter *json-get-instance-tmcl-url* "/json/tmcl/instance/?$") ;the json url for getting some tmcl information of a topic treated as an instance
(defparameter *json-get-overview* "/json/tmcl/overview/?$") ; returns a json-object representing a tree view
-(defparameter *ajax-user-interface-url* "/isidorus/?$") ;the url to the user interface; if you want to get all topics set start=0&end=nil -> localhost:8000/isidorus
+(defparameter *ajax-user-interface-url* "/isidorus/?$") ;the url to the user interface;
(defparameter *ajax-user-interface-css-prefix* "/css") ;the url to the css files of the user interface
(defparameter *ajax-user-interface-css-directory-path* "ajax/css") ;the directory contains the css files
(defparameter *ajax-user-interface-file-path* "ajax/isidorus.html") ;the file path to the HTML file implements the user interface
1
0
Author: lgiessmann
Date: Tue Jun 30 06:22:06 2009
New Revision: 81
Log:
ajax-client: set the default address to localhost:8000
Modified:
trunk/src/ajax/javascripts/constants.js
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Tue Jun 30 06:22:06 2009
@@ -11,7 +11,7 @@
// --- Some constants fot the http connections via the XMLHttpRequest-Object
-var HOST_PREF = "http://143.93.190.237:8000/"; // "http://localhost:8000/"; // of the form "http://(.+)/"
+var HOST_PREF = /*"http://143.93.190.237:8000/";*/ "http://localhost:8000/"; // of the form "http://(.+)/"
var GET_PREFIX = HOST_PREF + "json/get/";
var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/";
var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
1
0

[isidorus-cvs] r80 - in trunk/src: ajax/css ajax/javascripts unit_tests
by Lukas Giessmann 30 Jun '09
by Lukas Giessmann 30 Jun '09
30 Jun '09
Author: lgiessmann
Date: Tue Jun 30 06:16:38 2009
New Revision: 80
Log:
ajax-client: implemented a topic map overview
Modified:
trunk/src/ajax/css/tree.css
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/edit.js
trunk/src/ajax/javascripts/home.js
trunk/src/unit_tests/poems.xtm
Modified: trunk/src/ajax/css/tree.css
==============================================================================
--- trunk/src/ajax/css/tree.css (original)
+++ trunk/src/ajax/css/tree.css Tue Jun 30 06:16:38 2009
@@ -27,18 +27,28 @@
}
ul.topicPsis + span {
+ color: #7090d0;
+ font-size: 0.8em;
margin-left: 20px;
- margin-right: 2px;
}
-ul.topicPsis + span + span{
+ul.topicPsis + span + span + span {
+ color: #7090d0;
+ font-size: 0.8em;
+}
+
+ul.topicPsis + span + span {
+ color: #7090d0;
margin-left: 2px;
+ margin-right: 2px;
}
ul.topicPsis + span.disabled {
+ font-size: 0.8em;
color: #eaeaee;
}
-ul.topicPsis + span + span.disabled {
+ul.topicPsis + span + span + span.disabled {
+ font-size: 0.8em;
color: #eaeaee;
}
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Tue Jun 30 06:16:38 2009
@@ -11,7 +11,7 @@
// --- Some constants fot the http connections via the XMLHttpRequest-Object
-var HOST_PREF = /*"http://143.93.190.237:8000/";*/ "http://localhost:8000/"; // of the form "http://(.+)/"
+var HOST_PREF = "http://143.93.190.237:8000/"; // "http://localhost:8000/"; // of the form "http://(.+)/"
var GET_PREFIX = HOST_PREF + "json/get/";
var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/";
var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Tue Jun 30 06:16:38 2009
@@ -43,7 +43,7 @@
liTopicSelect.insert({"bottom" : err});
}
else {
- instanceOf = new InstanceOfC(json.flatten().sort(), innerMakeFragment);
+ instanceOf = new InstanceOfC(json.flatten().sort(), innerMakeFragment, psi);
liTopicSelect.insert({"bottom" : instanceOf.getFrame()});
}
}
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Tue Jun 30 06:16:38 2009
@@ -186,6 +186,18 @@
"enable" : function(){
this.__content__.removeAttribute("disabled");
this.__disabled__ = false;
+ },
+ "select" : function(value){
+ var opts = this.__content__.select("option");
+ for(var i = 0; i !== opts.length; ++i){
+ try{
+ if(opts[i].value === value){
+ opts[i].writeAttribute({"selected" : "selected"});
+ this.__content__.insert({"top" : opts[i]});
+ }
+ else opts[i].removeAttribute("selected");
+ }catch(err){ alert("err [" + i + "]" + err); }
+ }
}});
@@ -243,12 +255,13 @@
// --- Representation of a
-var EditC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun){
+var EditC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun, psi){
$super();
this.__frame__.writeAttribute({"class" : CLASSES.editFrame()});
this.__container__ = new Object();
try{
var row = new SelectrowC(contents, this.__container__, 1, 1);
+ if(psi && psi.length !== 0) row.select(psi);
this.__error__.insert({"before" : row.getFrame()});
}
catch(err){
@@ -274,6 +287,12 @@
clearFragment();
requestConstraints("[" + myself.toJSON() + "]", onSuccessHandler, null)
});
+
+ if(psi && psi.length !== 0) {
+ myself.hideError();
+ clearFragment();
+ requestConstraints("[" + myself.toJSON() + "]", onSuccessHandler, null);
+ }
}
setHandler(this);
@@ -288,12 +307,13 @@
// --- Represents a container for all instanceOf-Psis of a fragment's topic
-var InstanceOfC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun){
+var InstanceOfC = Class.create(ContainerC, {"initialize" : function($super, contents, successFun, psi){
$super();
this.__frame__.writeAttribute({"class" : CLASSES.instanceOfFrame()});
this.__container__ = new Object();
try{
var row = new SelectrowC(contents, this.__container__, 1, -1);
+ if(psi && psi.length !== 0) row.select(psi);
this.__error__.insert({"before" : row.getFrame()});
}
catch(err){
@@ -339,6 +359,12 @@
clearFragment();
requestConstraints(myself.toJSON(true), onSuccessHandler, null, true);
});
+
+ if(psi && psi.length !== 0) {
+ myself.hideError();
+ clearFragment();
+ requestConstraints(myself.toJSON(true), onSuccessHandler, null, true);
+ }
}
setHandler(this);
@@ -2824,7 +2850,7 @@
}
},
"__createFromContent__" : function(contents){
- if(!contents || contents.lenght === 0) return;
+ if(!contents || contents.length === 0) return;
var cContents = contents;
var usedContents = new Array();
Modified: trunk/src/ajax/javascripts/edit.js
==============================================================================
--- trunk/src/ajax/javascripts/edit.js (original)
+++ trunk/src/ajax/javascripts/edit.js Tue Jun 30 06:16:38 2009
@@ -53,7 +53,8 @@
liTopicSelect.insert({"bottom" : err});
}
else {
- edit = new EditC(json.flatten().sort(), innerMakeFragment);
+ if(!psi || psi.strip().lenght === 0) psi = null;
+ edit = new EditC(json.flatten().sort(), innerMakeFragment, psi);
liTopicSelect.insert({"bottom" : edit.getFrame()});
}
}
Modified: trunk/src/ajax/javascripts/home.js
==============================================================================
--- trunk/src/ajax/javascripts/home.js (original)
+++ trunk/src/ajax/javascripts/home.js Tue Jun 30 06:16:38 2009
@@ -42,6 +42,7 @@
}
+// --- Represents a list of trees.
var TreeViewC = Class.create({"initialize" : function(contents){
if(!contents) throw "From NodeC(): content must be set!";
try {
@@ -60,6 +61,7 @@
}});
+// --- Represents the root of a tree of nodes and contain all tree's nodes.
var TreeC = Class.create({"initialize" : function(content){
if(!content) throw "From NodeC(): content must be set!";
try {
@@ -75,17 +77,49 @@
}});
+// --- Represents a tree node with a topic as a list of psis,
+// --- an edit and a create button. Furter the node can contain
+// --- more nodes as listings of instances and subtypes of the
+// --- current node's topic.
var NodeC = Class.create({"initialize" : function(content){
if(!content) throw "From NodeC(): content must be set!";
try {
this.__frame__ = new Element("li", {"class" : CLASSES.node()});
+ this.__isMinimized__ = false;
+
+ function setClickHandler(myself){
+ myself.__frame__.observe("click", function(event){
+ if(myself.__isMinimized__ === false){
+ if(myself.__instances__) myself.__instances__.hide();
+ if(myself.__subtypes__) myself.__subtypes__.hide();
+ myself.__frame__.setStyle({"color" : "#ff7f00"});
+ myself.__isMinimized__ = true;
+ }
+ else {
+ if(myself.__instances__) myself.__instances__.show();
+ if(myself.__subtypes__) myself.__subtypes__.show();
+ myself.__frame__.setStyle({"color" : "inherit"});
+ myself.__isMinimized__ = false;
+ }
+ Event.stop(event);
+ });
+ }
+ setClickHandler(this);
+
+ if((content.instances && content.instances.length !== 0) || (content.subtypes && content.subtypes.length !== 0)) {
+ this.getFrame().setStyle({"cursor" : "pointer"});
+ }
+ else {
+ this.getFrame().setStyle({"cursor" : "text"});
+ }
+
this.__topic__ = new Element("ul", {"class" : CLASSES.topicPsis()});
- this.__frame__.update(this.__topic__);
+ this.__frame__.insert({"bottom" : this.__topic__});
for(var i = 0; content.topic && i !== content.topic.length; ++i){
var tLi = new Element("li").update(content.topic[i]);
this.__topic__.insert({"bottom" : tLi});
}
-
+
this.__edit__ = new Element("span", {"class" : CLASSES.clickable()}).update("edit");
this.__create__ = new Element("span", {"class" : CLASSES.clickable()}).update("create");
if(content.isType !== true){
@@ -93,9 +127,10 @@
}
else {
this.__create__.observe("click", function(event){
- alert("create");
+ setNaviClasses($(PAGES.create));
+ makePage(PAGES.create, content.topic[0]);
+ Event.stop(event);
});
- // TODO: define a handler
}
if(content.isInstance !== true){
@@ -103,14 +138,15 @@
}
else {
this.__edit__.observe("click", function(event){
- alert("edit");
+ setNaviClasses($(PAGES.edit));
+ makePage(PAGES.edit, content.topic[0]);
+ Event.stop(event);
});
- // TODO: define a handler
}
- this.__frame__.update(this.__topic__);
this.__frame__.insert({"bottom" : this.__edit__});
- this.__frame__.insert({"bottom" : "|"});
+ this.__frame__.insert({"bottom" : "<span>|</span>"});
this.__frame__.insert({"bottom" : this.__create__});
+ for(var i = 1; content.topic && i < content.topic.length; ++i) this.__frame__.insert({"bottom" : "<br/><span> </span>"});
this.__instances__ = null;
this.__subtypes__ = null;
Modified: trunk/src/unit_tests/poems.xtm
==============================================================================
--- trunk/src/unit_tests/poems.xtm (original)
+++ trunk/src/unit_tests/poems.xtm Tue Jun 30 06:16:38 2009
@@ -619,6 +619,7 @@
<!-- author -->
<tm:topic id="author">
<tm:subjectIdentifier href="http://some.where/base-psis/author"/>
+ <tm:subjectIdentifier href="http://some.where/base-psis/author-psi"/>
<tm:instanceOf><tm:topicRef href="#topictype"/></tm:instanceOf>
</tm:topic>
1
0

[isidorus-cvs] r79 - in trunk: docs src/ajax src/ajax/css src/ajax/javascripts
by Lukas Giessmann 29 Jun '09
by Lukas Giessmann 29 Jun '09
29 Jun '09
Author: lgiessmann
Date: Mon Jun 29 14:39:18 2009
New Revision: 79
Log:
ajax-client: implemented a skeleton for a topic map overview, currently a css-style and some handlers are missing
Added:
trunk/src/ajax/css/tree.css (contents, props changed)
- copied, changed from r73, /trunk/src/ajax/css/main.css
Modified:
trunk/docs/xtm_json.txt
trunk/src/ajax/css/main.css
trunk/src/ajax/isidorus.html
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/home.js
trunk/src/ajax/javascripts/requests.js
Modified: trunk/docs/xtm_json.txt
==============================================================================
--- trunk/docs/xtm_json.txt (original)
+++ trunk/docs/xtm_json.txt Mon Jun 29 14:39:18 2009
@@ -171,6 +171,27 @@
//+-----------------------------------------------------------------------------
+//+ topic map overview - node
+//+ Contains a list of trees, that represents a topic map by representing
+//+ all valid topics and their super-subtypes and type-instance
+//+ relationships.
+//+-----------------------------------------------------------------------------
+{
+ "topic" : ["psi-1", "psi-2"],
+ "isType" : <boolean>,
+ "isInstance" : <boolean>,
+ "instances" : [ <node> ]
+}
+
+
+//+-----------------------------------------------------------------------------
+//+ topic map overview - treeview
+//+ Contains alist of nodes.
+//+-----------------------------------------------------------------------------
+[ <node>, <node>, <...> ]
+
+
+//+-----------------------------------------------------------------------------
//+ Part 3: TMCL - data model
//+ This part explains how the tmcl-rules/suggestions of isidorus are
//+ sent via HTTP as JSON-data.
Modified: trunk/src/ajax/css/main.css
==============================================================================
--- trunk/src/ajax/css/main.css (original)
+++ trunk/src/ajax/css/main.css Mon Jun 29 14:39:18 2009
@@ -23,7 +23,7 @@
border-right: 1px solid #d1d1d3;
border-bottom: 1px solid #d1d1d3;
margin-top: -21px;
- padding-bottom: 21px;
+ padding-bottom: 60px;
}
h1 {
Copied: trunk/src/ajax/css/tree.css (from r73, /trunk/src/ajax/css/main.css)
==============================================================================
--- /trunk/src/ajax/css/main.css (original)
+++ trunk/src/ajax/css/tree.css Mon Jun 29 14:39:18 2009
@@ -10,57 +10,35 @@
/*----------------------------------------------------------------------------*/
-body {
- width: 1024px;
- margin-left: auto;
- margin-right: auto;
-}
-
-#subPage {
- color: #333377;
- min-height: 800px;
- border-left: 1px solid #d1d1d3;
- border-right: 1px solid #d1d1d3;
- border-bottom: 1px solid #d1d1d3;
- margin-top: -21px;
- padding-bottom: 21px;
+ul.treeView {
+ padding-top: 10px;
+ padding-left: 20px;
+ list-style-type: none;
}
-h1 {
- clear: left;
- margin-left: 10px;
- padding-top: 20px;
-}
-
-.clickable {
- cursor: pointer;
+ul.treeView ul {
+ padding-left: 20px;
+ list-style-type: none;
}
-.clickable:hover{
- color: #ff7f00;
-}
-
-.deselect {
- cursor: pointer;
+ul.topicPsis {
+ float: left;
+ clear: left;
}
-.deselect:hover{
- color: #ff7f00;
+ul.topicPsis + span {
+ margin-left: 20px;
+ margin-right: 2px;
}
-.errorMessage {
- margin: 0.5em;
- color: red;
- font-size: 0.85em;
+ul.topicPsis + span + span{
+ margin-left: 2px;
}
-div.loadFrame {
- padding: 2em;
- color: #ff7f00;
- text-align: center;
+ul.topicPsis + span.disabled {
+ color: #eaeaee;
}
-img.ajaxLoader {
- display: none;
- margin-left: 412px; /* the image has a width of 100px --> 1024/2 - 100 = 412*/
+ul.topicPsis + span + span.disabled {
+ color: #eaeaee;
}
\ No newline at end of file
Modified: trunk/src/ajax/isidorus.html
==============================================================================
--- trunk/src/ajax/isidorus.html (original)
+++ trunk/src/ajax/isidorus.html Mon Jun 29 14:39:18 2009
@@ -20,6 +20,7 @@
<link rel="stylesheet" type="text/css" href="css/main.css"/>
<link rel="stylesheet" type="text/css" href="css/frame.css"/>
<link rel="stylesheet" type="text/css" href="css/navi.css"/>
+ <link rel="stylesheet" type="text/css" href="css/tree.css"/>
<!-- error handling for javascript code -->
<script language="JavaScript" type="text/javascript"> <!--
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Mon Jun 29 14:39:18 2009
@@ -11,7 +11,7 @@
// --- Some constants fot the http connections via the XMLHttpRequest-Object
-var HOST_PREF = "http://143.93.190.237:8000/"; //"http://localhost:8000/"; // of the form "http://(.+)/"
+var HOST_PREF = /*"http://143.93.190.237:8000/";*/ "http://localhost:8000/"; // of the form "http://(.+)/"
var GET_PREFIX = HOST_PREF + "json/get/";
var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/";
var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
@@ -83,5 +83,11 @@
"load" : function(){ return "loadFrame"; },
"ajaxLoader" : function(){ return "ajaxLoader"; },
"editFrame" : function(){ return "editFrame"; },
- "disabled" : function(){ return "disabled"; }
+ "disabled" : function(){ return "disabled"; },
+ "node" : function(){ return "treeNode"; },
+ "tree" : function(){ return "tree"; },
+ "treeView" : function(){ return "treeView"; },
+ "instances" : function(){ return "instances"; },
+ "subtypes" : function(){ return "subtypes"; },
+ "topicPsis" : function(){ return "topicPsis"; }
};
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/home.js
==============================================================================
--- trunk/src/ajax/javascripts/home.js (original)
+++ trunk/src/ajax/javascripts/home.js Mon Jun 29 14:39:18 2009
@@ -16,4 +16,128 @@
var header = new Element("h1").update("Topic Map Overview");
content.insert({"bottom" : header});
$(CLASSES.subPage()).insert({"bottom" : content});
+
+ function successFun(xhr){
+ var json = null;
+ try{
+ json = xhr.responseText.evalJSON();
+ }
+ catch(innrErr){}
+
+ try{
+ if(json === null) {
+ alert("The server's response does not contain any topics!");
+ }
+ else {
+ var treeView = new TreeViewC(json);
+ content.insert({"bottom" : treeView.getFrame()});
+ }
+ }
+ catch(err) {
+ alert("Could not create a Topic Map overview: " + err);
+ }
+ }
+
+ requestTreeView(successFun, null);
}
+
+
+var TreeViewC = Class.create({"initialize" : function(contents){
+ if(!contents) throw "From NodeC(): content must be set!";
+ try {
+ this.__frame__ = new Element("ul", {"class" : CLASSES.treeView()});
+ for(var i = 0; i !== contents.length; ++i){
+ var tLi = new Element("li").update(new TreeC(contents[i]).getFrame());
+ this.__frame__.insert({"bottom" : tLi});
+ }
+ }
+ catch(err){
+ throw "From TreeC(): The following exception was thrown:\n" + err;
+ }
+ },
+ "getFrame" : function(){
+ return this.__frame__;
+ }});
+
+
+var TreeC = Class.create({"initialize" : function(content){
+ if(!content) throw "From NodeC(): content must be set!";
+ try {
+ this.__frame__ = new Element("ul", {"class" : CLASSES.tree()});
+ this.__frame__.update(new NodeC(content).getFrame());
+ }
+ catch(err){
+ throw "From TreeC(): The following exception was thrown:\n" + err;
+ }
+ },
+ "getFrame" : function(){
+ return this.__frame__;
+ }});
+
+
+var NodeC = Class.create({"initialize" : function(content){
+ if(!content) throw "From NodeC(): content must be set!";
+ try {
+ this.__frame__ = new Element("li", {"class" : CLASSES.node()});
+ this.__topic__ = new Element("ul", {"class" : CLASSES.topicPsis()});
+ this.__frame__.update(this.__topic__);
+ for(var i = 0; content.topic && i !== content.topic.length; ++i){
+ var tLi = new Element("li").update(content.topic[i]);
+ this.__topic__.insert({"bottom" : tLi});
+ }
+
+ this.__edit__ = new Element("span", {"class" : CLASSES.clickable()}).update("edit");
+ this.__create__ = new Element("span", {"class" : CLASSES.clickable()}).update("create");
+ if(content.isType !== true){
+ this.__create__.writeAttribute({"class" : CLASSES.disabled()});
+ }
+ else {
+ this.__create__.observe("click", function(event){
+ alert("create");
+ });
+ // TODO: define a handler
+ }
+
+ if(content.isInstance !== true){
+ this.__edit__.writeAttribute({"class" : CLASSES.disabled()});
+ }
+ else {
+ this.__edit__.observe("click", function(event){
+ alert("edit");
+ });
+ // TODO: define a handler
+ }
+ this.__frame__.update(this.__topic__);
+ this.__frame__.insert({"bottom" : this.__edit__});
+ this.__frame__.insert({"bottom" : "|"});
+ this.__frame__.insert({"bottom" : this.__create__});
+
+ this.__instances__ = null;
+ this.__subtypes__ = null;
+
+ if(content.instances && content.instances.length !== 0) {
+ this.__instances__ = new Element("ul", {"class" : CLASSES.instances()});
+ for(var i = 0; i !== content.instances.length; ++i){
+ var entry = new NodeC(content.instances[i]);
+ this.__instances__.insert({"bottom" : entry.getFrame()});
+ }
+ }
+
+ if(content.subtypes && content.subtypes.length !== 0) {
+ this.__subtypes__ = new Element("ul", {"class" : CLASSES.subtypes()});
+ for(var i = 0; i !== content.subtypes.length; ++i){
+ var entry = new NodeC(content.subtypes[i]);
+ this.__subtypes__.insert({"bottom" : entry.getFrame()});
+ }
+ }
+
+ if(this.__instances__) this.__frame__.insert({"bottom" : this.__instances__});
+ if(this.__subtypes__) this.__frame__.insert({"bottom" : this.__subtypes__});
+ }
+ catch(err){
+ throw "From NodeC(): The following exception was thrown:\n" + err;
+ }
+ },
+ "getFrame" : function(){
+ return this.__frame__;
+ }});
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Mon Jun 29 14:39:18 2009
@@ -233,4 +233,27 @@
catch(err){
alert("From requestFragment(): " + err);
}
+}
+
+
+// --- Request a topic map overview object from the server and calls
+// --- onSuccessHandler or OnFailureHandler.
+function requestTreeView(onSuccessHandler, onFailureHandler)
+{
+ if(!onSuccessHandler) throw "From requestTreeView(): onSuccessHandler must be set!";
+
+ try{
+ var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
+ var timeFun = setAjaxTimeout(6 * TIMEOUT, COMMIT_URL);
+ onLoad("Requesting a topic map overview from " + TM_OVERVIEW);
+
+ new Ajax.Request(TM_OVERVIEW, {
+ "method" : "get",
+ "requestHeaders" : INIT_DATE,
+ "onSuccess" : createXHRHandler(onSuccessHandler, timeFun),
+ "onFailure" : createXHRHandler(onFailure, timeFun)});
+ }
+ catch(err){
+ alert("From requestFragment(): " + err);
+ }
}
\ No newline at end of file
1
0

[isidorus-cvs] r78 - in trunk/src: ajax/javascripts json rest_interface unit_tests
by Lukas Giessmann 29 Jun '09
by Lukas Giessmann 29 Jun '09
29 Jun '09
Author: lgiessmann
Date: Mon Jun 29 10:24:53 2009
New Revision: 78
Log:
json-server: fixed a bug with topic-, association, role-, name- and occurrence-types; added the RESTful-handler "json/tmcl/overview/?" that returns a json-object representing the topics as a (or more) tree-view(s)
Modified:
trunk/src/ajax/javascripts/constants.js
trunk/src/json/json_tmcl.lisp
trunk/src/json/json_tmcl_validation.lisp
trunk/src/rest_interface/rest-interface.lisp
trunk/src/rest_interface/set-up-json-interface.lisp
trunk/src/unit_tests/poems.xtm
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Mon Jun 29 10:24:53 2009
@@ -22,6 +22,7 @@
var INSTANCE_PSIS_URL = HOST_PREF + "json/tmcl/instances/";
var OWN_URL = HOST_PREF + "isidorus";
var SUMMARY_URL = HOST_PREF + "json/summary"
+var TM_OVERVIEW = "/json/tmcl/overview/";
var TIMEOUT = 10000; // const TIMEOUT = 10000 --> "const" doesn't work under IE
Modified: trunk/src/json/json_tmcl.lisp
==============================================================================
--- trunk/src/json/json_tmcl.lisp (original)
+++ trunk/src/json/json_tmcl.lisp Mon Jun 29 10:24:53 2009
@@ -18,7 +18,7 @@
topic-psis must contain one item if it is treated as instance other wiese there can be more psis
then the fragment will be treated as an instanceOf all passed psis."
(let ((associationtype (get-item-by-psi *associationtype-psi*))
- (associationtype-constraint (get-item-by-psi *associationtype-constraint-psi*))
+ (associationtype-constraint (is-type-constrained :what *associationtype-constraint-psi*))
(topics nil))
(when (and (not (eql treat-as 'type))
(> (length topic-psis) 1))
@@ -102,9 +102,9 @@
(othertopictype-role (get-item-by-psi *othertopictype-role-psi*))
(otherroletype-role (get-item-by-psi *otherroletype-role-psi*))
(roletype (get-item-by-psi *roletype-psi*))
- (roletype-constraint (get-item-by-psi *roletype-constraint-psi*))
+ (roletype-constraint (is-type-constrained :what *roletype-constraint-psi*))
(topictype (get-item-by-psi *topictype-psi*))
- (topictype-constraint (get-item-by-psi *topictype-constraint-psi*)))
+ (topictype-constraint (is-type-constrained)))
(let ((otherrole-constraints
(loop for constraint-topic in constraint-topics
append (let ((players nil)
@@ -233,9 +233,9 @@
(topictype-role (get-item-by-psI *topictype-role-psi*))
(roletype-role (get-item-by-psi *roletype-role-psi*))
(roletype (get-item-by-psi *roletype-psi*))
- (roletype-constraint (get-item-by-psi *roletype-constraint-psi*))
+ (roletype-constraint (is-type-constrained :what *roletype-constraint-psi*))
(topictype (get-item-by-psi *topictype-psi*))
- (topictype-constraint (get-item-by-psi *topictype-constraint-psi*)))
+ (topictype-constraint (is-type-constrained)))
(let ((roleplayer-constraints
(loop for constraint-topic in constraint-topics
append (let ((constraint-list
@@ -327,7 +327,7 @@
(roletype-role (get-item-by-psi *roletype-role-psi*))
(constraint-role (get-item-by-psi *constraint-role-psi*))
(roletype (get-item-by-psi *roletype-psi*))
- (roletype-constraint (get-item-by-psi *roletype-constraint-psi*)))
+ (roletype-constraint (is-type-constrained :what *roletype-constraint-psi*)))
(let ((associationrole-constraints
(loop for constraint-topic in constraint-topics
append (let ((constraint-list
@@ -465,7 +465,7 @@
(applies-to (get-item-by-psi *applies-to-psi*))
(topictype-role (get-item-by-psi *topictype-role-psi*))
(topictype (get-item-by-psi *topictype-psi*))
- (topictype-constraint (get-item-by-psi *topictype-constraint-psi*)))
+ (topictype-constraint (is-type-constrained)))
(let ((topics
(remove-duplicates
(loop for exclusive-instances-list in exclusive-instances-lists
@@ -536,7 +536,7 @@
(applies-to (get-item-by-psi *applies-to-psi*))
(nametype-role (get-item-by-psi *nametype-role-psi*))
(nametype (get-item-by-psi *nametype-psi*))
- (nametype-constraint (get-item-by-psi *nametype-constraint-psi*)))
+ (nametype-constraint (is-type-constrained :what *nametype-constraint-psi*)))
(let ((topicname-constraints
(remove-if #'null
(loop for constraint-topic in constraint-topics
@@ -603,7 +603,7 @@
(applies-to (get-item-by-psi *applies-to-psi*))
(occurrencetype-role (get-item-by-psi *occurrencetype-role-psi*))
(occurrencetype (get-item-by-psi *occurrencetype-psi*))
- (occurrencetype-constraint (get-item-by-psi *occurrencetype-constraint-psi*)))
+ (occurrencetype-constraint (is-type-constrained :what *occurrencetype-constraint-psi*)))
(let ((topicoccurrence-constraints
(remove-if #'null
(loop for constraint-topic in constraint-topics
@@ -1069,7 +1069,7 @@
"Returns all constraint topics defined for associations if
the passed associationtype-topic."
(let ((akos-and-isas-of-this
- (topictype-p associationtype-topic (get-item-by-psi *associationtype-psi*) (get-item-by-psi *associationtype-constraint-psi*))))
+ (topictype-p associationtype-topic (get-item-by-psi *associationtype-psi*) (is-type-constrained :what *associationtype-constraint-psi*))))
(let ((all-associationrole-constraints nil)
(all-roleplayer-constraints nil)
(all-otherrole-constraints nil))
@@ -1133,3 +1133,159 @@
(map 'list #'(lambda(topic)
(map 'list #'uri (psis topic)))
topics)))
+
+
+(defun tree-view-to-json-string (tree-views)
+ "Returns a full tree-view as json-string."
+ (let ((json-string
+ (concatenate 'string "["
+ (if tree-views
+ (let ((inner-string ""))
+ (loop for tree-view in tree-views
+ do (setf inner-string (concatenate 'string inner-string (node-to-json-string tree-view) ",")))
+ (concatenate 'string (subseq inner-string 0 (- (length inner-string) 1)) "]"))
+ "null"))))
+ json-string))
+
+(defun make-tree-view ()
+ "Returns a list of the form:
+ ((<topictype> (direct-instances) (direc-subtypes)) (<...>));
+ -> direct-instances: (<any-topic> (direct-instances) (direct-subtypes))
+ -> direct-subtypes: (<any-topic> (direct-instances) (direct-subtypes))"
+ (let ((topictype (d:get-item-by-psi json-tmcl-constants::*topictype-psi*))
+ (topictype-constraint (is-type-constrained)))
+ (if topictype-constraint
+ (progn
+ (unless topictype
+ (error "From make-tree-view(): The topictype-constraint \"~a\" exists but the topictype \"~a\" is missing!"
+ json-tmcl-constants::*topictype-constraint-psi*
+ json-tmcl-constants::*topictype-psi*))
+ (list (make-nodes topictype t t)))
+ (let ((tree-roots
+ (get-all-tree-roots)))
+ (let ((tree-list
+ (loop for root in tree-roots
+ collect (let ((l-is-type
+ (handler-case (progn
+ (topictype-p root topictype topictype-constraint)
+ t)
+ (Condition () nil)))
+ (l-is-instance
+ (handler-case (progn
+ (valid-instance-p root)
+ t)
+ (Condition () nil))))
+ (make-nodes root l-is-type l-is-instance)))))
+ tree-list)))))
+
+
+(defun node-to-json-string(node)
+ "Returns a json-object of the form
+ {topic: [<psis>], isType: <bool>, isInstance: <bool>,
+ instances: [<nodes>], subtypes: [<nodes>]}."
+ (let ((topic-psis
+ (concatenate 'string "\"topic\":"
+ (json:encode-json-to-string (map 'list #'d:uri (d:psis (getf node :topic))))))
+ (is-type
+ (concatenate 'string "\"isType\":"
+ (if (getf node :is-type)
+ "true"
+ "false")))
+ (is-instance
+ (concatenate 'string "\"isInstance\":"
+ (if (getf node :is-instance)
+ "true"
+ "false")))
+ (instances
+ (concatenate 'string "\"instances\":"
+ (if (getf node :instances)
+ (let ((inner-string "["))
+ (loop for instance-node in (getf node :instances)
+ do (setf inner-string (concatenate 'string inner-string (node-to-json-string instance-node) ",")))
+ (concatenate 'string (subseq inner-string 0 (- (length inner-string) 1)) "]"))
+ "null")))
+ (subtypes
+ (concatenate 'string "\"subtypes\":"
+ (if (getf node :subtypes)
+ (let ((inner-string "["))
+ (loop for instance-node in (getf node :subtypes)
+ do (setf inner-string (concatenate 'string inner-string (node-to-json-string instance-node) ",")))
+ (concatenate 'string (subseq inner-string 0 (- (length inner-string) 1)) "]"))
+ "null"))))
+ (concatenate 'string "{" topic-psis "," is-type "," is-instance "," instances "," subtypes"}")))
+
+
+(defun make-nodes (topic-instance is-type is-instance)
+ "Creates a li of nodes.
+ A node looks like
+ (:topic <topic> :is-type <bool> :is-instance <bool> :instances <node> :subtypes <nodes>)."
+ (declare (d:TopicC topic-instance))
+ (let ((topictype (d:get-item-by-psi json-tmcl-constants::*topictype-psi*))
+ (topictype-constraint (is-type-constrained)))
+ (let ((isas-of-this
+ (map 'list #'(lambda(z)
+ (let ((l-is-type
+ (handler-case (progn
+ (topictype-p z topictype topictype-constraint)
+ t)
+ (Condition () nil)))
+ (l-is-instance
+ (handler-case (progn
+ (valid-instance-p z)
+ t)
+ (Condition () nil))))
+ (list :topic z :is-type l-is-type :is-instance l-is-instance)))
+ (remove-duplicates
+ (remove-if #'null
+ (remove-if #'(lambda(x) (when (eql topic-instance x)
+ t))
+ (get-direct-instances-of-topic topic-instance))))))
+ (akos-of-this
+ (map 'list #'(lambda(z)
+ (let ((l-is-type
+ (handler-case (progn
+ (topictype-p z topictype topictype-constraint)
+ t)
+ (Condition () nil)))
+ (l-is-instance
+ (handler-case (progn
+ (valid-instance-p z)
+ t)
+ (Condition () nil))))
+ (list :topic z :is-type l-is-type :is-instance l-is-instance)))
+ (remove-duplicates
+ (remove-if #'null
+ (remove-if #'(lambda(x) (when (eql topic-instance x)
+ t))
+ (get-direct-subtypes-of-topic topic-instance)))))))
+ (list :topic topic-instance
+ :is-type is-type
+ :is-instance is-instance
+ :instances (map 'list #'(lambda(x)
+ (make-nodes (getf x :topic) (getf x :is-type) (getf x :is-instance)))
+ isas-of-this)
+ :subtypes (map 'list #'(lambda(x)
+ (make-nodes (getf x :topic) (getf x :is-type) (getf x :is-instance)))
+ akos-of-this)))))
+
+
+(defun get-all-tree-roots ()
+ "Returns all topics that are no instanceOf and no subtype
+ of any other topic."
+ (let ((all-topics
+ (elephant:get-instances-by-class 'd:TopicC)))
+ (remove-if #'null
+ (map 'list #'(lambda(x)
+ (let ((isas-of-x
+ (remove-if #'(lambda(y)
+ (when (eql y x)
+ t))
+ (get-direct-types-of-topic x)))
+ (akos-of-x
+ (remove-if #'(lambda(y)
+ (when (eql y x)
+ t))
+ (get-direct-supertypes-of-topic x))))
+ (unless (or isas-of-x akos-of-x)
+ x)))
+ all-topics))))
\ No newline at end of file
Modified: trunk/src/json/json_tmcl_validation.lisp
==============================================================================
--- trunk/src/json/json_tmcl_validation.lisp (original)
+++ trunk/src/json/json_tmcl_validation.lisp Mon Jun 29 10:24:53 2009
@@ -36,7 +36,7 @@
(defun topictype-of-p (topic-instance type-instance &optional (topictype (get-item-by-psi *topictype-psi*))
- (topictype-constraint (get-item-by-psi *topictype-constraint-psi*))
+ (topictype-constraint (is-type-constrained))
checked-topics)
"Returns a list of all types and supertypes of this topic if this topic is a
valid instance-topic of the type-topic called type-instance. TMCL 4.4.2.
@@ -75,7 +75,7 @@
(defun topictype-p (topic-instance &optional (topictype (get-item-by-psi *topictype-psi*))
- (topictype-constraint (get-item-by-psi *topictype-constraint-psi*))
+ (topictype-constraint (is-type-constrained))
(checked-topics nil))
"Returns a list of all instanceOf-topics and all Supertypes of this topic
if this topic is a valid topic (-type). I.e. the passed topic is the
@@ -188,6 +188,26 @@
(remove-if #'null topic-types)))))
+(defun get-direct-instances-of-topic(topic-instance)
+ "Returns the direct instances of the topic as a list.
+ This function only returns the types of the type-instance-relationship -> TMDM 7.2
+ This function was defined for the use in topictype-p and not for a standalone
+ usage."
+ (let ((type-instance (get-item-by-psi *type-instance-psi*))
+ (instance (get-item-by-psi *instance-psi*))
+ (type (get-item-by-psi *type-psi*)))
+ (let ((topic-instances
+ (loop for role in (player-in-roles topic-instance)
+ when (eq type (instance-of role))
+ collect (loop for other-role in (roles (parent role))
+ when (and (not (eq role other-role))
+ (eq type-instance (instance-of (parent role)))
+ (eq instance (instance-of other-role)))
+ return (player other-role)))))
+ (when topic-instances
+ (remove-if #'null topic-instances)))))
+
+
(defun get-direct-supertypes-of-topic(topic-instance)
"Returns the direct supertypes of the topic as a list passed to this function.
This function only returns the types of the supertype-subtype-relationship -> TMDM 7.3.
@@ -204,11 +224,32 @@
(eq supertype-subtype (instance-of (parent role)))
(eq supertype (instance-of other-role)))
collect (player other-role)))))
- (remove-if #'null supertypes))))
+ (when supertypes
+ (remove-if #'null supertypes)))))
+
+
+(defun get-direct-subtypes-of-topic(topic-instance)
+ "Returns the direct subtypes of the topic as a list.
+ This function only returns the types of the supertype-subtype-relationship -> TMDM 7.3.
+ This function was defined for the use in topictype-p and not for a standalone
+ usage."
+ (let ((supertype-subtype (get-item-by-psi *supertype-subtype-psi*))
+ (supertype (get-item-by-psi *supertype-psi*))
+ (subtype (get-item-by-psi *subtype-psi*)))
+ (let ((subtypes
+ (loop for role in (player-in-roles topic-instance)
+ when (eq supertype (instance-of role))
+ append (loop for other-role in (roles (parent role))
+ when (and (not (eq role other-role))
+ (eq supertype-subtype (instance-of (parent role)))
+ (eq subtype (instance-of other-role)))
+ collect (player other-role)))))
+ (when subtypes
+ (remove-if #'null subtypes)))))
(defun list-subtypes (topic-instance &optional (topictype (get-item-by-psi *topictype-psi*))
- (topictype-constraint (get-item-by-psi *topictype-constraint-psi*))
+ (topictype-constraint (is-type-constrained))
(checked-topics nil) (valid-subtypes nil))
"Returns all valid subtypes of a topic, e.g.:
nametype-constraint ako constraint .
@@ -241,7 +282,7 @@
(defun list-instances (topic-instance &optional (topictype (get-item-by-psi *topictype-psi*))
- (topictype-constraint (get-item-by-psi *topictype-constraint-psi*)))
+ (topictype-constraint (is-type-constrained)))
"Returns the topic-instance, all subtypes found by the function list-subtypes and all direct
instances for the found subtypes."
(let ((all-subtypes-of-this
@@ -282,7 +323,7 @@
(get-direct-supertypes-of-topic topic-instance))
(psi-of-this (uri (first (psis topic-instance))))
(topictype (d:get-item-by-psi json-tmcl-constants::*topictype-psi*))
- (topictype-constraint (d:get-item-by-psi json-tmcl-constants::*topictype-constraint-psi*))
+ (topictype-constraint (is-type-constrained))
(local-all-checked-topics all-checked-topics)
(local-akos-checked))
@@ -292,7 +333,7 @@
(when (and topictype-constraint
(not topictype))
(error (format nil "From valid-instance-p(): The topic \"~a\" does not exist - please create it or remove the topic \"~a\""
- json-tmcl-constants::*topictype-psi* json-tmcl-constants::*topictype-constraint-psi*)))
+ json-tmcl-constants::*topictype-psi* (d:uri (first (d:psis topictype-constraint))))))
(when (eql topic-instance topictype)
(return-from valid-instance-p (remove-duplicates (append all-checked-topics (list topic-instance)))))
@@ -336,7 +377,7 @@
(let ((all-topics
(elephant:get-instances-by-class 'd:TopicC))
(topictype (get-item-by-psi json-tmcl-constants::*topictype-psi*))
- (topictype-constraint (get-item-by-psi json-tmcl-constants::*topictype-constraint-psi*)))
+ (topictype-constraint (is-type-constrained)))
(let ((all-types
(remove-if #'null
(map 'list #'(lambda(x)
@@ -366,4 +407,17 @@
(valid-instance-p x)
x)
(condition () nil))) all-topics))))
- valid-instances)))
\ No newline at end of file
+ valid-instances)))
+
+
+(defun is-type-constrained (&key (what json-tmcl::*topictype-constraint-psi*))
+ "Returns nil if there is no type-constraint otherwise the instance of the type-constraint."
+ (let ((topictype-constraint (d:get-item-by-psi what)))
+ (when topictype-constraint
+ (let ((ttc
+ (remove-duplicates
+ (remove-if #'null
+ (remove-if #'(lambda(x) (when (eql topictype-constraint x)
+ t))
+ (get-direct-instances-of-topic topictype-constraint))))))
+ ttc))))
\ No newline at end of file
Modified: trunk/src/rest_interface/rest-interface.lisp
==============================================================================
--- trunk/src/rest_interface/rest-interface.lisp (original)
+++ trunk/src/rest_interface/rest-interface.lisp Mon Jun 29 10:24:53 2009
@@ -34,6 +34,7 @@
:*json-get-topic-stub-prefix*
:*json-get-type-tmcl-prefix*
:*json-get-instance-tmcl-prefix*
+ :*json-get-overview*
:*ajax-user-interface-url*
:*ajax-user-interface-file-path*
:*ajax-javascript-directory-path*
Modified: trunk/src/rest_interface/set-up-json-interface.lisp
==============================================================================
--- trunk/src/rest_interface/set-up-json-interface.lisp (original)
+++ trunk/src/rest_interface/set-up-json-interface.lisp Mon Jun 29 10:24:53 2009
@@ -18,6 +18,7 @@
(defparameter *json-get-topic-stub-prefix* "/json/topicstubs/(.+)$") ;the json prefix for getting some topic stub information of a topic
(defparameter *json-get-type-tmcl-url* "/json/tmcl/type/?$") ;the json url for getting some tmcl information of a topic treated as a type
(defparameter *json-get-instance-tmcl-url* "/json/tmcl/instance/?$") ;the json url for getting some tmcl information of a topic treated as an instance
+(defparameter *json-get-overview* "/json/tmcl/overview/?$") ; returns a json-object representing a tree view
(defparameter *ajax-user-interface-url* "/isidorus/?$") ;the url to the user interface; if you want to get all topics set start=0&end=nil -> localhost:8000/isidorus
(defparameter *ajax-user-interface-css-prefix* "/css") ;the url to the css files of the user interface
(defparameter *ajax-user-interface-css-directory-path* "ajax/css") ;the directory contains the css files
@@ -34,6 +35,7 @@
(json-get-topic-stub-prefix *json-get-topic-stub-prefix*)
(json-get-type-tmcl-url *json-get-type-tmcl-url*)
(json-get-instance-tmcl-url *json-get-instance-tmcl-url*)
+ (json-get-overview *json-get-overview*)
(ajax-user-interface-url *ajax-user-interface-url*)
(ajax-user-interface-file-path *ajax-user-interface-file-path*)
(ajax-user-interface-css-prefix *ajax-user-interface-css-prefix*)
@@ -99,6 +101,9 @@
(return-tmcl-info-of-psis 'json-tmcl::instance)))
hunchentoot:*dispatch-table*)
(push
+ (create-regex-dispatcher json-get-overview #'return-overview)
+ hunchentoot:*dispatch-table*)
+ (push
(create-regex-dispatcher json-commit-url #'json-commit)
hunchentoot:*dispatch-table*)
(push
@@ -283,6 +288,19 @@
(format nil "Condition: \"~a\"" err))))))
+(defun return-overview (&optional param)
+ "Returns a json-object representing a topic map overview as a tree(s)"
+ (declare (ignorable param))
+ (handler-case (let ((json-string
+ (json-tmcl::tree-view-to-json-string (json-tmcl::make-tree-view))))
+ (setf (hunchentoot:content-type*) "application/json") ;RFC 4627
+ json-string)
+ (Condition (err) (progn
+ (setf (hunchentoot:return-code*) hunchentoot:+http-internal-server-error+)
+ (setf (hunchentoot:content-type*) "text")
+ (format nil "Condition: \"~a\"" err)))))
+
+
;; =============================================================================
;; --- some helper functions ---------------------------------------------------
;; =============================================================================
Modified: trunk/src/unit_tests/poems.xtm
==============================================================================
--- trunk/src/unit_tests/poems.xtm (original)
+++ trunk/src/unit_tests/poems.xtm Mon Jun 29 10:24:53 2009
@@ -148,7 +148,7 @@
<!-- the constraint roletype -->
<tm:topic id="constraint-role">
<tm:subjectIdentifier href="http://psi.topicmaps.org/tmcl/constraint-role"/>
- <tm:instanceOf><tm:topicref href="#roletype"/></tm:instanceOf>
+ <tm:instanceOf><tm:topicRef href="#roletype"/></tm:instanceOf>
</tm:topic>
<!-- ===================================================================== -->
@@ -225,7 +225,7 @@
<!-- constraints can be bound to a schema -->
<tm:topic id="schema">
<tm:subjectIdentifier href="http://psi.topicmaps.org/tmcl/schema"/>
- <tm:instanceOf><tm:topicref href="#topictype"/></tm:instanceOf>
+ <tm:instanceOf><tm:topicRef href="#topictype"/></tm:instanceOf>
</tm:topic>
1
0
Author: lgiessmann
Date: Mon Jun 29 05:11:38 2009
New Revision: 77
Log:
json-server: fixed a bug with tmcl-type-validation when there is no topictype or no topictype-constraint or if they isn't either a topictype nor a topictype-constraint
Modified:
trunk/src/json/json_tmcl.lisp
trunk/src/json/json_tmcl_validation.lisp
trunk/src/rest_interface/set-up-json-interface.lisp
Modified: trunk/src/json/json_tmcl.lisp
==============================================================================
--- trunk/src/json/json_tmcl.lisp (original)
+++ trunk/src/json/json_tmcl.lisp Mon Jun 29 05:11:38 2009
@@ -35,7 +35,7 @@
(let ((value
(get-constraints-of-topic topics :treat-as treat-as)))
(concatenate 'string "\"topicConstraints\":" value))))
- (let ((available-associations ;what's with association which have only a associationrole-constraints?
+ (let ((available-associations
(remove-duplicates
(loop for topic in topics
append (get-available-associations-of-topic topic :treat-as treat-as)))))
Modified: trunk/src/json/json_tmcl_validation.lisp
==============================================================================
--- trunk/src/json/json_tmcl_validation.lisp (original)
+++ trunk/src/json/json_tmcl_validation.lisp Mon Jun 29 05:11:38 2009
@@ -287,7 +287,7 @@
(local-akos-checked))
(when (not topictype-constraint)
- (return-from valid-instance-p topic-instance))
+ (return-from valid-instance-p (list topic-instance)))
(when (and topictype-constraint
(not topictype))
Modified: trunk/src/rest_interface/set-up-json-interface.lisp
==============================================================================
--- trunk/src/rest_interface/set-up-json-interface.lisp (original)
+++ trunk/src/rest_interface/set-up-json-interface.lisp Mon Jun 29 05:11:38 2009
@@ -169,8 +169,8 @@
(let ((external-format (flexi-streams:make-external-format :UTF-8 :eol-style :LF)))
(let ((json-data (hunchentoot:raw-post-data :external-format external-format :force-text t)))
(handler-case (let ((psis
- (json:decode-json-from-string json-data)))
- (let ((tmcl
+ (json:decode-json-from-string json-data)))
+ (let ((tmcl
(json-tmcl:get-constraints-of-fragment psis :treat-as treat-as)))
(if tmcl
(progn
1
0
Author: lgiessmann
Date: Mon Jun 29 04:33:22 2009
New Revision: 76
Log:
ajax-client: fixed a bug that accurrs when there are no valid topic instances or topic types
Modified:
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/edit.js
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Mon Jun 29 04:33:22 2009
@@ -38,10 +38,6 @@
var MMAX_INT = "*";
-// --- some css-styles
-var DISABLED_BACKGROUND_COLOR = {"backgroundColor" : "#eaeaee"};
-
-
// --- Contains most css classes used in this project
// --- There should be called only the function to be sure to don't override
// --- the original values.
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Mon Jun 29 04:33:22 2009
@@ -38,8 +38,14 @@
}
var instanceOf = null;
try{
- instanceOf = new InstanceOfC(json.flatten().sort(), innerMakeFragment);
- liTopicSelect.insert({"bottom" : instanceOf.getFrame()});
+ if(json === null){
+ var err = new Element("div", {"class" : CLASSES.error()}).update("There exist no valid topic types!<br/>Please update the TMCL-model.");
+ liTopicSelect.insert({"bottom" : err});
+ }
+ else {
+ instanceOf = new InstanceOfC(json.flatten().sort(), innerMakeFragment);
+ liTopicSelect.insert({"bottom" : instanceOf.getFrame()});
+ }
}
catch(innerErr){
alert("There occurred an error by creating an InstanceOfC frame, please reload this page!\n\n" + innerErr);
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Mon Jun 29 04:33:22 2009
@@ -4239,88 +4239,4 @@
var tr = newRow(CLASSES.typeFrame(), "Type", new SelectrowC(types, myself.__type__, 1, 1).getFrame());
myself.__table__.insert({"bottom" : tr});
return types;
-}
-
-// --- some helper to enable/disable some table rows
-
-function disableItemIdentity(myself)
-{
- myself.__itemIdentity__.disable();
- myself.__table__.select("tr." + CLASSES.itemIdentityFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
-}
-function enableItemIdentity(myself)
-{
- myself.__itemIdentity__.enable();
- myself.__table__.select("tr." + CLASSES.itemIdentityFrame())[0].removeAttribute("style");
-}
-function disableType(myself)
-{
- myself.__type__.__frames__[0].disable();
- myself.__table__.select("tr." + CLASSES.typeFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
-}
-function enableType(myself)
-{
- myself.__type__.__frames__[0].enable();
- myself.__table__.select("tr." + CLASSES.typeFrame())[0].removeAttribute("style");
-}
-function disableScope(myself){
- myself.__scope__.disable();
- myself.__table__.select("tr." + CLASSES.scopeContainer())[0].setStyle(DISABLED_BACKGROUND_COLOR);
-}
-function enableScope(myself)
-{
- myself.__scope__.enable();
- myself.__table__.select("tr." + CLASSES.scopeContainer())[0].removeAttribute("style");
-}
-function disableValue(myself)
-{
- try{ myself.__value__.__frames__[0].disable(); } catch(err){}
- try{ myself.__value__.writeAttribute({"readonly" : "readonly"}); } catch(err){}
- myself.__table__.select("tr." + CLASSES.valueFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
-}
-function enableValue(myself)
-{
- try{ myself.__value__.__frames__[0].enable(); } catch(err){}
- try{ myself.__value__.removeAttribute("readonly"); } catch(err){}
- myself.__table__.select("tr." + CLASSES.valueFrame())[0].removeAttribute("style");
-}
-function disableDatatype(myself)
-{
- myself.__datatype__.__frames__[0].disable();
- myself.__table__.select("tr." + CLASSES.datatypeFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
-}
-function enableDatatype(myself)
-{
- if(myself.__datatypeIsSet__ === false) myself.__datatype__.__frames__[0].enable();
- myself.__table__.select("tr." + CLASSES.datatypeFrame())[0].removeAttribute("style");
-}
-function disableVariants(myself)
-{
- myself.__variants__.disable();
- myself.__table__.select("tr." + CLASSES.variantContainer())[0].setStyle(DISABLED_BACKGROUND_COLOR);
-}
-function enableVariants(myself)
-{
- myself.__variants__.enable();
- myself.__table__.select("tr." + CLASSES.variantContainer())[0].removeAttribute("style");
-}
-function disableRole(myself)
-{
- myself.__roles__.disable();
- myself.__table__.select("tr." + CLASSES.roleContainer())[0].setStyle(DISABLED_BACKGROUND_COLOR);
-}
-function enableRole(myself)
-{
- myself.__roles__.enable();
- myself.__table__.select("tr." + CLASSES.roleContainer())[0].removeAttribute("style");
-}
-function disablePlayer(myself)
-{
- myself.__player__.__frames__[0].disable();
- myself.__table__.select("tr." + CLASSES.playerFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
-}
-function enablePlayer(myself)
-{
- myself.__player__.__frames__[0].enable();
- myself.__table__.select("tr." + CLASSES.playerFrame())[0].removeAttribute("style");
}
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/edit.js
==============================================================================
--- trunk/src/ajax/javascripts/edit.js (original)
+++ trunk/src/ajax/javascripts/edit.js Mon Jun 29 04:33:22 2009
@@ -48,8 +48,14 @@
var edit = null;
try{
- edit = new EditC(json.flatten().sort(), innerMakeFragment);
- liTopicSelect.insert({"bottom" : edit.getFrame()});
+ if(json === null){
+ var err = new Element("div", {"class" : CLASSES.error()}).update("There exist no valid topic instances!<br/>Please update the TMCL-model or create some new instances.");
+ liTopicSelect.insert({"bottom" : err});
+ }
+ else {
+ edit = new EditC(json.flatten().sort(), innerMakeFragment);
+ liTopicSelect.insert({"bottom" : edit.getFrame()});
+ }
}
catch(err){
alert("There occurred an error by creating an EditC frame, please reload this page!\n\n" + err);
1
0

[isidorus-cvs] r75 - in trunk/src: ajax/css ajax/javascripts unit_tests
by Lukas Giessmann 29 Jun '09
by Lukas Giessmann 29 Jun '09
29 Jun '09
Author: lgiessmann
Date: Mon Jun 29 04:19:47 2009
New Revision: 75
Log:
ajax-client: fixed the "disable/enable" safari-bug
Modified:
trunk/src/ajax/css/frame.css
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/unit_tests/poems.xtm
Modified: trunk/src/ajax/css/frame.css
==============================================================================
--- trunk/src/ajax/css/frame.css (original)
+++ trunk/src/ajax/css/frame.css Mon Jun 29 04:19:47 2009
@@ -8,7 +8,6 @@
/* You can find a detailed description in trunk/docs/LGPL-LICENSE.txt and */
/* in trunk/src/ajax/javascripts/external/MIT-LICENSE.txt. */
/*----------------------------------------------------------------------------*/
-
ul.fragmentFrame {
list-style-type: none;
padding-left: 0px;
@@ -203,12 +202,38 @@
border: 1px solid #ff7f00;
}
+/* === disabled name frame === */
+div.disabled table.nameFrame > tr.itemIdentityFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.nameFrame > tr.typeFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.nameFrame > tr.scopeContainer {
+ background-color: #eaeaee;
+}
+
+div.disabled table.nameFrame > tr.valueFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.nameFrame > tr.variantContainer {
+ background-color: #eaeaee;
+}
+
+
/* === variant frame ======================================================== */
table.nameFrame div.variantFrame {
margin-left: 24px;
}
+table.nameFrame div.disabled {
+ margin-left: 24px;
+}
+
table.nameFrame table.variantFrame {
width: 667px;
margin-top: 2px;
@@ -237,6 +262,23 @@
border: 1px solid #ff7f00;
}
+/* === disabled variant frame === */
+div.disabled table.variantFrame > tr.itemIdentityFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.variantFrame > tr.scopeContainer {
+ background-color: #eaeaee;
+}
+
+div.disabled table.variantFrame > tr.valueFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.variantFrame > tr.datatypeFrame {
+ background-color: #eaeaee;
+}
+
/* === occurrence frame ===================================================== */
table.topicFrame table.occurrenceFrame {
@@ -268,6 +310,31 @@
border: 1px solid #ff7f00;
}
+/* === disabled occurrence frame === */
+div.disabled {
+ background-color: #eaeaee;
+}
+
+div.disabled table.occurrenceFrame > tr.itemIdentityFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.occurrenceFrame > tr.typeFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.occurrenceFrame > tr.scopeContainer {
+ background-color: #eaeaee;
+}
+
+div.disabled table.occurrenceFrame > tr.valueFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.occurrenceFrame > tr.datatypeFrame {
+ background-color: #eaeaee;
+}
+
/* === association container / association frame ============================ */
div.associationContainer {
@@ -313,7 +380,22 @@
background-color: #f6f7f9;
}
+/* === disabled association frame === */
+div.disabled table.associationFrame > tr.itemIdentityFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.associationFrame > tr.typeFrame {
+ background-color: #eaeaee;
+}
+div.disabled table.associationFrame > tr.scopeContainer {
+ background-color: #eaeaee;
+}
+
+div.disabled table.associationFrame > tr.roleContainer {
+ background-color: #eaeaee;
+}
/* === associationrole frame ================================================ */
@@ -342,6 +424,18 @@
background-color: #f6f7f9;
}
+/* === disabled role frame === */
+div.disabled table.roleFrame > tr.itemIdentityFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.roleFrame > tr.typeFrame {
+ background-color: #eaeaee;
+}
+
+div.disabled table.roleFrame > tr.playerFrame {
+ background-color: #eaeaee;
+}
/* === tmId frame ========================================================== */
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Mon Jun 29 04:19:47 2009
@@ -11,8 +11,7 @@
// --- Some constants fot the http connections via the XMLHttpRequest-Object
-var TIMEOUT = 10000; // const TIMEOUT = 10000 --> "const" doesn't work under IE
-var HOST_PREF = "http://192.168.178.29:8000/"; //"http://localhost:8000/"; // of the form "http://(.+)/"
+var HOST_PREF = "http://143.93.190.237:8000/"; //"http://localhost:8000/"; // of the form "http://(.+)/"
var GET_PREFIX = HOST_PREF + "json/get/";
var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/";
var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
@@ -23,6 +22,7 @@
var INSTANCE_PSIS_URL = HOST_PREF + "json/tmcl/instances/";
var OWN_URL = HOST_PREF + "isidorus";
var SUMMARY_URL = HOST_PREF + "json/summary"
+var TIMEOUT = 10000; // const TIMEOUT = 10000 --> "const" doesn't work under IE
@@ -85,5 +85,6 @@
"tmIdFrame" : function(){ return "tmIdFrame"; },
"load" : function(){ return "loadFrame"; },
"ajaxLoader" : function(){ return "ajaxLoader"; },
- "editFrame" : function(){ return "editFrame"; }
+ "editFrame" : function(){ return "editFrame"; },
+ "disabled" : function(){ return "disabled"; }
};
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Mon Jun 29 04:19:47 2009
@@ -1225,26 +1225,25 @@
},
"disable" : function(){
this.hideError();
- disableItemIdentity(this);
+ this.__itemIdentity__.disable();
// TODO: scope
- this.__table__.select("tr." + CLASSES.scopeContainer())[0].setStyle(DISABLED_BACKGROUND_COLOR);
- disableValue(this);
- disableDatatype(this);
+ this.__value__.writeAttribute({"readonly" : "readonly"});
+ this.__datatype__.__frames__[0].disable();
this.hideRemoveButton();
this.hideAddButton();
- this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
+ this.getFrame().writeAttribute({"class" : CLASSES.disabled()});
this.__disabled__ = true;
},
"enable" : function(){
this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].hide();
- enableItemIdentity(this);
+ this.__itemIdentity__.enable();
// TODO: scope
- this.__table__.select("tr." + CLASSES.scopeContainer())[0].removeAttribute("style");
- enableValue(this);
- enableDatatype(this);
+ this.__value__.removeAttribute("readonly")
+ this.__datatype__.__frames__[0].enable();
if(this.__owner__.__frames__.length > 1) this.showRemoveButton();
this.showAddButton();
this.getFrame().removeAttribute("style");
+ this.getFrame().writeAttribute({"class" : CLASSES.variantFrame()});
this.__disabled__ = false;
},
"minimize" : function(){
@@ -1474,23 +1473,36 @@
},
"disable" : function(){
this.hideError();
+ this.__itemIdentity__.disable();
+ this.__type__.__frames__[0].disable();
+ this.__scope__.disable();
+ this.__value__.__frames__[0].disable();
+ this.__variants__.disable();
+/*
disableItemIdentity(this);
disableType(this);
disableScope(this);
disableValue(this);
disableVariants(this);
- this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
+ this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);*/
+ this.getFrame().writeAttribute({"class" : CLASSES.disabled()});
this.getFrame().writeAttribute({"title" : this.__cssTitle__});
this.hideAddButton();
this.__disabled__ = true;
},
"enable" : function(){
+ this.__itemIdentity__.enable();
+ this.__type__.__frames__[0].enable();
+ this.__scope__.enable();
+ this.__value__.__frames__[0].enable();
+ this.__variants__.enable();
+/*
enableItemIdentity(this);
enableType(this);
enableScope(this);
enableValue(this);
- enableVariants(this);
- this.getFrame().removeAttribute("style");
+ enableVariants(this);*/
+ this.getFrame().writeAttribute({"class" : CLASSES.nameFrame()});
this.getFrame().removeAttribute("title");
checkRemoveAddButtons(this.__owner__, 1, this.__max__, this);
this.__disabled__ = false;
@@ -1863,24 +1875,25 @@
this.__isMinimized__ = false;
}
},
- "disable" : function(){try{
+ "disable" : function(){
this.hideError();
- disableItemIdentity(this);
- disableType(this);;
- disableScope(this);
- disableValue(this);
- disableDatatype(this);
- this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
+ this.__itemIdentity__.disable();
+ this.__type__.__frames__[0].disable();
+ this.__scope__.disable();
+ this.__value__.writeAttribute({"readonly" : "readonly"});
+ this.__datatype__.__frames__[0].disable();
+ this.getFrame().writeAttribute({"class" : CLASSES.disabled()});
this.getFrame().writeAttribute({"title" : this.__cssTitle__});
this.hideAddButton();
- this.__disabled__ = true;}catch(err){ alert("err: " + err); }
+ this.__disabled__ = true;
},
"enable" : function(){
- enableItemIdentity(this);
- enableType(this);;
- enableScope(this);
- enableValue(this);
- enableDatatype(this);
+ this.__itemIdentity__.enable();
+ this.__type__.__frames__[0].enable();
+ this.__scope__.enable();
+ this.__value__.removeAttribute("readonly");
+ if(this.__datatypeIsSet__ === false) this.__datatype__.__frames__[0].enable();
+ this.getFrame().writeAttribute({"class" : CLASSES.occurrenceFrame()});
this.getFrame().removeAttribute("style");
this.getFrame().removeAttribute("title");
checkRemoveAddButtons(this.__owner__, 1, this.__max__, this);
@@ -2514,17 +2527,17 @@
},
"disable" : function(){
this.hideError();
- disableItemIdentity(this);
- disableType(this);
- disablePlayer(this);
- this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
+ this.__itemIdentity__.disable()
+ this.__type__.__frames__[0].disable();
+ this.__player__.__frames__[0].disable();
+ this.getFrame().writeAttribute({"class" : CLASSES.disabled()});
this.__disabled__ = true;
},
"enable" : function(){
- enableItemIdentity(this);
- enableType(this);
- enablePlayer(this);
- this.getFrame().removeAttribute("style");
+ this.__itemIdentity__.enable()
+ this.__type__.__frames__[0].enable();
+ this.__player__.__frames__[0].enable();
+ this.getFrame().writeAttribute({"class" : CLASSES.roleFrame()});
this.__disabled__ = false;
},
"minimize" : function(){
@@ -3619,23 +3632,23 @@
},
"disable" : function(){
this.hideError();
- disableItemIdentity(this);
- disableRole(this);
- disableType(this);
- disableScope(this);
+ this.__itemIdentity__.disable();
+ this.__roles__.disable();
+ this.__type__.__frames__[0].disable();
+ this.__scope__.disable();
this.hideRemoveButton();
this.hideAddButton();
- this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
+ this.getFrame().writeAttribute({"class" : CLASSES.disabled()});
this.__disabled__ = true;
},
"enable" : function(){
- enableItemIdentity(this);
- enableRole(this);
- enableType(this);
- enableScope(this);
+ this.__itemIdentity__.enable();
+ this.__roles__.enable();
+ this.__type__.__frames__[0].enable();
+ this.__scope__.enable();
if(this.__owner__.__frames__.length > 1 || !this.__constraints__ || this.__constraints__.length !== 0) this.showRemoveButton();
if(this.__constraints__ && this.__constraints__.length !== 0) this.showAddButton();
- this.getFrame().removeAttribute("style");
+ this.getFrame().writeAttribute({"class" : CLASSES.associationFrame()});
this.__disabled__ = false;
},
"minimize" : function(){
Modified: trunk/src/unit_tests/poems.xtm
==============================================================================
--- trunk/src/unit_tests/poems.xtm (original)
+++ trunk/src/unit_tests/poems.xtm Mon Jun 29 04:19:47 2009
@@ -16,7 +16,6 @@
<tm:topicRef href="#written"/>
</tm:role>
</tm:association>
-
<!-- end test -->
@@ -2876,7 +2875,7 @@
<tm:association>
<tm:itemIdentity href="written-by-association-shiller-resignation"/>
- <tm:type><tm:topicRef href="#place"/></tm:type>
+ <tm:type><tm:topicRef href="#written-by"/></tm:type>
<tm:scope><tm:topicRef href="#de"/></tm:scope>
<tm:role>
<tm:itemIdentity href="writer-role-schiller"/>
1
0
Author: lgiessmann
Date: Sun Jun 28 13:30:32 2009
New Revision: 74
Log:
ajax-client: fixed a bug with the minimize-handler of all some frames
Modified:
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Sun Jun 28 13:30:32 2009
@@ -95,7 +95,7 @@
this.__regExpString__ = regexp;
this.__frame__.writeAttribute({"class" : CLASSES.textrowWithRemoveButton()});
this.__content__.remove();
- this.__content__ = new Element("input", {"type" : "text", "value" : content, "size" : 40});
+ this.__content__ = new Element("input", {"type" : "text", "value" : content, "size" : 48});
this.__dblClickHandler__ = dblClickHandler;
if(cssTitle && cssTitle.length){
this.__content__.writeAttribute({"title" : cssTitle});
@@ -1132,8 +1132,8 @@
this.__table__ = new Element("table", {"class" : CLASSES.variantFrame()});
this.__frame__.insert({"top" : this.__table__});
this.__owner__ = owner;
- this.__owner__ = owner;
this.__dblClickHandler__ = dblClickHandler;
+ this.__isMinimized__ = false;
try{
var itemIdentityContent = null;
@@ -1156,7 +1156,7 @@
this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", new Element("div"))});
// --- resource value and datatype
- makeResource(this, contents, null, null, null, {"rows" : 3, "cols" : 40});
+ makeResource(this, contents, null, null, null, {"rows" : 3, "cols" : 55});
this.getFrame().observe("dblclick", function(event){
dblClickHandler(owner, event);
@@ -1236,6 +1236,7 @@
this.__disabled__ = true;
},
"enable" : function(){
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].hide();
enableItemIdentity(this);
// TODO: scope
this.__table__.select("tr." + CLASSES.scopeContainer())[0].removeAttribute("style");
@@ -1247,10 +1248,21 @@
this.__disabled__ = false;
},
"minimize" : function(){
- var trs = this.__table__.select("tr");
- for(var i = 0; i != trs.length; ++i){
- if(i === 0) trs[i].show();
- else trs[i].hide();
+ if(this.__isMinimized__ === false) {
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].show();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.scopeContainer())[0].hide();
+ this.getFrame().select("tr." + CLASSES.valueFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.datatypeFrame())[0].hide();
+ this.__isMinimized__ = true;
+ }
+ else {
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].hide();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.scopeContainer())[0].show();
+ this.getFrame().select("tr." + CLASSES.valueFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.datatypeFrame())[0].show();
+ this.__isMinimized__ = false;
}
}});
@@ -1337,6 +1349,7 @@
this.__owner__ = owner;
this.__dblClickHandler__ = dblClickHandler;
this.__constraint__ = simpleConstraint;
+ this.__isMinimized__ = false;
try{
var itemIdentityContent = null;
@@ -1440,10 +1453,23 @@
return this.__scope__.isValid();
},
"minimize" : function(){
- var trs = this.__table__.select("tr");
- for(var i = 0; i != trs.length; ++i){
- if(i === 0) trs[i].show();
- else trs[i].hide();
+ if(this.__isMinimized__ === false){
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].show();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.typeFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.scopeContainer())[0].hide();
+ this.getFrame().select("tr." + CLASSES.valueFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.variantContainer())[0].hide();
+ this.__isMinimized__ = true;
+ }
+ else {
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].hide();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.typeFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.scopeContainer())[0].show();
+ this.getFrame().select("tr." + CLASSES.valueFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.variantContainer())[0].show();
+ this.__isMinimized__ = false;
}
},
"disable" : function(){
@@ -1697,6 +1723,7 @@
this.__constraint__ = constraint;
this.__owner__ = owner;
this.__dblClickHandler__ = dblClickHandler;
+ this.__isMinimized__ = false;
try{
var itemIdentityContent = null;
@@ -1751,7 +1778,7 @@
var cssTitle = "No constraint found for this occurrence";
if(noConstraint === false) cssTitle = "min: " + _min + " max: " + _max + " regular expression: " + constraint.regexp;
this.__cssTitle__ = cssTitle;
- makeResource(this, contents, constraint, (occurrenceTypes ? occurrenceTypes[0].datatypeConstraint : null), cssTitle, {"rows" : 5, "cols" : 60});
+ makeResource(this, contents, constraint, (occurrenceTypes ? occurrenceTypes[0].datatypeConstraint : null), cssTitle, {"rows" : 5, "cols" : 70});
this.getFrame().observe("dblclick", function(event){
dblClickHandler(owner, event);
@@ -1817,10 +1844,23 @@
return this.__scope__.isValid();
},
"minimize" : function(){
- var trs = this.__table__.select("tr");
- for(var i = 0; i != trs.length; ++i){
- if(i === 0) trs[i].show();
- else trs[i].hide();
+ if(this.__isMinimized__ === false){
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].show();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.typeFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.scopeContainer())[0].hide();
+ this.getFrame().select("tr." + CLASSES.valueFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.datatypeFrame())[0].hide();
+ this.__isMinimized__ = true;
+ }
+ else {
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].hide();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.typeFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.scopeContainer())[0].show();
+ this.getFrame().select("tr." + CLASSES.valueFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.datatypeFrame())[0].show();
+ this.__isMinimized__ = false;
}
},
"disable" : function(){try{
@@ -2271,6 +2311,7 @@
this.__typeMin__ = typeMin;
this.__parentElem__ = parent;
this.__constraint__ = true; // is needed for checkAddRemoveButtons
+ this.__isMinimized__ = false;
try{
// --- control row + itemIdentity
@@ -2485,6 +2526,22 @@
enablePlayer(this);
this.getFrame().removeAttribute("style");
this.__disabled__ = false;
+ },
+ "minimize" : function(){
+ if(this.__isMinimized__ === false) {
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].show();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.typeFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.playerFrame())[0].hide();
+ this.__isMinimized__ = true;
+ }
+ else {
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].hide();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.typeFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.playerFrame())[0].show();
+ this.__isMinimized__ = false;
+ }
}});
@@ -3448,6 +3505,7 @@
this.__constraints__ = constraints;
this.__owner__ = owner;
this.__dblClickHandler__ = dblClickHandlerF;
+ this.__isMinimized__ = false;
try{
var itemIdentityContent = null;
@@ -3579,6 +3637,24 @@
if(this.__constraints__ && this.__constraints__.length !== 0) this.showAddButton();
this.getFrame().removeAttribute("style");
this.__disabled__ = false;
+ },
+ "minimize" : function(){
+ if(this.__isMinimized__ === false) {
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].show();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.typeFrame())[0].hide();
+ this.getFrame().select("tr." + CLASSES.scopeContainer())[0].hide();
+ this.getFrame().select("tr." + CLASSES.roleContainer())[0].hide();
+ this.__isMinimized__ = true;
+ }
+ else {
+ this.getFrame().select("tr." + CLASSES.showHiddenRows())[0].hide();
+ this.getFrame().select("tr." + CLASSES.itemIdentityFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.typeFrame())[0].show();
+ this.getFrame().select("tr." + CLASSES.scopeContainer())[0].show();
+ this.getFrame().select("tr." + CLASSES.roleContainer())[0].show();
+ this.__isMinimized__ = false;
+ }
}});
@@ -3702,7 +3778,7 @@
this.__caption__ = new Element("caption", {"class" : CLASSES.clickable()}).update("Topic Map ID");
this.__table__.update(this.__caption__);
var value = contents && contents.length !== 0 ? decodeURI(contents[0]) : "";
- this.__contentrow__ = new Element("input", {"type" : "text", "value" : value, "size" : 40});
+ this.__contentrow__ = new Element("input", {"type" : "text", "value" : value, "size" : 48});
this.__tr__ = new Element("tr", {"class" : CLASSES.tmIdFrame()});
var td =new Element("td", {"class" : CLASSES.content()});
this.__tr__.update(td);
@@ -3882,18 +3958,22 @@
myself.__table__.insert({"top" : trCtrl});
trCtrl.hide();
trCtrl.observe("click", function(){
- var trs = myself.__table__.select("tr");
+ /*var trs = myself.__table__.select("tr");
for(var i = 0; i != trs.length; ++i) trs[i].show();
- trCtrl.hide();
+ trCtrl.hide();*/
+ try{myself.minimize();}catch(err){ alert("err: " + err); }
});
// --- min click-handler
min.observe("click", function(event){
+ /*
var trs = myself.__table__.select("tr");
for(var i = 0; i != trs.length; ++i){
if(i === 0) trs[i].show();
else trs[i].hide();
}
+ */
+ try{myself.minimize();}catch(err){ alert("err: " + err); }
});
}
@@ -3960,7 +4040,7 @@
// --- sets the resource value and datatype of names and occurrences
function makeResource(myself, content, constraints, datatypeConstraint, cssTitle, size)
{
- if(!size) size = {"rows" : 3, "cols" : 40};
+ if(!size) size = {"rows" : 3, "cols" : 60};
var value = "";
var datatype = "";
if(content && content.resourceRef && content.resourceRef.length !== 0){
1
0
Author: lgiessmann
Date: Sun Jun 28 12:35:36 2009
New Revision: 73
Log:
ajax-client: fixed a bug with disabling the datatype frames; fixed a style-bug with disabling frames; added css stylesheets
Modified:
trunk/src/ajax/css/frame.css
trunk/src/ajax/css/main.css
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/requests.js
Modified: trunk/src/ajax/css/frame.css
==============================================================================
--- trunk/src/ajax/css/frame.css (original)
+++ trunk/src/ajax/css/frame.css Sun Jun 28 12:35:36 2009
@@ -11,15 +11,17 @@
ul.fragmentFrame {
list-style-type: none;
+ padding-left: 0px;
}
-caption {
+ul.fragmentFrame table > caption {
font-size: 1.5em;
font-weight: bold;
}
td.controlColumn {
background-color: #eaeaee;
+ width: 13px;
}
tr.showHiddenRows {
@@ -31,11 +33,337 @@
font-size: 1.2em;
}
+li.instanceOfFrame > div {
+ margin-left: 10px;
+}
+
+li.instanceOfFrame > div > input[type="button"]{
+ margin-left: 24px;
+}
+
input[value="generate fragment"] {
margin-top: 10px;
margin-bottom: 10px;
}
+input[value="validate fragment"] {
+ float: right;
+}
+
input[value="commit fragment"] {
+ margin-left: 5px;
float: right;
+}
+
+
+/* === remove/add buttons in any kind of rows =============================== */
+div.textrowWithoutRemoveButton span{
+ display: inline-block;
+ width: 20px;
+ margin-left: 2px;
+ margin-right: 2px;
+ text-align: center;
+}
+
+div.textrowWithRemoveButton span{
+ display: inline-block;
+ width: 20px;
+ margin-left: 2px;
+ margin-right: 2px;
+ text-align: center;
+}
+
+div.selectrowWithoutRemoveButton span{
+ display: inline-block;
+ width: 20px;
+ margin-left: 2px;
+ margin-right: 2px;
+ text-align: center;
+}
+
+div.selectrowWithRemoveButton span{
+ display: inline-block;
+ width: 20px;
+ margin-left: 2px;
+ margin-right: 2px;
+ text-align: center;
+}
+
+input[type="text"] {
+ background-color: #white;
+ border: 1px solid darkgray;
+ margin-bottom: 1px;
+ margin-top: 1px;
+}
+
+input[type="text"][readonly="readonly"] {
+ background-color: #eaeaee;
+ border: 1px solid darkgray;
+ margin-bottom: 1px;
+ margin-top: 1px;
+}
+
+
+div.textrowWithRemoveButton > input[type="text"]{
+ margin-left: 0px;
+ font-weight: normal;
+}
+
+div.textrowWithoutRemoveButton > input[type="text"]{
+ margin-left: 24px;
+ font-weight: normal;
+}
+
+div.selectrowWithRemoveButton > select {
+ margin-left: 0px;
+ font-weight: normal;
+}
+
+div.selectrowWithoutRemoveButton > select {
+ margin-left: 24px;
+ font-weight: normal;
+}
+
+textarea {
+ margin-left: 24px;
+ background-color: white;
+ border: 1px solid darkgray;
+ margin-bottom: 1px;
+ margin-top: 1px;
+}
+
+textarea[readonly="readonly"] {
+ margin-left: 24px;
+ background-color: #eaeaee;
+ border: 1px solid darkgray;
+ margin-bottom: 1px;
+ margin-top: 1px;
+}
+
+
+/* === topic frame ========================================================== */
+table.topicFrame {
+ width: 1022px;
+ border-collapse: collapse;
+ border: 1px solid #d1d1d3;
+}
+
+table.topicFrame > tr > td.description {
+ width: 163px;
+}
+
+table.topicFrame > tr > td.content {
+ width: 854px;
+}
+
+table.topicFrame > tr.topicIdFrame {
+ background-color: #f6f7f9;
+}
+
+table.topicFrame > tr.subjectLocatorFrame {
+ background-color: #f6f7f9;
+}
+
+table.topicFrame > tr.nameContainer {
+ background-color: #f6f7f9;
+}
+
+table.topicFrame:hover {
+ border: 1px solid #ff7f00;
+}
+
+
+/* === name frame =========================================================== */
+table.topicFrame table.nameFrame {
+ width: 851px;
+ margin-top: 2px;
+ margin-bottom: 2px;
+ margin-left: 1px;
+ border-collapse: collapse;
+ border: 1px solid #d1d1d3;
+}
+
+table.topicFrame table.nameFrame td.description {
+ width: 142px;
+}
+
+table.topicFrame table.nameFrame td.content {
+ width: 689px;
+}
+
+table.topicFrame table.nameFrame > tr.typeFrame {
+ background-color: white;
+}
+
+table.topicFrame table.nameFrame > tr.valueFrame {
+ background-color: white;
+}
+
+table.topicFrame table.nameFrame:hover {
+ border: 1px solid #ff7f00;
+}
+
+
+/* === variant frame ======================================================== */
+table.nameFrame div.variantFrame {
+ margin-left: 24px;
+}
+
+table.nameFrame table.variantFrame {
+ width: 667px;
+ margin-top: 2px;
+ margin-bottom: 2px;
+ border-collapse: collapse;
+ border: 1px solid #d1d1d3;
+}
+
+table.nameFrame table.variantFrame > tr > td.description {
+ width: 142px;
+}
+
+table.nameFrame table.variantFrame > tr > td.content {
+ width: 505px;
+}
+
+table.nameFrame table.variantFrame tr.scopeContainer {
+ background-color: white;
+}
+
+table.nameFrame table.variantFrame tr.datatypeFrame {
+ background-color: white;
+}
+
+table.nameFrame table.variantFrame:hover {
+ border: 1px solid #ff7f00;
+}
+
+
+/* === occurrence frame ===================================================== */
+table.topicFrame table.occurrenceFrame {
+ width: 851px;
+ margin-top: 2px;
+ margin-bottom: 2px;
+ margin-left: 1px;
+ border-collapse: collapse;
+ border: 1px solid #d1d1d3;
+}
+
+table.topicFrame table.occurrenceFrame td.description {
+ width: 142px;
+}
+
+table.topicFrame table.occurrenceFrame td.content {
+ width: 689px;
+}
+
+table.topicFrame table.occurrenceFrame > tr.typeFrame {
+ background-color: #f6f7f9;
+}
+
+table.topicFrame table.occurrenceFrame > tr.valueFrame {
+ background-color: #f6f7f9;
+}
+
+table.topicFrame table.occurrenceFrame:hover {
+ border: 1px solid #ff7f00;
+}
+
+
+/* === association container / association frame ============================ */
+div.associationContainer {
+ margin-top: 30px;
+}
+
+table.associationContainer {
+ border-collapse: collapse;
+ width: 1022px;
+ border: 1px solid #d1d1d3;
+}
+
+table.associationContainer:hover {
+ border: 1px solid #ff7f00;
+}
+
+table.associationFrame {
+ border-collapse: collapse;
+ margin-left: 1px;
+ margin-top: 1px;
+ margin-bottom: 1px;
+ border: 1px solid #d1d1d3;
+ width: 1018px;
+}
+
+table.associationFrame:hover {
+ border: 1px solid #ff7f00;
+}
+
+table.associationFrame > tr > td.description {
+ width: 142px;
+}
+
+table.associationFrame > tr > td.content {
+ width: 853px;
+}
+
+table.associationFrame > tr.itemIdentityFrame {
+ background-color: #f6f7f9;
+}
+
+table.associationFrame > tr.scopeContainer {
+ background-color: #f6f7f9;
+}
+
+
+
+
+/* === associationrole frame ================================================ */
+table.associationFrame table.roleFrame {
+ width: 853px;
+ margin-left: 1px;
+ margin-top: 2px;
+ margin-bottom: 2px;
+ border-collapse: collapse;
+ border: 1px solid #d1d1d3;
+}
+
+table.associationFrame table.roleFrame:hover {
+ border: 1px solid #ff7f00;
+}
+
+table.associationFrame table.roleFrame > tr > td.description {
+ width: 142px;
+}
+
+table.associationFrame table.roleFrame > tr > td.content {
+ width: 692px;
+}
+
+table.roleFrame > tr.typeFrame {
+ background-color: #f6f7f9;
+}
+
+
+
+/* === tmId frame ========================================================== */
+div.tmIdFrame {
+ margin-top: 30px;
+}
+
+table.tmIdFrame {
+ width: 1023px;
+ border-collapse: collapse;
+ border: 1px solid #d1d1d3;
+ background-color: #f6f7f9;
+}
+
+table.tmIdFrame:hover {
+ border: 1px solid #ff7f00;
+}
+
+li.tmIdFrame {
+ margin-bottom: 10px;
+}
+
+table.tmIdFrame input[type="text"] {
+ margin-left: 12px;
}
\ No newline at end of file
Modified: trunk/src/ajax/css/main.css
==============================================================================
--- trunk/src/ajax/css/main.css (original)
+++ trunk/src/ajax/css/main.css Sun Jun 28 12:35:36 2009
@@ -27,6 +27,7 @@
}
h1 {
+ clear: left;
margin-left: 10px;
padding-top: 20px;
}
@@ -61,5 +62,5 @@
img.ajaxLoader {
display: none;
- margin-left: 412px; /* the image has a width of 100px */
+ margin-left: 412px; /* the image has a width of 100px --> 1024/2 - 100 = 412*/
}
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Sun Jun 28 12:35:36 2009
@@ -12,7 +12,7 @@
// --- Some constants fot the http connections via the XMLHttpRequest-Object
var TIMEOUT = 10000; // const TIMEOUT = 10000 --> "const" doesn't work under IE
-var HOST_PREF = "http://143.93.190.237:8000/"; //"http://localhost:8000/"; // of the form "http://(.+)/"
+var HOST_PREF = "http://192.168.178.29:8000/"; //"http://localhost:8000/"; // of the form "http://(.+)/"
var GET_PREFIX = HOST_PREF + "json/get/";
var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/";
var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
@@ -37,95 +37,53 @@
var MAX_INT = "MAX_INT";
var MMAX_INT = "*";
+
+// --- some css-styles
+var DISABLED_BACKGROUND_COLOR = {"backgroundColor" : "#eaeaee"};
+
+
// --- Contains most css classes used in this project
// --- There should be called only the function to be sure to don't override
// --- the original values.
-var CLASSES = {"__divPage__" : "page",
- "__divSubPage__" : "subPage",
- "__divContent__" : "content",
- "__divTextrowWithRemoveButton__" : "textrowWithRemoveButton",
- "__divTextrowWithoutRemoveButton__" : "textrowWithoutRemoveButton",
- "__divSelectrowWithRemoveButton__" : "selectrowWithRemoveButton",
- "__divSelectrowWithoutRemoveButton__" : "selectrowWithoutRemoveButton",
- "__spanClickable__" : "clickable",
- "__notVisible__" : "notvisible",
- "__divError__" : "errorMessage",
- "__ulFragmentFrame__" : "fragmentFrame",
- "__tableTopicFrame__" : "topicFrame",
- "__trTopicIdFrame__" : "topicIdFrame",
- "__tdContent__" : "content",
- "__tdDescription__" : "description",
- "__divInstanceOfFrame__" : "instanceOfFrame",
- "__divItemIdentityFrame__" : "itemIdentityFrame",
- "__divSubjectLocatorFrame__" : "subjectLocatorFrame",
- "__divSubjectIdentifierFrame__" : "subjectIdentifierFrame",
- "__divNameContainer__" : "nameContainer",
- "__divNameFrame__" : "nameFrame",
- "__trControlColumn__" : "controlColumn",
- "__trShowHiddenRows__" : "showHiddenRows",
- "__trTypeFrame__" : "typeFrame",
- "__divScopeFrame__" : "scopeFrame",
- "__divScopeContainer__" : "scopeContainer",
- "__divValueFrame__" : "valueFrame",
- "__divVariantFrame__" : "variantFrame",
- "__divVariantContainer__" : "variantContainer",
- "__divDatatypeFrame__" : "datatypeFrame",
- "__divOccurrenceContainer__" : "occurrenceContainer",
- "__divOccurrenceFrame__" : "occurrenceFrame",
- "__divAssociationContainer__" : "associationContainer",
- "__divAssociationFrame__" : "associationFrame",
- "__divRoleContainer__" : "roleContainer",
- "__divRoleFrame__" : "roleFrame",
- "__divPlayerFrame__" : "playerFrame",
- "__spanDeselect__" : "deselect",
- "__divFog__" : "fog",
- "__inputCommitButton__" : "commitButton",
- "__divTmIdFrame__" : "tmIdFrame",
- "__divLoad__" : "loadFrame",
- "__imgAjaxLoader__" : "ajaxLoader",
- "__divEditFrame__" : "editFrame",
-
- "page" : function(){ return this.__divPage__; },
- "subPage" : function(){ return this.__divSubPage__; },
- "content" : function(){ return this.__divContent__; },
- "textrowWithRemoveButton" : function(){ return this.__divTextrowWithRemoveButton__; },
- "textrowWithoutRemoveButton" : function(){ return this.__divTextrowWithoutRemoveButton__; },
- "selectrowWithRemoveButton" : function(){ return this.__divSelectrowWithRemoveButton__; },
- "selectrowWithoutRemoveButton" : function(){ return this.__divSelectrowWithoutRemoveButton__; },
- "clickable" : function(){ return this.__spanClickable__; },
- "notVisible" : function(){ return this.__notVisible__; },
- "error" : function(){ return this.__divError__; }, "fragmentFrame" : function(){ return this.__ulFragmentFrame__; },
- "topicFrame" : function(){ return this.__tableTopicFrame__; },
- "topicIdFrame" : function(){ return this.__trTopicIdFrame__; },
- "content" : function(){ return this.__tdContent__; },
- "description" : function(){ return this.__tdDescription__; },
- "instanceOfFrame" : function(){ return this.__divInstanceOfFrame__; },
- "itemIdentityFrame" : function(){ return this.__divItemIdentityFrame__; },
- "subjectLocatorFrame" : function(){ return this.__divSubjectLocatorFrame__; },
- "subjectIdentifierFrame" : function(){ return this.__divSubjectIdentifierFrame__; },
- "nameContainer" : function(){ return this.__divNameContainer__; },
- "nameFrame" : function(){ return this.__divNameFrame__; },
- "controlColumn" : function(){ return this.__trControlColumn__; },
- "showHiddenRows" : function(){ return this.__trShowHiddenRows__; },
- "typeFrame" : function(){ return this.__trTypeFrame__; },
- "scopeFrame" : function(){ return this.__divScopeFrame__; },
- "scopeContainer" : function(){ return this.__divScopeContainer__; },
- "valueFrame" : function(){ return this.__divValueFrame__; },
- "variantFrame" : function(){ return this.__divVariantFrame__; },
- "variantContainer" : function(){ return this.__divVariantContainer__; },
- "datatypeFrame" : function(){ return this.__divDatatypeFrame__; },
- "occurrenceContainer" : function(){ return this.__divOccurrenceContainer__; },
- "occurrenceFrame" : function(){ return this.__divOccurrenceFrame__; },
- "associationContainer" : function(){ return this.__divAssociationContainer__; },
- "associationFrame" : function(){ return this.__divAssociationFrame__; },
- "roleContainer" : function(){ return this.__divRoleContainer__; },
- "roleFrame" : function(){ return this.__divRoleFrame__; },
- "playerFrame" : function(){ return this.__divPlayerFrame__; },
- "deselect" : function(){ return this.__spanDeselect__; },
- "fog" : function(){ return this.__divFog__; },
- "commitButton" : function(){ return this.__inputCommitButton__; },
- "tmIdFrame" : function(){ return this.__divTmIdFrame__; },
- "load" : function(){ return this.__divLoad__; },
- "ajaxLoader" : function(){ return this.__imgAjaxLoader__; },
- "editFrame" : function(){ return this.__divEditFrame__; }
+var CLASSES = {"page" : function(){ return "page"; },
+ "subPage" : function(){ return "subPage"; },
+ "content" : function(){ return "content"; },
+ "textrowWithRemoveButton" : function(){ return "textrowWithRemoveButton"; },
+ "textrowWithoutRemoveButton" : function(){ return "textrowWithoutRemoveButton"; },
+ "selectrowWithRemoveButton" : function(){ return "selectrowWithRemoveButton"; },
+ "selectrowWithoutRemoveButton" : function(){ return "selectrowWithoutRemoveButton"; },
+ "clickable" : function(){ return "clickable"; },
+ "error" : function(){ return "errorMessage" },
+ "fragmentFrame" : function(){ return "fragmentFrame"; },
+ "topicFrame" : function(){ return "topicFrame"; },
+ "topicIdFrame" : function(){ return "topicIdFrame"; },
+ "content" : function(){ return "content"; },
+ "description" : function(){ return "description"; },
+ "instanceOfFrame" : function(){ return "instanceOfFrame"; },
+ "itemIdentityFrame" : function(){ return "itemIdentityFrame"; },
+ "subjectLocatorFrame" : function(){ return "subjectLocatorFrame"; },
+ "subjectIdentifierFrame" : function(){ return "subjectIdentifierFrame"; },
+ "nameContainer" : function(){ return "nameContainer"; },
+ "nameFrame" : function(){ return "nameFrame"; },
+ "controlColumn" : function(){ return "controlColumn"; },
+ "showHiddenRows" : function(){ return "showHiddenRows"; },
+ "typeFrame" : function(){ return "typeFrame"; },
+ "scopeFrame" : function(){ return "scopeFrame"; },
+ "scopeContainer" : function(){ return "scopeContainer"; },
+ "valueFrame" : function(){ return "valueFrame"; },
+ "variantFrame" : function(){ return "variantFrame"; },
+ "variantContainer" : function(){ return "variantContainer"; },
+ "datatypeFrame" : function(){ return "datatypeFrame"; },
+ "occurrenceContainer" : function(){ return "occurrenceContainer"; },
+ "occurrenceFrame" : function(){ return "occurrenceFrame"; },
+ "associationContainer" : function(){ return "associationContainer"; },
+ "associationFrame" : function(){ return "associationFrame"; },
+ "roleContainer" : function(){ return "roleContainer"; },
+ "roleFrame" : function(){ return "roleFrame"; },
+ "playerFrame" : function(){ return "playerFrame"; },
+ "commitButton" : function(){ return "commitButton"; },
+ "tmIdFrame" : function(){ return "tmIdFrame"; },
+ "load" : function(){ return "loadFrame"; },
+ "ajaxLoader" : function(){ return "ajaxLoader"; },
+ "editFrame" : function(){ return "editFrame"; }
};
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Sun Jun 28 12:35:36 2009
@@ -101,6 +101,17 @@
tmId.isValid();
}
+ var validateButton = new Element("input", {"type" : "button", "value" : "validate fragment"});
+ validateButton.observe("click", function(event){
+ var ret = true;
+ if(topic.isValid() === false) ret = false;
+ if(associations && associations.isValid() === false) ret = false;
+ if(tmId.isValid() === false) ret = false;
+
+ if(ret === true) alert("Fragment is valid!");
+ else alert("Fragment is not valid!");
+ });
+
var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment"})
commitButton.observe("click", function(event){
// --- validates the given data
@@ -146,7 +157,8 @@
});
var liCB = new Element("li", {"class" : CLASSES.commitButton()});
- liCB.update(commitButton);
+ liCB.insert({"top" : validateButton});
+ liCB.insert({"top" : commitButton});
liTm.insert({"after" : liCB});
}
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Sun Jun 28 12:35:36 2009
@@ -95,7 +95,7 @@
this.__regExpString__ = regexp;
this.__frame__.writeAttribute({"class" : CLASSES.textrowWithRemoveButton()});
this.__content__.remove();
- this.__content__ = new Element("input", {"type" : "text", "value" : content});
+ this.__content__ = new Element("input", {"type" : "text", "value" : content, "size" : 40});
this.__dblClickHandler__ = dblClickHandler;
if(cssTitle && cssTitle.length){
this.__content__.writeAttribute({"title" : cssTitle});
@@ -1156,7 +1156,7 @@
this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", new Element("div"))});
// --- resource value and datatype
- makeResource(this, contents, null, null, null);
+ makeResource(this, contents, null, null, null, {"rows" : 3, "cols" : 40});
this.getFrame().observe("dblclick", function(event){
dblClickHandler(owner, event);
@@ -1225,25 +1225,25 @@
},
"disable" : function(){
this.hideError();
- this.__itemIdentity__.disable();
+ disableItemIdentity(this);
// TODO: scope
- this.__value__.writeAttribute({"readonly" : "readonly"});
- this.__datatype__.__frames__[0].disable();
+ this.__table__.select("tr." + CLASSES.scopeContainer())[0].setStyle(DISABLED_BACKGROUND_COLOR);
+ disableValue(this);
+ disableDatatype(this);
this.hideRemoveButton();
this.hideAddButton();
- this.getFrame().setStyle({"backgroundColor" : "#edeceb"});
- this.getFrame().setStyle({"border" : "1px solid darkgrey"});
+ this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
this.__disabled__ = true;
},
"enable" : function(){
- this.__itemIdentity__.enable();
+ enableItemIdentity(this);
// TODO: scope
- this.__value__.removeAttribute("readonly");
- this.__datatype__.__frames__[0].enable();
+ this.__table__.select("tr." + CLASSES.scopeContainer())[0].removeAttribute("style");
+ enableValue(this);
+ enableDatatype(this);
if(this.__owner__.__frames__.length > 1) this.showRemoveButton();
this.showAddButton();
- this.getFrame().setStyle({"backgroundColor" : "inherit"});
- this.getFrame().setStyle({"border" : "none"});
+ this.getFrame().removeAttribute("style");
this.__disabled__ = false;
},
"minimize" : function(){
@@ -1392,11 +1392,9 @@
// --- name element will be shown
function addSecondShowHandler(myself){
myself.__table__.select("tr")[0].observe("click", function(event){
- try{
- for(var i = 0; i != myself.__variants__.__container__.__frames__.length; ++i){
- myself.__variants__.__container__.__frames__[i].minimize();
- }
- }catch(tmp){ alert(tmp);}
+ for(var i = 0; i != myself.__variants__.__container__.__frames__.length; ++i){
+ myself.__variants__.__container__.__frames__[i].minimize();
+ }
});
}
@@ -1450,25 +1448,23 @@
},
"disable" : function(){
this.hideError();
- this.__itemIdentity__.disable();
- this.__type__.__frames__[0].disable();
- this.__scope__.disable();
- this.__value__.__frames__[0].disable();
- this.__variants__.disable();
- this.getFrame().setStyle({"backgroundColor" : "#edeceb"});
- this.getFrame().setStyle({"border" : "1px solid darkgrey"});
+ disableItemIdentity(this);
+ disableType(this);
+ disableScope(this);
+ disableValue(this);
+ disableVariants(this);
+ this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
this.getFrame().writeAttribute({"title" : this.__cssTitle__});
this.hideAddButton();
this.__disabled__ = true;
},
"enable" : function(){
- this.__itemIdentity__.enable();
- this.__type__.__frames__[0].enable();
- this.__scope__.enable();
- this.__value__.__frames__[0].enable();
- this.__variants__.enable();
- this.getFrame().setStyle({"backgroundColor" : "inherit"});
- this.getFrame().setStyle({"border" : "none"});
+ enableItemIdentity(this);
+ enableType(this);
+ enableScope(this);
+ enableValue(this);
+ enableVariants(this);
+ this.getFrame().removeAttribute("style");
this.getFrame().removeAttribute("title");
checkRemoveAddButtons(this.__owner__, 1, this.__max__, this);
this.__disabled__ = false;
@@ -1755,7 +1751,7 @@
var cssTitle = "No constraint found for this occurrence";
if(noConstraint === false) cssTitle = "min: " + _min + " max: " + _max + " regular expression: " + constraint.regexp;
this.__cssTitle__ = cssTitle;
- makeResource(this, contents, constraint, (occurrenceTypes ? occurrenceTypes[0].datatypeConstraint : null), cssTitle);
+ makeResource(this, contents, constraint, (occurrenceTypes ? occurrenceTypes[0].datatypeConstraint : null), cssTitle, {"rows" : 5, "cols" : 60});
this.getFrame().observe("dblclick", function(event){
dblClickHandler(owner, event);
@@ -1827,27 +1823,25 @@
else trs[i].hide();
}
},
- "disable" : function(){
+ "disable" : function(){try{
this.hideError();
- this.__itemIdentity__.disable();
- this.__type__.__frames__[0].disable();
- this.__scope__.disable();
- this.__value__.writeAttribute({"readonly" : "readonly"});
- this.__datatype__.__frames__[0].disable();
- this.getFrame().setStyle({"backgroundColor" : "#edeceb"});
- this.getFrame().setStyle({"border" : "1px solid darkgrey"});
+ disableItemIdentity(this);
+ disableType(this);;
+ disableScope(this);
+ disableValue(this);
+ disableDatatype(this);
+ this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
this.getFrame().writeAttribute({"title" : this.__cssTitle__});
this.hideAddButton();
- this.__disabled__ = true;
+ this.__disabled__ = true;}catch(err){ alert("err: " + err); }
},
"enable" : function(){
- this.__itemIdentity__.enable();
- this.__type__.__frames__[0].enable();
- this.__scope__.enable();
- this.__value__.removeAttribute("readonly");
- this.__datatype__.__frames__[0].enable();
- this.getFrame().setStyle({"backgroundColor" : "inherit"});
- this.getFrame().setStyle({"border" : "none"});
+ enableItemIdentity(this);
+ enableType(this);;
+ enableScope(this);
+ enableValue(this);
+ enableDatatype(this);
+ this.getFrame().removeAttribute("style");
this.getFrame().removeAttribute("title");
checkRemoveAddButtons(this.__owner__, 1, this.__max__, this);
this.__disabled__ = false;
@@ -2479,19 +2473,17 @@
},
"disable" : function(){
this.hideError();
- this.__itemIdentity__.disable();
- this.__type__.__frames__[0].disable();
- this.__player__.__frames__[0].disable();
- this.getFrame().setStyle({"backgroundColor" : "#edeceb"});
- this.getFrame().setStyle({"border" : "1px solid darkgrey"});
+ disableItemIdentity(this);
+ disableType(this);
+ disablePlayer(this);
+ this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
this.__disabled__ = true;
},
"enable" : function(){
- this.__itemIdentity__.enable();
- this.__type__.__frames__[0].enable();
- this.__player__.__frames__[0].enable();
- this.getFrame().setStyle({"backgroundColor" : "inherit"});
- this.getFrame().setStyle({"border" : "none"});
+ enableItemIdentity(this);
+ enableType(this);
+ enablePlayer(this);
+ this.getFrame().removeAttribute("style");
this.__disabled__ = false;
}});
@@ -3569,25 +3561,23 @@
},
"disable" : function(){
this.hideError();
- this.__itemIdentity__.disable();
- this.__roles__.disable();
- this.__type__.__frames__[0].disable();
- this.__scope__.disable();
+ disableItemIdentity(this);
+ disableRole(this);
+ disableType(this);
+ disableScope(this);
this.hideRemoveButton();
this.hideAddButton();
- this.getFrame().setStyle({"backgroundColor" : "#edeceb"});
- this.getFrame().setStyle({"border" : "1px solid darkgrey"});
+ this.getFrame().setStyle(DISABLED_BACKGROUND_COLOR);
this.__disabled__ = true;
},
"enable" : function(){
- this.__itemIdentity__.enable();
- this.__roles__.enable();
- this.__type__.__frames__[0].enable();
- this.__scope__.enable();
+ enableItemIdentity(this);
+ enableRole(this);
+ enableType(this);
+ enableScope(this);
if(this.__owner__.__frames__.length > 1 || !this.__constraints__ || this.__constraints__.length !== 0) this.showRemoveButton();
if(this.__constraints__ && this.__constraints__.length !== 0) this.showAddButton();
- this.getFrame().setStyle({"backgroundColor" : "inherit"});
- this.getFrame().setStyle({"border" : "none"});
+ this.getFrame().removeAttribute("style");
this.__disabled__ = false;
}});
@@ -3712,7 +3702,7 @@
this.__caption__ = new Element("caption", {"class" : CLASSES.clickable()}).update("Topic Map ID");
this.__table__.update(this.__caption__);
var value = contents && contents.length !== 0 ? decodeURI(contents[0]) : "";
- this.__contentrow__ = new Element("input", {"type" : "text", "value" : value});
+ this.__contentrow__ = new Element("input", {"type" : "text", "value" : value, "size" : 40});
this.__tr__ = new Element("tr", {"class" : CLASSES.tmIdFrame()});
var td =new Element("td", {"class" : CLASSES.content()});
this.__tr__.update(td);
@@ -3968,8 +3958,9 @@
// --- sets the resource value and datatype of names and occurrences
-function makeResource(myself, content, constraints, datatypeConstraint, cssTitle)
+function makeResource(myself, content, constraints, datatypeConstraint, cssTitle, size)
{
+ if(!size) size = {"rows" : 3, "cols" : 40};
var value = "";
var datatype = "";
if(content && content.resourceRef && content.resourceRef.length !== 0){
@@ -3989,18 +3980,20 @@
this.__datatype__.__frames__[0].remove();
this.__datatype__ = new Object();
}catch(err){}
- myself.__value__ = new Element("textarea", {"rows" : 3}).setValue(value);
+ myself.__value__ = new Element("textarea", size).setValue(value);
myself.__table__.insert({"bottom" : newRow(CLASSES.valueFrame(), "Resource Value", myself.__value__)});
if(cssTitle && cssTitle.length !== 0) myself.__value__.writeAttribute({"title" : cssTitle});
// --- datatype
myself.__datatype__ = new Object();
- if(datatypeConstraint && datatypeConstraint.length !== 0){
+ if((datatypeConstraint && datatypeConstraint.length !== 0) || datatype === ANY_URI){
new TextrowC(datatypeConstraint, datatypeConstraint, myself.__datatype__, 1, 1, null);
myself.__datatype__.__frames__[0].getFrame().select("input")[0].writeAttribute({"readonly" : "readonly"});
+ myself.__datatypeIsSet__ = true;
}
else {
new TextrowC(datatype, ".*", myself.__datatype__, 1, 1, null);
+ myself.__datatypeIsSet__ = false;
}
myself.__table__.insert({"bottom" : newRow(CLASSES.datatypeFrame(), "Datatype", myself.__datatype__.__frames__[0].getFrame())});
}
@@ -4153,4 +4146,88 @@
var tr = newRow(CLASSES.typeFrame(), "Type", new SelectrowC(types, myself.__type__, 1, 1).getFrame());
myself.__table__.insert({"bottom" : tr});
return types;
+}
+
+// --- some helper to enable/disable some table rows
+
+function disableItemIdentity(myself)
+{
+ myself.__itemIdentity__.disable();
+ myself.__table__.select("tr." + CLASSES.itemIdentityFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
+}
+function enableItemIdentity(myself)
+{
+ myself.__itemIdentity__.enable();
+ myself.__table__.select("tr." + CLASSES.itemIdentityFrame())[0].removeAttribute("style");
+}
+function disableType(myself)
+{
+ myself.__type__.__frames__[0].disable();
+ myself.__table__.select("tr." + CLASSES.typeFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
+}
+function enableType(myself)
+{
+ myself.__type__.__frames__[0].enable();
+ myself.__table__.select("tr." + CLASSES.typeFrame())[0].removeAttribute("style");
+}
+function disableScope(myself){
+ myself.__scope__.disable();
+ myself.__table__.select("tr." + CLASSES.scopeContainer())[0].setStyle(DISABLED_BACKGROUND_COLOR);
+}
+function enableScope(myself)
+{
+ myself.__scope__.enable();
+ myself.__table__.select("tr." + CLASSES.scopeContainer())[0].removeAttribute("style");
+}
+function disableValue(myself)
+{
+ try{ myself.__value__.__frames__[0].disable(); } catch(err){}
+ try{ myself.__value__.writeAttribute({"readonly" : "readonly"}); } catch(err){}
+ myself.__table__.select("tr." + CLASSES.valueFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
+}
+function enableValue(myself)
+{
+ try{ myself.__value__.__frames__[0].enable(); } catch(err){}
+ try{ myself.__value__.removeAttribute("readonly"); } catch(err){}
+ myself.__table__.select("tr." + CLASSES.valueFrame())[0].removeAttribute("style");
+}
+function disableDatatype(myself)
+{
+ myself.__datatype__.__frames__[0].disable();
+ myself.__table__.select("tr." + CLASSES.datatypeFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
+}
+function enableDatatype(myself)
+{
+ if(myself.__datatypeIsSet__ === false) myself.__datatype__.__frames__[0].enable();
+ myself.__table__.select("tr." + CLASSES.datatypeFrame())[0].removeAttribute("style");
+}
+function disableVariants(myself)
+{
+ myself.__variants__.disable();
+ myself.__table__.select("tr." + CLASSES.variantContainer())[0].setStyle(DISABLED_BACKGROUND_COLOR);
+}
+function enableVariants(myself)
+{
+ myself.__variants__.enable();
+ myself.__table__.select("tr." + CLASSES.variantContainer())[0].removeAttribute("style");
+}
+function disableRole(myself)
+{
+ myself.__roles__.disable();
+ myself.__table__.select("tr." + CLASSES.roleContainer())[0].setStyle(DISABLED_BACKGROUND_COLOR);
+}
+function enableRole(myself)
+{
+ myself.__roles__.enable();
+ myself.__table__.select("tr." + CLASSES.roleContainer())[0].removeAttribute("style");
+}
+function disablePlayer(myself)
+{
+ myself.__player__.__frames__[0].disable();
+ myself.__table__.select("tr." + CLASSES.playerFrame())[0].setStyle(DISABLED_BACKGROUND_COLOR);
+}
+function enablePlayer(myself)
+{
+ myself.__player__.__frames__[0].enable();
+ myself.__table__.select("tr." + CLASSES.playerFrame())[0].removeAttribute("style");
}
\ No newline at end of file
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Sun Jun 28 12:35:36 2009
@@ -16,6 +16,7 @@
{
return setTimeout(function(){
alert("The AJAX request for \"" + url + "\" timed out. Please check your network connection!");
+ hideLoad();
}, time);
}
1
0
Author: lgiessmann
Date: Fri Jun 26 10:10:52 2009
New Revision: 72
Log:
ajax-client: fixed a bug with safari by minimizing frames. instead of minimizing they were hidden without any chance to display them! Currentyl the client is able to be used with all functions in firefox, opera and safari - with IE it is not useable and will take a while until this will change
Modified:
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Fri Jun 26 10:10:52 2009
@@ -3888,7 +3888,7 @@
myself.__table__.insert({"bottom" : tr});
var trCtrl = new Element("tr", {"class" : CLASSES.showHiddenRows()});
- trCtrl.insert({"top" : new Element("td", {"class" : CLASSES.clickable()}).update("»")});
+ trCtrl.insert({"top" : new Element("td", {"class" : CLASSES.clickable()}).update("»")});
myself.__table__.insert({"top" : trCtrl});
trCtrl.hide();
trCtrl.observe("click", function(){
1
0
Author: lgiessmann
Date: Fri Jun 26 09:58:31 2009
New Revision: 71
Log:
ajax-client: fixed a bug with safari -> the commit button wasn't displayed by safari, this was caused by the attribute "margin: -21px;" currently the owner-div owns a "padding: 21px" attribute
Modified:
trunk/src/ajax/css/frame.css
trunk/src/ajax/css/main.css
trunk/src/ajax/javascripts/create.js
Modified: trunk/src/ajax/css/frame.css
==============================================================================
--- trunk/src/ajax/css/frame.css (original)
+++ trunk/src/ajax/css/frame.css Fri Jun 26 09:58:31 2009
@@ -37,6 +37,5 @@
}
input[value="commit fragment"] {
- margin-top: -20px;
float: right;
}
\ No newline at end of file
Modified: trunk/src/ajax/css/main.css
==============================================================================
--- trunk/src/ajax/css/main.css (original)
+++ trunk/src/ajax/css/main.css Fri Jun 26 09:58:31 2009
@@ -23,6 +23,7 @@
border-right: 1px solid #d1d1d3;
border-bottom: 1px solid #d1d1d3;
margin-top: -21px;
+ padding-bottom: 21px;
}
h1 {
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Fri Jun 26 09:58:31 2009
@@ -144,6 +144,7 @@
}
getTopicStubs(referencedTopics, onSuccessHandler, onErrorHandler);
});
+
var liCB = new Element("li", {"class" : CLASSES.commitButton()});
liCB.update(commitButton);
liTm.insert({"after" : liCB});
1
0

[isidorus-cvs] r70 - in trunk/src: ajax/javascripts json rest_interface
by Lukas Giessmann 26 Jun '09
by Lukas Giessmann 26 Jun '09
26 Jun '09
Author: lgiessmann
Date: Fri Jun 26 09:29:12 2009
New Revision: 70
Log:
ajax-client: fixed some bugs that were discovered by using opera; json-server: implemented a new json-handler, this handler returns a topic-psi-list of all valid topic-instances (valid: is oriented only on topic-typing and tmcl - all other constraints are not checked by the server)
Modified:
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/edit.js
trunk/src/ajax/javascripts/requests.js
trunk/src/json/json_tmcl.lisp
trunk/src/json/json_tmcl_validation.lisp
trunk/src/rest_interface/rest-interface.lisp
trunk/src/rest_interface/set-up-json-interface.lisp
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Fri Jun 26 09:29:12 2009
@@ -12,7 +12,7 @@
// --- Some constants fot the http connections via the XMLHttpRequest-Object
var TIMEOUT = 10000; // const TIMEOUT = 10000 --> "const" doesn't work under IE
-var HOST_PREF = "192.168.178.21/"; //"http://localhost:8000/";
+var HOST_PREF = "http://143.93.190.237:8000/"; //"http://localhost:8000/"; // of the form "http://(.+)/"
var GET_PREFIX = HOST_PREF + "json/get/";
var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/";
var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
@@ -20,6 +20,7 @@
var COMMIT_URL = HOST_PREF + "json/commit/";
var ALL_PSIS_URL = HOST_PREF + "json/psis/";
var TYPE_PSIS_URL = HOST_PREF + "json/tmcl/types/";
+var INSTANCE_PSIS_URL = HOST_PREF + "json/tmcl/instances/";
var OWN_URL = HOST_PREF + "isidorus";
var SUMMARY_URL = HOST_PREF + "json/summary"
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Fri Jun 26 09:29:12 2009
@@ -46,7 +46,7 @@
}
} //onSuccessHandler
- getPsis(onSuccessHandler, null, true);
+ getPsis(onSuccessHandler, null, {"types" : true});
}catch(err){
alert("From makeCreate(): " + err);
}
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Fri Jun 26 09:29:12 2009
@@ -20,7 +20,7 @@
this.__remove__ = new Element("span", {"class" : CLASSES.clickable()}).update("-");
this.__add__ = new Element("span", {"class" : CLASSES.clickable()}).update("+");
- checkRemoveAddButtons(owner, min, max);
+ checkRemoveAddButtons(owner, min, max, null);
this.__error__ = new Element("div", {"class" : CLASSES.error()});
this.__error__.hide();
@@ -32,7 +32,7 @@
this.__frame__.insert({"bottom" : this.__error__});
this.__disabled__ = false;
- setRemoveAddHandler(this, owner, min, max, function(){
+ setRemoveAddHandler(this, true, owner, min, max, function(){
return new FrameC("", owner, min, max);
});
},
@@ -102,9 +102,9 @@
}
this.__remove__.insert({"after" : this.__content__});
- checkRemoveAddButtons(owner, min, max);
+ checkRemoveAddButtons(owner, min, max, null);
var myself = this;
- setRemoveAddHandler(this, owner, min, max, function(){
+ setRemoveAddHandler(this, true, owner, min, max, function(){
return new TextrowC("", regexp, owner, min, max, cssTitle, dblClickHandler);
});
@@ -138,7 +138,7 @@
},
"enable" : function(){
this.__content__.removeAttribute("readonly");
- checkRemoveAddButtons(this.__owner__, this.__min__, this.__max__);
+ checkRemoveAddButtons(this.__owner__, this.__min__, this.__max__, null);
this.__disabled__ = false;
},
"getRegexp" : function(){
@@ -162,8 +162,8 @@
}
this.__remove__.insert({"after" : this.__content__});
- checkRemoveAddButtons(owner, min, max);
- setRemoveAddHandler(this, owner, min, max, function(){
+ checkRemoveAddButtons(owner, min, max, null);
+ setRemoveAddHandler(this, true, owner, min, max, function(){
return new SelectrowC(contents, owner, min, max);
});
},
@@ -1145,8 +1145,8 @@
// --- control row + itemIdentity
makeControlRow(this, 4, itemIdentityContent);
- checkRemoveAddButtons(owner, 1, -1);
- setRemoveAddHandler(this, owner, 1, -1, function(){
+ checkRemoveAddButtons(owner, 1, -1, null);
+ setRemoveAddHandler(this, true, owner, 1, -1, function(){
return new VariantC(null, owner, dblClickHandler, parent);
});
@@ -1336,6 +1336,7 @@
this.__max__ = max;
this.__owner__ = owner;
this.__dblClickHandler__ = dblClickHandler;
+ this.__constraint__ = simpleConstraint;
try{
var itemIdentityContent = null;
@@ -1353,8 +1354,8 @@
// --- control row + ItemIdentity
makeControlRow(this, 5, itemIdentityContent);
- checkRemoveAddButtons(owner, min, max);
- setRemoveAddHandler(this, owner, min, max, function(){
+ checkRemoveAddButtons(owner, min, max, this);
+ setRemoveAddHandler(this, this.__constraint__, owner, min, max, function(){
return new NameC(null, nametypescopes, simpleConstraint, owner, min, max, dblClickHandler);
});
@@ -1469,7 +1470,7 @@
this.getFrame().setStyle({"backgroundColor" : "inherit"});
this.getFrame().setStyle({"border" : "none"});
this.getFrame().removeAttribute("title");
- checkRemoveAddButtons(this.__owner__, 1, this.__max__);
+ checkRemoveAddButtons(this.__owner__, 1, this.__max__, this);
this.__disabled__ = false;
}});
@@ -1713,8 +1714,8 @@
// --- control row + itemIdentity
makeControlRow(this, 5, itemIdentityContent);
- checkRemoveAddButtons(owner, 1, max);
- setRemoveAddHandler(this, owner, 1, max, function(){
+ checkRemoveAddButtons(owner, 1, max, this);
+ setRemoveAddHandler(this, this.__constraint__, owner, 1, max, function(){
return new OccurrenceC(null, occurrenceTypes, constraint, uniqueConstraints, owner, min, max, cssTitle, dblClickHandler);
});
@@ -1848,7 +1849,7 @@
this.getFrame().setStyle({"backgroundColor" : "inherit"});
this.getFrame().setStyle({"border" : "none"});
this.getFrame().removeAttribute("title");
- checkRemoveAddButtons(this.__owner__, 1, this.__max__);
+ checkRemoveAddButtons(this.__owner__, 1, this.__max__, this);
this.__disabled__ = false;
}});
@@ -2275,12 +2276,13 @@
this.__owner__ = owner;
this.__typeMin__ = typeMin;
this.__parentElem__ = parent;
+ this.__constraint__ = true; // is needed for checkAddRemoveButtons
try{
// --- control row + itemIdentity
makeControlRow(this, 3, itemIdentities); // make control row have to be changed to a separate control row for roles
- checkRemoveAddButtons(owner, 1, -1);
- setRemoveAddHandler(this, owner, 1, -1, function(){ /*do nothing*/ });
+ checkRemoveAddButtons(owner, 1, -1, this);
+ setRemoveAddHandler(this, this.__constraint__, owner, 1, -1, function(){ /*do nothing*/ });
// --- gets the add and remove button
var cTd = this.__table__.select("tr." + CLASSES.itemIdentityFrame())[0].select("td." + CLASSES.controlColumn())[0].select("span." + CLASSES.clickable());
this.__removeButton__ = cTd[1];
@@ -2514,6 +2516,10 @@
}
},
"__orderContentsToRoles__" : function(contents, roleContainer, usedContents, alreadyUsedRoles){
+ if(!roleContainer || roleContainer.length === 0){
+ return {"usedContents" : usedContents, "contents" : contents, "alreadyUsedRoles" : alreadyUsedRoles};
+ }
+
for(var i = 0; i !== contents.length; ++i){
var rType = contents[i].type;
var player = contents[i].topicRef;
@@ -2819,7 +2825,7 @@
this.__makeRolesFromARC__(arc, foundRpcs);
}
// --- creates roles from otherrole-constraints
- for(var i = 0; i !== this.__arContainer__.__frames__.length; ++i){
+ for(var i = 0; this.__arContainer__.__frames__ && i !== this.__arContainer__.__frames__.length; ++i){
this.__makeRolesFromORC__(this.__arContainer__.__frames__[i].getType(), this.__arContainer__.__frames__[i].getPlayer());
}
},
@@ -3465,13 +3471,14 @@
// --- control row + ItemIdentity
makeControlRow(this, 4, itemIdentityContent);
- checkRemoveAddButtons(owner, 1, -1);
- setRemoveAddHandler(this, owner, 1, -1, function(){
+ checkRemoveAddButtons(owner, 1, -1, this);
+ setRemoveAddHandler(this, this.__constraints__, owner, 1, -1, function(){
return new AssociationC(null, constraints, owner);
});
// --- type
- var types = makeTypes(this, typeContent, constraints);
+ var types = makeTypes(this, typeContent, constraints);
+ if(types.flatten().length === 0 || types.flatten()[0].strip().length === 0 || !constraints || constraints.length === 0) this.hideAddButton();
// --- scopes
var currentConstraint = this.getCurrentConstraint();
@@ -3577,8 +3584,8 @@
this.__roles__.enable();
this.__type__.__frames__[0].enable();
this.__scope__.enable();
- if(this.__owner__.__frames__.length > 1) this.showRemoveButton();
- this.showAddButton();
+ if(this.__owner__.__frames__.length > 1 || !this.__constraints__ || this.__constraints__.length !== 0) this.showRemoveButton();
+ if(this.__constraints__ && this.__constraints__.length !== 0) this.showAddButton();
this.getFrame().setStyle({"backgroundColor" : "inherit"});
this.getFrame().setStyle({"border" : "none"});
this.__disabled__ = false;
@@ -3605,6 +3612,11 @@
tr.update(td);
this.__table__.insert({"bottom" : tr});
}
+ if(!constraints || constraints.length === 0){
+ for(var i = 0; i !== this.__container__.__frames__.length; ++i){
+ this.__container__.__frames__[i].hideAddButton();
+ }
+ }
if(!this.__container__.__frames__ && constraints && constraints.length !== 0){
var association = new AssociationC(null, constraints, this.__container__);
@@ -3773,7 +3785,7 @@
// --- Helper function for the constructors of all classes
// --- of the type FrameC.
// --- There will be set the remome and add handler.
-function setRemoveAddHandler(myself, owner, min, max, call)
+function setRemoveAddHandler(myself, constraint, owner, min, max, call)
{
myself.__remove__.stopObserving();
myself.__add__.stopObserving();
@@ -3783,12 +3795,12 @@
if(disabled === false){
myself.remove();
owner.__frames__ = owner.__frames__.without(myself);
- if(min >= owner.__frames__.length){
+ if(min >= owner.__frames__.length && constraint){
for(var i = 0; i != owner.__frames__.length; ++i){
owner.__frames__[i].hideRemoveButton();
}
}
- if(max > owner.__frames__.length){
+ if((max === -1 || max > owner.__frames__.length) && constraint){
for(var i = 0; i != owner.__frames__.length; ++i){
owner.__frames__[i].showAddButton();
}
@@ -3802,12 +3814,12 @@
if(disabled === false){
var newElem = call();
myself.append(newElem.getFrame());
- if(remove === true && min !== -1 && owner.__frames__.length > min){
+ if((remove === true && min !== -1 && owner.__frames__.length > min) || !constraint){
for(var i = 0; i != owner.__frames__.length; ++i){
owner.__frames__[i].showRemoveButton();
}
}
- if(max > -1 && max <= owner.__frames__.length){
+ if((max > -1 && max <= owner.__frames__.length) || !constraint){
for(var i = 0; i != owner.__frames__.length; ++i){
owner.__frames__[i].hideAddButton();
}
@@ -3818,30 +3830,33 @@
// --- Helper function for the constructors of all classes
-// --- of the type FrameC.
+// --- of the type FrameC and some of the type ContainerC.
// --- There will be checked the visibility of the remove and
// --- add buttons.
-function checkRemoveAddButtons(owner, min, max)
+function checkRemoveAddButtons(owner, min, max, myself)
{
- if(min >= owner.__frames__.length){
+ var constraint = true;
+ if(myself && !myself.__constraint__ && (!myself.__constraints__ || myself.__constraints__.length === 0)) constraint = false;
+
+ if(min >= owner.__frames__.length && constraint === true){
for(var i = 0; i != owner.__frames__.length; ++i){
owner.__frames__[i].hideRemoveButton();
}
}
- if(min > -1 && min < owner.__frames__.length){
+ if((min > -1 && min < owner.__frames__.length) || constraint === false){
for(var i = 0; i != owner.__frames__.length; ++i){
owner.__frames__[i].showRemoveButton();
}
}
- if(max > -1 && max <= owner.__frames__.length){
+ if((max > -1 && max <= owner.__frames__.length) || constraint === false){
for(var i = 0; i != owner.__frames__.length; ++i){
owner.__frames__[i].hideAddButton();
}
}
- if(max === -1 || max > owner.__frames__.length){
+ if((max === -1 || max > owner.__frames__.length) && constraint === true){
for(var i = 0; i != owner.__frames__.length; ++i){
owner.__frames__[i].showAddButton();
}
Modified: trunk/src/ajax/javascripts/edit.js
==============================================================================
--- trunk/src/ajax/javascripts/edit.js (original)
+++ trunk/src/ajax/javascripts/edit.js Fri Jun 26 09:29:12 2009
@@ -55,7 +55,7 @@
alert("There occurred an error by creating an EditC frame, please reload this page!\n\n" + err);
}
}
- getPsis(onSuccessHandler, null, false);
+ getPsis(onSuccessHandler, null, {"instances" : true});
}
catch(err){
alert("From makeEdit(): " + err);
Modified: trunk/src/ajax/javascripts/requests.js
==============================================================================
--- trunk/src/ajax/javascripts/requests.js (original)
+++ trunk/src/ajax/javascripts/requests.js Fri Jun 26 09:29:12 2009
@@ -83,7 +83,7 @@
// --- Gets all psis from the server. If typePsis is set to true
// --- there will be requested only TopicType's psis.
-function getPsis(onSuccessHandler, onFailureHandler, typePsis)
+function getPsis(onSuccessHandler, onFailureHandler, what)
{
try{
var onFailure = onFailureHandler ? onFailureHandler : defaultFailureHandler;
@@ -91,7 +91,9 @@
onLoad("Requesting all type PSIs");
var url = ALL_PSIS_URL;
- if(typePsis === true) url = TYPE_PSIS_URL;
+ if(what && what.types && what.types === true) url = TYPE_PSIS_URL;
+ else if(what && what.instances && what.instances === true) url = INSTANCE_PSIS_URL;
+ else if(what && what.all && what.all === true) url = ALL_PSIS_URL;
new Ajax.Request(url, {
"method" : "get",
Modified: trunk/src/json/json_tmcl.lisp
==============================================================================
--- trunk/src/json/json_tmcl.lisp (original)
+++ trunk/src/json/json_tmcl.lisp Fri Jun 26 09:29:12 2009
@@ -992,8 +992,7 @@
(remove-duplicates
(if (eql treat-as 'type)
(topictype-p topic-instance)
- (loop for topic in (union (get-direct-types-of-topic topic-instance) (get-direct-supertypes-of-topic topic-instance))
- append (topictype-p topic))))))
+ (valid-instance-p topic-instance)))))
(let ((all-abstract-topictype-constraints nil)
(all-exclusive-instance-constraints nil)
(all-subjectidentifier-constraints nil)
@@ -1104,8 +1103,7 @@
(remove-duplicates
(if (eql treat-as 'type)
(topictype-p topic-instance)
- (loop for topic in (union (get-direct-types-of-topic topic-instance) (get-direct-supertypes-of-topic topic-instance))
- append (topictype-p topic))))))
+ (valid-instance-p topic-instance)))))
(let ((all-available-associationtypes
(remove-duplicates
(loop for possible-player-topic in all-possible-player-topics
Modified: trunk/src/json/json_tmcl_validation.lisp
==============================================================================
--- trunk/src/json/json_tmcl_validation.lisp (original)
+++ trunk/src/json/json_tmcl_validation.lisp Fri Jun 26 09:29:12 2009
@@ -12,6 +12,7 @@
(:export :get-constraints-of-fragment
:topictype-p
:abstract-p
+ :valid-instance-p
:list-subtypes))
@@ -272,6 +273,64 @@
all-subtypes-of-all-instances)))))))
+(defun valid-instance-p (topic-instance &optional (akos-checked nil) (all-checked-topics nil))
+ "Returns a list of all checked topics or throws an exception if the given
+ topic is not a valid instance of any topictype in elephant."
+ (let ((isas-of-this
+ (get-direct-types-of-topic topic-instance))
+ (akos-of-this
+ (get-direct-supertypes-of-topic topic-instance))
+ (psi-of-this (uri (first (psis topic-instance))))
+ (topictype (d:get-item-by-psi json-tmcl-constants::*topictype-psi*))
+ (topictype-constraint (d:get-item-by-psi json-tmcl-constants::*topictype-constraint-psi*))
+ (local-all-checked-topics all-checked-topics)
+ (local-akos-checked))
+
+ (when (not topictype-constraint)
+ (return-from valid-instance-p topic-instance))
+
+ (when (and topictype-constraint
+ (not topictype))
+ (error (format nil "From valid-instance-p(): The topic \"~a\" does not exist - please create it or remove the topic \"~a\""
+ json-tmcl-constants::*topictype-psi* json-tmcl-constants::*topictype-constraint-psi*)))
+
+ (when (eql topic-instance topictype)
+ (return-from valid-instance-p (remove-duplicates (append all-checked-topics (list topic-instance)))))
+
+ (unless (or isas-of-this akos-of-this)
+ (error (format nil "The topic \"~a\" is not a valid topic-instance for any topic-type" psi-of-this)))
+
+ (when (find topic-instance akos-checked)
+ (return-from valid-instance-p all-checked-topics))
+
+ (pushnew topic-instance local-all-checked-topics)
+ (pushnew topic-instance local-akos-checked)
+
+ (dolist (isa isas-of-this)
+ (handler-case (let ((topics
+ (topictype-p isa topictype topictype-constraint)))
+ (dolist (top topics)
+ (pushnew top local-all-checked-topics)))
+ (condition (err) (error (format nil "The topic \"~a\" is not a valid topic-instance for any topic-type~%~%~a" psi-of-this err)))))
+
+ (dolist (ako akos-of-this)
+ (when (not (handler-case (let ((topics
+ (topictype-p ako topictype topictype-constraint all-checked-topics)))
+ (dolist (top topics)
+ (pushnew top local-all-checked-topics))
+ (pushnew ako local-akos-checked)
+ topics)
+ (condition () nil)))
+ (handler-case (let ((topics
+ (valid-instance-p ako akos-checked (append all-checked-topics (list ako)))))
+ (dolist (top topics)
+ (pushnew top local-all-checked-topics)
+ (pushnew top local-akos-checked))
+ topics)
+ (condition (err) (error (format nil "The topic \"~a\" is not a valid topic-instance for any topic-type~%~%~a" psi-of-this err))))))
+ local-all-checked-topics))
+
+
(defun return-all-tmcl-types ()
"Returns all topics that are valid tmcl-types"
(let ((all-topics
@@ -282,7 +341,7 @@
(remove-if #'null
(map 'list #'(lambda(x)
(handler-case (progn
- (json-tmcl::topictype-p x topictype topictype-constraint)
+ (topictype-p x topictype topictype-constraint)
x)
(condition () nil))) all-topics))))
(let ((not-abstract-types
@@ -291,4 +350,20 @@
(unless (json-tmcl:abstract-p x)
x))
all-types))))
- not-abstract-types))))
\ No newline at end of file
+ not-abstract-types))))
+
+
+(defun return-all-tmcl-instances ()
+ "Returns all topics that are valid instances of any topic type.
+ The validity is only oriented on the typing of topics, e.g.
+ type-instance or supertype-subtype."
+ (let ((all-topics
+ (elephant:get-instances-by-class 'd:TopicC)))
+ (let ((valid-instances
+ (remove-if #'null
+ (map 'list #'(lambda(x)
+ (handler-case (progn
+ (valid-instance-p x)
+ x)
+ (condition () nil))) all-topics))))
+ valid-instances)))
\ No newline at end of file
Modified: trunk/src/rest_interface/rest-interface.lisp
==============================================================================
--- trunk/src/rest_interface/rest-interface.lisp (original)
+++ trunk/src/rest_interface/rest-interface.lisp Fri Jun 26 09:29:12 2009
@@ -30,6 +30,7 @@
:*json-get-all-psis*
:*json-get-summary-prefix*
:*json-get-all-type-psis*
+ :*json-get-all-instance-psis*
:*json-get-topic-stub-prefix*
:*json-get-type-tmcl-prefix*
:*json-get-instance-tmcl-prefix*
Modified: trunk/src/rest_interface/set-up-json-interface.lisp
==============================================================================
--- trunk/src/rest_interface/set-up-json-interface.lisp (original)
+++ trunk/src/rest_interface/set-up-json-interface.lisp Fri Jun 26 09:29:12 2009
@@ -14,6 +14,7 @@
(defparameter *json-get-all-psis* "/json/psis/?$") ;the url to get all topic psis of isidorus -> localhost:8000/json/psis
(defparameter *json-get-summary-url* "/json/summary/?$") ;the url to get a summary of all topic stored in isidorus; you have to set the GET-parameter "start" for the start index of all topics within elephant and the GET-paramter "end" for the last index of the topic sequence -> http://localhost:8000/json/summary/?start=12&end=13
(defparameter *json-get-all-type-psis* "/json/tmcl/types/?$") ;returns a list of all psis that can be a type
+(defparameter *json-get-all-instance-psis* "/json/tmcl/instances/?$") ;returns a list of all psis that belongs to a valid topic-instance
(defparameter *json-get-topic-stub-prefix* "/json/topicstubs/(.+)$") ;the json prefix for getting some topic stub information of a topic
(defparameter *json-get-type-tmcl-url* "/json/tmcl/type/?$") ;the json url for getting some tmcl information of a topic treated as a type
(defparameter *json-get-instance-tmcl-url* "/json/tmcl/instance/?$") ;the json url for getting some tmcl information of a topic treated as an instance
@@ -29,6 +30,7 @@
(json-commit-url *json-commit-url*)
(json-get-summary-url *json-get-summary-url*)
(json-get-all-type-psis *json-get-all-type-psis*)
+ (json-get-all-instance-psis *json-get-all-instance-psis*)
(json-get-topic-stub-prefix *json-get-topic-stub-prefix*)
(json-get-type-tmcl-url *json-get-type-tmcl-url*)
(json-get-instance-tmcl-url *json-get-instance-tmcl-url*)
@@ -84,6 +86,9 @@
(create-regex-dispatcher json-get-all-type-psis #'return-all-tmcl-types)
hunchentoot:*dispatch-table*)
(push
+ (create-regex-dispatcher json-get-all-instance-psis #'return-all-tmcl-instances)
+ hunchentoot:*dispatch-table*)
+ (push
(create-regex-dispatcher json-get-type-tmcl-url #'(lambda(&optional param)
(declare (ignorable param))
(return-tmcl-info-of-psis 'json-tmcl::type)))
@@ -104,7 +109,7 @@
;; --- some handlers for the json-rest-interface -------------------------------
;; =============================================================================
(defun return-all-tmcl-types(&optional param)
- "Returns all topics that are valid types -> so they have to be valid to the
+ "Returns all topic-psi that are valid types -> so they have to be valid to the
topictype-constraint (if it exists) and the can't be abstract."
(declare (ignorable param))
(handler-case (let ((topic-types (json-tmcl::return-all-tmcl-types)))
@@ -118,6 +123,23 @@
(setf (hunchentoot:content-type*) "text")
(format nil "Condition: \"~a\"" err)))))
+(defun return-all-tmcl-instances(&optional param)
+ "Returns all topic-psis that are valid instances of any topic type.
+ The validity is only oriented on the typing of topics, e.g.
+ type-instance or supertype-subtype."
+ (declare (ignorable param))
+ (handler-case (let ((topic-instances (json-tmcl::return-all-tmcl-instances)))
+ (setf (hunchentoot:content-type*) "application/json") ;RFC 4627
+ (json:encode-json-to-string
+ (map 'list #'(lambda(y)
+ (map 'list #'uri y))
+ (map 'list #'psis topic-instances))))
+ (condition (err) (progn
+ (setf (hunchentoot:return-code*) hunchentoot:+http-internal-server-error+)
+ (setf (hunchentoot:content-type*) "text")
+ (format nil "Condition: \"~a\"" err)))))
+
+
(defun return-topic-stub-of-psi(&optional psi)
"Returns a json string of a topic depending on the
passed psi as a topic-stub-construct."
1
0

25 Jun '09
Author: lgiessmann
Date: Thu Jun 25 15:07:40 2009
New Revision: 69
Log:
ajax-client: fixed a bug by creating an association from existing contents. The problem occurred if there were more than one association type available and the existing content is not of the first type in the list - so there were used the constraints of the first type and not of the used type
Modified:
trunk/src/ajax/javascripts/datamodel.js
trunk/src/unit_tests/poems.xtm
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 15:07:40 2009
@@ -3442,7 +3442,6 @@
if(!owner) throw "From NameC(): owner must be set but is null";
if(!owner.__frames__) owner.__frames__ = new Array();
owner.__frames__.push(this);
-
this.__frame__.writeAttribute({"class" : CLASSES.associationFrame()});
this.__table__ = new Element("table", {"class" : CLASSES.associationFrame()});
this.__frame__.insert({"top" : this.__table__});
@@ -3451,7 +3450,7 @@
this.__constraints__ = constraints;
this.__owner__ = owner;
this.__dblClickHandler__ = dblClickHandlerF;
-
+
try{
var itemIdentityContent = null;
var typeContent = null;
@@ -3472,7 +3471,7 @@
});
// --- type
- var types = makeTypes(this, typeContent, constraints);
+ var types = makeTypes(this, typeContent, constraints);
// --- scopes
var currentConstraint = this.getCurrentConstraint();
@@ -3480,11 +3479,14 @@
this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())});
// --- roles
- var _roleConstraints = _playerConstraints = _otherRoleConstraints = null;
- if(this.__constraints__){
- _roleConstraints = this.__constraints__[0].associationRoleConstraints;
- _playerConstraints = this.__constraints__[0].rolePlayerConstraints;
- _otherRoleConstraints = this.__constraints__[0].otherRoleConstraints;
+ var _roleConstraints = null;
+ var _playerConstraints = null;
+ var _otherRoleConstraints = null;
+ var cc = this.getCurrentConstraint();
+ if(cc){
+ _roleConstraints = cc.associationRoleConstraints;
+ _playerConstraints = cc.rolePlayerConstraints;
+ _otherRoleConstraints = cc.otherRoleConstraints;
}
this.__roles__ = new RoleContainerC(rolesContent, _roleConstraints, _playerConstraints, _otherRoleConstraints, this);
@@ -3505,26 +3507,16 @@
}
},
"resetValues" : function(){
- // --- scope, depends only to the associationtype, roles can be ignored
- // --- finds the scopes depending to the selected type
- var foundIdx = -1;
- for(var i = 0; this.__constraints__ && i != this.__constraints__.length; ++i)
- {
- if(foundIdx !== -1) break;
- for(var j = 0; j != this.__constraints__[i].associationType.length; ++j){
- if(this.__type__.__frames__[0].getContent() === this.__constraints__[i].associationType[j]){
- foundIdx = i;
- break;
- }
- }
- }
- this.__scope__.resetValues(null, (foundIdx === -1 ? null : this.__constraints__[foundIdx].scopeConstraints));
+ var cc = this.getCurrentConstraint();
+ this.__scope__.resetValues(null, (cc ? cc.scopeConstraints : null));
- var _roleConstraints = _playerConstraints = _otherRoleConstraints = null;
- if(foundIdx !== -1){
- _roleConstraints = this.__constraints__[foundIdx].associationRoleConstraints;
- _playerConstraints = this.__constraints__[foundIdx].rolePlayerConstraints;
- _otherRoleConstraints = this.__constraints__[foundIdx].otherRoleConstraints;
+ var _roleConstraints = null;
+ var _playerConstraints = null;
+ var _otherRoleConstraints = null;
+ if(cc){
+ _roleConstraints = cc.associationRoleConstraints;
+ _playerConstraints = cc.rolePlayerConstraints;
+ _otherRoleConstraints = cc.otherRoleConstraints;
}
this.__roles__.resetValues(_roleConstraints, _playerConstraints, _otherRoleConstraints);
},
Modified: trunk/src/unit_tests/poems.xtm
==============================================================================
--- trunk/src/unit_tests/poems.xtm (original)
+++ trunk/src/unit_tests/poems.xtm Thu Jun 25 15:07:40 2009
@@ -1,5 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<tm:topicMap version="2.0" xmlns:tm="http://www.topicmaps.org/xtm/">
+ <!-- test: subtype for the roletype written -->
+ <tm:topic id="sub-written">
+ <tm:subjectIdentifier href="sub-written-psi"/>
+ </tm:topic>
+
+ <tm:association>
+ <tm:type><tm:topicRef href="#supertype-subtype"/></tm:type>
+ <tm:role>
+ <tm:type><tm:topicRef href="#subtype"/></tm:type>
+ <tm:topicRef href="#sub-written"/>
+ </tm:role>
+ <tm:role>
+ <tm:type><tm:topicRef href="#supertype"/></tm:type>
+ <tm:topicRef href="#written"/>
+ </tm:role>
+ </tm:association>
+
+ <!-- end test -->
+
+
<!-- test: defines some scopes constraints for associations of the type "born-in" -->
<tm:topic id="scoped-born-in-constraint-1">
<tm:subjectIdentifier href="http://some.where/constraint-psis/scoped-born-in-constraint-1"/>
@@ -637,6 +657,7 @@
<!-- available scopes -->
<tm:topic id="de">
<tm:subjectIdentifier href="http://some.where/base-psis/de"/>
+ <tm:subjectIdentifier href="http://some.where/base-psis/ger"/>
<tm:instanceOf><tm:topicRef href="#scopetype"/></tm:instanceOf>
</tm:topic>
@@ -924,7 +945,7 @@
</tm:occurrence>
<tm:occurrence>
<tm:type><tm:topicRef href="#card-max"/></tm:type>
- <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">2</tm:resourceData>
+ <tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#unsignedInt">1</tm:resourceData>
</tm:occurrence>
<tm:occurrence>
<tm:type><tm:topicRef href="#regexp"/></tm:type>
@@ -2474,6 +2495,7 @@
</tm:topic>
<tm:association>
+ <tm:itemIdentity href="born-in-frankfurt-goethe"/>
<tm:type><tm:topicRef href="#born-in"/></tm:type>
<tm:role>
<tm:type><tm:topicRef href="#place"/></tm:type>
@@ -2525,7 +2547,7 @@
</tm:name>
<tm:occurrence>
<tm:type><tm:topicRef href="#poem-content"/></tm:type> <!-- must have an occurrence of the type poem-content with the scope de or en -->
- <tm:scope><tm:topicRef href="#de"/></tm:scope>
+ <tm:scope><tm:topicRef href="#en"/></tm:scope>
<tm:resourceData datatype="http://www.w3.org/2001/XMLSchema#string">Hat der alte Hexenmeister
sich doch einmal wegbegeben!
Und nun sollen seine Geister
@@ -2693,7 +2715,9 @@
</tm:topic>
<tm:association>
+ <tm:itemIdentity href="wirtten-by-zauberlehrling-goethe"/>
<tm:type><tm:topicRef href="#written-by"/></tm:type>
+ <tm:scope><tm:topicRef href="#de"/></tm:scope>
<tm:role>
<tm:type><tm:topicRef href="#writer"/></tm:type>
<tm:topicRef href="#goethe"/>
@@ -2705,7 +2729,9 @@
</tm:association>
<tm:association>
+ <tm:itemIdentity href="wirtten-by-erlkoenig-goethe"/>
<tm:type><tm:topicRef href="#written-by"/></tm:type>
+ <tm:scope><tm:topicRef href="#de"/></tm:scope>
<tm:role>
<tm:type><tm:topicRef href="#writer"/></tm:type>
<tm:topicRef href="#goethe"/>
@@ -2849,12 +2875,16 @@
</tm:topic>
<tm:association>
- <tm:type><tm:topicRef href="#written-by"/></tm:type>
+ <tm:itemIdentity href="written-by-association-shiller-resignation"/>
+ <tm:type><tm:topicRef href="#place"/></tm:type>
+ <tm:scope><tm:topicRef href="#de"/></tm:scope>
<tm:role>
+ <tm:itemIdentity href="writer-role-schiller"/>
<tm:type><tm:topicRef href="#writer"/></tm:type>
<tm:topicRef href="#schiller"/>
</tm:role>
<tm:role>
+ <tm:itemIdentity href="written-role-resignation"/>
<tm:type><tm:topicRef href="#written"/></tm:type>
<tm:topicRef href="#resignation"/>
</tm:role>
@@ -2889,6 +2919,7 @@
<tm:association>
<tm:type><tm:topicRef href="#written-by"/></tm:type>
+ <tm:scope><tm:topicRef href="#de"/></tm:scope>
<tm:role>
<tm:type><tm:topicRef href="#writer"/></tm:type>
<tm:topicRef href="#eichendorff"/>
1
0

[isidorus-cvs] r68 - in trunk/src: ajax/javascripts json rest_interface
by Lukas Giessmann 25 Jun '09
by Lukas Giessmann 25 Jun '09
25 Jun '09
Author: lgiessmann
Date: Thu Jun 25 14:16:30 2009
New Revision: 68
Log:
ajax-client: fixed a general bug with optional occurrences, currently they are not disabled or minimized, when they own any content; fixed a bug with opera and textarea-values, currently there is used the method setValue instead of using update(<value>) - so in the browsers firefox, opera, safari there are no problems - therefore IE makes a lot of trouble\!
Modified:
trunk/src/ajax/javascripts/constants.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/json/json_tmcl_validation.lisp
trunk/src/rest_interface/set-up-json-interface.lisp
Modified: trunk/src/ajax/javascripts/constants.js
==============================================================================
--- trunk/src/ajax/javascripts/constants.js (original)
+++ trunk/src/ajax/javascripts/constants.js Thu Jun 25 14:16:30 2009
@@ -12,7 +12,7 @@
// --- Some constants fot the http connections via the XMLHttpRequest-Object
var TIMEOUT = 10000; // const TIMEOUT = 10000 --> "const" doesn't work under IE
-var HOST_PREF = "http://localhost:8000/";
+var HOST_PREF = "192.168.178.21/"; //"http://localhost:8000/";
var GET_PREFIX = HOST_PREF + "json/get/";
var GET_STUB_PREFIX = HOST_PREF + "json/topicstubs/";
var TMCL_TYPE_URL = HOST_PREF + "json/tmcl/type/";
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 14:16:30 2009
@@ -1913,9 +1913,11 @@
var _content = null;
if(_contents && _contents.length > k) _content = _contents[k];
var occurrence = new OccurrenceC(_content, constraints[i].occurrenceTypes, constraints[i].constraints[j], constraints[i].uniqueConstraints, this.__containers__[i][j], min === 0 ? 1 : min, max === MMAX_INT ? -1 : max, title, dblClickHandler);
- if(min === 0) occurrence.disable();
+ if(min === 0 && !_content){
+ occurrence.disable();
+ occurrence.minimize();
+ }
this.__error__.insert({"before" : occurrence.getFrame()});
- if(min === 0)occurrence.minimize();
}
}
}
@@ -2199,11 +2201,19 @@
else {
this.__topicid__.__frames__[0].hideError();
}
+ if(this.__subjectIdentifier__.getContent().length === 0){
+ ret = false;
+ this.showError("The topic must contain at least one SubjectIdentifier!<br/>If it is not possible to insert one - please create a subjectidentifier-constraint for this topic (-type)!");
+ }
+ else if(ret === true){
+ this.hideError();
+ }
if(this.__subjectLocator__.isValid() === false) ret = false;
if(this.__subjectIdentifier__.isValid() === false) ret = false;
if(this.__name__.isValid() === false) ret = false;
if(this.__occurrence__.isValid() === false) ret = false;
+
return ret;
},
"getReferencedTopics" : function(){
@@ -2488,8 +2498,8 @@
var RoleContainerC = Class.create(ContainerC, {"initialize" : function($super, contents, associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints, parent){
$super();
this.__frame__.writeAttribute({"class" : CLASSES.roleContainer()});
- this.__arContainer__ = new Object();
- this.__orContainer__ = new Object();
+ this.__arContainer__ = new Object(); this.__arContainer__.__frames__ = new Array();
+ this.__orContainer__ = new Object(); this.__orContainer__.__frames__ = new Array();
this.__associationRoleConstraints__ = associationRoleConstraints;
this.__otherRoleConstraints__ = otherRoleConstraints;
this.__rolePlayerConstraints__ = rolePlayerConstraints;
@@ -2567,7 +2577,7 @@
return {"usedContents" : usedContents, "contents" : contents, "alreadyUsedRoles" : alreadyUsedRoles};
},
"__createAdditionalRolesFromContents__" : function(contents,usedContents, alreadyUsedRoles, isARC){
- var roleContainer = this.__orContainer__.__frames__;
+ var roleContainer = this.__orContainer__.__frames__;
if(isARC === true) roleContainer = this.__arContainer__.__frames__;
if(roleContainer && roleContainer.length !== 0){
@@ -3972,8 +3982,7 @@
this.__datatype__.__frames__[0].remove();
this.__datatype__ = new Object();
}catch(err){}
-
- myself.__value__ = new Element("textarea", {"rows" : 3}).update(value);
+ myself.__value__ = new Element("textarea", {"rows" : 3}).setValue(value);
myself.__table__.insert({"bottom" : newRow(CLASSES.valueFrame(), "Resource Value", myself.__value__)});
if(cssTitle && cssTitle.length !== 0) myself.__value__.writeAttribute({"title" : cssTitle});
Modified: trunk/src/json/json_tmcl_validation.lisp
==============================================================================
--- trunk/src/json/json_tmcl_validation.lisp (original)
+++ trunk/src/json/json_tmcl_validation.lisp Thu Jun 25 14:16:30 2009
@@ -121,7 +121,7 @@
(not akos-are-topictype)
topictype-constraint)
;(return-from topictype-p nil))
- (error "~a is not a valid -- type for ~a" (uri (first (psis topic-instance))) (uri (first (psis topictype)))))
+ (error "~a is not a valid type for ~a" (uri (first (psis topic-instance))) (uri (first (psis topictype)))))
(loop for isa-of-this in isas-of-this
when (and (not (find isa-of-this current-checked-topics :test #'eq))
@@ -269,4 +269,26 @@
(topictype-of-p x nil)
x)
(condition () nil)))
- all-subtypes-of-all-instances)))))))
\ No newline at end of file
+ all-subtypes-of-all-instances)))))))
+
+
+(defun return-all-tmcl-types ()
+ "Returns all topics that are valid tmcl-types"
+ (let ((all-topics
+ (elephant:get-instances-by-class 'd:TopicC))
+ (topictype (get-item-by-psi json-tmcl-constants::*topictype-psi*))
+ (topictype-constraint (get-item-by-psi json-tmcl-constants::*topictype-constraint-psi*)))
+ (let ((all-types
+ (remove-if #'null
+ (map 'list #'(lambda(x)
+ (handler-case (progn
+ (json-tmcl::topictype-p x topictype topictype-constraint)
+ x)
+ (condition () nil))) all-topics))))
+ (let ((not-abstract-types
+ (remove-if #'null
+ (map 'list #'(lambda(x)
+ (unless (json-tmcl:abstract-p x)
+ x))
+ all-types))))
+ not-abstract-types))))
\ No newline at end of file
Modified: trunk/src/rest_interface/set-up-json-interface.lisp
==============================================================================
--- trunk/src/rest_interface/set-up-json-interface.lisp (original)
+++ trunk/src/rest_interface/set-up-json-interface.lisp Thu Jun 25 14:16:30 2009
@@ -107,28 +107,12 @@
"Returns all topics that are valid types -> so they have to be valid to the
topictype-constraint (if it exists) and the can't be abstract."
(declare (ignorable param))
- (handler-case (let ((all-topics
- (elephant:get-instances-by-class 'd:TopicC))
- (topictype (get-item-by-psi json-tmcl-constants::*topictype-psi*))
- (topictype-constraint (get-item-by-psi json-tmcl-constants::*topictype-constraint-psi*)))
- (let ((all-types
- (remove-if #'null
- (map 'list #'(lambda(x)
- (handler-case (progn
- (json-tmcl::topictype-p x topictype topictype-constraint)
- x)
- (condition () nil))) all-topics))))
- (let ((not-abstract-types
- (remove-if #'null
- (map 'list #'(lambda(x)
- (unless (json-tmcl:abstract-p x)
- x))
- all-types))))
- (setf (hunchentoot:content-type*) "application/json") ;RFC 4627
- (json:encode-json-to-string
- (map 'list #'(lambda(y)
- (map 'list #'uri y))
- (map 'list #'psis not-abstract-types))))))
+ (handler-case (let ((topic-types (json-tmcl::return-all-tmcl-types)))
+ (setf (hunchentoot:content-type*) "application/json") ;RFC 4627
+ (json:encode-json-to-string
+ (map 'list #'(lambda(y)
+ (map 'list #'uri y))
+ (map 'list #'psis topic-types))))
(condition (err) (progn
(setf (hunchentoot:return-code*) hunchentoot:+http-internal-server-error+)
(setf (hunchentoot:content-type*) "text")
1
0
Author: lgiessmann
Date: Thu Jun 25 08:58:36 2009
New Revision: 67
Log:
ajax-client: fixed a bug by committing edited fragments - so finally there are used the "real" instanceOf-elements and not the topic itself\!
Modified:
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
trunk/src/json/json_tmcl_validation.lisp
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Thu Jun 25 08:58:36 2009
@@ -70,6 +70,10 @@
for(var i = 0; psis && i !== psis.length; ++i){
instanceOfs.push(new Array(psis[i]));
}
+ if(contents) {
+ if(topicContent) instanceOfs = topicContent.instanceOfs;
+ else instanceOfs = new Array();
+ }
var topic = new TopicC(topicContent, (constraints ? constraints.topicConstraints : null), instanceOfs);
var liT = new Element("li", {"class" : CLASSES.topicFrame()}).update(topic.getFrame());
context.insert({"after" : liT});
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 08:58:36 2009
@@ -3465,7 +3465,8 @@
var types = makeTypes(this, typeContent, constraints);
// --- scopes
- this.__scope__ = new ScopeContainerC(scopesContent, this.__constraints__ && this.__constraints__[0].scopeConstraints ? this.__constraints__[0].scopeConstraints : null);
+ var currentConstraint = this.getCurrentConstraint();
+ this.__scope__ = new ScopeContainerC(scopesContent, currentConstraint && currentConstraint.scopeConstraints ? currentConstraint.scopeConstraints : null);
this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())});
// --- roles
@@ -3532,7 +3533,29 @@
",\"scopes\":" + this.__scope__.toJSON() +
",\"roles\":" + this.__roles__.toJSON() + "}";
},
+ "getCurrentConstraint" : function(){
+ if(!this.__constraints__ || this.__constraints__.length === 0) return null;
+ var currentConstraint = null;
+ for(var i = 0; i !== this.__constraints__.length; ++i){
+ var aType = this.__constraints__[i].associationType;
+ aType = aType.flatten();
+ if(aType.indexOf(this.__type__.__frames__[0].getContent()) !== -1){
+ currentConstraint = this.__constraints__[i];
+ break;
+ }
+ }
+
+ return currentConstraint;
+ },
"isValid" : function(){
+ if(!this.getCurrentConstraint()){
+ this.showError("No constraints found for this association!");
+ return false;
+ }
+ else {
+ this.hideError();
+ }
+
return this.__roles__.isValid() && this.__scope__.isValid();
},
"disable" : function(){
Modified: trunk/src/json/json_tmcl_validation.lisp
==============================================================================
--- trunk/src/json/json_tmcl_validation.lisp (original)
+++ trunk/src/json/json_tmcl_validation.lisp Thu Jun 25 08:58:36 2009
@@ -121,7 +121,7 @@
(not akos-are-topictype)
topictype-constraint)
;(return-from topictype-p nil))
- (error "~a is not a valid type for ~a" (uri (first (psis topic-instance))) (uri (first (psis topictype)))))
+ (error "~a is not a valid -- type for ~a" (uri (first (psis topic-instance))) (uri (first (psis topictype)))))
(loop for isa-of-this in isas-of-this
when (and (not (find isa-of-this current-checked-topics :test #'eq))
1
0
Author: lgiessmann
Date: Thu Jun 25 06:49:59 2009
New Revision: 66
Log:
ajax-client: fixed some bugs which occurs by validating scopes; now it is also possible to edit fragments (but not the instanceOf-element) and commit them if they are valid;
Modified:
trunk/src/ajax/javascripts/create.js
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/create.js
==============================================================================
--- trunk/src/ajax/javascripts/create.js (original)
+++ trunk/src/ajax/javascripts/create.js Thu Jun 25 06:49:59 2009
@@ -89,6 +89,14 @@
var tmId = new TmIdC(tmContent);
var liTm = new Element("li", {"class" : CLASSES.tmIdFrame()}).update(tmId.getFrame());
liA.insert({"after" : liTm});
+
+ // --- validates the data if there is any content
+ if(contents){
+ topic.isValid();
+ if(associations) associations.isValid();
+ tmId.isValid();
+ }
+
var commitButton = new Element("input", {"type" : "button", "value" : "commit fragment"})
commitButton.observe("click", function(event){
// --- validates the given data
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 06:49:59 2009
@@ -3294,9 +3294,6 @@
}
this.__disable__ = false;
},
- "scopeIsValid" : function(){
- return this.__scope__.isValid();
- },
"isValid" : function(){
var ret = true;
var errorStr = "";
@@ -3423,10 +3420,9 @@
}
}
- var scopeValid = this.scopeIsValid();
if(ret === false) this.showError(errorStr);
else this.hideError();
- return ret && scopeIsValid;
+ return ret;
}});
@@ -3537,7 +3533,7 @@
",\"roles\":" + this.__roles__.toJSON() + "}";
},
"isValid" : function(){
- return this.__roles__.isValid();
+ return this.__roles__.isValid() && this.__scope__.isValid();
},
"disable" : function(){
this.hideError();
1
0
Author: lgiessmann
Date: Thu Jun 25 06:23:01 2009
New Revision: 65
Log:
ajax-client: fixed a bug that occurs if an existing association(-type) doesn't match any constraint
Modified:
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 06:23:01 2009
@@ -2743,7 +2743,6 @@
this.__error__.insert({"before" : role.getFrame()})
}
role.hideAddButton();
-
}
},
"__createFromContent__" : function(contents){
@@ -4096,6 +4095,7 @@
function makeTypes(myself, typeContent, xtypescopes)
{
var types = new Array();
+ var matched = false;
for(var i = 0; xtypescopes && i !== xtypescopes.length; ++i){
var xtype = xtypescopes[i].nameType;
if(!xtype) xtype = xtypescopes[i].occurrenceType;
@@ -4104,11 +4104,14 @@
types.push(xtype[j]);
if(typeContent && typeContent[0] === xtype[j]){
var selected = xtype[j];
+ matched = true;
if(types.length !== 0) types[types.length - 1] = types[0];
types[0] = selected;
}
}
}
+ if(matched === false && typeContent && typeContent.length !== 0) types.unshift(typeContent);
+
if(types.length === 0 && typeContent && typeContent.length !== 0) types = typeContent;
if(!types || types.length === 0) types = new Array("");
myself.__type__ = new Object();
1
0
Author: lgiessmann
Date: Thu Jun 25 06:08:47 2009
New Revision: 64
Log:
ajax-client: currently all roles which exist in the json fragment will be displayed in the fragment template
Modified:
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 06:08:47 2009
@@ -2724,7 +2724,27 @@
"__createNewRolesFromContents__" : function(contents){
if(!contents || contents.length === 0) return;
- // TODO: implement
+ for(var i = 0; i !== contents.length; ++i){
+ var rType = contents[i].type;
+ if(!rType) rType = new Array("");
+ rType = new Array(rType);
+ var rPlayer = contents[i].topicRef;
+ if(!rPlayer) rPlayer = new Array("");
+ rPlayer = new Array(rPlayer);
+ var itemIdentities = contents[i].itemIdentities;
+
+ // itemIdentities, roleTypes, rolePlayers, owner, typeMin, parent){
+ var role = new RoleC(itemIdentities, rType, rPlayer, this.__arContainer__, 0, this.__parentElem__);
+ if(this.__arContainer__.__frames__ && this.__arContainer__.__frames__.length > 1){
+ var insertPoint = this.__arContainer__.__frames__[this.__arContainer__.__frames__.length - 2];
+ insertPoint.getFrame().insert({"after" : role.getFrame()});
+ }
+ else {
+ this.__error__.insert({"before" : role.getFrame()})
+ }
+ role.hideAddButton();
+
+ }
},
"__createFromContent__" : function(contents){
if(!contents || contents.lenght === 0) return;
1
0
Author: lgiessmann
Date: Thu Jun 25 05:25:49 2009
New Revision: 63
Log:
ajax-client: now all roles created from existing content, also display the existing itemIdentity-elements
Modified:
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 05:25:49 2009
@@ -2314,6 +2314,20 @@
alert("From RoleC(): " + err);
}
},
+ "addItemIdentities" : function(additionalItemIdentities){
+ if(!additionalItemIdentities || additionalItemIdentities.length === 0) return;
+
+ var con = this.getContent();
+ if(!con) con = new Array();
+ else con = con.itemIdentities;
+
+ con = con.concat(additionalItemIdentities);
+ var td = this.__itemIdentity__.getFrame().parentNode;
+ this.__itemIdentity__.remove();
+
+ this.__itemIdentity__ = new ItemIdentityC(con.uniq(), this);
+ td.update(this.__itemIdentity__.getFrame());
+ },
"selectPlayer" : function(playerPsi){
if(this.getPlayer() === playerPsi) return;
var opts = this.__player__.__frames__[0].getFrame().select("select")[0].select("option");
@@ -2493,6 +2507,7 @@
for(var i = 0; i !== contents.length; ++i){
var rType = contents[i].type;
var player = contents[i].topicRef;
+ var itemIdentities = contents[i].itemIdentities;
// --- searches existing roles in the role-container
for(var j = 0; j !== roleContainer.length; ++j){
@@ -2540,6 +2555,9 @@
// --- selects the current roletype
role.selectType(rType[0]);
+
+ // --- creates itemIdentities for the current role
+ role.addItemIdentities(itemIdentities);
break;
}
}
@@ -2553,9 +2571,11 @@
if(isARC === true) roleContainer = this.__arContainer__.__frames__;
if(roleContainer && roleContainer.length !== 0){
+ var currentUsedContents = new Array();
for(var i = 0; i !== contents.length; ++i){
var rType = contents[i].type;
var player = contents[i].topicRef;
+ var itemIdentities = contents[i].itemIdentities;
// --- gets all existing roles corresponding to the current content
var existingRoles = new Array();
@@ -2685,14 +2705,27 @@
this.__setORCAddHandler__(role, orc, orpcs);
this.__setORCRemoveHandler__(role, orc, orpcs);
}
+ // --- adds itemIdentities
+ role.addItemIdentities(itemIdentities);
var lastRole = roleContainer[roleContainer.length -2];
lastRole.getFrame().insert({"after" : role.getFrame()});
+ currentUsedContents.push(contents[i]);
}
- }
+ }
+
+ // --- removes all used contents from contents
+ if(!usedContents) usedContents = new Array();
+ usedContents = usedContents.concat(currentUsedContents).uniq();
+ for(var i = 0; i !== usedContents.length; ++i) contents = contents.without(usedContents[i]);
}
return {"usedContents" : usedContents, "contents" : contents, "alreadyUsedRoles" : alreadyUsedRoles};
},
+ "__createNewRolesFromContents__" : function(contents){
+ if(!contents || contents.length === 0) return;
+
+ // TODO: implement
+ },
"__createFromContent__" : function(contents){
if(!contents || contents.lenght === 0) return;
@@ -2724,7 +2757,7 @@
usedContents = ret.usedContents;
alreadyUsedRoles = ret.alreadyUsedRoles;
- // TODO: create roles that does not belong to any constraint
+ this.__createNewRolesFromContents__(cContents);
},
"resetValues" : function(associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints){
this.__associationRoleConstraints__ = associationRoleConstraints;
1
0
Author: lgiessmann
Date: Thu Jun 25 04:38:25 2009
New Revision: 62
Log:
ajax-cient: fixed a bug with remove-buttons in role-frames created from otherrole-constraints; added the functionality of creating role-frames from existing content - so there will be all existing roles selected as default-value - if there exist any constraints for the content
Modified:
trunk/src/ajax/javascripts/datamodel.js
trunk/src/ajax/javascripts/tmcl_tools.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Thu Jun 25 04:38:25 2009
@@ -2314,6 +2314,36 @@
alert("From RoleC(): " + err);
}
},
+ "selectPlayer" : function(playerPsi){
+ if(this.getPlayer() === playerPsi) return;
+ var opts = this.__player__.__frames__[0].getFrame().select("select")[0].select("option");
+ for(var i = 0; i !== opts.length; ++i){
+ if(opts[i].value !== playerPsi) opts[i].removeAttribute("selected");
+ else {
+ opts[i].writeAttribute({"selected" : "selected"});
+ this.__player__.__frames__[0].getFrame().select("select")[0].insert({"top" : opts[i]});
+ }
+ }
+ },
+ "selectType" : function(typePsi){
+ if(this.getType() === typePsi) return;
+ var opts = this.__type__.__frames__[0].getFrame().select("select")[0].select("option");
+ for(var i = 0; i !== opts.length; ++i){
+ if(opts[i].value !== typePsi) opts[i].removeAttribute("selected");
+ else {
+ opts[i].writeAttribute({"selected" : "selected"});
+ this.__type__.__frames__[0].getFrame().select("select")[0].insert({"top" : opts[i]});
+ }
+ }
+ },
+ "getAllPlayers" : function(){
+ if(!this.__rolePlayers__ || this.__rolePlayers__.length === 0) return new Array();
+ return this.__rolePlayers__.clone();
+ },
+ "getAllTypes" : function(){
+ if(!this.__roleTypes__ || this.__roleTypes__.length === 0) return new Array();
+ return this.__roleTypes__;
+ },
"setAddHandler" : function(handler){
if(!handler) return;
this.__addButton__.stopObserving();
@@ -2452,17 +2482,250 @@
this.__parentElem__ = parent;
try{
- if((!contents || contents.length === 0) && associationRoleConstraints){
- this.resetValues(associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints);
- }
- else {
- // TODO: check already existing contents and order them to the corresponding fields
- }
- }
+ this.resetValues(associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints, contents);
+ this.__createFromContent__(contents);
+ }
catch(err){
alert("From RoleContainerC(): " + err);
}
},
+ "__orderContentsToRoles__" : function(contents, roleContainer, usedContents, alreadyUsedRoles){
+ for(var i = 0; i !== contents.length; ++i){
+ var rType = contents[i].type;
+ var player = contents[i].topicRef;
+
+ // --- searches existing roles in the role-container
+ for(var j = 0; j !== roleContainer.length; ++j){
+ var role = roleContainer[j];
+ if(alreadyUsedRoles.indexOf(role) !== -1) continue;
+
+ var typesOfRole = role.getAllTypes().flatten();
+ var playersOfRole = role.getAllPlayers().flatten();
+ var iter = 0;
+ for( ; iter !== rType.length; ++iter){
+ if(typesOfRole.indexOf(rType[iter]) !== -1) break;
+ }
+ if(iter === rType.length) continue;
+ for(iter = 0; iter !== player.length; ++iter){
+ if(playersOfRole.indexOf(player[iter]) !== -1) break;
+ }
+ if(iter === player.length) continue;
+
+ alreadyUsedRoles.push(role);
+ usedContents.push(contents[i]);
+
+ // --- inserts the deselected player of all other roles of this type
+ var oldPlayer = new Array(role.getPlayer());
+ var _tmp = role.getAllPlayers();
+ for(var i = 0; i !== _tmp.length; ++i){
+ if(_tmp[i].indexOf(oldPlayer[0]) !== -1){
+ oldPlayer = _tmp[i];
+ break;
+ }
+ }
+
+ for(var k = 0; k !== roleContainer.length; ++k){
+ if(roleContainer[k] === role) continue;
+ roleContainer[k].addPlayer(oldPlayer);
+ }
+
+ // --- removes the current player from all other roles with this type
+ for(var k = 0; k !== roleContainer.length; ++k){
+ if(roleContainer[k] === role) continue;
+ roleContainer[k].removePlayer(player);
+ }
+
+ // --- selects the currentPlayer/type
+ role.selectPlayer(player[0]);
+
+ // --- selects the current roletype
+ role.selectType(rType[0]);
+ break;
+ }
+ }
+ // --- removes all used contents from contents
+ for(var i = 0; i !== usedContents.length; ++i) contents = contents.without(usedContents[i]);
+
+ return {"usedContents" : usedContents, "contents" : contents, "alreadyUsedRoles" : alreadyUsedRoles};
+ },
+ "__createAdditionalRolesFromContents__" : function(contents,usedContents, alreadyUsedRoles, isARC){
+ var roleContainer = this.__orContainer__.__frames__;
+ if(isARC === true) roleContainer = this.__arContainer__.__frames__;
+
+ if(roleContainer && roleContainer.length !== 0){
+ for(var i = 0; i !== contents.length; ++i){
+ var rType = contents[i].type;
+ var player = contents[i].topicRef;
+
+ // --- gets all existing roles corresponding to the current content
+ var existingRoles = new Array();
+ for(var j = 0; j !== roleContainer.length; ++j){
+ var iTypes = roleContainer[j].getAllTypes().flatten();
+ var iPlayers = roleContainer[j].getAllPlayers().flatten();
+ var iter = 0;
+ for( ; iter !== rType.length; ++iter) if(iTypes.indexOf(rType[iter]) !== -1) break;
+ if(iter === rType.length) continue;
+ for(iter = 0; iter !== player.length; ++iter) if(iPlayers.indexOf(player[iter]) !== -1) break;
+ if(iter === player.length) continue;
+
+ existingRoles.push(roleContainer[j]);
+ }
+
+ // --- collects the selected players
+ if(existingRoles && existingRoles.length > 0){
+ var selectedPlayers = new Array();
+ for(var j = 0; j !== existingRoles.length; ++j){
+ var _tmp = existingRoles[j].getAllPlayers();
+ for(var k = 0; k !== _tmp.length; ++k){
+ if(_tmp[k].indexOf(existingRoles[j].getPlayer()) !== -1){
+ selectedPlayers.push(_tmp[k]);
+ break;
+ }
+ }
+ }
+ selectedPlayers = selectedPlayers.flatten();
+ var allPlayers = existingRoles[0].getAllPlayers();
+ var playersToRemove = new Array();
+ for(var j = 0; j !== allPlayers.length; ++j){
+ for(var k = 0; k !== selectedPlayers.length; ++k){
+ if(allPlayers[j].indexOf(selectedPlayers[k]) !== -1){
+ playersToRemove.push(allPlayers[j]);
+ break;
+ }
+ }
+ }
+ for(var j = 0; j !== playersToRemove.length; ++j) allPlayers = allPlayers.without(playersToRemove[j]);
+ var newTypes = existingRoles[0].getAllTypes();
+ var min = 0;
+ var arc = null;
+ var orc = null;
+ if(isARC === true){
+ for(var j = 0; this.__associationRoleConstraints__ && j !== this.__associationRoleConstraints__.length; ++j){
+ if(arc) break;
+ var arcTypes = this.__associationRoleConstraints__[j].roleType;
+ if(arcTypes) arcTypes = arcTypes.flatten();
+ var nTs = newTypes.flatten();
+ for(var k = 0; k !== nTs.length; ++k){
+ if(arcTypes.indexOf(nTs[k]) !== -1){
+ arc = this.__associationRoleConstraints__[j];
+ min = parseInt(arc.cardMin);
+ break;
+ }
+ }
+ }
+ }
+ else {
+ for(var j = 0; this.__otherRoleConstraints__ && j !== this.__otherRoleConstraints__.length; ++j){
+ if(orc) break;
+ var oPlayers = this.__otherRoleConstraints__[j].otherPlayers;
+ if(oPlayers) oPlayers = oPlayers.flatten();
+ var oTypes = this.__otherRoleConstraints__[j].otherRoleType;
+ if(oTypes) oTypes = oTypes.flatten();
+
+ for(var k = 0; k !== rType.length; ++k){
+ if(orc) break;
+ if(oTypes.indexOf(rType[k]) !== -1){
+ for(var l = 0; l !== player.length; ++l){
+ if(oPlayers.indexOf(player[l]) !== -1){
+ orc = this.__otherRoleConstraints__[j];
+ min = parseInt(orc.cardMin);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ var role = null;
+ if(isARC === true) role = new RoleC(null, newTypes, allPlayers, this.__arContainer__, min, this.__parentElem__);
+ else role = new RoleC(null, newTypes, allPlayers, this.__orContainer__, min, this.__parentElem__);
+ for(var j = 0; j !== roleContainer.length; ++j){
+ if(roleContainer[j] !== role) roleContainer[j].removePlayer(player);
+ }
+ role.selectPlayer(player[0]);
+ role.selectType(rType[0]);
+
+ if(isARC === true){
+ var rpcs = getRolePlayerConstraintsForRole(newTypes, this.__rolePlayerConstraints__);
+ var allAvailablePlayers = extractPlayersOfConstraints(rpcs);
+ var allRolesToCheck = existingRoles;
+ allRolesToCheck.push(role);
+ this.__checkARCButtons__(allRolesToCheck, allAvailablePlayers, arc);
+ this.__setARCAddHandler__(role, allAvailablePlayers, arc);
+ this.__setARCRemoveHandler__(role, arc);
+ this.__setRoleChangePlayerHandler__(role, this.__arContainer__.__frames__, rpcs, null);
+ }
+ else {
+ var orpcs = new Array();
+ var ac = this.__arContainer__.__frames__;
+ for(var j = 0; ac && j !== ac.length; ++j){
+ var fType = new Array(ac[j].getType());
+ var fPlayer = new Array(ac[j].getPlayer());
+ orpcs = orpcs.concat(getOtherRoleConstraintsForRole(fType, fPlayer, this.__otherRoleConstraints__));
+ }
+ var _orpcs = new Array();
+ for(var j = 0; j !== orpcs.length; ++j){
+ var players = orpcs[j].otherPlayers;
+ if(players) players = players.flatten();
+ var types = orpcs[j].otherRoleType;
+ if(types) types = types.flatten();
+ if(!types || !players) continue;
+ for(var k = 0; k !== rType.length; ++k){
+ if(types.indexOf(rType[k]) !== -1){
+ for(var l = 0; l !== player.length; ++l){
+ if(players.indexOf(player[l]) !== -1) _orpcs.push(orpcs[j]);
+ }
+ }
+ }
+ }
+
+ orpcs = _orpcs.uniq();
+ this.__checkORCButtons__(role, orc);
+ this.__setRoleChangePlayerHandler__(role, this.__orContainer__.__frames__, null, orpcs);
+ this.__setORCAddHandler__(role, orc, orpcs);
+ this.__setORCRemoveHandler__(role, orc, orpcs);
+ }
+
+ var lastRole = roleContainer[roleContainer.length -2];
+ lastRole.getFrame().insert({"after" : role.getFrame()});
+ }
+ }
+ }
+ return {"usedContents" : usedContents, "contents" : contents, "alreadyUsedRoles" : alreadyUsedRoles};
+ },
+ "__createFromContent__" : function(contents){
+ if(!contents || contents.lenght === 0) return;
+
+ var cContents = contents;
+ var usedContents = new Array();
+ var alreadyUsedRoles = new Array();
+
+ // --- searches for associaitonrole-constraints and roleplayer-constraints
+ var ret = this.__orderContentsToRoles__(cContents, this.__arContainer__.__frames__, usedContents, alreadyUsedRoles);
+ cContents = ret.contents;
+ usedContents = ret.usedContents;
+ alreadyUsedRoles = ret.alreadyUsedRoles;
+
+ // --- searches for otherrole-constraints
+ ret = this.__orderContentsToRoles__(cContents, this.__orContainer__.__frames__, usedContents, alreadyUsedRoles);
+ cContents = ret.contents;
+ usedContents = ret.usedContents;
+ alreadyUsedRoles = ret.alreadyUsedRoles;
+
+ // --- creates additional roles (associationrole-constraints)
+ ret = this.__createAdditionalRolesFromContents__(cContents, usedContents, alreadyUsedRoles, true);
+ cContents = ret.contents;
+ usedContents = ret.usedContents;
+ alreadyUsedRoles = ret.alreadyUsedRoles;
+
+ // --- creates additional roles (associationrole-constraints)
+ ret = this.__createAdditionalRolesFromContents__(cContents, usedContents, alreadyUsedRoles, false);
+ cContents = ret.contents;
+ usedContents = ret.usedContents;
+ alreadyUsedRoles = ret.alreadyUsedRoles;
+
+ // TODO: create roles that does not belong to any constraint
+ },
"resetValues" : function(associationRoleConstraints, rolePlayerConstraints, otherRoleConstraints){
this.__associationRoleConstraints__ = associationRoleConstraints;
this.__rolePlayerConstraints__ = rolePlayerConstraints;
@@ -2488,7 +2751,6 @@
}
// --- creates all roles from existing associationroleconstraints and roleplayerConstraints
- // TODO: insert existing contents to the corresponding constraints
for(var i = 0; this.__associationRoleConstraints__ && i !== this.__associationRoleConstraints__.length; ++i){
var arc = this.__associationRoleConstraints__[i];
var foundRpcs = getRolePlayerConstraintsForRole(arc.roleType, this.__rolePlayerConstraints__);
@@ -2502,7 +2764,7 @@
"__makeRolesFromARC__" : function(associationRoleConstraint, rolePlayerConstraints){
if(!associationRoleConstraint || !rolePlayerConstraints || rolePlayerConstraints.length === 0) return;
checkCardinalitiesARC_RPC(associationRoleConstraint, rolePlayerConstraints);
-
+
// --- creates all roles with all needed players
var currentRoles = new Array();
var rolesCreated = 0;
@@ -2631,11 +2893,11 @@
}
// --- remove button
- if(cardMin > existingRoles.length){
- for(var i = 0; i !== existingRoles.length; ++i) existingRoles[i].showRemoveButton();
+ if(cardMin >= existingRoles.length){
+ for(var i = 0; i !== existingRoles.length; ++i) existingRoles[i].hideRemoveButton();
}
else {
- for(var i = 0; i !== existingRoles.length; ++i) existingRoles[i].hideRemoveButton();
+ for(var i = 0; i !== existingRoles.length; ++i) existingRoles[i].showRemoveButton();
}
},
"__checkARCButtons__" : function(rolesToCheck, players, associationRoleConstraint){
@@ -3143,8 +3405,7 @@
scopesContent = contents.scopes;
rolesContent = contents.roles;
}
-
-
+
// --- control row + ItemIdentity
makeControlRow(this, 4, itemIdentityContent);
checkRemoveAddButtons(owner, 1, -1);
Modified: trunk/src/ajax/javascripts/tmcl_tools.js
==============================================================================
--- trunk/src/ajax/javascripts/tmcl_tools.js (original)
+++ trunk/src/ajax/javascripts/tmcl_tools.js Thu Jun 25 04:38:25 2009
@@ -82,7 +82,7 @@
}
}
}
- return foundConstraints;
+ return foundConstraints.uniq();
}
1
0
Author: lgiessmann
Date: Wed Jun 24 03:35:51 2009
New Revision: 61
Log:
ajax-client: fixed a bug with scope-topics that occurs during the scope-selection with scope-topics that owns more than one psi
Modified:
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Wed Jun 24 03:35:51 2009
@@ -653,9 +653,9 @@
for(var j = 0; j != values.length; ++j){
if(values[j].indexOf(selectedItems[i]) !== -1){
for(var k = 0; k != values[j].length; ++k){
- select.insert({"bottom" : new Element("option", {"value" : values[j][k]}).update(values[j][k])});
- if(values[j][k] === selectedItems[i])select.writeAttribute({"selected" : "selected"});
- //values = values.without(values[j]);
+ var opt = new Element("option", {"value" : values[j][k]}).update(values[j][k]);
+ select.insert({"bottom" : opt});
+ if(values[j][k] === selectedItems[i]) opt.writeAttribute({"selected" : "selected"});
selectedIdx.push(j);
}
break;
@@ -931,6 +931,7 @@
this.__container__ = new Array();
this.resetValues(contents, constraints);
this.__constraints__ = constraints;
+
},
"resetValues" : function(contents, constraints){
try{
1
0
Author: lgiessmann
Date: Tue Jun 23 15:37:47 2009
New Revision: 60
Log:
ajax-client: fixed a lot of bugs in scope/type-handling; now also scopes will be validated and if there exist some scopes in the requested fragment these scopes will be used as default; currently it is possible to use one scope twice - if there are more scope-constraints with an intersection of scope-topics - this should be fixed anytime
Modified:
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Tue Jun 23 15:37:47 2009
@@ -930,6 +930,7 @@
this.__frame__.writeAttribute({"class" : CLASSES.scopeContainer()});
this.__container__ = new Array();
this.resetValues(contents, constraints);
+ this.__constraints__ = constraints;
},
"resetValues" : function(contents, constraints){
try{
@@ -942,6 +943,8 @@
this.__container__ = new Array();
}
+ this.__constraints__ = constraints;
+
// --- sets contents corresponding to the passed constraints
if(constraints && constraints.length){
var cContents = contents ? contents.clone() : null;
@@ -1010,10 +1013,81 @@
return false;
},
"isValid" : function(){
- for(var i = 0; i != this.__container__.length; ++i){
- if(this.__container__[i].isUsed() === true) return true;
+ var errorStr = "";
+ var ret = true;
+ var allContent = this.getContent();
+ if(!allContent) allContent = new Array();
+ var allFoundContent = new Array();
+ if(allContent) allContent = allContent.flatten();
+ if((!this.__constraints__ || this.__constraints__length === 0) && allContent.length !== 0){
+ this.showError("No constraints found for the existing scopes!");
+ return false;
}
- return false;
+ for(var i = 0; this.__constraints__ && i !== this.__constraints__.length; ++i){
+ var min = parseInt(this.__constraints__[i].cardMin);
+ var max = this.__constraints__[i].cardMax === MAX_INT ? MMAX_INT : parseInt(this.__constraints__[i].cardMax);
+ var scopes = this.__constraints__[i].scopeTypes;
+ if(scopes) scopes = scopes.flatten();
+ else scopes = new Array();
+
+ // --- checks all available types for the current constraint
+ var currentFoundContent = new Array();
+ for(var j = 0; j !== allContent.length; ++j){
+ if(scopes.indexOf(allContent[j]) !== -1){
+ currentFoundContent.push(allContent[j]);
+ allFoundContent.push(allContent[j]);
+ }
+ }
+ currentFoundContent = currentFoundContent.uniq();
+ allFoundContent = allFoundContent.uniq();
+
+ // --- find topics for the found psis
+ var foundScopes = 0;
+ var _scopes = this.__constraints__[i].scopeTypes;
+ for(var j = 0; _scopes && j !== _scopes.length; ++j){
+ for(var k = 0; k !== _scopes[j].length; ++k){
+ for(var l = 0; l !== currentFoundContent.length; ++l){
+ if(_scopes[j][k].indexOf(currentFoundContent[l]) !== -1){
+ ++foundScopes;
+ break;
+ }
+ }
+ }
+ }
+ // --- checks card-min/card-max
+ var scStr = "";
+ for(var j = 0; j !== scopes.length; ++j){
+ if(scopes[j].length !== 0) scStr += "<br/> *" + scopes[j];
+ }
+
+ if(min > foundScopes){
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-min(" + min + ") of the scope-constraint with the available scopes" + scStr + "<br/>is not satisfied(" + foundScopes + ")!"
+ ret = false;
+ }
+ if(max !== MMAX_INT && max < foundScopes){
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "card-max(" + max + ") of the scope-constraint with the available scopes" + scStr + "<br/>is not satisfied(" + foundScopes + ")!"
+ ret = false;
+ }
+ }
+
+ // --- removes all checked contents
+ for(var i = 0; i !== allFoundContent.length; ++i) allContent = allContent.without(allFoundContent[i]);
+ if(allContent && allContent.length !== 0){
+ allContent = allContent.flatten();
+ scStr = "";
+ for(var j = 0; j !== allContent.length; ++j){
+ if(allContent[j].length !== 0) scStr += "<br/> *" + allContent[j];
+ }
+ if(errorStr.length !== 0) errorStr += "<br/><br/>";
+ errorStr += "No constraint found for the scopes \"" + scStr + "\"!";
+ ret = false;
+ }
+
+ if(ret === true) this.hideError();
+ else if(errorStr.length !== 0)this.showError(errorStr);
+ return ret;
},
"getContent" : function(){
var values = new Array();
@@ -1022,16 +1096,19 @@
var cValues = this.__container__[i].getContent(true, true);
for(var j = 0; j != cValues.length; ++j){
if(values.indexOf(cValues[j]) !== -1) continue;
- values.push(cValues[j]);
+ values.push(cValues[j][0]);
}
}
}catch(err){
return new Array();
}
+ if(values.length === 0) return null;
+ values = values.uniq();
+ for(var i = 0; i !== values.length; ++i) values[i] = new Array(values[i]);
return values;
},
"toJSON" : function(){
- if(this.getContent().length === 0) return "null";
+ if(!this.getContent() || this.getContent().length === 0) return "null";
return this.getContent().toJSON();
},
"disable" : function(){
@@ -1356,7 +1433,11 @@
if(valueValid === false) this.showError("The name-value \"" + this.__value__.__frames__[0].getContent() + "\" doesn't matches the constraint \"" + this.__value__.__frames__[0].getRegexp() + "\"!");
else this.hideError();
var variantsValid = this.__variants__.isValid();
- return valueValid && variantsValid;
+ var scopeValid = this.scopeIsValid();
+ return valueValid && variantsValid && scopeValid;
+ },
+ "scopeIsValid" : function(){
+ return this.__scope__.isValid();
},
"minimize" : function(){
var trs = this.__table__.select("tr");
@@ -1537,6 +1618,7 @@
for(var j = 0; j !== this.__containers__[i].length; ++j){
for(var k = 0; k !== this.__containers__[i][j].__frames__.length; ++k){
this.__containers__[i][j].__frames__[k].hideError();
+ if(this.__containers__[i][j].__frames__[k].scopeIsValid() === false) ret = false;
if(this.__containers__[i][j].__frames__[k].isUsed() === true && this.__containers__[i][j].__frames__[k].isEmpty() === false){
allNames.push(this.__containers__[i][j].__frames__[k]);
}
@@ -1730,7 +1812,11 @@
var regexp = new RegExp(this.__constraint__.regexp);
// TODO: validate the data via the given datatype
// TODO: validate the uniqeuoccurrence-constraint
- return regexp.match(this.__value__.value);
+ var scopeValid = this.scopeIsValid();
+ return regexp.match(this.__value__.value) && scopeValid;
+ },
+ "scopeIsValid" : function(){
+ return this.__scope__.isValid();
},
"minimize" : function(){
var trs = this.__table__.select("tr");
@@ -1887,6 +1973,7 @@
allOccurrences.push(this.__containers__[i][j].__frames__[k]);
}
this.__containers__[i][j].__frames__[k].hideError();
+ if(this.__containers__[i][j].__frames__[k].scopeIsValid() === false) ret = false;
}
}
}
@@ -2892,6 +2979,9 @@
}
this.__disable__ = false;
},
+ "scopeIsValid" : function(){
+ return this.__scope__.isValid();
+ },
"isValid" : function(){
var ret = true;
var errorStr = "";
@@ -3018,10 +3108,10 @@
}
}
-
+ var scopeValid = this.scopeIsValid();
if(ret === false) this.showError(errorStr);
else this.hideError();
- return ret;
+ return ret && scopeIsValid;
}});
1
0
Author: lgiessmann
Date: Tue Jun 23 10:24:07 2009
New Revision: 59
Log:
ajax-client: added a onchange-handler for scope-frames
Modified:
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Tue Jun 23 10:24:07 2009
@@ -728,8 +728,77 @@
}
function changeHandler(event){
- alert("changed!");
- }
+ try{
+ var eventOwner = event.element();
+ var newValue = eventOwner.value;
+ var oldValue = null;
+ var allValues = new Array();
+ var allOpts = myself.getFrame().select("option");
+ var allOwnOpts = eventOwner.select("option");
+ for(var i = 0; i !== allOwnOpts.length; ++i) allOpts = allOpts.without(allOwnOpts[i]);
+
+ // --- collects all selected values
+ for(var i = 0; i !== allOpts.length; ++i) allValues.push(allOpts[i].value);
+ allValues = allValues.uniq();
+ var foundContent = new Array();
+ for(var i = 0; i !== allValues.length; ++i){
+ for(var j = 0; contents && j !== contents.length; ++j){
+ for(var k = 0; k !== contents[j].length; ++k){
+ if(contents[j][k].indexOf(allValues[i]) !== -1) foundContent.push(contents[j]);
+ if(contents[j][k].indexOf(newValue) !== -1) foundContent.push(contents[j]);
+ }
+ }
+ }
+ foundContent = foundContent.uniq();
+ // --- searches for the content to be removed from all other select elements
+ // --- and for the values to be inserted to all other elements
+ var contentToAdd = null;
+ var contentToRemove = null;
+ if(contents && contents.length !== 0){
+ for(var i = 0; i !== contents.length; ++i){
+ if(foundContent.indexOf(contents[i]) === -1) contentToAdd = contents[i];
+ if(!contentToRemove){
+ for(var j = 0; j !== contents[i].length; ++j){
+ if(contentToRemove) break;
+ for(var k = 0; k !== contents[i][j].length; ++k){
+ if(contents[i][j][k].indexOf(newValue) !== -1){
+ contentToRemove = contents[i];
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // --- iterates through all select elements and adds/removes the found values
+ var selects = myself.getFrame().select("select");
+ selects = selects.without(eventOwner);
+ if(contentToAdd) contentToAdd = contentToAdd.flatten();
+ if(contentToRemove) contentToRemove = contentToRemove.flatten();
+ for(var i = 0; i !== selects.length; ++i){
+ var opts = selects[i].select("option");
+ var val = selects[i].value;
+ for(var j = 0; j !== opts.length; ++j){
+ if(contentToRemove.indexOf(opts[j].value) !== -1) opts[j].remove();
+ }
+
+ if(contentToAdd){
+ var selectOpts = new Array();
+ for(var j = 0; j !== opts.length; ++j) selectOpts.push(opts[j].value);
+ var iter = 0;
+ for( ; iter !== contentToAdd.length; ++iter){
+ if(selectOpts.indexOf(contentToAdd[iter]) !== -1) break;
+ }
+ if(iter === contentToAdd.length){
+ for(var j = 0; j !== contentToAdd.length; ++j){
+ selects[i].insert({"bottom" : new Element("option", {"value" : contentToAdd[j]}).update(contentToAdd[j])});
+ }
+ }
+ }
+ }
+ }catch(err){ alert("ch: " + err);}
+ } // changeHandler
for(var i = 0; i != rows.length; ++i){
var selectE = rows[i].select("select");
1
0
Author: lgiessmann
Date: Tue Jun 23 09:19:45 2009
New Revision: 58
Log:
ajax-client: existing scopes can be inserted into existing constraint-frames
Modified:
trunk/src/ajax/javascripts/datamodel.js
Modified: trunk/src/ajax/javascripts/datamodel.js
==============================================================================
--- trunk/src/ajax/javascripts/datamodel.js (original)
+++ trunk/src/ajax/javascripts/datamodel.js Tue Jun 23 09:19:45 2009
@@ -586,16 +586,16 @@
// --- Represantation of a scope frame, doesn't contain SelectrowCs, because the values must be unique!
// --- So this class uses another implementation.
-var ScopeC = Class.create(ContainerC, {"initialize" : function($super, contents, min, max){
+var ScopeC = Class.create(ContainerC, {"initialize" : function($super, contents, selectedContents, min, max){
$super();
this.__frame__.writeAttribute({"class" : CLASSES.scopeFrame()});
this.__error__ = this.__error__.remove();
this.__container__ = null;
this.__contents__ = contents;
- this.resetRows(this.__contents__, min, max);
+ this.resetRows(this.__contents__, min, max, selectedContents);
},
- "resetRows" : function(contents, min, max){
+ "resetRows" : function(contents, min, max, selectedContents){
try{
for(var i = 0; i != this.__container__.__frames__.length; ++i){
this.__container__.__frames__[i].remove();
@@ -637,6 +637,7 @@
function checkValues(myself){
var rows = myself.getFrame().select("div");
var selectedItems = new Array();
+
// --- collects all old selected values and removes the elements
for(var i = 0; i != rows.length; ++i){
var selects = rows[i].select("select");
@@ -664,11 +665,11 @@
for(var k = 0; k != values.length; ++k){
if(selectedIdx.indexOf(k) === -1){
cleanedValues.push(values[k]);
- }
+ }
}
values = cleanedValues;
}
-
+
// --- if there is an empty value "" (if cardMin == 0), this value should be the last
// --- in the array (only when there is another value selected)
for(var h = 0; h != rows.length; ++h){
@@ -726,7 +727,12 @@
addHandlers(myself);
}
+ function changeHandler(event){
+ alert("changed!");
+ }
+
for(var i = 0; i != rows.length; ++i){
+ var selectE = rows[i].select("select");
var spans = rows[i].select("span." + CLASSES.clickable());
var removeS = null;
var addS = null;
@@ -762,21 +768,42 @@
rows[i].writeAttribute({"class" : CLASSES.selectrowWithoutRemoveButton()});
removeS.hide();
}
+ if(selectE.length !== 0){
+ selectE[0].stopObserving("change");
+ selectE[0].observe("change", changeHandler);
+ }
}
} // addHandlers
- for(var i = 0; i != (min === -1 ? 1 : min); ++i){
- var div = new Element("div", {"class" : CLASSES.selectrowWithoutRemoveButton()});
- var select = new Element("select");
- for(var j = 0; j != options.length; ++j){
- if(j === i || j > min){
- for(var k = 0; k != options[j].length; ++k){
- select.insert({"bottom" : new Element("option", {"value" : options[j][k]}).update(options[j][k])});
+
+ var endIdx = (min === -1 ? 1 : min);
+ if(selectedContents && selectedContents.length > endIdx) endIdx = selectedContents.length;
+ if(endIdx > options.length) throw "From ScopeC(): not enough scope-topics(" + options.length + ") to satisfie card-min(" + min + ")!";
+ for(var i = 0; i != endIdx; ++i){
+ var currentScope = null;
+ if(selectedContents && selectedContents.length > i) currentScope = selectedContents[i];
+ var currentOptions = options.clone();
+
+ var optionsToRemove = new Array();
+ for(var j = 0; selectedContents && j !== selectedContents.length; ++j){
+ for(var k = 0; k !== selectedContents[j].length; ++k){
+ for(var l = 0; l !== currentOptions.length; ++l){
+ if(currentOptions[l].indexOf(selectedContents[j][k]) !== -1) optionsToRemove.push(currentOptions[l]);
}
}
}
-
+ optionsToRemove = optionsToRemove.uniq();
+ for(var j = 0; j !== optionsToRemove.length; ++j) currentOptions = currentOptions.without(optionsToRemove[j]);
+ if(currentScope) currentOptions.unshift(currentScope);
+ var div = new Element("div", {"class" : CLASSES.selectrowWithoutRemoveButton()});
+ var select = new Element("select");
+ for(var j = 0; j != currentOptions.length; ++j){
+ for(var k = 0; k != currentOptions[j].length; ++k){
+ select.insert({"bottom" : new Element("option", {"value" : currentOptions[j][k]}).update(currentOptions[j][k])});
+ }
+ }
+
div.insert({"top" : select});
this.getFrame().insert({"bottom" : div});
addHandlers(this);
@@ -848,19 +875,58 @@
// --- sets contents corresponding to the passed constraints
if(constraints && constraints.length){
+ var cContents = contents ? contents.clone() : null;
+ var foundContents = new Array();
for(var i = 0; i != constraints.length; ++i){
var scopeTypes = constraints[i].scopeTypes;
var min = parseInt(constraints[i].cardMin);
var max = constraints[i].cardMax !== MAX_INT ? parseInt(constraints[i].cardMax) : MMAX_INT;
- // TODO: check and adds contents to the types
-
- // --- if min === 0 && there is no content, adds an empty option
- if(min === 0){ // TODO: check contents of this type
+ // --- checks already existing scopes with the given scope-constraints
+ var currentFoundContents = new Array();
+ if(cContents && cContents.length !== 0){
+ var allCurrentTypes = scopeTypes ? scopeTypes.flatten() : new Array();
+ for(var j = 0; j !== cContents.length; ++j){
+ for(var k = 0; k !== allCurrentTypes.length; ++k){
+ if(cContents[j].indexOf(allCurrentTypes[k]) !== -1){
+ foundContents.push(cContents[j]);
+ currentFoundContents.push(cContents[j]);
+ break;
+ }
+ }
+ }
+ foundContents = foundContents.uniq();
+ }
+
+ // --- if min === 0 adds an empty option
+ if(min === 0){
scopeTypes.unshift(new Array(new Array(""))); // [[""]]
}
- this.__container__.push(new ScopeC(scopeTypes, min === 0 ? 1 : min, max === MMAX_INT ? -1 : max));
- this.__error__.insert({"before" : this.__container__[this.__container__.length - 1].getFrame()});
+
+ var scp = new ScopeC(scopeTypes, currentFoundContents, min === 0 ? 1 : min, max === MMAX_INT ? -1 : max);
+ this.__container__.push(scp);
+ this.__error__.insert({"before" : scp.getFrame()});
+ }
+
+ // --- removes contents that are already used
+ if(cContents && cContents.length !== 0){
+ for(var i = 0; i !== foundContents.length; ++i) cContents = cContents.without(foundContents[i]);
+
+ // --- inserts all contents that doesn't correspond with any constraint
+ for(var i = 0; i !== cContents.length; ++i) cContents[i] = new Array(cContents[i]);
+ var cmax = cContents.length;
+ for(var i = 0; i !== cContents.length; ++i){
+ var scp = new ScopeC(new Array(cContents[i]), null, 1, 1);
+ this.__container__.push(scp);
+ this.__error__.insert({"before" : scp.getFrame()});
+ }
+ }
+ }
+ else if(contents && contents.length){
+ for(var i = 0; i !== contents.length; ++i){
+ var scp = new ScopeC(new Array(new Array(contents[i])), null, 1, 1);
+ this.__container__.push(scp);
+ this.__error__.insert({"before" : scp.getFrame()});
}
}
else {
@@ -1504,7 +1570,24 @@
var types = makeTypes(this, typeContent, occurrenceTypes);
// --- scopes
- this.__scope__ = new ScopeContainerC(scopesContent, occurrenceTypes && occurrenceTypes[0].scopeConstraints ? occurrenceTypes[0].scopeConstraints : null);
+ var scopes = null;
+ if(contents){
+ if(typeContent){
+ for(var i = 0; occurrenceTypes && i !== occurrenceTypes.length; ++i){
+ if(scopes) break;
+ for(var j = 0; j !== occurrenceTypes[i].occurrenceType.length; ++j){
+ if(typeContent.indexOf(occurrenceTypes[i].occurrenceType[j]) !== -1){
+ scopes = occurrenceTypes[i].scopeConstraints;
+ break;
+ }
+ }
+ }
+ }
+ }
+ else if(occurrenceTypes && occurrenceTypes[0].scopeConstraints){
+ scopes = occurrenceTypes[0].scopeConstraints;
+ }
+ this.__scope__ = new ScopeContainerC(scopesContent, scopes);
this.__table__.insert({"bottom" : newRow(CLASSES.scopeContainer(), "Scope", this.__scope__.getFrame())});
onTypeChangeScope(this, contents && contents.scopes ? contents.scopes : null, occurrenceTypes, "occurrence");
@@ -1663,7 +1746,7 @@
break;
}
}
- var endIdx = min;
+ var endIdx = (min === 0 ? 1 : min);
endIdx = _contents && _contents.length > endIdx ? _contents.length : endIdx;
var regexp = constraints[i].constraints[j].regexp;
if(max !== 0 || (_contents && contents.length)){
1
0