Created
October 20, 2012 13:43
-
-
Save jophof/3923305 to your computer and use it in GitHub Desktop.
OM code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<meta http-equiv="Pragma" content="no-cache"> | |
<title>Entityviewer YUI</title> | |
<head> | |
<!-- | |
* Open Modeling Environment | |
* Copyright (C) 2012 Open Modeling Foundation | |
* | |
* This library is free software; you can redistribute it and/or | |
* modify it under the terms of the GNU General Public License | |
* as published by the Free Software Foundation; either version 2 | |
* of the License, or (at your option) any later version. | |
* | |
* This library is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
* General Public License for more details. | |
* | |
* The full license is located at the root of this distribution | |
* in the LICENSE file. | |
--> | |
<!-- Individual YUI CSS files --> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/paginator/assets/skins/sam/paginator.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/menu/assets/skins/sam/menu.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/calendar/assets/skins/sam/calendar.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/logger/assets/skins/sam/logger.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/menu/assets/skins/sam/menu.css"> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/fonts/fonts-min.css" > | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js" > | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/calendar/calendar-min.js" > | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/button/assets/skins/sam/button.css" /> | |
<link rel="stylesheet" type="text/css" href="../include/yui_2.9.0/build/container/assets/skins/sam/container.css" /> | |
<link rel="stylesheet" type="text/css" href="../style/buttonbar.css"> | |
<link rel="stylesheet" type="text/css" href="../style/yui_multipledates_onapage.css"/> | |
<style type="text/css"> | |
/*margin and padding on body element | |
can introduce errors in determining | |
element position and are not recommended; | |
we turn them off as a foundation for YUI | |
CSS treatments. */ | |
body { | |
margin:0; | |
padding:0; | |
} | |
.loading { | |
position:relative; | |
float:left; | |
display:block; | |
clear:both; | |
font-style:italic; | |
padding:4px; | |
} | |
.custom-class { | |
opacity: 0.6;filter:alpha(opacity=60); | |
color:blue; | |
border: 2px solid gray; | |
} | |
#datatable tr { | |
cursor: pointer; | |
} | |
#entitymessage { | |
float:left; | |
margin-top:1em; | |
display:block; | |
cursor:default; | |
font-family:Verdana, Arial, Helvetica, sans-serif; | |
font-size:0.78em; | |
width:100%; | |
color:red; | |
} | |
#viewerdata { | |
position:relative; | |
margin-top:1em; | |
display:block; | |
cursor:default; | |
font-family:Verdana, Arial, Helvetica, sans-serif; | |
font-size:1em; | |
left:2em; | |
} | |
#dragentityviewer { | |
position:relative; | |
float:left; | |
margin-top:1em; | |
display:block; | |
cursor:default; | |
font-family:Verdana, Arial, Helvetica, sans-serif; | |
font-size:1em; | |
} | |
#searchfilterarea { | |
position:relative; | |
clear:both; | |
float:left; | |
overflow-x:hidden; | |
} | |
.entitytypedescription { | |
position:relative; | |
float:left; | |
left:2em; | |
text-align:left; | |
border:#000000 solid 1px; | |
background-color:#F0C080; | |
margin-top:1em; | |
margin-right:4em; | |
padding:4px; | |
width:80%; | |
display:none; | |
} | |
.entitytypedescriptiontext { | |
position:relative; | |
left:2em; | |
float:left; | |
display:block; | |
cursor:default; | |
font-family:Verdana, Arial, Helvetica, sans-serif; | |
font-size:0.78em; | |
width:100%; | |
} | |
.actionpaneinputtext { | |
position:relative; | |
float:left; | |
left:0.1em; | |
overflow:hidden; | |
margin-top:0.3em; | |
padding:0; | |
font-size:1em; | |
border:1px solid threedlightshadow; | |
} | |
#quick-edit-controls { | |
display: none; | |
} | |
#caption { | |
position:relative; | |
float:left; | |
} | |
#entityviewer { | |
position:relative; | |
float:left; | |
} | |
</style> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/yahoo/yahoo.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/dom/dom.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/event/event.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/event-mouseenter/event-mouseenter.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/selector/selector.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/event-delegate/event-delegate.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/element/element.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/button/button.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/connection/connection.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/datasource/datasource.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/calendar/calendar.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/dragdrop/dragdrop.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/paginator/paginator.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/datatable/datatable.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/container/container_core.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/menu/menu.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/animation/animation.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/logger/logger.js"></script> | |
<script type="text/javascript" src="../include/yui_2.9.0/build/container/container-min.js"></script> | |
<script src="../include/yui_multipledates_onapage.js"></script> | |
<script src="../include/clientsniffer.js"></script> | |
<script src="../include/debug.js"></script> | |
<script src="../include/parsexml.js"></script> | |
<script src="../include/session2client.js"></script> | |
<script src="../include/clkeyunderscore.js"></script> | |
<script src="../include/xmlescape.js"></script> | |
<script src="../include/error.js"></script> | |
<script src="../include/util.js"></script> | |
<script src="../include/querystring.js"></script> | |
<script src="../include/clbuttonbar.js"></script> | |
<script> | |
function getinnertext (oelem) { | |
var s = "", onode; | |
for (var i=0;i<oelem.childNodes.length;i++) { | |
onode = oelem.childNodes[i]; | |
if (onode.nodeType == 3) | |
s += trim(onode.nodeValue); | |
else if (onode.nodeType == 1) | |
s += " " + trim(getinnertext (onode)); | |
} | |
return ( s ); | |
} | |
function hideshowdescription () { | |
var oel = document.getElementById ("opencloseddescription"), csource; | |
if (oel) csource = oel.src; | |
if (oel && csource.indexOf ("_open.gif") != -1) { // now we hide text | |
oel.src="../images/menu_folder_closed.gif"; | |
oel = document.getElementById ("entitytypedescription"); | |
if (oel) oel.style.display = "none"; | |
} else if (oel && csource.indexOf ("_closed.gif") != -1) { | |
oel.src="../images/menu_folder_open.gif"; | |
oel = document.getElementById ("entitytypedescription"); | |
if (oel) oel.style.display = "block"; | |
} | |
} | |
sessionparse(); | |
var clanguage = session ( "language" ); | |
//Metamodel doesn't support all languages | |
if ( querystring ( "meta" ) == "1" && ( clanguage == "1" || clanguage == "2" ) ) clanguage = "4"; | |
loadservermessages ( 1, clanguage ); | |
ccolheader = showmessage (473); | |
//create namespace: | |
YAHOO.namespace("openmodeling.widget"); | |
YAHOO.openmodeling.widget.Data = { | |
entities: [] | |
} | |
//YAHOO.openmodeling.widget.Data.entities = oentities; | |
YAHOO.openmodeling.widget.DataView = function(elContainer, oColumnSet, oDataSource, oConfigs) { | |
if (arguments.length > 0) { | |
YAHOO.openmodeling.widget.DataView.superclass.constructor.call (this, elContainer , oColumnSet , oDataSource , oConfigs); | |
} | |
//Call ContextMenu initialization method | |
this._initHideMenu (oColumnSet); | |
}; | |
// inherit form YAHOO.widget.DataTable | |
YAHOO.lang.extend ( YAHOO.openmodeling.widget.DataView, YAHOO.widget.DataTable); | |
YAHOO.openmodeling.widget.DataView.prototype._initHideMenu = function(oColumnSet) { | |
keys = oColumnSet.keys; | |
oColumnSet = this._oColumnSet, | |
_hideCol = [], | |
this.aColState=[]; | |
for (var i=0; i<keys.length;i++) { | |
if(keys[i].hideable) { | |
itemText = keys[i].text || keys[i].key; | |
_hideCol.push({text:itemText,checked:true, colNum:i}) | |
} | |
this.aColState[i]=0; | |
} | |
if (_hideCol.length>0) { | |
var oContextMenu = new YAHOO.widget.ContextMenu("hideMenu", { trigger: this.getHead() } ); | |
// Define the items for the menu | |
var aMenuItemData =_hideCol | |
var nMenuItems = aMenuItemData.length; | |
var oMenuItem; | |
for(var i=0; i<nMenuItems; i++) { | |
var item= aMenuItemData[i] | |
oMenuItem = oContextMenu.addItem(item); | |
oMenuItem.clickEvent.subscribe(this.onhideMenuClick, [oMenuItem,item.colNum],this); | |
} | |
oContextMenu.render(document.body); | |
} | |
}; | |
YAHOO.openmodeling.widget.Entityviewer = function() { | |
// Custom sort handler to sort by state and then by areacode | |
// where a and b are Record instances to compare | |
var Dom = YAHOO.util.Dom, | |
Event = YAHOO.util.Event, | |
DDM = YAHOO.util.DragDropMgr, | |
oentry, | |
myDTDTargets = {}; | |
this.url = querystring.value; | |
this.mydata = []; | |
this.maxrelation = parseInt ( session ("maxrelation") ); | |
this.mode = ""; | |
this.level = "../"; | |
this.searchpossible = true; | |
this.filterpossible = true; | |
this.printpossible = true; | |
this.settings = function ( cmeta, cmodel, cmmodel, centitytype, ccode, cins, cupd, cdel, cnrofpkeys, cnt ) { | |
this.level = "../"; | |
this.title = showmessage ( 304 ); // Entities | |
this.meta = cmeta; | |
this.model = cmodel; | |
this.mmodel = cmmodel; | |
this.language = session ( "language" ); | |
this.entitytype = centitytype; | |
this.code = ccode; | |
this.addpossible = ( cins == "Yes" ); | |
this.editpossible = ( cupd == "Yes" ); | |
this.deletepossible = ( cdel == "Yes" ); | |
this.nrofpkeys = parseInt ( cnrofpkeys ); | |
this.set = false; | |
if ( cnt == null ) this.cnt = ""; else this.cnt = cnt; | |
}, | |
this.setmode = function ( cmode) { | |
this.mode = cmode; | |
}, | |
this.xmlparse = function ( curl ) { | |
sessionparse (); | |
var oparsed = parsexmluri ( curl ); | |
if (oparsed [1]) { | |
alert ( showmessage ( 1, cerr ) ); | |
} else { | |
xmldoc = oparsed [0]; | |
this.xmldoc = xmldoc; | |
x = xmldoc.getElementsByTagName ("error"); | |
if (x[0]) { | |
displayerror(x[0]); | |
} else { | |
this.getheader (); | |
} | |
} | |
}, // xmlparse | |
this.getdescription = function () { | |
var curl, oexplanation, odescription, oel, cexplanation = ""; | |
var onode, osubnode, osubsubnode; | |
if (this.meta == "0") { | |
curl = this.level + "modelview/getentitydescription.jsp?mmodel=" + this.mmodel + "&entity=" + this.entitytype + "&language=" + this.language; | |
} else { | |
curl = this.level + "modelview/getmetaentitydescription.jsp?entity=" + this.entitytype + "&language=" + this.language; | |
} | |
var xmldoc, oparsed = parsexmluri (curl), cexplanation; | |
// replace the XML data with layout and content. | |
if (oparsed [1] ) { | |
alert ( showmessage ( 1, oparsed[1] ) ); | |
} else { | |
xmldoc = oparsed [0]; | |
oexplanation = xmldoc.getElementsByTagName ("info"); | |
if (oexplanation.length > 0) { | |
cexplanation = glxmlprocessexplanation ( oexplanation[0] ); | |
odescription = document.createElement ("div"); | |
odescription.innerHTML = "<p>" + cexplanation + "</p>"; | |
cexplanation = getinnertext ( odescription.firstChild ); | |
odescription = null; | |
oel = document.getElementById ("entitytypedescription"); | |
if (cexplanation != "" && cexplanation != " ") { | |
oel.style.display = "block"; | |
oel.innerHTML = cexplanation; | |
if ( cexplanation != "" ) oel.innerHTML = "<div class=\"entitytypedescriptiontext\">" + cexplanation +"</div>"; | |
} else { | |
oel = document.getElementById ("opencloseddescription"); | |
oel.style.display = "none"; | |
} | |
} | |
} | |
}, | |
/* | |
* Process heading tag | |
*/ | |
this.getheader = function () { | |
var ocolumn, ocount; | |
var ochilds, ocolumntag, cdateformat; | |
var cname, ctype, nmaxrelation, nlen; | |
var ocolumnsxml = this.xmldoc.getElementsByTagName ("heading")[0]; | |
if ( ocolumnsxml != null ) { | |
ochilds = ocolumnsxml.childNodes; | |
for (var j=0,nlenchild=ochilds.length;j<nlenchild;j++) { | |
ocolumntag = ochilds [j]; | |
switch (ocolumntag.tagName) { | |
case "header" : { | |
cname = ocolumntag.firstChild.nodeValue; | |
if (oentry) this.myColumnDefs.push (oentry); | |
oentry = new Object(); | |
oentry.key = replacespacebyunderscore (cname); | |
oentry.label = cname | |
oentry.width = 250; | |
oentry.resizeable = true; | |
oentry.sortable = true; | |
break; | |
} | |
case "id" : { | |
oentry.databaseid = ocolumntag.firstChild.nodeValue; | |
break; | |
} | |
case "length" : { | |
if ( ocolumntag.firstChild ) { | |
nlen = parseFloat ( ocolumntag.firstChild.nodeValue ); | |
if (nlen == 1) { | |
oentry.width = 100; | |
} else { | |
oentry.width = nlen * 3.9; | |
} | |
} | |
break; | |
} | |
case "dateformat" : { | |
if (ocolumntag.firstChild) { | |
oentry.dateformat = ocolumntag.firstChild.nodeValue; | |
oentry.width = 210; | |
} | |
break; | |
} | |
case "type" : { | |
ctype = ocolumntag.firstChild.nodeValue; | |
oentry.type = ctype; | |
if ( ctype == "Single" || ctype == "Numeric") oentry.width = 185; | |
break; | |
} | |
} | |
} | |
// provide column headers | |
var ocount = this.xmldoc.getElementsByTagName ( "entitycount" )[0]; | |
if (ocount) | |
this.entitycount = parseInt ( ocount.firstChild.nodeValue ); | |
} | |
this.myColumnDefs.push (oentry); | |
// Error handling | |
ocolumnsxml = this.xmldoc.getElementsByTagName ("error")[0]; | |
if (ocolumnsxml) { | |
displayerror( ocolumnsxml ); | |
} | |
}, | |
this.getrecords = function () { | |
var orows = this.xmldoc.getElementsByTagName ("option"); | |
this.processrows ( orows ) ; | |
}, // getrecords | |
this.processrows = function ( oxmlrows ) { | |
var ctagname, orowtag, orow, oentityrow, ocolumn, ochilds, nlenname; | |
var nlenchild, ckey, cupd, cdel, nlenname, onamechilds, ccell; | |
var lmeta = false; | |
for (var i=0,nlen=oxmlrows.length;i<nlen;i++) { | |
cupd = "Yes"; | |
cdel = "Yes"; | |
ckey = this.entitytype + "_" + this.model; // target environment key0 = the model | |
orow = oxmlrows [i]; | |
ochilds = orow.childNodes; | |
oentityrow = new Array (); | |
for (var j=0,nlenchild=ochilds.length;j<nlenchild;j++) { | |
orowtag = ochilds [j]; | |
ctagname = orowtag.tagName; | |
if ( ctagname == "optionid" ) { | |
ckey += "_" + orowtag.firstChild.nodeValue; | |
} else if ( ctagname == "upd" ) { | |
cupd = "No"; | |
} else if ( ctagname == "del" ) { | |
cdel = "No"; | |
} else if ( ctagname == "name" ) { | |
onamechilds = orowtag.childNodes; | |
nlenname = onamechilds.length; | |
oentry = new Object (); | |
for (var k=0;k<nlenname;k++) { | |
(onamechilds[k] && onamechilds[k].firstChild) ? (ccell = onamechilds[k].firstChild.nodeValue) : (ccell = ""); | |
oentityrow.push ( ccell ); | |
oentry [ this.myColumnDefs [k].key ] = ccell; | |
} | |
} | |
} | |
oentry.omkey = ckey; // to go to the open modeling record | |
this.myDataTable.addRow (oentry); | |
ocell = new Object (); | |
ocell.key = new clkeyunderscore (ckey, this.meta ); | |
ocell.upd = (cupd == "Yes"); | |
ocell.del = (cdel == "Yes"); | |
oentityrow.push (ocell); // so the last cell contains all the key information to navigate to the pages | |
this.mydata.push (oentityrow); | |
} // for | |
}, // function | |
/* | |
* Deletes an entity and all descendant entities when cascade is indicated | |
*/ | |
this.entitydelete = function ( cascade ) { | |
var nselected, cdatabaseid; | |
var xmldoc, x, y; | |
var oselectedrows = this.myDataTable.getSelectedRows (); | |
var crecordID = ""; | |
var nselected = oselectedrows.length; | |
if ( nselected > -1 ) { | |
for (var i=0;i<nselected;i++) { // possible to delete multiple records | |
if ( this.meta == "1" ) { | |
curl = this.level + "store/delmetaentity.jsp?"; | |
} else { | |
curl = this.level + "store/delentity.jsp?"; | |
} | |
crecordID = oselectedrows [i]; | |
orecord = this.myDataTable.getRecord (crecordID); | |
// remove the row from the filter index | |
// orecordstoshow.removeelement ( oselectedrows[i] ); | |
okey = new clkeyunderscore ( orecord.getData("omkey"), this.meta ); | |
curl += okey.makeurl (); | |
curl += "&cascade=" + cascade; | |
// delete the rows on the server | |
var oparsed = parsexmluri (curl); | |
if (oparsed [1]) { | |
alert ( showmessage ( 1, cerr ) ); | |
} else { | |
xmldoc = oparsed [0]; | |
x = xmldoc.getElementsByTagName ("error"); | |
if (x[0]) { | |
displayerror(x[0]); | |
} else { | |
//replace the current filter index | |
this.myDataTable.deleteRows ( crecordID, 1); | |
} | |
} | |
} // for | |
} // if | |
}, | |
/* | |
* Goto the edit page | |
*/ | |
this.gotoedit = function () { | |
var oselectedrows = this.myDataTable.getSelectedRows (); | |
var nselected = oselectedrows.length; | |
var orecord, crecordID = ''; | |
// in case of one row selected navigates to the edit page if it is not a diagram | |
if ( nselected == 1 && this.code == "" ) { // editing is not allowed to a diagram | |
crecordID = oselectedrows [0]; | |
orecord = this.myDataTable.getRecord (crecordID); | |
okey = new clkeyunderscore ( orecord.getData("omkey"), this.meta ); | |
window.location = this.level + "edit/edit.htm?" + okey.makeurl (false); | |
window.status = ""; | |
} | |
}, | |
this.doubleclick_gotopresentation = function () { | |
this.tablecontroller.gotopresentation (); | |
}, | |
this.gotopresentation = function () { | |
var oselectedrows = this.myDataTable.getSelectedRows (); | |
var nselected = oselectedrows.length; | |
var curl = "", cext = "", okey = null, cset, lpartof = false, cdiagramdir; | |
var cusermode = this.mode; | |
var crecordID = ""; | |
var orecords; | |
var now = new Date(); | |
// in case of one row selected navigates to the presentation in addmode switch to the last row | |
if ( (nselected == 1) || (oselectedrows && cusermode == "add")) { | |
if ( this.code == "" ) { | |
if (cusermode == "add") { | |
// take the last record | |
curl = this.level + "edit/edit.htm?"; | |
// get key of the last row | |
orecords = this.myDataTable.getRecordSet().getRecords(); | |
orecord = orecords [ orecords.length -1]; | |
okey = new clkeyunderscore ( orecord.getData("omkey"), this.meta ); | |
} else { | |
cset = (this.set) ? "1" :"0"; | |
curl = this.level + "presentation/showpresentation.htm?set=" + cset; | |
lpartof = true; // url in makeurl end of routine is part of a bigger url | |
} | |
} else { | |
curl = determinediagramtype ( this.level, this.code ); | |
} | |
if (!okey) { | |
var crecordID = oselectedrows [0]; | |
orecord = this.myDataTable.getRecord(crecordID); | |
okey = new clkeyunderscore ( orecord.getData("omkey"), this.meta ); | |
} | |
okey.language = this.language; | |
if ( this.code == "MAT" ) okey.key[0] = session("model"); | |
curl += "&" + okey.makeurl ( lpartof ); //Querystring is generated as a whole string | |
if ( is_embeddedsvg ) | |
curl += "&contextpath=" + session ("contextpath") + "&file=user" + session("sessionid") + "&time="+now.valueOf(); | |
window.location = curl; | |
} | |
window.status = ""; | |
}, | |
/** | |
* Make the add search grid | |
*/ | |
this.addsearchfilteraction = function ( cusermode, cmode ) { | |
this.mode = cmode; | |
var nmsgnr = 0; | |
switch ( cusermode ) { | |
case "Add" : { | |
nmsgnr = 84; | |
break; | |
} | |
case "Search" : { | |
nmsgnr = 88; | |
break; | |
} | |
case "Filter" : { | |
nmsgnr = 87; | |
break; | |
} | |
} | |
oel = document.getElementById ("cancel-quick-edit"); | |
if (oel) { | |
oel.parent = this; | |
oel.onclick = function (e) { this.parent.cancelquickedit () }; | |
}; | |
oel = document.getElementById ("save-quick-edit"); | |
if (oel) { | |
oel.parent = this; | |
oel.innerHTML = showmessage (nmsgnr); | |
oel.onclick = function (e) { this.parent.processinputs () }; | |
} | |
this.mySearchDataTable = new YAHOO.widget.DataTable ("searchfilter", this.myColumnDefs, | |
this.myDataSource, {width:"550", height:"20", | |
caption: showmessage (nmsgnr) } ); | |
var orowinput = new Array (), oel; | |
var nlen, nsize = 7, chtml = ""; | |
ncollen = this.myColumnDefs.length; | |
orowentry = new Object (); | |
for (var i=0;i<ncollen;i++) { | |
ocolumn = this.myColumnDefs [i]; | |
chtml = ""; // not all types are covered e.g. radio is missing | |
switch ( ocolumn.type ) { | |
case "Alphanumeric" : { | |
chtml = "<input onFocus=\"gltextcursor(this)\" type=\"text\" id=\"_input" + i + "\" maxlength =\"" + | |
ocolumn.width + "\" class=\"actionpaneinputtext\" />"; | |
break; | |
} | |
case "Bit" : { | |
chtml = "<input type=\"checkbox\" id=\"_input" + i + "\" class=\"actionpaneinputtext\""; | |
chtml += "\"/>"; | |
break; | |
} // case bit | |
case "Date" : { | |
chtml = "<input type=\"text\" id=\"_input" + i + "\" name=\"date" + i + "\" value=\"\" />"; | |
chtml += "<button type=\"button\" id=\"show\" title=\"Show Calendar\" onClick=\"myf(show,_input"+ i + ")\">"; | |
chtml += "<img src=\"../include/yui_2.9.0/examples/button/assets/calendar_icon.gif\""; | |
chtml += "width=\"18\" height=\"18\" alt=\"Calendar\">"; | |
chtml += "</button>"; | |
break; | |
} // case date | |
case "Email" : { | |
chtml = "<input onFocus=\"gltextcursor(this)\" type=\"text\" id=\"_input" + i + "\" maxlength =\"" + ocolumn.size + | |
"\" onchange=\"isemail('_input" + i + "')\" class=\"actionpaneinputtext\" "; | |
chtml += "\"/>"; | |
break; | |
} // case email | |
case "Encrypted" : { | |
chtml = "<input onFocus=\"gltextcursor(this)\" type=\"text\" id=\"_input" + i + "\" maxlength =\"" + ocolumn.size + "\" class=\"actionpaneinputtext\" "; | |
chtml += "\"/>"; | |
break; | |
} // case encrypted | |
case "Numeric" : { | |
chtml = "<input onFocus=\"gltextcursor(this)\" type=\"text\" id=\"_input" + i + "\" maxlength =\"" + ocolumn.width+ | |
"\" onchange=\"isfloat('_input" + i + "')\" class=\"actionpaneinputtext\""; | |
chtml += "\"/>"; | |
break; | |
} // case numeric | |
case "Postcode" : { | |
chtml = "<input onFocus=\"gltextcursor(this)\" type=\"text\" id=\"_input" + i + "\" maxlength =\"" + ocolumn.size + "\" onchange=\"ispostcode()\" class=\"actionpaneinputtext\" "; | |
chtml += "\"/>"; | |
break; | |
} // postcode | |
case "Radio" : { | |
chtml = "<select type=\"select-single\" id=\"_input" + i + "\" size =\"1\" class=\"actionpaneinputtext"; | |
chtml += "\"/>"; | |
break; | |
} // case Radio | |
case "Radio horizontal" : { | |
chtml = "<select type=\"select-single\" id=\"_input" + i + "\" size =\"1\" class=\"actionpaneinputtext"; | |
chtml += "\"/>"; | |
break; | |
} // case Radio horizontal | |
case "Single" : { | |
chtml = "<select type=\"select-single\" id=\"_input" + i + "\" size =\"1\" class=\"actionpaneinputtext"; | |
chtml += "\"/>"; | |
break; | |
} // case single | |
} // switch subtype | |
if (chtml != "") | |
orowentry [ this.myColumnDefs [i].key ] = chtml; | |
else | |
orowentry [ this.myColumnDefs [i].key ] = '<input type="text" id="_input' + i + '"/>'; | |
} // for | |
this.mySearchDataTable.addRow (orowentry); | |
this.showseserachaddgrid (cmode); | |
oel = document.getElementById ( "_input0" ); | |
if (oel) oel.focus (); | |
for (var i=0;i<ncollen;i++) { | |
ocolumn = this.myColumnDefs [i]; | |
if ( ( ocolumn.type == "Radio") || ( ocolumn.type == "Radio horizontal" ) || ( ocolumn.type == "Single")) { | |
oinput = document.getElementById ("_input" + i); | |
if (oinput) { | |
populatefieldwithoptions ( oinput, | |
"../modelview/getchoice.jsp?mmodel=" + session ("mmodel") + | |
"&model=" + session ("model") + "&column=" + ocolumn.databaseid ); | |
} else { | |
alert ("Not Found " + i) | |
} | |
} | |
//ocolumn.databaseid | |
} | |
}, | |
this.seturl = function ( curl ) { | |
( curl.indexOf ( "&startswith0" ) == -1 ) ? ( this.url = curl + "&startswith0=&startswith1=&startswith2=&startswith3=" ) : ( this.url = curl ); | |
}, | |
this.cancelquickedit = function () { | |
var oel = document.getElementById ( "searchfilter" ); | |
if (oel) oel.style.display = "none"; | |
var oel = document.getElementById ( "quick-edit-controls" ); | |
if (oel) oel.style.display = "none"; | |
}, | |
this.processinputs = function () { | |
var oinputs = this.getinputs (); // now we have all user input in an array | |
if (this.mode == "searchsoft") { | |
this.searchsoft (oinputs); | |
} else if (this.mode == "add") { | |
this.add (oinputs); | |
} else if (this.mode == "filter") { | |
this.filter (oinputs); | |
} | |
this.inputsprocessed = true; | |
this.cancelquickedit (); | |
}, | |
this.getinputs = function () { | |
var oinputs = new Array (); | |
var nlen = this.myColumnDefs.length; | |
for (var i=0;i<nlen;i++) { | |
oinputs.push ( document.getElementById ("_input" + i ) ); | |
} // for | |
return ( oinputs ); | |
}, | |
/* | |
* The end of the routine is a bit of magic the width calc is dependent on the number of columns | |
*/ | |
this.getcontainerwidth = function () { | |
var nlen = this.myColumnDefs.length; | |
var nwidth = 0; | |
for (var i=0;i<nlen;i++) { | |
ocolumn = this.myColumnDefs [i]; | |
nwidth += ocolumn.width; | |
} | |
if (nlen == 1) { | |
nwidth += 39; | |
} else if (nlen == 2) { | |
nwidth += 60; | |
} | |
return ( nwidth ); | |
}, | |
/** | |
* Search for the string and select the rows | |
*/ | |
this.searchsoft = function (oinputs) { | |
var ninputlen = oinputs.length; | |
var orecords = this.myDataTable.getRecordSet().getRecords(); | |
var orecord, ocolumn, ccell = ""; | |
var nlen = orecords.length; | |
var oselectedrows = this.myDataTable.getSelectedRows (); | |
var nselected, crecordID, nindex; | |
var nfound = -1; | |
// if not found we restore the selected rows at the end of function | |
this.myDataTable.unselectAllRows (); | |
var oinputs_searchable = new Array (); | |
for (var j=0;j<ninputlen;j++) { | |
ocolumn = this.myColumnDefs [j]; | |
if ( ocolumn.type == "Bit" ) { | |
if ( oinputs [j].value == "on") { | |
oinputs_searchable.push ("JA"); | |
} else { | |
oinputs_searchable.push ("NEE"); | |
} | |
} else { | |
oinputs_searchable.push ( trim (oinputs [j].value).toUpperCase() ) ; | |
} | |
} | |
for (var i=0;i<nlen;i++) { | |
orecord = orecords [i]; | |
for (var j=0;j<ninputlen;j++) { | |
ocolumn = this.myColumnDefs [j]; | |
ccell = orecord.getData( ocolumn.key ).toUpperCase(); | |
if (oinputs_searchable [j] != "") { | |
if ( ccell.indexOf ( oinputs_searchable [j] ) != -1 ) { | |
nfound = i; | |
ofoundkey = orecord.getData("omkey"); | |
this.myDataTable.selectRow ( i ); | |
} | |
} | |
} | |
} | |
if (nfound == -1) { | |
alert ( showmessage ( 253 ) ); //Not found | |
// now display the original selected rows | |
var nselected = oselectedrows.length; | |
if ( nselected > -1 ) { | |
for (var i=0;i<nselected;i++) { // possible to delete multiple records | |
crecordID = oselectedrows [i]; | |
orecord = this.myDataTable.getRecord (crecordID); | |
nindex = this.myDataTable.getRecordIndex (orecord); | |
this.myDataTable.selectRow ( nindex ); | |
} | |
} | |
} else { | |
this.myDataTable.scrollTo ( nfound ); | |
} | |
}, // end searchsoft | |
this.filter = function ( oinputs ) { | |
var cstarts = "", curl, cvalue; | |
var ocolumndata = this.myColumnDefs; | |
var nlen = ocolumndata.length | |
var ltitlebar, lactionpane, oel, ocolumn; | |
for (var ncolindex=0;ncolindex<nlen;ncolindex++) { | |
ocolumn = ocolumndata [ ncolindex ]; | |
switch ( ocolumn.type ) { | |
case "Bit" : { ( oinputs[ncolindex].checked ) ? ( cvalue="1" ) : ( cvalue="0" ); break; } | |
case "Date" : { | |
cvalue = oinputs [ ncolindex ].value; | |
if (cvalue!= "") { | |
cvalue = glresetdate ( oinputs [ ncolindex ].value, ocolumn.dateformat, window ); | |
cvalue = cvalue.replace ( /\//g,"-" ); | |
} | |
break; | |
} | |
case "Single" : { | |
cvalue = oinputs [ ncolindex ].value; | |
cvalue = cvalue.toUpperCase (); | |
if ( cvalue.indexOf("__") != -1 ) cvalue = cvalue.substring ( 0, cvalue.indexOf ( "__" ) ); | |
break; | |
} | |
default : { | |
cvalue = oinputs [ ncolindex ].value; | |
//&'s are not allowed in the url and % needs no escaping | |
cvalue = cvalue.replace ( /%/g, "^25" ); | |
cvalue = cvalue.replace ( /</g, "<" ); | |
cvalue = cvalue.replace ( />/g, ">" ); | |
cvalue = cvalue.replace ( /^25/g, "%25" ); | |
cvalue = cvalue.toUpperCase (); | |
break; | |
} | |
} | |
cstarts += "&startswith"+ncolindex + "=" + escape ( escape ( xmlescape ( cvalue ) ) ); | |
} | |
if ( this.code == "" || this.code == null ) { | |
if (this.metadatayn () ) { | |
curl = this.level + "modelview/getmetaentity.jsp?meta=1&mmodel=" + this.mmodel + "&language=" + this.language + "&entity="+ this.entitytype | |
} else if ( this.meta == "1" ) { // we are working in the meta environment and we select target data in case of a relation | |
curl = this.level + "modelview/getentity.jsp?meta=0&model=" + this.model2 + "&mmodel=" + this.mmodel + "&language=" + this.language + "&entity="+ this.entitytype; | |
} else { | |
curl = this.level + "modelview/getentity.jsp?meta=0&model=" + this.model + "&mmodel=" + this.mmodel + "&language=" + this.language + "&entity="+ this.entitytype; | |
} | |
} else { | |
curl = this.level + "modelview/getdiagram.jsp?meta=0&mmodel=" + this.mmodel + "&model=" + this.model + "&language=" + this.language + "&entity="+ this.entitytype + | |
"&code=" + this.code; | |
} | |
curl += cstarts; | |
if ( this.set ) curl += "&set=1"; | |
this.seturl ( curl ); | |
this.refreshdata (); | |
}, | |
/** | |
* Produces a list of filtered data | |
*/ | |
this.refreshdata = function () { | |
var ocolumndata = this.myColumnDefs; | |
var nlen = ocolumndata.length; | |
var oparsed = parsexmluri ( this.url ), nmaxrelation; | |
var ocount; | |
var oel = document.getElementById ( "entitymessage" + this.cnt ); | |
if ( oel ) oel.innerHTML = ""; | |
this.myDataTable.getRecordSet().reset (); | |
if (oparsed [1]) { | |
alert ( showmessage ( 1, oparsed[1] ) ); | |
} else { | |
this.xmldoc = oparsed [0]; | |
if (this.xmldoc) { | |
this.getrecords (); | |
var ocount = this.xmldoc.getElementsByTagName ("entitycount")[0]; | |
} | |
} | |
//provide cells and headers text | |
orecords = this.myDataTable.getRecordSet().getRecords(); | |
this.rowcount = orecords.length; | |
var ocolumndata = this.myColumnDefs; | |
var nlen = ocolumndata.length; | |
for (i=0;i<nlen;i++) { | |
if (ocolumndata [i].sortable) | |
this.myDataTable.sortColumn ( ocolumndata [i] ); | |
} | |
nmaxrelation = this.maxrelation; | |
if ( parseInt(ocount.text) > nmaxrelation ) { | |
if ( oel ) oel.innerHTML = "<div>" + showmessage ( 501, this.rowcount, nmaxrelation ) + "</div>"; //Too many entities | |
} | |
this.myDataTable.render (); | |
} | |
/** | |
* Defines whether a target list is to be produced. Some mixed relations contain both meta and target entitytypes | |
* entityoptionlist is present in case of relation editor | |
*/ | |
this.metadatayn = function () { | |
var lmeta = true; | |
if ( this.meta == "0" ) | |
lmeta = false; | |
else if ( this.parent && this.parent.entityoptionlist ) | |
//Only in relation dialogue a mix can occur | |
lmeta = this.parent.entityoptionlist [ this.parent.findentityid ( this.entitytype, "" ) ].meta; | |
return ( lmeta ); | |
}, | |
this.add = function ( oinputs ) { | |
var nlen = this.myColumnDefs.length; | |
var lequal, ldoit = true; | |
var cid, curl, cvalue, x, cparturl, cdatabaseid, nkeyshifting = 0; | |
var xmldoc, oparsed, oentityrow, olastcell; | |
var orecords = this.myDataTable.getRecordSet().getRecords(); | |
for (i=0; i < orecords.length; i++) {// first find out if row is unique | |
lequal = true; | |
for (var j=0,ninputlen=oinputs.length;j<ninputlen;j++) { | |
ccell = trim (orecords[i].getData ( this.myColumnDefs[j].key ).toUpperCase()); | |
cinput = trim (oinputs [j].value.toUpperCase()); | |
if (oinputs [j].value != "") { | |
lequal = lequal && (ccell == cinput); | |
} | |
} | |
if (lequal) break; | |
} | |
if (lequal) { | |
alert ( showmessage ( 38 ) ); // Entity is not unique! | |
} else { | |
// unique entry | |
cid = "0"; | |
if ( this.meta == "1" ) { | |
curl = this.level + "store/insertmetaentity.jsp"; | |
} else { | |
curl = this.level + "store/insertentity.jsp"; | |
} | |
curl += "?entity=" + this.entitytype; | |
if ( this.meta == "0" ) curl += "&model=" + this.model; | |
curl += "&language=" + this.language; | |
if ( this.nrofpkeys > 1 ) { | |
curl += "&key0=" + this.mmodel; | |
nkeyshifting = 1; | |
} | |
var nlen = this.myColumnDefs.length; | |
for (var ncolindex=0;ncolindex<nlen;ncolindex++) { | |
ocolumn = this.myColumnDefs [ncolindex]; | |
switch ( ocolumn.type ) { | |
case "Bit" : { (oinputs[ncolindex].checked) ? (cvalue="1") : (cvalue="0"); break; } | |
case "Email" : { | |
ldoit = isemail ("_input" + ncolindex); | |
} | |
case "Date" : { | |
cvalue = glresetdate(oinputs[ncolindex].value, ocolumn.dateformat, window); | |
cvalue = cvalue.replace(/\//g,"-"); // format to store in datebase | |
break; | |
} | |
case "Single" : { | |
cvalue = oinputs[ncolindex].value; | |
if (cvalue.indexOf("__") != -1 ) cvalue = cvalue.substring(0, cvalue.indexOf("__")); | |
break; | |
} | |
default : { cvalue = oinputs[ncolindex].value; } | |
} | |
if (cvalue == "" || cvalue == null) { | |
ldoit = false; | |
break; | |
} else { | |
cvalue = cvalue.replace( /&/g, "%26amp;" ); | |
cvalue = cvalue.replace( /'/g, "%26apos;" ); | |
cvalue = cvalue.replace( /"/g, "%26quot;" ); | |
curl += "&key" + (ncolindex + nkeyshifting) + "=" + escape ( escape ( xmlescape ( cvalue ) ) ); | |
} | |
} | |
if ( ldoit ) { | |
oparsed = parsexmluri (curl); // send insert statement to the server | |
if (oparsed[1]) { | |
alert ( showmessage ( 1, oparsed[1] ) ); | |
} else { | |
xmldoc = oparsed [0]; | |
x = xmldoc.getElementsByTagName ("error"); | |
if (x[0]) { | |
displayerror( x[0] ); | |
} else { | |
x = xmldoc.getElementsByTagName ("info"); | |
if (x[0]) { | |
window.status = showmessage ( 223 ); // 1 record created | |
// add the just created record to the table on the screen (already stored in database via insertentity.jsp) | |
oentityrow = new Array (); | |
cdatabaseid = textnode (x[0].childNodes [0]); | |
oentry = new Object (); | |
var nlen = this.myColumnDefs.length; | |
for (var ncolindex=0;ncolindex<nlen;ncolindex++) { | |
ocolumn = this.myColumnDefs [ncolindex]; | |
switch ( ocolumn.type ) { | |
case "Bit" : { | |
(oinputs[ncolindex].checked) ? (oentry [ this.myColumnDefs [ncolindex].key ] = "X") : | |
(oentry [ this.myColumnDefs [ncolindex].key ] = " ") ; break; | |
} | |
case "Date" : { | |
oentry [ this.myColumnDefs [ncolindex].key ] = oinputs[ncolindex].value; | |
} | |
case "Single" : { | |
cvalue = oinputs[ncolindex].value; | |
if (cvalue.indexOf("__") != -1 ) cvalue = cvalue.substring(0, cvalue.indexOf("__")); | |
oentry [ this.myColumnDefs [ncolindex].key ] = cvalue; | |
break; | |
} | |
default : { | |
oentry [ this.myColumnDefs [ncolindex].key ] = oinputs[ncolindex].value; | |
} | |
} | |
} | |
oentry.omkey = cdatabaseid; // to go to the open modeling record | |
this.myDataTable.addRow (oentry); | |
} | |
this.myDataTable.render (); | |
if (oentry) { | |
// in add mode gotopresentation navigates to the last selected row | |
if (this.gotopresentation) { // true for entityviewer.htm | |
this.gotopresentation (); | |
} | |
} | |
} | |
} | |
} else { | |
alert ( showmessage ( 37 ) ); // incomplete key | |
} | |
} | |
}, | |
this.printentitytable = function () { | |
if ( session ( "sessionid" ) == null ) top.location = "../login/login.jsp?reset=1"; | |
var ckeystr = "", curl = "", curlrest = ""; | |
var cfile = "user" + session ( "sessionid" ); // make the file unique | |
var ccont = session ( "contextpath" ); | |
var centity = "", cmodel = "", ckey = "", cseq = "", cdiagram = "", cdiagramdir = "", cx = ""; | |
var centityold = "", cmodelold = "", ckeyold = "", cseqold = "", clanguageold = "", cdiagramold = ""; | |
var lfirst = true, ldiagram = false; | |
var now = new Date(), cdir; | |
var centitytype = this.entitytype; | |
var otextnode, nhypers, ncoldatabaseid = this.myColumnDefs.length, orecord, okey, cx = ""; | |
var oselectedrows = this.myDataTable.getSelectedRows (); | |
var crecordID = ""; | |
var nselectedrows = oselectedrows.length; | |
window.status = showmessage ( 476, "Diagram 1" ); // Printing | |
if (this.meta == "1") { | |
curl = this.level + "modelview/getmetapresentation.jsp?entity=" + centitytype + "&language=" + this.language; | |
curl += "&time=" + now.valueOf(); | |
} else { | |
curl = this.level + "modelview/getpresentation.jsp?model=" + this.model + "&entity=" + centitytype + "&language=" + this.language + "&code=" + this.code; | |
curl += "&time=" + now.valueOf(); | |
} | |
// comma separated field parameter to the sql query | |
// getpresentation gets all the presentation | |
for (var nrow=0;nrow<nselectedrows;nrow++) { | |
crecordID = oselectedrows [nrow]; | |
orecord = this.myDataTable.getRecord (crecordID); | |
okey = new clkeyunderscore (orecord.getData("omkey"), this.meta ); | |
ckeystr = okey.getkeyonly () + ","; | |
} | |
// if we have databaseids send them together with the URL | |
if (ckeystr != "") curl += "&keystr=" + ckeystr.substring (0, ckeystr.length-1); | |
// now as a parameter | |
var oparsed = parsexmluri ( curl ); | |
if (oparsed [1]) { | |
alert ( showmessage ( 1, oparsed [1] ) ); | |
} else { | |
xmldoc = oparsed [0]; | |
otextnode = xmldoc.getElementsByTagName ("hyper"); | |
nhypers = otextnode.length; | |
ldiagram = false; | |
for (var i=0;i<nhypers;i++) { | |
ohypernode = otextnode.item (i).childNodes; | |
nhypernodelength = ohypernode.length; | |
for (var j=0;j<nhypernodelength;j++) { | |
cnodename = ohypernode.item (j).nodeName; | |
switch (cnodename) { | |
case "ent" : { centity = textnode (ohypernode.item (j)); break; } | |
case "key0" : { cmodel = textnode (ohypernode.item (j)); break; } | |
case "key1" : { ckey = textnode (ohypernode.item (j)); break; } | |
case "lan" : { clanguage = textnode (ohypernode.item (j)); break; } | |
case "dia" : { cdiagram = textnode (ohypernode.item (j)); ldiagram = ( cdiagram == "1" ); break; } | |
case "seq" : { cseq = textnode (ohypernode.item (j)); break; } | |
} | |
} | |
if ( ldiagram ) { | |
cdiagramdir = "diagram"; | |
if (lfirst) { | |
lfirst = false; | |
curlrest = "meta=" + this.meta + "&code=" + this.code + "&entity=" + centity + "&key0=" + cmodel + "&key1=" + ckey + "&language=" + this.language + "&contextpath=" + ccont + "&file=" + cfile + "&print=1&time=" + now.valueOf() + cseq; | |
parsexmluri ( this.level + "administer/clearsessionvar.jsp?sessionvar=diagram" ); | |
if ( !is_embeddedsvg ) { | |
oparsed = parsexmluri ( this.level + cdiagramdir + "/savediagramurl.jsp?" + escape( curlrest ) ); | |
if (oparsed[1]) alert ( showmessage ( 1, oparsed[1] ) ); | |
} | |
window.frames["diagram"].location = determinediagramtype ( this.level, this.code ) + "&" + curlrest; | |
window.status = showmessage ( 476, "Diagram 1" ); // Printing | |
} else { | |
otimer[i] = new cltimer(); | |
curl = escape("meta=" + this.meta + "&code=" + this.code + "&entity=" + centity + "&key0=" + cmodel + "&key1=" + ckey+ "&language=" + clanguage); | |
curlold = this.code.toLowerCase() + "_" + centityold + "_" + cmodelold + "_" + ckeyold + "_" + clanguageold; | |
otimer[i].timerid = setInterval("otimer[" + i + "].pollallresult(\"" + curlold + "\", \"" + ccont + "\", \"" + curl + "\", \"" + this.code + "\", \"" + cfile + "\", \"" + now.valueOf() + "\", \"" + cseq + "\")", npolltime); | |
} | |
} | |
centityold = centity; | |
cmodelold = cmodel; | |
ckeyold = ckey; | |
cseqold = cseq; | |
clanguageold = clanguage; | |
cdiagramold = cdiagram; | |
} | |
if (!lfirst) { | |
otimer[nhypers] = new cltimer(); | |
curl = "-1"; | |
curlold = this.code.toLowerCase() + "_" + centityold + "_" + cmodelold + "_" + ckeyold + "_" + clanguageold; | |
otimer[nhypers].timerid = setInterval("otimer[" + (nhypers) + "].pollallresult(\"" + curlold + "\", \"" + ccont + "\", \"" + curl + "\", \"" + this.code + "\", \"" + cfile + "\", \"" + now.valueOf() + "\", \"" + cseq + "\")", npolltime); | |
} | |
if ( !ldiagram ) print2pdf ( cfile + now.valueOf() ); | |
window.status = ""; | |
} | |
}, | |
/* | |
* Calendar | |
*/ | |
this.showseserachaddgrid = function ( cusermode ) { | |
var oel = document.getElementById ( "searchfilter" ); | |
var ocolumn, cformat, oinput; | |
if (oel) oel.style.display = "block"; | |
oel = document.getElementById ( "quick-edit-controls" ); | |
if (oel) oel.style.display = "block"; | |
ncollen = this.myColumnDefs.length; | |
for (var k=0;k<ncollen;k++) { | |
ocolumn = oentry [ this.myColumnDefs [k].key ]; | |
switch ( ocolumn.type ) { | |
case "Single" : { | |
oinput = document.getElementById ("_input" + i); | |
if (oinput) { | |
populatefieldwithoptions ( oinput, | |
"../modelview/getchoice.jsp?mmodel=" + session ("mmodel") + | |
"&model=" + session ("model") + "&column=" + ocolumn.databaseid ); | |
} | |
break; | |
} | |
case "Date" : { | |
cformat = ocolumn.dateformat.replace("dd","%d"); | |
cformat = cformat.replace("MM","%m"); | |
cformat = cformat.replace("mm","%M"); | |
cformat = cformat.replace("yyyy","%Y"); | |
var cal1 = new YAHOO.widget.Calendar("_datepicker" + i); | |
cal1.render(); | |
break; | |
} | |
} | |
} | |
}, | |
this.settings ( querystring ("meta"), | |
querystring ("model"), | |
querystring ("mmodel"), | |
querystring ("entity"), | |
querystring ("code"), | |
querystring ("ins"), | |
querystring ("upd"), | |
querystring ("del"), | |
querystring ("nrofpkeys")); | |
this.getdescription (); | |
this.myDataSource = new YAHOO.util.DataSource (YAHOO.openmodeling.widget.Data.entities); | |
this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY; | |
this.myColumnDefs = []; | |
// parse xml and create headers | |
this.xmlparse ( "./getentity.jsp?" + this.url + "&startswith0=&startswith1=&startswith2=&startswith3="); | |
nwidth = this.getcontainerwidth (); | |
owidthheight = new Object (); | |
owidthheight.width = String (nwidth); | |
//owidthheight.height = "420"; | |
this.myDataTable = new YAHOO.widget.ScrollingDataTable ("entityviewer", this.myColumnDefs, | |
this.myDataSource, owidthheight ); | |
this.getrecords (); | |
oDOMel = document.getElementById ('caption'); | |
if (oDOMel) | |
oDOMel.innerHTML = this.title; // entiteiten | |
oDOMel = document.getElementById ('entityviewerloading'); | |
if (oDOMel) { | |
oDOMel.style.display = "none"; | |
} | |
var myConfigs = { | |
sortedBy:{key:"name",dir:"asc"}, | |
/* | |
paginator: new YAHOO.widget.Paginator({ | |
rowsPerPage: 25, | |
template: YAHOO.widget.Paginator.TEMPLATE_ROWS_PER_PAGE, | |
rowsPerPageOptions: [10,25,50,100], | |
pageLinks: 5 | |
}), | |
*/ | |
draggableColumns:true | |
} | |
this.myDataTable.subscribe ("rowClickEvent", this.myDataTable.onEventSelectRow ); | |
this.myDataTable.subscribe ("rowDblclickEvent", this.doubleclick_gotopresentation ); | |
this.myDataTable.tablecontroller = this; | |
this.myDataTable.on('postRenderEvent', function() { | |
var Dom = YAHOO.util.Dom, | |
width = Dom.getStyle(this.getTableEl(),'width'), | |
bdContEl = this.getBdContainerEl(); | |
Dom.setStyle(bdContEl,'width',width); | |
if (bdContEl.clientWidth < bdContEl.scrollWidth) { | |
width = (parseInt(width,10) + bdContEl.scrollWidth - bdContEl.clientWidth) +'px'; | |
Dom.setStyle(bdContEl,'width',width); | |
} | |
Dom.setStyle(this.getHdContainerEl(),'width',width); | |
}); | |
/* | |
* Tested and runs fine | |
*/ | |
var onContextMenuClick = function (p_sType, p_aArgs, p_myDataTable) { | |
var task = p_aArgs [1]; | |
if (task) { | |
// Extract which TR element triggered the context menu | |
var elRow = this.contextEventTarget; | |
elRow = p_myDataTable.getTrEl (elRow); | |
if (elRow) { | |
switch(task.index) { | |
case 0: // Open presentation | |
p_myDataTable.tablecontroller.gotopresentation (); | |
break; | |
case 1: // Edit presentation | |
p_myDataTable.tablecontroller.gotoedit (); | |
break; | |
case 2: // Add | |
p_myDataTable.tablecontroller.addsearchfilteraction ( "Add", "add" ); | |
break; | |
case 3: // Delete row upon confirmation | |
p_myDataTable.tablecontroller.entitydelete ( "no" ); // no is for cascade | |
break; | |
case 4: // Search | |
p_myDataTable.tablecontroller.addsearchfilteraction ( "Search", "searchsoft" ); | |
break; | |
case 5: // Filter | |
p_myDataTable.tablecontroller.addsearchfilteraction ( "Filter", "filter" ); | |
break; | |
case 6: // Print | |
p_myDataTable.tablecontroller.printentitytable (); | |
break; | |
} // switch | |
} // if elrow | |
} // if task | |
}; | |
this.ContextMenu = new YAHOO.widget.ContextMenu ("mycontextmenu", {trigger:this.myDataTable.getTbodyEl()}); | |
this.ContextMenu.addItem( showmessage (315) ); // open | |
// Render the ContextMenu instance to the parent container of the DataTable | |
this.ContextMenu.render("myDOMContextmenu"); | |
this.ContextMenu.clickEvent.subscribe (onContextMenuClick, this.myDataTable); | |
this.ContextMenu.addItem( showmessage (314) ); // edit | |
this.ContextMenu.addItem( showmessage (307) ); // add | |
this.ContextMenu.addItem( showmessage (308) ); // delete | |
this.ContextMenu.addItem( showmessage (310) ); // search | |
this.ContextMenu.addItem( showmessage (311) ); // filter | |
this.ContextMenu.addItem( showmessage (312) ); // print | |
return { | |
oDS: this.myDataSource, | |
oDT: this.myDataTable | |
}; | |
}; | |
YAHOO.openmodeling.widget.DataView.prototype.isFiltered=false; | |
YAHOO.openmodeling.widget.DataView.prototype.doBeforeLoadData= function( sRequest ,oResponse ) { | |
if (oResponse) { | |
this.defaultView=oResponse; | |
} | |
return true; | |
} | |
</script> | |
<body class="yui-skin-sam"> | |
<div id="buttonbar"></div> | |
<script> | |
/************************************************/ | |
// Global paramters used for printing only | |
var cfile = "user" + session ( "sessionid" ); | |
var otimer = new Array(); | |
var npolltime = 10000; // elapsed number of miliseconds to poll the server for updates on the diagram | |
var nmaxtrials = 60; // number of times trying to get the data from the server | |
/************************************************/ | |
document.body.bgColor = "#FEFDDE"; | |
var obuttonbar = new clbuttonbar ( 1 ); | |
obuttonbar.addbutton ( "javascript:hideshowdescription ()", "../images/menu_folder_open.gif", "opencloseddescription", "Hide description" ); | |
</script> | |
<br/> | |
<br/> | |
<div> | |
<div id="entitytypedescription" class="entitytypedescription"></div> | |
<div class="spacer"> </div> | |
</div> | |
<div class="innerspace"></div> | |
<div id="viewerdata"> | |
<div id="searchfilterarea"> | |
<span id="quick-edit-controls"> </p> | |
<button id="save-quick-edit">Save</button> <!-- save showmessage --> | |
<button id="cancel-quick-edit">Cancel</button> <!-- cancel showmessage --> | |
</span> | |
<div id="searchfilter" ></div> | |
<div id="entityviewerloading" class="loading">Loading...</div> | |
<div id='caption'></div> <!-- entiteitenen --> | |
<br/> | |
<div id="entityviewer"></div> | |
<div id="entitymessage"></div> | |
</div> | |
</div> | |
<div id="myDOMContextmenu"></div> | |
<div id="count"></div> | |
<iframe id="diagram" name="diagram" src="dummy.htm" | |
style="position:absolute;top:100;left:0;width:10px;height:10px;display:block;" frameborder="0" scrolling="no"></iframe> | |
<script> | |
oentityviewer = new YAHOO.openmodeling.widget.Entityviewer (); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment