/*
 * Copyright (c) 2005-2006, Image Matters LLC. All Rights Reserved.
 * 
 * This software is distributed under the terms of the LICENSE file
 * included with the program and available here:
 * 
 * http://www.imagemattersllc.com/legal-notice/LICENSE-userSmartsGX.html
 */
namespace("userSmarts.wt.dialogs");userSmarts.wt.dialogs.Dialog=function(properties){if(isPrototype(arguments)){return;}
var predefaultModal=properties.modal;properties=setdefault(properties,{modal:true,title:"Dialog",position:{x:0,y:0},width:150,height:100});if(predefaultModal===false){properties.modal=false;}
setdefault(this,properties);};userSmarts.wt.dialogs.Dialog.prototype.open=function(){this.deferred=new Deferred();this.dialogDiv=this.paint();this.dialogDiv.style.display="none";document.body.appendChild(this.dialogDiv);this.dialogDiv.style.display="block";this.focus();return this.deferred;};userSmarts.wt.dialogs.Dialog.prototype.close=function(){if(this.dialogDiv){this.dialogDiv.style.display="none";document.body.removeChild(this.dialogDiv);this.dialogDiv=null;}};userSmarts.wt.dialogs.Dialog.prototype.okPressed=function(){if(this.deferred){this.deferred.callback(true);this.deferred=null;}};userSmarts.wt.dialogs.Dialog.prototype.cancelPressed=function(){if(this.deferred){this.deferred.callback(false);this.deferred=null;}};userSmarts.wt.dialogs.Dialog.prototype.getTitleBar=function(){return this.titleBar;};userSmarts.wt.dialogs.Dialog.prototype.getDialogArea=function(){return this.dialogArea;};userSmarts.wt.dialogs.Dialog.prototype.getButtonBar=function(){return this.buttonBar;};userSmarts.wt.dialogs.Dialog.prototype.getOKButton=function(){return this.okButton;};userSmarts.wt.dialogs.Dialog.prototype.getCancelButton=function(){return this.cancelButton;};userSmarts.wt.dialogs.Dialog.prototype.createDialogArea=function(parent){var result=DIV();if(this.description){result.innerHTML=this.description.replace(/\n/,"<BR/>");}
parent.appendChild(result);};userSmarts.wt.dialogs.Dialog.prototype.setPosition=function(x,y){if(!(this.modal===true)){this.position.x=x;this.position.y=y;}};userSmarts.wt.dialogs.Dialog.prototype.setSize=function(width,height){this.width=parseInt(width);this.height=parseInt(height);if(this.innerTable){this.innerTable.setAttribute("width",this.width);this.innerTable.setAttribute("height",this.height);}};userSmarts.wt.dialogs.Dialog.prototype.onOk=function(){this.okPressed();this.close();};userSmarts.wt.dialogs.Dialog.prototype.onCancel=function(){this.cancelPressed();this.close();};userSmarts.wt.dialogs.Dialog.prototype.focus=function(){};userSmarts.wt.dialogs.Dialog.prototype.createButtonBar=function(parent){var cancelBtn=BUTTON(null,"Cancel");connect(cancelBtn,'onclick',this,this.onCancel);this.cancelButton=cancelBtn;parent.appendChild(cancelBtn);var okBtn=BUTTON(null,"OK");connect(okBtn,'onclick',this,this.onOk);this.okButton=okBtn;parent.appendChild(okBtn);};userSmarts.wt.dialogs.Dialog.prototype.paint=function(){var thead=THEAD();var tbody=TBODY();var tfoot=TFOOT();var innerTable=TABLE({'class':'dialog',width:this.width+'',height:this.height+'',cellspacing:'0',cellSpacing:'0',cellpadding:'5',cellPadding:'5',border:'1',align:'center',valign:'middle'},thead,tbody,tfoot);this.innerTable=innerTable;this.titleBar=TD({width:'100%',align:'left'},this.title);thead.appendChild(TR({'class':'dialog-titlearea'},this.titleBar));this.buttonBar=TD({width:'100%'});this.createButtonBar(this.buttonBar);tfoot.appendChild(TR({'class':'dialog-buttonbar'},this.buttonBar));this.dialogArea=TD({width:'100%'});this.createDialogArea(this.dialogArea);tbody.appendChild(TR({'class':'dialog-dialogarea'},this.dialogArea));var top=this.position.y;var left=this.position.x;var width=this.width;var height=this.height;if(this.modal===true){var outerTable=TABLE({width:'100%',height:'100%'},TBODY({},TR(null,TD({vAlign:'center',valign:'center',align:'center'},innerTable))));top=0;left=0;width=parseInt(window.innerWidth)||parseInt(document.body.clientWidth);height=parseInt(window.innerHeight)||parseInt(document.body.clientHeight);}
var dialogDiv=DIV();if(this.modal===true){dialogDiv.className='dialog-modal-container';}else{dialogDiv.className='dialog-container';}
dialogDiv.style.position="absolute";dialogDiv.style.top=top+"px";dialogDiv.style.left=left+"px";dialogDiv.style.width=width+"px";dialogDiv.style.height=height+"px";dialogDiv.style.textAlign="center";dialogDiv.style.verticalAlign="middle";if(this.modal===true){dialogDiv.appendChild(outerTable);}else{dialogDiv.appendChild(innerTable);}
return dialogDiv;};userSmarts.wt.dialogs.DialogWizard=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{title:"Wizard",name:"",width:300,height:200});setdefault(this,properties);userSmarts.wt.dialogs.Dialog.call(this,properties);this.pages=[];this.currentPage=-1;this.lastPage=-1;};userSmarts.wt.dialogs.DialogWizard.inheritsFrom(userSmarts.wt.dialogs.Dialog);userSmarts.wt.dialogs.DialogWizard.prototype.addPage=function(dialog){if(dialog instanceof userSmarts.wt.dialogs.Dialog){this.pages.push(dialog);if(this.currentPage<0){this.currentPage=0;this.isFirstPage=true;}}};userSmarts.wt.dialogs.DialogWizard.prototype.addPages=function(){};userSmarts.wt.dialogs.DialogWizard.prototype.getNextButton=function(){return this.nextButton;};userSmarts.wt.dialogs.DialogWizard.prototype.getPreviousButton=function(){return this.prevButton;};userSmarts.wt.dialogs.DialogWizard.prototype.getFinishButton=function(){return this.finishButton;};userSmarts.wt.dialogs.DialogWizard.prototype.finishPressed=function(){this.okPressed();};userSmarts.wt.dialogs.DialogWizard.prototype.createDialogArea=function(parent){this.renderDialogArea();};userSmarts.wt.dialogs.DialogWizard.prototype.renderDialogArea=function(){var clb=this.getCancelButton();var bbar=this.getButtonBar();var prb=BUTTON(null,"Previous");prb.onclick=bind(this.prevPage,this);this.prevButton=prb;var nxb=BUTTON(null,"Next");nxb.onclick=bind(this.nextPage,this);this.nextButton=nxb;var fnb=BUTTON(null,"Finish");fnb.onclick=bind(this.finishPressed,this);this.finishButton=fnb;if(this.isFirstPage&&this.isLastPage){replaceChildNodes(bbar,[clb,fnb]);}else if(this.isFirstPage){replaceChildNodes(bbar,[clb,nxb]);}else if(this.isLastPage){replaceChildNodes(bbar,[clb,prb,fnb]);}else{if(this.canFinish){replaceChildNodes(bbar,[clb,prb,nxb,fnb]);}else{replaceChildNodes(bbar,[clb,prb,nxb]);}}
var page=this.pages[this.currentPage];page.paint();this.setSize(page.width,page.height);var parent=this.titleBar.parentNode;parent.replaceChild(page.titleBar,this.titleBar);this.titleBar=page.titleBar;replaceChildNodes(this.dialogArea,page.dialogArea.childNodes);};userSmarts.wt.dialogs.DialogWizard.prototype.nextPage=function(){this.lastPage=this.currentPage;if(this.currentPage<this.pages.length){this.currentPage++;if(this.currentPage==this.pages.length-1){this.isLastPage=true;}else{this.isLastPage=false;}}
this.onPageChange();this.renderDialogArea();};userSmarts.wt.dialogs.DialogWizard.prototype.prevPage=function(){this.lastPage=this.currentPage;if(this.currentPage>0){this.currentPage--;if(this.currentPage==this.pages.length-1){this.isFirstPage=true;}else{this.isFirstPage=false;}}
this.onPageChange();this.renderDialogArea();};userSmarts.wt.dialogs.DialogWizard.prototype.onPageChange=function(){};$namespace.MessageDialog=Class.create(userSmarts.wt.dialogs.Dialog);$prototype.initialize=function(superClass){superClass.call(this,arguments);};$prototype.open=function(){throw new Error("Must use 'openError', 'openWarning', 'openInformation', or "+"'openConfirm' when opening a MessageDialog!");};$prototype.close=function(){return false;};$prototype.okPressed=function(){};$prototype.cancelPressed=function(){};$namespace.MessageDialog.openError=function(title,msg){alert("Error: "+title+"\n\n"+msg);};$namespace.MessageDialog.openWarning=function(title,msg){alert("Warning: "+title+"\n\n"+msg);};$namespace.MessageDialog.openInformation=function(title,msg){alert(title+"\n\n"+msg);};$namespace.MessageDialog.openConfirm=function(title,msg){return confirm(msg);};$namespace.ConfirmDialog=Class.create(userSmarts.wt.dialogs.Dialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:"Confirm",modal:false,width:200,height:100});};$prototype.createButtonBar=function(){var yesBtn=BUTTON(null,"Yes");connect(yesBtn,'onclick',this,this.onOk);this.okButton=yesBtn;parent.appendChild(yesBtn);var noBtn=BUTTON(null,"No");connect(noBtn,'onclick',this,this.onCancel);parent.appendChild(noBtn);var cancelBtn=BUTTON(null,"Cancel");connect(cancelBtn,'onclick',this,this.onAbort);this.cancelButton=cancelBtn;parent.appendChild(cancelBtn);};$prototype.onAbort=function(){if(this.deferred){this.deferred.callback(null);this.deferred=null;}
this.close();};userSmarts.wt.dialogs.ConfigureTableDialog=function(properties){if(isPrototype(arguments))return;properties=properties||{};setdefault(properties,{title:"Configure Table Columns",description:"Check or uncheck each column to change visibility:",modal:false,width:200,height:125});userSmarts.wt.dialogs.Dialog.call(this,properties);};userSmarts.wt.dialogs.ConfigureTableDialog.inheritsFrom(userSmarts.wt.dialogs.Dialog);userSmarts.wt.dialogs.ConfigureTableDialog.prototype.createDialogArea=function(parent){parent.appendChild(document.createTextNode(this.description));parent.appendChild(BR());var columns=this.model.getColumns();var box;var colName;for(var i=0;i<columns.length;i++){colName=this.model.getColumnLabel(columns[i],null);box=INPUT({type:'checkbox',name:colName});box.column=i;box.checked=box.defaultChecked=!(columns[i].visible===false);connect(box,'onclick',this,this.onColumnChange);parent.appendChild(box);parent.appendChild(document.createTextNode(" "+colName));parent.appendChild(BR());}
this.modifiedColumns=[];};userSmarts.wt.dialogs.ConfigureTableDialog.prototype.onColumnChange=function(event){var box=event.src();this.modifiedColumns[box.column]=box.checked;};userSmarts.wt.dialogs.ConfigureTableDialog.prototype.okPressed=function(){for(var k in this.modifiedColumns){if(this.modifiedColumns[k]===true){this.model.showColumn(k*1);}else if(this.modifiedColumns[k]===false){this.model.hideColumn(k*1);}}
this.model.setProperty("modified",true);userSmarts.wt.dialogs.Dialog.prototype.okPressed.call(this);};userSmarts.wt.dialogs.ToolbarMenu=function(properties){if(isPrototype(arguments))return;properties=properties||{};setdefault(properties,{title:"",modal:false,width:150,height:250});userSmarts.wt.dialogs.Dialog.call(this,properties);};userSmarts.wt.dialogs.ToolbarMenu.inheritsFrom(userSmarts.wt.dialogs.Dialog);$prototype.createDialogArea=function(parent){this.titleBar.style.display="none";this.getButtonBar().style.display="none";parent.style.padding="none";var div=DIV();div.style.width="100%";div.style.border="1px solid #555555";div.style.backgroundColor="#FFFFCC";div.style.font="12px small Arial";this.listeners=[];if(this.toolbarManager){var item;var node;var icon;var text;var items=this.toolbarManager.getItems();for(var i=0;i<items.length;i++){item=items[i];if(item instanceof userSmarts.wt.action.Action&&!(item instanceof userSmarts.wt.action.OpenToolbarSelectorAction)){icon=IMG({src:item.getImage()});text=" ";if(typeof(item.getText)=='function'){text+=(item.getText()||"Item");}else{text+="Item";}
node=DIV({'class':'toolbar-menu-item'},icon,text);node.index=i;if(i==0){node.style.borderTop="none";}
this.listeners.push(connect(node,"onclick",this,this.executeItem));div.appendChild(node);}}}
parent.appendChild(div);};$prototype.executeItem=function(event){var node=event.src();var itemIndex=node.index;this.onOk();this.toolbarManager.getItems()[itemIndex].execute();};$prototype.close=function(){for(var i=0;i<this.listeners.length;++i){disconnect(this.listeners[i]);this.listeners[i]=null;}
userSmarts.wt.dialogs.Dialog.prototype.close.call(this);};$namespace.SelectColumnDialog=Class.create(userSmarts.wt.dialogs.Dialog);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{title:"Select List Column",modal:false,width:200,height:125,description:"Choose which column to select from the list below:"});userSmarts.wt.dialogs.Dialog.call(this,properties);};$prototype.createDialogArea=function(parent){parent.appendChild(document.createTextNode(this.description));parent.appendChild(BR());var dt={uri:{namespaceURI:'http://www.usersmarts.com/rcp/wt/list',prefix:'list',localPart:'columns'},facets:{enumeration:[]}};var model=this.model||(this.list?this.list.model:null);if(model){var option;var columns=this.model.getColumns();for(var i=0;i<columns.length;++i){if(columns[i].visible!=false){option={label:columns[i].label||columns[i].name,value:columns[i]};if(columns[i].name==model.getSortElement()){option.selected=true;this.column=columns[i];}
dt.facets.enumeration.push(option);}}}else{dt.facets.enumeration.push({label:"No columns",value:null});}
if(!this.column){this.column=dt.facets.enumeration[0].value;}
var props={size:1,parent:null,binding:new BeanPropertyBinding(this,'column'),optionModel:new userSmarts.wt.forms.DefaultOptionModel({datatype:dt})};var select=new userSmarts.wt.forms.SelectWidget(props);parent.appendChild(select.paint());};$prototype.getSelectedColumn=function(){return this.column;};namespace("userSmarts.wt.widgets");userSmarts.wt.widgets.Display=function(root){if(userSmarts.wt.widgets.Display.inst===null){userSmarts.wt.widgets.Display.inst=this;}
this.window=window;this.shells=[];this.root=root;if(!this.root){this.root=document.getElementById("display")||document.documentElement.getElementsByTagName("BODY")[0];}
connect(this.window,"onresize",this,this.onResize);};userSmarts.wt.widgets.Display.prototype.getShells=function(){return this.shells;};userSmarts.wt.widgets.Display.prototype.getHiddenDiv=function(){if(!this.hiddenDiv){this.hiddenDiv=$("testSizeDiv");}
if(!this.hiddenDiv){var div=this.hiddenDiv=DIV({id:"testSizeDiv",style:"position:fixed; left:0; top:0; width:100%; height:100%; visibility:hidden; z-index:-1"});div.style.position="fixed";div.style.left="0px";div.style.top="0px";div.style.width="100%";div.style.height="100%";}
document.body.appendChild(this.hiddenDiv);return this.hiddenDiv;};userSmarts.wt.widgets.Display.prototype.getWidth=function(){var div=this.getHiddenDiv();var result=parseInt(div.scrollWidth);if(userSmarts.util.Browser.isIE){result=document.documentElement.clientWidth;if(result>0){result-=16;}else{result=document.body.clientWidth;}}
return result;};userSmarts.wt.widgets.Display.prototype.getHeight=function(){var div=this.getHiddenDiv();var result=parseInt(div.scrollHeight);if(userSmarts.util.Browser.isIE){result=document.documentElement.clientHeight;if(result>0){result-=16;}else{result=document.body.clientHeight;}}
return result;};userSmarts.wt.widgets.Display.prototype.getNewSize=function(){var div=this.getHiddenDiv();var result={height:parseInt(div.scrollHeight),width:parseInt(div.scrollWidth)};if(userSmarts.util.Browser.isIE){result={height:document.documentElement.clientHeight,width:document.documentElement.clientWidth};if(result.width>0){result.width-=16;}else{result.width=document.body.clientWidth;}
if(result.height>0){result.height-=16;}else{result.height=document.body.clientHeight;}}
return result;};userSmarts.wt.widgets.Display.prototype.onResize=function(){for(var i=0;i<this.shells.length;++i){var shell=this.shells[i];if(shell){var node=shell.node;if(node){node.oldDisplay=node.style.display;node.style.display="none";}}}
var size=this.getNewSize();for(var i=0;i<this.shells.length;++i){var shell=this.shells[i];if(shell){shell.setBounds(0,0,size.width,size.height);shell.update();shell.node.style.display=shell.node.oldDisplay;}}};userSmarts.wt.widgets.Display.getDefault=function(){if(!userSmarts.wt.widgets.Display.inst){userSmarts.wt.widgets.Display.inst=new userSmarts.wt.widgets.Display();}
return userSmarts.wt.widgets.Display.inst;};userSmarts.wt.widgets.Control=Class.create(Bean);$prototype.initialize=function(superClass,properties){properties=setdefault(properties||{},{size:{width:0,height:0},margin:{left:0,right:0,top:0,bottom:0},padding:{left:0,right:0,top:0,bottom:0},border:{style:"none",left:0,right:0,top:0,bottom:0}});superClass.call(this,properties);if(this.parent instanceof userSmarts.wt.widgets.Composite){this.parent.add(this);}};$prototype.setParent=function(parent){this.parent=parent;};$prototype.getParent=function(){return this.parent;};$prototype.dispose=function(){this.disposed=true;this.node=null;};$prototype.isDisposed=function(){return this.disposed;};$prototype.isVisible=function(){var result=this.visible!==false;if(result&&this.parent){result=this.parent.isVisible();}
return result;};$prototype.getShell=function(){return this.getParent().getShell();};$prototype.getSize=function(){return this.size;};$prototype.setSize=function(width,height){if(!this.size){this.size={};}
var modified=!(this.size.width==width&&this.size.height==height);this.size.width=width||0;this.size.height=height||0;if(this.size.width<0)this.size.width=1;if(this.size.height<1)this.size.height=1;var node=this.getNode();node.style.width=this.size.width+"px";node.style.height=this.size.height+"px";return modified;};$prototype.setLocation=function(left,top){var modified=!(this.left==left&&this.top==top);this.left=left|0;this.top=top|0;var node=this.getNode();node.style.left=left+"px";node.style.top=top+"px";node.style.position="absolute";return modified;};$prototype.getLocation=function(){return{left:this.left,top:this.y};};$prototype.setBounds=function(left,top,width,height){var modified;var width=width||0;var height=height||0;if(width>0){width-=((this.margin.left||0)+(this.margin.right||0)+(this.padding.left||0)+(this.padding.right||0)+(this.border.left||0)+(this.border.right||0));}
if(height>0){height-=((this.margin.top||0)+(this.margin.bottom||0)+
(this.padding.top||0)+(this.padding.bottom||0)+
(this.border.top||0)+(this.border.bottom||0));}
left=(left||0);top=(top||0)+this.margin.top+this.padding.top+this.border.top;modified=this.setLocation(left,top);modified=this.setSize(width,height)||modified;if(this.updateOnBoundsChange){if(modified&&this.isVisible()){this.update();}}};$prototype.getBounds=function(){return{x:this.left,y:this.top,width:this.size.width,height:this.size.height};};$prototype.getNode=function(){if(!this.node){var atts={};if(this["class"]){atts["class"]=this["class"];}
if(this.style){atts.style=this.style;}
if(this.id){atts.id=this.id;}
this.node=createDOM(this.nodeName||"div",atts);var m=this.margin;var p=this.padding;var b=this.border;var s=this.node.style;s.position="absolute";s.marginLeft=m.left+"px";s.marginRight=m.right+"px";s.marginTop=m.top+"px";s.marginBottom=m.bottom+"px";s.paddingLeft=p.left+"px";s.paddingRight=p.right+"px";s.paddingTop=p.top+"px";s.paddingBottom=p.bottom+"px";s.borderStyle=b.style
s.borderLeftWidth=b.left+"px";s.borderRightWidth=b.right+"px";s.borderTopWidth=b.top+"px";s.borderBottomWidth=b.bottom+"px";this.initNode();}
return this.node;};$prototype.initNode=function(){this.update();};$prototype.update=function(){};$prototype.paint=function(){return this.getNode();};$prototype.repaint=function(){this.update();};$prototype.setLayoutData=function(layoutData){this.layoutData=layoutData;};$prototype.getLayoutData=function(){return this.layoutData;};$prototype.setVisibility=function(visible){this.visible=visible;if(this.node){this.node.style.display=visible?"block":"none";}};$namespace.Composite=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){this.children=[];superClass.call(this,properties||{});};$prototype.update=function(){if(!this.node){return;}
this.layout();var nodes=[];for(var i=0;i<this.children.length;++i){var child=this.children[i];if(child.visible===undefined||child.visible===true){try{child.update();}catch(e){}}
var node=child.getNode();nodes.push(node);}
replaceChildNodes(this.node,nodes);};$prototype.getClientArea=function(){return this.getBounds();};$prototype.layout=function(){if(this._layout){this._layout.layout(this);}};$prototype.setLayout=function(layout){this._layout=layout;};$prototype.getLayout=function(layout){return this._layout;};$prototype.getChildren=function(layout){return this.children;};$prototype.remove=function(child){try{var index=-1;for(var i=0;i<this.children.length;++i){if(child==this.children[i]){index=i;break;}}
if(index>=0){this.children.splice(index,1);}
if(child){var node=child.getNode();if(node){this.getNode().removeChild(node);}}
return child;}catch(e){logError("Error removing child from composite");}};$prototype.add=function(child){var result=-1;try{var node=child.getNode();if(node){this.getNode().appendChild(node);this.append("children",child);result=this.children.length-1;}}catch(e){logError("Error appending child to composite");}
return result;};$prototype.replace=function(newChild,oldChild){try{var index=-1;for(var i=0;i<this.children.length;++i){if(oldChild==this.children[i]){index=i;break;}}
if(index>=0){this.children.splice(index,1,newChild);}
if(oldChild){var node=oldChild.getNode();if(node&&newChild){this.getNode().replaceChild(newChild.getNode(),node);}else{this.getNode().removeChild(node);}}
return oldChild;}catch(e){logError("Error removing child from composite");}};$prototype.dispose=function(){var children=this.children;var length=children.length;for(var i=0;i<length;++i){try{children[i].dispose();}catch(e){}}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};userSmarts.wt.widgets.Layout=function(properties){if(isPrototype(arguments)){return;}
Bean.call(this,properties);};userSmarts.wt.widgets.Layout.inheritsFrom(Bean);userSmarts.wt.widgets.Layout.VERTICAL="vertical";userSmarts.wt.widgets.Layout.HORIZONTAL="horizontal";userSmarts.wt.widgets.Layout.prototype.layout=function(composite){var width=composite.getWidth();var height=composite.getHeight();};userSmarts.wt.widgets.Shell=function(properties){if(isPrototype(arguments)){return;}
userSmarts.wt.widgets.Composite.call(this,properties);if(this.parent){this.display=this.parent.getDisplay();}
if(!this.display){this.display=userSmarts.wt.widgets.Display.getDefault();}
if(!this.node){this.node=this.display.root;}
if(!this.parent){this.display.getShells().push(this);}};userSmarts.wt.widgets.Shell.inheritsFrom(userSmarts.wt.widgets.Composite);userSmarts.wt.widgets.Shell.prototype.close=function(){};userSmarts.wt.widgets.Shell.prototype.getShell=function(){return this;};userSmarts.wt.widgets.Shell.prototype.getShells=function(){return this.shells;};userSmarts.wt.widgets.Shell.prototype.getDisplay=function(){return this.display;};userSmarts.wt.widgets.Shell.prototype.getStyle=function(){return this.style;};userSmarts.wt.widgets.TreeNode=function(label,parent){if(isPrototype(arguments)){return;}
this.label=label;this.parent=parent;this.children=[];this.uid=new Date().getTime()+Math.random();};userSmarts.wt.widgets.TreeNode.prototype.getLabel=function(){return this.label;};userSmarts.wt.widgets.TreeNode.prototype.getParent=function(){return this.parent;};userSmarts.wt.widgets.TreeNode.prototype.addNode=function(node){this.children.push(node);};userSmarts.wt.widgets.TreeNode.prototype.hasChildren=function(){return(this.children.length!==0);};userSmarts.wt.widgets.TreeNode.prototype.getChildren=function(){return this.children;};userSmarts.wt.widgets.TreeNode.prototype.hasChild=function(child){for(var i=0;i<this.children.length;i++){if(this.children[i].uid.equals(child.uid)){return true;}}
return false;};userSmarts.wt.widgets.TreeNode.prototype.equals=function(node){return node.uid&&(this.uid==node.uid);};userSmarts.wt.widgets.TreeNode.prototype.toString=function(){return this.label;};userSmarts.wt.widgets.TreeModel=function(){if(isPrototype(arguments)){return;}};userSmarts.wt.widgets.TreeModel.prototype.setSource=function(source){this.source=source;};userSmarts.wt.widgets.TreeModel.prototype.getRoot=function(){return this.source;};userSmarts.wt.widgets.TreeModel.prototype.getLabel=function(element){return element.getLabel();};userSmarts.wt.widgets.TreeModel.prototype.hasChildren=function(element){return element.hasChildren();};userSmarts.wt.widgets.TreeModel.prototype.getChildren=function(element){return element.getChildren();};userSmarts.wt.widgets.TreeModel.prototype.getParent=function(element){return element.getParent();};userSmarts.wt.widgets.TreeModel.prototype.getClassName=function(element,expanded){if(this.hasChildren(element)){if(expanded===true){return'folder-open';}else if(expanded===false){return'folder-closed';}else{return'folder';}}else{return'file';}};userSmarts.wt.widgets.TreeModel.prototype.compareNodes=function(element1,element2){return element1.equals(element2);};userSmarts.wt.widgets.BeanTreeModel=Class.create(Bean);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);setdefault(this,{root:{}});};$prototype.getRoot=function(){return this.root;};$prototype.getLabel=function(node){return node.label||"";};$prototype.hasChildren=function(node){return(node.iterable&&node[node.iterable].length>0);};$prototype.getChildren=function(node){return node[node.iterable]||[];};$prototype.getParent=function(node){return(node)?node.parent:null;};$prototype.getClassName=function(node,expanded){var result=node['class'];if(!result){if(this.hasChildren(node)){if(expanded===true){result='folder-open';}else if(expanded===false){result='folder-closed';}else{result='folder';}}else{result='file';}}
return result;};$prototype.getSelectionHandler=function(node){return node.onselect||function(){alert("selected!");};};$prototype.compareNodes=function(node1,node2){return node1.equals(node2);};userSmarts.wt.widgets.DOMTreeModel=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{useAttributes:false});Bean.call(this,properties);new URLChangeListener(this,"source","document");this.addChangeListener(bind(this.onSourceChange,this),"document");logDebug("DOMTReeModel created! source: "+this.source);};userSmarts.wt.widgets.DOMTreeModel.inheritsFrom(Bean);userSmarts.wt.widgets.DOMTreeModel.prototype.onSourceChange=function(event){logDebug("document: "+this.document);logDebug("source: "+this.source);this.setSource(event.newValue);};userSmarts.wt.widgets.DOMTreeModel.prototype.onDocumentChange=function(event){logDebug("document: "+this.document);logDebug("source: "+this.source);};userSmarts.wt.widgets.DOMTreeModel.prototype.setSource=function(document){this.document=document;this.setProperty('modelChanged',true);};userSmarts.wt.widgets.DOMTreeModel.prototype.getRoot=function(){var result=null;if(this.document){if(this.document.nodeType==9){result=this.document.documentElement;}else if(this.document.nodeType==1){result=this.document;}}else{logDebug("DOMTreeModel document: "+this.document);}
logDebug("treeRoot: "+result);return result;};userSmarts.wt.widgets.DOMTreeModel.prototype.hasChildren=function(element){var result=false;if(element){for(var i=0;i<element.childNodes.length;i++){if(element.childNodes[i].nodeType==Node.ELEMENT_NODE){result=true;break;}}}
logDebug("hasChildren: "+result);return result;};userSmarts.wt.widgets.DOMTreeModel.prototype.getChildren=function(element){var children=[];for(var i=0;i<element.childNodes.length;i++){if(element.childNodes[i].nodeType==Node.ELEMENT_NODE){children.push(element.childNodes[i]);}}
return children;};userSmarts.wt.widgets.DOMTreeModel.prototype.getParent=function(element){if(!element){return null;}
return element.parentNode;};userSmarts.wt.widgets.DOMTreeModel.prototype.getLabel=function(element){if(!element){return"";}
if(this.useAttributes){return element.getAttribute('label');}else{return element.localName||element.baseName;}};userSmarts.wt.widgets.DOMTreeModel.prototype.getClassName=function(element,expanded){if(this.getRoot()==element){return'root';}
if(this.hasChildren(element)){if(expanded){return'folder-open';}else if(!expanded){return'folder-closed';}else{return'folder';}}else{return'file';}};userSmarts.wt.widgets.DOMTreeModel.prototype.getSelectionHandler=function(element){return function(node){alert(node+' is selected');};};userSmarts.wt.widgets.DOMTreeModel.prototype.compareNodes=function(element1,element2){return(element1==element2);};userSmarts.wt.widgets.MenuTreeModel=function(){if(isPrototype(arguments)){return;}};userSmarts.wt.widgets.MenuTreeModel.prototype.setSource=function(source){this.source=source;};userSmarts.wt.widgets.MenuTreeModel.prototype.getRoot=function(){return this.source;};userSmarts.wt.widgets.MenuTreeModel.prototype.getLabel=function(element){return(element.getLabel)?element.getLabel():element;};userSmarts.wt.widgets.MenuTreeModel.prototype.hasChildren=function(element){return(element.hasChildren)?element.hasChildren():false;};userSmarts.wt.widgets.MenuTreeModel.prototype.getChildren=function(element){return(element.getChildren)?element.getChildren():[];};userSmarts.wt.widgets.MenuTreeModel.prototype.getParent=function(element){return(element.getParent)?element.getParent():null;};userSmarts.wt.widgets.MenuTreeModel.prototype.getClassName=function(element,expanded){return'';};userSmarts.wt.widgets.MenuTreeModel.prototype.getSelectionHandler=function(element){return null;};userSmarts.wt.widgets.MenuTreeModel.prototype.compareNodes=function(element1,element2){return element1.equals(element2);};userSmarts.wt.widgets.DOMMenuTreeModel=function(){if(isPrototype(arguments)){return;}
Bean.call(this,{});new URLChangeListener(this,"source","document");this.addChangeListener(bind(this.onSourceChange,this),"document");};userSmarts.wt.widgets.DOMMenuTreeModel.inheritsFrom(Bean);userSmarts.wt.widgets.DOMMenuTreeModel.prototype.onSourceChange=function(event){this.setSource(event.newValue);};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.setSource=function(source){this.source=source;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getRoot=function(){return(this.source)?this.source.documentElement:null;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getLabel=function(element){if(!element){return"";}
return element.localName||element.baseName;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.hasChildren=function(element){if(!element){return false;}
for(var i=0;i<element.childNodes.length;i++){if(element.childNodes[i].nodeType==Node.ELEMENT_NODE){return true;}}
return false;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getChildren=function(element){var children=[];for(var i=0;i<element.childNodes.length;i++){if(element.childNodes[i].nodeType==Node.ELEMENT_NODE){children.push(element.childNodes[i]);}}
return children;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getParent=function(element){if(!element){return null;}
return element.parentNode;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getClassName=function(element,expanded){return'';};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.getSelectionHandler=function(element){return null;};userSmarts.wt.widgets.DOMMenuTreeModel.prototype.compareNodes=function(element1,element2){return(element1==element2);};userSmarts.wt.widgets.TreeWidget=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{selected:null,imageBase:"../../images/tree/",loadAll:false,"class":'tree'});userSmarts.wt.widgets.Control.call(this,properties);connect(this,"model",this,this.onModelChange);if(this.model){this.touch("model");}};userSmarts.wt.widgets.TreeWidget.inheritsFrom(userSmarts.wt.widgets.Control);userSmarts.wt.widgets.TreeWidget.prototype.setModel=function(model){this.setProperty("model",model);};userSmarts.wt.widgets.TreeWidget.prototype.getModel=function(){return this.model;};userSmarts.wt.widgets.TreeWidget.prototype.onModified=function(event){this.update();};userSmarts.wt.widgets.TreeWidget.prototype.onModelChange=function(event){if(!this.modifiedSub){disconnect(this.modifiedSub);}
this.modifiedSub=connect(this.model,"modelChanged",this,this.onModified);this.update();};userSmarts.wt.widgets.TreeWidget.prototype.cleanupNode=function(node){if(node.source){node.source=null;}
return node.childNodes;};userSmarts.wt.widgets.TreeWidget.prototype.dispose=function(){if(this.node){nodeWalk(this.node,this.cleanupNode);}
if(this.modifiedSub){disconnect(this.modifiedSub);this.modifiedSub=null;}
userSmarts.wt.widgets.Control.prototype.dispose.call(this);};userSmarts.wt.widgets.TreeWidget.prototype.initNode=function(){this.update();connect(this.node,"onclick",this,this.onClick);}
userSmarts.wt.widgets.TreeWidget.prototype.update=function(){if(arguments.length==1){this.updateNode(arguments[0]);logDebug("Please call updateNode instead.");return;}
var root=this.model.getRoot();if(!root){return;}
var node=this.getNode();var subtree;if(!this.hideRoot){subtree=this.buildNode(this.model.getRoot(),null,true,true);this.loadChildren(subtree);}else{subtree=DIV();subtree.isLast=true;subtree.isHidden=true;subtree.source=this.model.getRoot();this.loadChildren(subtree,true);}
if(subtree){replaceChildNodes(node,subtree);if(this.selected){this.select(this.selected);}}};userSmarts.wt.widgets.TreeWidget.prototype.buildNode=function(element,parent,showOpen,isLast){if(!element){return null;}
if(!showOpen){showOpen=false;}
var nodeLabel=this.model.getLabel(element);var node=document.createElement("div");node.className="tree-node";node.source=element;node.isLast=isLast;node.hasChildrenLoaded=false;node.expanded=(this.loadAll||showOpen)?true:false;if(this.selected&&typeof(this.model.compareNodes)=='function'&&this.model.compareNodes(this.selected,element)){this.selectNodeQuiet(node);}
this.pad(node,parent,showOpen);var className=this.model.getClassName(element,showOpen);if(typeof(this.model.isCheckable)!='undefined'&&this.model.isCheckable(element)){var checkbox=INPUT({'type':'checkbox'});checkbox.defaultChecked=this.model.isChecked(element)||false;checkbox.style.height='10px';checkbox.style.width='10px';checkbox.style.verticalAlign='middle';checkbox.style.marginLeft='0px';checkbox.style.marginRight='3px';node.appendChild(checkbox);}
var icon=document.createElement("img");icon.src=this.getBlankImage();icon.className="icon "+className;icon.style.cursor="pointer";node.appendChild(icon);var label=document.createElement("span");label.className="label";label.appendChild(document.createTextNode(nodeLabel));node.appendChild(label);return node;};userSmarts.wt.widgets.TreeWidget.prototype.loadChildren=function(node,nopad){var element=node.source;var parent=nopad?null:node;if(this.model.hasChildren(element)){var children=this.model.getChildren(element);var last=children.length-1;var length=children.length;for(var i=0;i<length;i++){var child=this.buildNode(children[i],parent,this.loadAll,i==last);node.appendChild(child);if(this.loadAll){this.loadChildren(child);}}}
node.hasChildrenLoaded=true;};userSmarts.wt.widgets.TreeWidget.prototype.onClick=function(event){var target=event.target();var node=target.parentNode;var element=node.source;var tree=this;if(!node){return;}
if(!target.ispad){if(typeof target.defaultChecked!="undefined"){this.setProperty("checked",{node:node.source,value:target.checked});}else{tree.selectNode(node);}}else if(target.isparent){var padding=target;if(node.expanded){tree.collapseNode(node);if(node.isLast){padding.className='plusbottom';}else{padding.className='plus';}}else{tree.expandNode(node);if(node.isLast){padding.className='minusbottom';}else{padding.className='minus';}}}
event.stopPropagation();};userSmarts.wt.widgets.TreeWidget.prototype.pad=function(node,parent,showOpen){var tree=this;var spacer=this.getBlankImage();var composite=this.model.hasChildren(node.source);var cname;if(!node.isLast){if(composite){cname=(this.loadAll||showOpen)?'minus':'plus';}else{cname='join';}}else{if(composite){cname=(this.loadAll||showOpen)?'minusbottom':'plusbottom';}else{cname='joinbottom';}}
var padding=document.createElement("img");padding.src=spacer;padding.className=cname;padding.ispad=true;if(composite){padding.isparent=true;}
node.insertBefore(padding,node.firstChild);while(parent&&parent.source&&!parent.isHidden){cname='empty';if(!parent.isLast){cname='line';}
var padding=document.createElement("img");padding.src=spacer;padding.className=cname;padding.ispad=true;node.insertBefore(padding,node.firstChild);parent=parent.parentNode;}};userSmarts.wt.widgets.TreeWidget.prototype.select=function(element){var node=this.getTreeNode(element);this.selectNode(node);};userSmarts.wt.widgets.TreeWidget.prototype.selectNode=function(node){if(!node)return;if(this.selectedNode){removeElementClass(this.selectedNode,'selected-tree-node');}
addElementClass(node,'selected-tree-node');this.setProperty("selected",node.source);this.setProperty("selectedNode",node);};userSmarts.wt.widgets.TreeWidget.prototype.selectNodeQuiet=function(node){if(!node)return;if(this.selectedNode){removeElementClass(this.selectedNode,'selected-tree-node');}
addElementClass(node,'selected-tree-node');this.selected=node.source;this.selectedNode=node;};userSmarts.wt.widgets.TreeWidget.prototype.findIcon=function(node){for(var i=0;i<node.childNodes.length;++i){var child=node.childNodes[i];var className=child.className;if(className&&className.startsWith("icon ")){return child;}}
return null;};userSmarts.wt.widgets.TreeWidget.prototype.expand=function(element){var node=this.getTreeNode(element);if(!node){return;}
this.expandNode(node);};userSmarts.wt.widgets.TreeWidget.prototype.expandNode=function(node){if(!node){return;}
if(!node.hasChildrenLoaded){this.loadChildren(node);}
node.expanded=true;var icon=this.findIcon(node);if(icon){icon.className="icon "+this.model.getClassName(node.source,true);}
for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes[i];if(child.className=='tree-node'&&child.style){child.style.display='block';}}};userSmarts.wt.widgets.TreeWidget.prototype.collapse=function(element){var node=this.getTreeNode(element);this.collapseNode(node);};userSmarts.wt.widgets.TreeWidget.prototype.collapseNode=function(node){if(!node||!node.expanded){return;}
node.expanded=false;var icon=this.findIcon(node);if(icon){icon.className="icon "+this.model.getClassName(node.source,false);}
for(var i=0;i<node.childNodes.length;i++){var child=node.childNodes[i];if(child.className=='tree-node'&&child.style){child.style.display='none';}}};userSmarts.wt.widgets.TreeWidget.prototype.updateNode=function(node){if(!node.source){node=this.getTreeNode(node);}
if(!node||!node.source){return;}
var parent=node.parentNode;var newChild=this.buildNode(node.source,parent,true,node.isLast);parent.replaceChild(newChild,node);this.loadChildren(newChild);};userSmarts.wt.widgets.TreeWidget.prototype.getTreeNode=function(element,parent){if(!parent&&this.model){parent=this.node;}
if(parent.source==element){return parent;}
var children=parent.childNodes;var length=children.length;for(var i=0;i<length;++i){var child=children[i];if(child.source==element){return child;}}
var foundNode;for(var i=0;i<length;++i){var child=children[i];if(child.source){foundNode=this.getTreeNode(element,child);if(foundNode){return foundNode;}}}
return null;};userSmarts.wt.widgets.TreeWidget.prototype.getBlankImage=function(){return this.imageBase+'spacer.gif';};userSmarts.wt.widgets.Tree=function(properties){userSmarts.wt.widgets.TreeWidget.call(this,properties);};userSmarts.wt.widgets.Tree.inheritsFrom(userSmarts.wt.widgets.TreeWidget);userSmarts.wt.widgets.CheckableTreeWidget=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{selected:null,imageBase:"../../images/tree/",loadAll:false});userSmarts.wt.widgets.TreeWidget.apply(this,[properties]);};userSmarts.wt.widgets.CheckableTreeWidget.inheritsFrom(userSmarts.wt.widgets.TreeWidget);userSmarts.wt.widgets.CheckableTreeWidget.prototype.recursivelyBuildTree=function(element,parent,level,showOpen){if(!element){return null;}else if(!showOpen){showOpen=false;}
var nodeLabel=this.model.getLabel(element);var node=DIV({'id':nodeLabel,'class':'tree-node'});node.source=element;node.style.verticalAlign='middle';node.hasChildrenLoaded=false;this.pad(element,node,level,showOpen);var tree=this;if(typeof(this.model.isCheckable)!='undefined'&&this.model.isCheckable(element)){var checkbox=INPUT({'type':'checkbox'});checkbox.defaultChecked=this.model.isChecked(element)||false;checkbox.style.height='10px';checkbox.style.width='10px';checkbox.style.verticalAlign='middle';checkbox.style.marginLeft='0px';checkbox.style.marginRight='3px';checkbox.onclick=bind(function(elem,cb){this.setProperty("checked",{node:elem,value:cb.checked});},this,element,checkbox);node.appendChild(checkbox);}
var className=this.model.getClassName(element,showOpen);var icon=IMG({'src':this.getBlankImage(),'class':className});node.icon=icon;node.appendChild(icon);var label=SPAN({'class':'label'});label.appendChild(document.createTextNode(nodeLabel));node.label=label;label.onclick=bind(this.select,this,element);node.appendChild(label);if(this.loadAll||showOpen){if(this.model.hasChildren(element)){var children=this.model.getChildren(element);for(var i=0;i<children.length;i++){node.appendChild(this.recursivelyBuildTree(children[i],node,level+1,this.loadAll));}}
node.hasChildrenLoaded=true;}
return node;};userSmarts.wt.widgets.Clock=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){superClass.call(properties);this.tick=bind(userSmarts.wt.widgets.Clock.prototype.tick,this);};$prototype.initNode=function(){var content=this.content=document.createTextNode(toISOTimestamp(new Date()));this.node.appendChild(content);this.start();};$prototype.update=function(){var content=document.createTextNode(toISOTimestamp(new Date()));this.node.replaceChild(content,this.content);this.content=content;};$prototype.start=function(){if(!this.running){this.running=true;this.tick();}};$prototype.stop=function(){this.running=false;};$prototype.tick=function(){this.update();if(this.running){this.timer=setTimeout(this.tick,1000);}};userSmarts.wt.widgets.SliderWidget=function(properties){if(isPrototype(arguments))return;properties=setdefault(properties,{width:150,value:0});Bean.call(this,properties);connect(this,'onchange',this,"onValueChange");};userSmarts.wt.widgets.SliderWidget.inheritsFrom(Bean);userSmarts.wt.widgets.SliderWidget.prototype.paint=function(){if(!this.content){this.content=DIV();this.content.style.width=this.width+"px";this.sliderValue=DIV({'class':'slider-value'});this.sliderValue.style.width=this.width+"px";this.content.appendChild(this.sliderValue);this.slider=DIV({'class':'slider'});this.slider.style.width=this.width+"px";this.content.appendChild(this.slider);this.sliderMarker=DIV({'class':'slider-marker'});this.sliderMarker.style.width=this.width+"px";this.content.appendChild(this.sliderMarker);}
this.repaint();return this.content;};userSmarts.wt.widgets.SliderWidget.prototype.repaint=function(){if(typeof(this.min)=='number'&&typeof(this.max)=='number'&&typeof(this.increment)=='number'){var perc=(this.value*this.width);if(!this.bar){this.bar=DIV({'class':'slider-bar'},IMG({src:'../../images/map/background-bar-red.gif',height:'6',width:'2'}));this.slider.appendChild(this.bar);this.sliderClickListener=connect(this.content,'onclick',this,'onClick');}
this.bar.style.width=perc+'px';this.bar.style.textAlign='right';var marker=SPAN({},'^');marker.style.position='relative';marker.style.left=perc+'px';marker.style.font='8px arial';replaceChildNodes(this.sliderMarker,marker);var val=SPAN({},this.value.toFixed(2));val.style.position='relative';val.style.left=perc+'px';val.style.font='8px arial';replaceChildNodes(this.sliderValue,val);}};userSmarts.wt.widgets.SliderWidget.prototype.onClick=function(evt){var event=fixE(evt.event());var pos=elementPosition(this.content);var posRelToSlider={x:event.clientX-pos.x+parseInt(document.body.scrollLeft),y:event.clientY-pos.y+parseInt(document.body.scrollTop)};var wp=posRelToSlider.x/this.width;this.value=this.max*wp;this.value=Math.min(this.value,this.max);this.value=Math.max(this.value,this.min);signal(this,'onchange',this.value);};userSmarts.wt.widgets.SliderWidget.prototype.onValueChange=function(value){this.setProperty("selected",value);this.repaint();};userSmarts.wt.widgets.SliderWidget.prototype.getValue=function(){return this.value;};userSmarts.wt.widgets.SliderWidget.prototype.setValue=function(value){this.value=value;};userSmarts.wt.widgets.SliderWidget.prototype.dispose=function(){if(this.sliderClickListener){disconnect(this.sliderClickListener);}
if(this.content){disconnectAll(this.content);replaceChildNodes(this.content,null);this.bar=null;this.sliderValue=null;this.slider=null;this.sliderMarker=null;this.content=null;}};$namespace.Slider=Class.create(userSmarts.wt.widgets.SliderWidget);$prototype.initialize=function(superClass,properties){superClass.call(this,properties);};$namespace.PlaceHolderControl=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){superClass.call(this,properties||{});};$prototype.update=function(){var content=this.content;if(content instanceof userSmarts.wt.widgets.Control){var location=content.getLocation();if(location&&this.size.width>0&&this.size.height>0){content.setBounds(location.left,location.top,this.size.width,this.size.height);}
try{var node=content.getNode();replaceChildNodes(this.node,node);}catch(e){replaceChildNodes(this.node,DIV(null,"Error rendering view"));}}};userSmarts.wt.widgets.TabFolder=Class.create(userSmarts.wt.widgets.Composite);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{items:[],"class":"tabbox"});superClass.call(this,properties);this.tabControl=new userSmarts.wt.widgets.Composite({parent:this,"class":"tabs",layoutData:{width:"100%",height:'30px'}});this.toolbar=new userSmarts.wt.widgets.PlaceHolderControl({parent:this,"class":"wt-toolbar",layoutData:{width:"100%",height:'27px'}});this.panels=new userSmarts.wt.widgets.Composite({parent:this,"class":"wt-tabpanels",layoutData:{width:"100%",height:'*'}});this.panels.setLayout(new userSmarts.wt.layout.StackLayout());this.tabControl.setLayout(new userSmarts.wt.layout.RowLayout({type:"horizontal"}));this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));};$prototype.addItem=function(tabItem){tabItem.layoutData={width:"*",height:"30px"};this.items.push(tabItem);this.tabControl.add(tabItem);this.panels.add(tabItem.getControl()||new userSmarts.wt.widgets.Control());if(!this.selected){this.setSelection(tabItem);}};$prototype.removeItem=function(tabItem){tabItem=this.resolve(tabItem);if(tabItem){var control=tabItem.getControl();this.items.remove(tabItem);this.tabControl.remove(tabItem);this.panels.remove(control);this.setSelection(0);}
return tabItem;};$prototype.setSelection=function(tabItem){var previous=this.selected;tabItem=this.resolve(tabItem);if(previous!=tabItem){if(previous instanceof userSmarts.wt.widgets.TabItem){previous.setProperty("selected",false);}
if(tabItem instanceof Bean){tabItem.setProperty("selected",true);}
this.setProperty("selected",tabItem);this.update();}};$prototype.resolve=function(tabItem){if(typeof tabItem=="number"){tabItem=this.items[tabItem];}else if(typeof tabItem=="string"){for(var i=0;i<this.items.length;++i){if(this.items[i].name==tabItem){tabItem=this.items[i];break;}}}else if(!(tabItem instanceof userSmarts.wt.widgets.TabItem)){tabItem=null;}
return tabItem;};$prototype.update=function(){if(!this.toolbar){return;}
var tbNode=null;var tabItem=this.selected;this.panels.getLayout().topControl=tabItem?tabItem.getControl():null;this.panels.layout();userSmarts.wt.widgets.Composite.prototype.update.apply(this);if(tabItem){var toolbar=tabItem.getToolbar();if(toolbar){this.toolbar.content=toolbar;this.toolbar.update();}}};namespace("userSmarts.wt.widgets");$namespace.TabItem=Class.create($namespace.Control);$prototype.initialize=function(superClass,properties){var parent=properties.parent;properties=setdefault(properties,{text:"",nodeName:"span","class":"tab",border:{style:"solid",left:1,right:1,top:1,bottom:0},padding:{top:2,bottom:2,left:2,right:2},margin:{top:0,bottom:0,left:1,right:0}});properties.parent=null;superClass.call(this,properties);this.parent=parent;if(parent instanceof userSmarts.wt.widgets.TabFolder){parent.addItem(this);}};$prototype.getText=function(){return this.text;};$prototype.getImage=function(){return this.image;};$prototype.getControl=function(){return this.control;};$prototype.getToolbar=function(){return this.toolbar;};$prototype.onClick=function(event){this.parent.setSelection(this);};$prototype.onClose=function(event){if(typeof this.close=="function"){this.close();}};$prototype.initNode=function(){var node=this.node;var img=this.getImage();var text=this.getText()||"";if(img){var theme=userSmarts.runtime.Platform.getTheme();if(theme){var imgtag=theme.getImage(img,null);if(imgtag){node.appendChild(imgtag);imgtag="(X)";}else{node.appendChild(IMG({src:img,alt:""}));}}else{node.appendChild(IMG({src:img,alt:""}));}}
node.appendChild(document.createTextNode(" "+text));if(this.isCloseable()){var closeImg=IMG({src:userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/close_icon.gif'),alt:"(X)"});connect(closeImg,"onclick",this,this.onClose);closeImg.style.cursor="pointer";node.appendChild(closeImg);}
connect(node,"onclick",this,this.onClick);};$prototype.update=function(){if(this.selected){addElementClass(this.getNode(),"selected-tab");}else{removeElementClass(this.getNode(),"selected-tab");}};$prototype.isCloseable=function(){return this.closeable||false;};userSmarts.wt.widgets.TableModel=function(properties){if(isPrototype(arguments)){return;}
Bean.apply(this,[properties]);setdefault(this,{columns:[],items:{},modified:new Date(),maximumRows:25,currentRow:0,buffer:[],pageSize:10});if(this.items.addChangeListener){this.items.addChangeListener(bind(this.onItemsChanged,this),"modified");}};userSmarts.wt.widgets.TableModel.inheritsFrom(Bean);userSmarts.wt.widgets.TableModel.prototype.onItemsChanged=function(event){this.items=event.newValue;this.populate();};userSmarts.wt.widgets.TableModel.prototype.getLabel=function(column,row){return column.getLabel(row);};userSmarts.wt.widgets.TableModel.prototype.getClassName=function(column,row){return"";};userSmarts.wt.widgets.TableModel.prototype.getColumnLabel=function(column,row){return column.label;};userSmarts.wt.widgets.TableModel.prototype.getImage=function(column,row){if(column&&typeof(column.getImage)=='function'){return column.getImage(row);}else{return null;}};userSmarts.wt.widgets.TableModel.prototype.getColumnClassName=function(column,row){return"";};userSmarts.wt.widgets.TableModel.prototype.getColumns=function(){return this.columns;};userSmarts.wt.widgets.TableModel.prototype.hideColumn=function(col){var column;if(typeof(col)=="number"){column=this.columns[col];}else{column=col;}
column.visible=false;};userSmarts.wt.widgets.TableModel.prototype.showColumn=function(col){var column;if(typeof(col)=="number"){column=this.columns[col];}else{column=col;}
column.visible=true;};userSmarts.wt.widgets.TableModel.prototype.isColumnVisible=function(col){var column;if(typeof(col)=="number"){column=this.columns[col];}else{column=col;}
return!(column.visible===false);};userSmarts.wt.widgets.TableModel.prototype.getRows=function(){return this.buffer;};userSmarts.wt.widgets.TableModel.prototype.isSelected=function(row){return this.selectedRow==row;};userSmarts.wt.widgets.TableModel.prototype.setMaxRows=function(maxRows){this.maximumRows=maxRows*1;};userSmarts.wt.widgets.TableModel.prototype.getMaxRows=function(){return this.maximumRows;};userSmarts.wt.widgets.TableModel.prototype.setPageSize=function(pageSize){this.pageSize=pageSize*1;};userSmarts.wt.widgets.TableModel.prototype.getPageSize=function(){return this.pageSize;};userSmarts.wt.widgets.TableModel.prototype.nextPage=function(){return this.populate(this.currentRow+this.pageSize);};userSmarts.wt.widgets.TableModel.prototype.previousPage=function(){return this.populate(this.currentRow-this.pageSize);};userSmarts.wt.widgets.TableModel.prototype.size=function(){return(this.items.length)?this.items.length:0;};userSmarts.wt.widgets.TableModel.prototype.getOffset=function(){return this.currentRow;};userSmarts.wt.widgets.TableModel.prototype.populate=function(position){if(position!==undefined&&position!==null&&(position>=0&&position<this.size())){this.currentRow=position*1;}
var l=this.buffer.length;for(var i=0;i<l;i++){this.buffer.shift();}
var items=this.items;var size=this.size();var ps=this.pageSize||items.length;if(size<(this.currentRow+this.pageSize)){ps=size-this.currentRow;}
if(items.length){this.buffer=items.slice(this.currentRow,(this.currentRow+ps));}else{logError("items are not array-like");}
var deferred=new Deferred();deferred.size=function(){return ps;};deferred.addCallback(bind(function(property,value){this.setProperty(property,value);},this,'modified'));deferred.callback(this.items);return deferred;};userSmarts.wt.widgets.TableModel.prototype.sort=function(column){if(typeof(column.compare)=='function'){this.sortAsc=(typeof(this.sortAsc)=='undefined')?true:!this.sortAsc;var l=0;var r=0;if(this.buffer&&this.buffer.length){r=this.buffer.length-1;}else if(this.items&&this.items.length){r=this.items.length-1;}
this.sortItems(column,l,r,this.sortAsc);this.setProperty("modified",true);}};userSmarts.wt.widgets.TableModel.prototype.sortItems=function(column,left,right,flag){var items;if(this.buffer&&this.buffer.length){items=this.buffer;}else if(this.items&&this.items.length){items=this.items;}else{return;}
var l_hold=left;var r_hold=right;var pivot=items[left];while(left<right){if(flag){while((column.compare(items[right],pivot)>=0)&&(left<right)){--right;}}else{while((column.compare(items[right],pivot)<=0)&&(left<right)){--right;}}
if(left!=right){items[left]=items[right];++left;}
if(flag){while((column.compare(items[left],pivot)<=0)&&(left<right)){++left;}}else{while((column.compare(items[left],pivot)>=0)&&(left<right)){++left;}}
if(left!=right){items[right]=items[left];--right;}}
items[left]=pivot;pivot=left;left=l_hold;right=r_hold;if(left<pivot){this.sortItems(column,left,pivot-1,flag);}
if(right>pivot){this.sortItems(column,pivot+1,right,flag);}};userSmarts.wt.widgets.DOMTableModel=Class.create(userSmarts.wt.widgets.TableModel);$prototype.initialize=function(superclass,properties){setdefault(properties,{resource:new Resource({params:{format:"text/xml"}}),matches:0,depth:0,nodeOffset:0,nodeNames:[]});superclass.call(this,properties);this.loadCallback=bind(this.onDocumentLoad,this);this.errback=bind(this.onDocumentError,this);connect(this,'source',this.onSourceChange);};$prototype.onSourceChange=function(event){if(this.resource){this.resource.setProperty("url",this.source);this.resource.params.format="text/xml";}
this.populate(0);};$prototype.addColumn=function(column){if(!this.columns)this.columns=[];this.columns.push(column);};$prototype.getLabel=function(column,row){return column.getLabel(row);};$prototype.getClassName=function(column,row){return"dom-table-cell";};$prototype.getColumnLabel=function(column,row){return column.getColumnLabel();};$prototype.getColumnClassName=function(column,row){return"dom-table-column";};$prototype.getColumns=function(){return this.columns;};$prototype.getRows=function(){return this.buffer;};$prototype.size=function(){return this.matches||0;};$prototype.populate=function(position){if(position!==undefined&&position!==null&&(position>=0&&position<this.size())){this.currentRow=position*1;}
if(this.resource){var deferred=this.resource.get();deferred.addCallback(this.loadCallback);deferred.addErrback(this.errback);this.setProperty("populating",true);}else{this.loadCallback(null);}};$prototype.onDocumentLoad=function(document){this.buffer=[];this.matches=0;var root=this.getRootNode(document);if(root){this.buffer=this.parseRows(root);}else{logError("DOMTableModel.onDocumentLoad - "+"Unable to populate model, root element of response was null");}
this.setProperty("modified",true);};$prototype.getRootNode=function(document){if(document){if(document.nodeType==9){return document.documentElement;}
return document;}
return null;};$prototype.parseRows=function(root){var buffer=[];var nodes=this.findRowNodes(root);this.matches=nodes.length;var start=0;var end=nodes.length;if(start>=0&&start<end){var node;for(var i=start;i<end;++i){node=nodes[i];buffer.push(new DOMTableRowWrapper(node));}}
return buffer;};$prototype.findRowNodes=function(root){var nodes=[];if(this.nodeNames||this.nodeNames.length>0){this.getChildrenByNames(root,nodes);}else{for(var i=0;i<this.depth;++i){if(!node)break;node=this.getNthChildNode(node,this.nodeOffset);}
if(node){nodes.push(node);}}
return nodes;};$prototype.getChildrenByNames=function(node,results){var child;for(var i=0;i<node.childNodes.length;++i){child=node.childNodes[i];if(child.nodeType!=1)continue;if(this.nodeNames.contains(child.localName||child.nodeName)){results.push(child);}else{this.getChildrenByNames(child,results);}}}
$prototype.getNthChildNode=function(root,n){var position=0;var children=root.childNodes;for(var i=0;i<children.length;++i){if(children[i].nodeType==1){if(position==n)return children[i];++position;}}
return null;};$prototype.onDocumentError=function(e){logError(e);this.loadCallback(null);};DOMTableRowWrapper=function(node){this.rowNode=node;};DOMTableRowWrapper.prototype.getNode=function(){return this.rowNode;};DOMTableRowWrapper.prototype.getName=function(){return(this.rowNode.localName||this.rowNode.nodeName);};DOMTableRowWrapper.prototype.getValue=function(){return scrapeText(this.rowNode);};DOMTableRowWrapper.prototype.getChildren=function(){return this.rowNode.childNodes;};DOMTableRowWrapper.prototype.equals=function(row){var result=false;if(row){if(row instanceof DOMTableRowWrapper){var node1=this.getNode();var node2=row.getNode();var id1=scrapeText(node1.getElementsByTagName("id")[0]);var id2=scrapeText(node2.getElementsByTagName("id")[0]);result=(id1==id2);}}
return result;};$namespace.OpenSearchTableModel=function(properties){if(isPrototype(arguments))return;properties=properties||{};setdefault(properties,{sortElement:null,sortOrder:true,keywords:[]});userSmarts.wt.widgets.DOMTableModel.call(this,properties);}
$namespace.OpenSearchTableModel.inheritsFrom(userSmarts.wt.widgets.DOMTableModel);$prototype.populate=function(position){if(position!==undefined&&position!==null&&(position>=0&&position<this.size())){this.currentRow=position*1;}
if(this.resource){this.resource.params.startIndex=this.getStartIndex();this.resource.params.startPage=this.getStartPage();this.resource.params.count=this.getPageSize();this.resource.params.format="text/xml";this.resource.params.q=arrayToString(this.getKeywords()," ");this.resource.params.useAnd=this.useAndOperator;var sortElement=this.getSortElement();var sortOrder=this.getSortOrder();if(sortElement&&typeof(sortOrder)!='undefined'){this.resource.params.sortElement=sortElement;this.resource.params.sortOrder=sortOrder;}else{delete this.resource.params.sortElement;delete this.resource.params.sortOrder;}
var deferred=this.resource.get();deferred.addCallback(this.loadCallback);this.setProperty("populating",true);}else{this.loadCallback(null);}};$prototype.parseRows=function(root){var buffer=userSmarts.wt.widgets.DOMTableModel.prototype.parseRows.call(this,root);this.matches=this.getOpenSearchResponseInfo(root);return buffer;};$prototype.getOpenSearchResponseInfo=function(root){var matches=0;var trNodes=root.getElementsByTagName("totalResults");if(trNodes.length==1){var trNode=trNodes[0];matches=scrapeText(trNode)*1;}
return matches;};$prototype.getStartIndex=function(){return 0;};$prototype.getStartPage=function(){return Math.floor(this.getOffset()/this.getPageSize())+1;};$prototype.getSortElement=function(){return this.sortElement;};$prototype.setSortElement=function(name){this.sortElement=name;};$prototype.getSortOrder=function(){return this.sortOrder;};$prototype.setSortOrder=function(order){this.sortOrder=(order===true||order==="true");};$prototype.setKeywords=function(keywords){if(typeof(keywords.push)=='function'){this.keywords=keywords;this.populate(0);}else if(typeof(keywords)=='string'){this.keywords=[keywords];this.populate(0);}else{logWarning("Unrecognized keywords type - "+typeof(keywords)+" - ignoring keywords!");}};$prototype.getKeywords=function(){return this.keywords;};$prototype.sort=function(column){var sortElement=this.getSortElement();if(sortElement&&sortElement==column.name){column.order=!column.order;}
this.setSortOrder(column.order);this.setSortElement(column.name);this.populate(this.getOffset());};$namespace.TableColumn=function(properties){if(isPrototype(arguments)){return;}
Bean.apply(this,[properties]);};$namespace.TableColumn.inheritsFrom(Bean);$prototype.getLabel=function(row){var result="";if(this.name){result=row[this.name];}
return result;};$prototype.getImage=function(row){var result=null;if(this.image){result=IMG({src:this.image,alt:this.label});}
return result;};$prototype.compare=function(row1,row2){if(this.name){var rv1=row1[this.name];var rv2=row2[this.name];if(typeof(rv1)=='string'&&typeof(rv2)=='string'){try{rv1=parseInt(rv1);}catch(Error){rv1=row1[this.name];}
if(isNaN(rv1))rv1=row1[this.name];try{rv2=parseInt(rv2);}catch(Error){rv2=row2[this.name];}
if(isNaN(rv2))rv2=row2[this.name];if(rv1>rv2){return 1;}else if(rv1<rv2){return-1;}else if(rv1==rv2){return 0;}}else if(typeof(rv1.compare)=='function'){return rv1.compare(rv2);}}
return-1;};userSmarts.wt.widgets.DOMTableColumn=Class.create(userSmarts.wt.widgets.TableColumn);$prototype.initialize=function(superclass,properties){setdefault(properties,{isAttr:false,fallback:""});superclass.call(this,properties);};$prototype.getLabel=function(row,name){var result="";var name=name||this.name;if(name&&row){var child;var children=row.getNode().getElementsByTagName(name);if(children.length>0){var child=children[0];if(this.isAttribute()){result=getNodeAttribute(child,this.attrName);}else{if(child.childNodes.length>1){result="[node]";}else{result=scrapeText(child);}}}}
if(!result){result=this.fallback;}
return result;};$prototype.isAttribute=function(){return(this.isAttr&&this.attrName);};$prototype.getColumnLabel=function(row){return this.label;};$prototype.compare=function(row1,row2){if(this.name){var rv1=this.getLabel(row1);var rv2=this.getLabel(row2);if(typeof(rv1)=='string'&&typeof(rv2)=='string'){try{rv1=parseInt(rv1);}catch(Error){rv1=this.getLabel(row1);}
if(isNaN(rv1))rv1=this.getLabel(row1);try{rv2=parseInt(rv2);}catch(Error){rv2=this.getLabel(row2);}
if(isNaN(rv2))rv2=this.getLabel(row2);if(rv1>rv2){return 1;}else if(rv1<rv2){return-1;}else if(rv1==rv2){return 0;}}else if(typeof(rv1.compare)=='function'){return rv1.compare(rv2);}}
return-1;};userSmarts.wt.widgets.TablePageControl=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{'class':"wt-table-controls",layoutData:{width:"100%",height:"25px"},minimum:false});this.table=this.table||properties.parent;userSmarts.wt.widgets.Control.call(this,properties);}
userSmarts.wt.widgets.TablePageControl.inheritsFrom(userSmarts.wt.widgets.Control);userSmarts.wt.widgets.TablePageControl.prototype.update=function(){var node=this.getNode();this.node.style.width="100%";var model=this.table.model;if(!model)return;var results=[];var start=model.getOffset();var pageSize=model.getPageSize();var end=model.size();if(pageSize===undefined){pageSize=end;}
var pageIndex=Math.floor(start/pageSize)+1;var lastPage=Math.ceil(end/pageSize);var numLinks=Math.min(15,lastPage);var midPoint=Math.ceil(numLinks/2);numLinks--;var numNextLinks=0;var numPrevLinks=0;if(lastPage>1){if(pageIndex<=midPoint){numPrevLinks=pageIndex-1;numNextLinks=numLinks-numPrevLinks;}else{numNextLinks=(lastPage-pageIndex>midPoint-1)?midPoint-1:lastPage-pageIndex;numPrevLinks=numLinks-numNextLinks;}}
if(pageIndex>1){var prevLink;var theme=userSmarts.runtime.Platform.getTheme();if(theme){var imgURL=theme.get("image.page.previous");prevLink=IMG({width:'16',height:'16',border:'0',src:imgURL});}else{var imgdir=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/');prevLink=IMG({width:'16',height:'16',border:'0',src:imgdir+'resultset_previous.png'});}
results.push(this.buildPageLink(prevLink,start-pageSize));if(!this.minimum){for(var lc=(pageIndex-numPrevLinks);lc<pageIndex;lc++){results.push(this.buildPageLink(' '+lc+' ',start+(-1*pageSize*(pageIndex-lc))));numLinks--;}}}
if(this.minimum&&pageIndex>1){results.push("...");}
results.push(SPAN({'class':'table-page-current'},' '+((lastPage>1)?pageIndex:'')+' '));if(this.minimum&&pageIndex<lastPage){results.push("...");}
if(pageIndex<lastPage){if(!this.minimum){for(var lc=pageIndex+1;lc<=(pageIndex+numNextLinks);lc++){results.push(this.buildPageLink(' '+lc+' ',start+(pageSize*(lc-pageIndex))));}}
var nextLink;var theme=userSmarts.runtime.Platform.getTheme();if(theme){var imgURL=theme.get("image.page.next");nextLink=IMG({width:'16',height:'16',border:'0',src:imgURL});}else{var imgdir=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/');nextLink=IMG({width:'16',height:'16',border:'0',src:imgdir+'resultset_next.png'});}
results.push(this.buildPageLink(nextLink,start+pageSize));}
pageIndex--;var descriptor="No results";if(end>0){descriptor=(this.minimum?"":"Displaying ")+
(pageIndex*pageSize+1)+" - "+
((pageIndex*pageSize+pageSize<end)?pageIndex*pageSize+pageSize:end)+" of "+end+
(this.minimum?"":" results");}
if(!this.pageSizeSelect){var sizeOptions=[];var sizes=[5,10,20,50,100];for(var i=0;i<sizes.length;i++){if(pageSize==sizes[i]){sizeOptions.push(OPTION({value:sizes[i],selected:"selected"},sizes[i]+""));}else if(i<(sizes.length-1)){sizeOptions.push(OPTION({value:sizes[i]},sizes[i]+""));if(pageSize>sizes[i]&&pageSize<sizes[i+1]){sizeOptions.push(OPTION({value:pageSize,selected:"selected"},pageSize+""));}}else if(i==(sizes.length-1)){sizeOptions.push(OPTION({value:sizes[i]},sizes[i]+""));if(pageSize>sizes[i]){sizeOptions.push(OPTION({value:pageSize,selected:"selected"},pageSize+""));}}else if(i==0){if(pageSize<sizes[i]){sizeOptions.push(OPTION({value:pageSize,selected:"selected"},pageSize+""));}
sizeOptions.push(OPTION({value:sizes[i]},sizes[i]+""));}}
var pageSizeSelect=SELECT({name:'pageSizeSelect'},sizeOptions);connect(pageSizeSelect,'onchange',this,this.changePageSize);this.pageSizeSelect=pageSizeSelect;}
var psSelArr=[];if(!this.minimum)psSelArr.push("View ");psSelArr.push(this.pageSizeSelect);if(!this.minimum)psSelArr.push(" results per page");var content=TABLE({width:"100%"},TBODY(null,TR(null,TD({align:"left",width:"30%",valign:'top'},descriptor),TD({align:"left",width:"1",valign:'top'},"|"),TD({align:"center",width:"30%",valign:'top'},psSelArr),TD({align:"left",width:"1",valign:'top'},"|"),TD({align:"right",width:"40%",valign:'top'},results))));replaceChildNodes(node,content);};userSmarts.wt.widgets.TablePageControl.prototype.buildPageLink=function(page,offset){var anchor=A({'class':'offAnchor'},page);anchor.onclick=bind(function(){var deferred=this.table.model.populate(offset);},this);anchor.onmouseover=function(){anchor.className='overAnchor';};anchor.onmouseout=function(){anchor.className='offAnchor';};return anchor;};userSmarts.wt.widgets.TablePageControl.prototype.changePageSize=function(){var model=this.table.model;var index=this.pageSizeSelect.selectedIndex;var option=this.pageSizeSelect.options[index];var value=option.value*1;if(model){var currentFirstElementInPage=model.getOffset();var newCurrentPageIndex=Math.floor(currentFirstElementInPage/value);var newCurrentPageOffset=0;var currentFirstElementInNewPage=(newCurrentPageIndex*value)+newCurrentPageOffset;model.setPageSize(value);model.populate(currentFirstElementInNewPage);}};userSmarts.wt.widgets.Table=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{"class":"wt-table",updateOnBoundsChange:true,showFooter:true,allowSelection:true});userSmarts.wt.widgets.Composite.call(this,properties);connect(this,"model",this,this.onModelChange);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));new userSmarts.wt.widgets.InnerTable({parent:this,allowSelection:this.allowSelection});if(this.showFooter){new userSmarts.wt.widgets.TablePageControl({parent:this});}
this.touch("model");};userSmarts.wt.widgets.Table.inheritsFrom(userSmarts.wt.widgets.Composite);userSmarts.wt.widgets.Table.prototype.onModelChange=function(event){if(this.modelsub){disconnect(this.modelsub);}
if(this.model){this.modelsub=connect(this.model,"modified",this,this.onModelModified);}
this.update();};userSmarts.wt.widgets.Table.prototype.onModelModified=function(event){this.update();};userSmarts.wt.widgets.Table.prototype.select=function(rowObj){if(rowObj){var tr=rowObj.node;if(tr){if(this.selected){this.deselect(this.selected);}
addElementClass(tr,'selected');this.setProperty("selected",rowObj);}}};userSmarts.wt.widgets.Table.prototype.deselect=function(rowObj){if(rowObj){var tr=rowObj.node;if(tr){removeElementClass(tr,'selected');this.setProperty("selected",null);}}};userSmarts.wt.widgets.Table.prototype.isSelected=function(rowObj){var result=false;if(this.selected){if(typeof(this.selected.equals)=="function"){return this.selected.equals(rowObj);}else if(this.selected.id&&rowObj.id){result=this.selected.id==rowObj.id;}else{result=this.selected==rowObj;}}
return result;};userSmarts.wt.widgets.InnerTable=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{allowSelection:true,layoutData:{width:"*",height:"*"}});this.table=properties.table||properties.parent;userSmarts.wt.widgets.Control.call(this,properties);};userSmarts.wt.widgets.InnerTable.inheritsFrom(userSmarts.wt.widgets.Control);userSmarts.wt.widgets.InnerTable.prototype.initNode=function(){if(this.allowSelection){connect(this.node,"onclick",this,this.onClick);}};userSmarts.wt.widgets.InnerTable.prototype.update=function(){var node=this.getNode();node.style.overflow="auto";var thead=THEAD();var body=TBODY();var model=this.table.model;if(!model){thead.appendChild(TR({},TD({},"")));body.appendChild(TR({},TD({},"")));}else{var items=model.getRows()||[];var len=items.length;var tr=TR();thead.appendChild(tr);var cols=model.getColumns();var ncols=cols.length;var numVisibleCols=ncols;for(var i=0;i<ncols;++i){var col=cols[i];if(model.isColumnVisible(col)){var td=this.createColumnHeader(col,i);tr.appendChild(td);}else{--numVisibleCols;}}
if(len==0){var row=TR(null,TD({colspan:numVisibleCols}));body.appendChild(row);}else{for(var i=0;i<len;++i){var row=items[i];var tr=TR();for(var j=0;j<ncols;++j){var column=cols[j];if(model.isColumnVisible(column)){var td=TD({'class':model.getClassName(column)},model.getLabel(column,row));if(column.width)td.style.width=column.width+"px";td.row=row;tr.appendChild(td);}}
if((this.table.selected&&this.table.selected==row)||model.isSelected(row)){addElementClass(tr,'selected');}
body.appendChild(tr);}}}
replaceChildNodes(node,TABLE({"class":"wt-inner-table"},thead,body));};userSmarts.wt.widgets.InnerTable.prototype.createColumnHeader=function(column,columnIndex){var model=this.table.model;var labelValue=model.getColumnLabel(column);var label;if(labelValue){label=SPAN({'class':'table-header-cell'},labelValue);}else{label='';}
var td=TD({'class':model.getColumnClassName(column)},label);if(column.width)td.style.width=column.width+"px";td.columnIndex=columnIndex;connect(td,"onclick",this,this.onColumnClick);return td;};userSmarts.wt.widgets.InnerTable.prototype.onClick=function(evt){var source=evt.target();var row=source.row;if(row){var tr=source.parentNode;row.node=tr;if(this.table.isSelected(row)){this.table.deselect(row);}else{this.table.select(row);}}};userSmarts.wt.widgets.InnerTable.prototype.onColumnClick=function(evt){var model=this.table.model;var source=evt.target();var columnIndex=source.columnIndex;if(typeof(columnIndex)=='number'){var columns=model.getColumns();if(columnIndex>=0&&columnIndex<columns.length){var column=columns[columnIndex];model.sort(column);}}};$namespace.List=function(properties){if(isPrototype(arguments))return;properties=setdefault(properties,{'class':'wt-list',updateOnBoundsChange:true,showFooter:true,autoExpand:false,allowSelection:true});userSmarts.wt.widgets.Composite.call(this,properties);this.setLayout(new userSmarts.wt.layout.RowLayout({type:"vertical"}));this.innerList=new userSmarts.wt.widgets.InnerList({parent:this,autoExpand:this.autoExpand,allowSelection:this.allowSelection});if(this.showFooter!=false){new userSmarts.wt.widgets.TablePageControl({parent:this,minimum:true});}
connect(this,'model',this,this.onModelChange);this.touch("model");};$namespace.List.inheritsFrom(userSmarts.wt.widgets.Composite);$prototype.setModel=function(model){if(this.modelModifiedListener){disconnect(this.modelModifiedListener);}
if(model&&model instanceof userSmarts.wt.widgets.TableModel){this.modelModifiedListener=connect(model,'modified',this,this.update);model.populate(0);}
this.model=model;};$prototype.onModelChange=function(event){this.setModel(event.newValue);};$prototype.select=function(rowObj){if(rowObj){var entry=rowObj.listNode;if(entry){addElementClass(entry,'selected');this.setProperty("selected",rowObj);}}};$prototype.unselect=function(rowObj,fire){if(rowObj){var entry=rowObj.listNode;if(entry){removeElementClass(entry,'selected');if(fire!=false){this.setProperty("selected",null);}else{this.selected=null;}}}};$prototype.isSelected=function(row){var result=false;if(this.selected){if(typeof(this.selected.equals)=="function"){return this.selected.equals(row);}else{result=this.selected==row;}}
return result;};$prototype.toggleNode=function(row){var source=row.listNode;var content=source.childNodes[1];if(content.style.display!="none"){content.style.display="none";}else{content.style.display="block";}};$prototype.collapse=function(row){if(this.isSelected(row)){this.unselect(row);}
this.innerList.collapse(row);};$prototype.expand=function(row){this.innerList.expand(row);};$namespace.InnerList=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{autoExpand:false,allowSelection:true,layoutData:{width:"*",height:"*"}});this.list=properties.list||properties.parent;this['class']="wt-inner-list";userSmarts.wt.widgets.Control.call(this,properties);};$namespace.InnerList.inheritsFrom(userSmarts.wt.widgets.Control);$prototype.update=function(){var entries=[];if(this.list.model){var entry;var selectedEntry;var rows=this.list.model.getRows();for(var i=0;i<rows.length;++i){if(!selectedEntry&&this.list.isSelected(rows[i])){selectedEntry=rows[i];}
var row=rows[i];row.position=i;entry=this.buildEntry(rows[i]);addElementClass(entry,((i%2)==0)?"even":"odd");if(entry){entries.push(entry);if(this.autoExpand){this.expand(rows[i]);}}}}
replaceChildNodes(this.getNode(),entries);if(selectedEntry){this.list.select(selectedEntry);this.expand(selectedEntry);}else{this.list.selected=null;}};$prototype.buildEntry=function(row){if(!row){return null;}
var entry=DIV({'class':'wt-list-entry'});if(this.allowSelection){connect(entry,'onclick',this,this.onClick);}
entry.setAttribute("row",row.position+"");row.listNode=entry;row.hasExpandedContents=false;var model=this.list.model;var titleDIV;var item;var image;var className;var cols=model.getColumns();var length=cols.length;for(var i=0;i<length;++i){if(cols[i].visible!=false){title=model.getLabel(cols[i],row);if(title){image=model.getImage(cols[i],row);if(image){titleDIV=DIV({'class':'wt-list-title'},image,title);}else{titleDIV=DIV({'class':'wt-list-title'},title);}
className=model.getColumnClassName(cols[i],row);if(className){addElementClass(titleDIV,className);}
entry.appendChild(titleDIV);}
break;}}
return entry;};$prototype.buildExpandedContents=function(row){var model=this.list.model;if(!row.hasExpandedContents){var content=DIV({'class':'wt-list-content'});row.listNode.appendChild(content);row.hasExpandedContents=true;var cols=model.getColumns();var foundTitle=false;for(var i=0;i<cols.length;++i){if(cols[i].visible!=false){if(!foundTitle){foundTitle=true;}else{var item=model.getColumnLabel(cols[i],row);if(item){item+=": "+model.getLabel(cols[i],row);}else{item=model.getLabel(cols[i],row);}
if(item){content.appendChild(DIV({'class':'wt-list-content-item'},item));}}}}}}
$prototype.onClick=function(event){var source=event.src();var rowpos=parseInt(source.getAttribute("row"));var row=this.list.model.getRows()[rowpos];if(row){if(this.list.isSelected(row)){this.list.unselect(row);if(this.isExpanded(row)){this.list.collapse(row);}}else{if(this.list.selected){this.list.unselect(this.list.selected,false);}
this.list.select(row);if(!this.isExpanded(row)){this.expand(row);}}}};$prototype.isExpanded=function(row){var entry=row.listNode;var content=entry.childNodes[1];return content&&content.style.display!="none";};$prototype.expand=function(row){if(!row.hasExpandedContents){this.buildExpandedContents(row);}
var entry=row.listNode;var content=entry.childNodes[1];content.style.display="block";};$prototype.collapse=function(row){if(this.list.isSelected(row)){this.list.unselect(row);}
var entry=row.listNode;var content=entry.childNodes[1];if(content){content.style.display="none";}};namespace("userSmarts.wt.action");userSmarts.wt.action.ContributionItem=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties||{},{nodeName:"span","class":"contribution-item"});superClass.call(this,properties);};$prototype.getId=function(){return this.id;};$prototype.execute=function(){};userSmarts.wt.action.ContributionManager=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{"class":'widget-bar',items:[]});superClass.call(this,properties);};$prototype.addItem=function(item){if(item instanceof userSmarts.wt.widgets.Control){this.items.push(item);}else if(item.nodeType){addElementClass(item,'widget-item');var widget={paint:function(context){return item;},update:function(context){}};this.addItem(widget);}else if(typeof(item)=='string'){this.addItem(SPAN({'class':'widget-item'},item));}else{logWarning("ContributionManager.addItem :: Unable to add item, item is not of either type Control, Node or String");}};$prototype.update=function(){var renderedItems=[];for(var i=0;i<this.items.length;++i){var item=this.items[i];item.update();renderedItems.push(item.getNode());}
replaceChildNodes(this.getNode(),renderedItems);};$namespace.Action=Class.create(userSmarts.wt.action.ContributionItem);$prototype.initialize=function(superClass,desc){desc=setdefault(desc,{id:'',enabled:true,showText:false,text:"",className:'action-item',margin:{left:5,right:5,top:0,bottom:0},run:function(){logDebug("Running empty action");}});superClass.call(this,desc);};$prototype.execute=function(){if(typeof(this.run)=='function'){this.run();}};$prototype.getId=function(){return this.id;};$prototype.setId=function(id){this.id=id;};$prototype.getClassName=function(){return this.className;};$prototype.getImage=function(){return this.image;};$prototype.setImage=function(image){this.image=image;};$prototype.getDisabledImage=function(){return this.disabledImage;};$prototype.setDisabledImage=function(image){this.disabledImage=image;};$prototype.getText=function(){return this.text;};$prototype.setText=function(text){this.text=text;};$prototype.getToolTipText=function(){return this.toolTipText;};$prototype.setToolTipText=function(text){this.toolTipText=text;};$prototype.getAccelerator=function(){return this.accelerator;};$prototype.setAccelerator=function(key){this.accelerator=key;};$prototype.isEnabled=function(){return this.enabled;};$prototype.setEnabled=function(bool){if(bool===true){this.enabled=true;if(this.node){if(this.showText){this.node.className="action";this.icon.src=this.getImage();}else{this.node.src=this.getImage();}
this.node.title=this.getToolTipText();if(!this.clickListener){this.clickListener=connect(this.node,'onclick',this,this.execute);}}}else if(bool===false){this.enabled=false;if(this.node){if(this.showText){this.node.className="action-disabled";this.icon.src=this.getDisabledImage()||this.getImage();}else{this.node.src=this.getDisabledImage()||this.getImage();}
this.node.title=this.getToolTipText()+" (DISABLED)";if(this.clickListener){disconnect(this.clickListener);this.clickListener=null;}}}};$prototype.getNode=function(){if(!this.node){var img=(this.enabled)?this.getImage():this.getDisabledImage();if(!img)img=this.getImage();var text=this.getText();if(this.showText){this.textNode=document.createTextNode(text);this.icon=IMG({src:img,alt:text,'class':this.getClassName()});this.node=DIV({'class':'action'},this.icon,this.textNode);connect(this.icon,'onmouseover',this,this.onOver);connect(this.icon,'onmouseout',this,this.onOut);}else{this.node=IMG({src:img,alt:text,'class':this.getClassName()});connect(this.node,"onmouseover",this,this.onOver);connect(this.node,"onmouseout",this,this.onOut);}
this.node.title=this.getToolTipText()+(this.enabled?"":" (DISABLED)");if(this.enabled){this.clickListener=connect(this.node,'onclick',this,this.execute);}
var m=this.margin;var p=this.padding;var b=this.border;var s=this.node.style;s.marginLeft=m.left+"px";s.marginRight=m.right+"px";s.marginTop=m.top+"px";s.marginBottom=m.bottom+"px";s.paddingLeft=(p.left||0)+"px";s.paddingRight=(p.right||0)+"px";s.paddingTop=(p.top||0)+"px";s.paddingBottom=(p.bottom||0)+"px";s.borderStyle=b.style
s.borderLeftWidth=b.left+"px";s.borderRightWidth=b.right+"px";s.borderTopWidth=b.top+"px";s.borderBottomWidth=b.bottom+"px";this.initNode();}
return this.node;};$prototype.toString=function(){return"[Action id='"+this.getId()+"']";};$prototype.onOver=function(event){if(this.showText){if(this.icon){this.icon.className=this.getClassName()+"-hover";}}else{if(this.node){this.node.className=this.getClassName()+"-hover";}}};$prototype.onOut=function(event){if(this.showText){if(this.icon){this.icon.className=this.getClassName();}}else{if(this.node){this.node.className=this.getClassName();}}};$namespace.StatefulAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{checked:false,checkedClassName:'action-item-checked'});superClass.call(this,properties);};$prototype.getClassName=function(){var className;if(this.checked){className=this.getCheckedClassName();}else{className=this.className;}
return className;};$prototype.getCheckedClassName=function(){return this.checkedClassName;};$prototype.setClassName=function(className){this.className=className;};$prototype.setCheckedClassName=function(className){this.checkedClassName=className;};$prototype.getText=function(){var text;if(this.checked&&this.checkedText){text=this.checkedText;}else{text=this.text;}
return text;};$prototype.setCheckedText=function(text){this.checkedText=text;};$prototype.setChecked=function(bool){if(bool===true&&!this.checked){this.checked=true;}else if(bool===false&&this.checked){this.checked=false;}
if(this.showText){var newText=document.createTextNode(this.getText());this.node.replaceChild(newText,this.textNode);this.textNode=newText;this.icon.className=this.getClassName();}else{this.getNode().className=this.getClassName();}};$prototype.isChecked=function(){return this.checked;};$prototype.execute=function(){if(!this.isChecked()){this.setChecked(true);if(typeof(this.run)=='function'){this.run();}}else{this.setChecked(false);this.stop();}};$prototype.stop=function(){if(typeof(this.run)=='function'){this.run();}};$prototype.onOver=function(event){if(this.showText){if(this.icon&&!this.isChecked()){this.icon.className=this.getClassName()+"-hover";}}else{if(this.node&&!this.isChecked()){this.node.className=this.getClassName()+"-hover";}}};$prototype.onOut=function(event){if(this.showText){if(this.icon&&!this.isChecked()){this.icon.className=this.getClassName();}}else{if(this.node&&!this.isChecked()){this.node.className=this.getClassName();}}};userSmarts.wt.action.StatusLineManager=function(properties){Bean.call(this,properties);this.clearFunc=bind(this.clear,this);};userSmarts.wt.action.StatusLineManager.inheritsFrom(Bean);userSmarts.wt.action.StatusLineManager.prototype.setMessage=function(text){if(this.clearTimer){clearTimeout(this.clearTimer);}
if(text&&text!==""){this.appendToDisplay(text);this.clearTimer=setTimeout(this.clearFunc,4000);}else{this.clear();}};userSmarts.wt.action.StatusLineManager.prototype.getMessage=function(){var sb=$("statusBar");if(sb){return sb.childNodes[0];}
return null;};userSmarts.wt.action.StatusLineManager.prototype.paint=function(){return DIV();};userSmarts.wt.action.StatusLineManager.prototype.clear=function(){this.appendToDisplay("");this.clearTimer=null;};userSmarts.wt.action.StatusLineManager.prototype.appendToDisplay=function(args){var sb=$("statusBar");if(sb){replaceChildNodes(sb,args);}};userSmarts.wt.action.ToolbarManager=Class.create(userSmarts.wt.widgets.Control);$prototype.initialize=function(superClass,properties){superClass.call(this,properties||{});this.nodeName="span";this["class"]="action-toolbar";this.layoutData={width:"*",height:"*"};this.items=[];};$prototype.update=function(){var item;var childNodes=[];for(var i=0;i<this.items.length;++i){item=this.items[i];if(item instanceof userSmarts.wt.action.ContributionItem){item.update();childNodes.push(item.getNode());}}
replaceChildNodes(this.getNode(),childNodes);};$prototype.add=function(item){this.items.push(item);};$prototype.remove=function(itemId){var item;for(var i=0;i<this.items.length;i++){item=this.items[i];if(item.getId()==itemId){this.items.slice(i,1);break;}}};$prototype.getItems=function(){return this.items;};$prototype.isEmpty=function(){return(this.items.length===0);};$prototype.removeAll=function(){this.items=[];};$prototype.getNode=function(){var node=userSmarts.wt.widgets.Control.prototype.getNode.call(this);node.style.position="relative";return node;}
userSmarts.wt.action.ConfigureTableAction=Class.create(userSmarts.wt.action.StatefulAction);$prototype.initialize=function(superClass,properties){if(isPrototype(arguments))return;properties=properties||{};setdefault(properties,{adapter:this,id:'confTableAction',text:"Configure Table",toolTipText:'Configure visible columns'});superClass.call(this,properties);var theme=userSmarts.runtime.Platform.getTheme();if(theme){this.image=theme.get("image.table.configure");}else{this.image=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/table_config.png');}
this.run=this.runMethod;};$prototype.runMethod=function(){if(!this.isChecked())return;var model;if(this.model){model=this.model;}else if(this.control.model){model=this.control.model;}
if(model){var dialog=new userSmarts.wt.dialogs.ConfigureTableDialog({model:model});var width=(window.ActiveXObject)?document.body.offsetWidth:window.innerWidth;var height=(window.ActiveXObject)?document.body.offsetHeight:window.innerHeight;dialog.setPosition(width/2-(dialog.width/2),height/2-(dialog.height/2));var deferred=dialog.open();deferred.addCallback(bind(function(){this.setChecked(false);},this));}else{this.setChecked(false);}};$namespace.SortOnColumnAction=Class.create(userSmarts.wt.action.StatefulAction);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{id:'sortOnColAction',text:"Sort Items",toolTipText:'Select a column to sort on'});superClass.call(this,properties);var theme=userSmarts.runtime.Platform.getTheme();if(theme){this.image=theme.get("image.table.configure");}else{this.image=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/table_config.png');}
this.run=this.runMethod;};$prototype.runMethod=function(){if(!this.isChecked())return;if(this.control){var model=this.control.model;if(model){var dialog=new userSmarts.wt.dialogs.SelectColumnDialog({model:model});var position=elementPosition(this.node);var x=position.x-dialog.width;if(x<0)x=position.x+16;var y=position.y-dialog.height-50;if(y<0)y=position.y+16;dialog.setPosition(x,y);var def=dialog.open();def.addCallback(bind(this.onDialogClosed,this,dialog));}else{alert("Control has no model!");}}else{alert("No control configured!");}};$prototype.onDialogClosed=function(dialog,okPressed){if(okPressed){var column=dialog.getSelectedColumn();if(column){var model=this.control.model;if(model){model.sort(column);}}}
this.setChecked(false);};userSmarts.wt.action.RefreshTableAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{adapter:this,id:'refTableAction',text:"Refresh Table",toolTipText:'Refresh Table'});superClass.call(this,properties);var theme=userSmarts.runtime.Platform.getTheme();if(theme){this.image=theme.get("image.refresh");}else{this.image=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/refresh.icon.gif');}
this.run=this.runMethod;};$prototype.runMethod=function(){var model=null;if(this.model){model=this.model;}else if(this.control){model=this.control.model;}
if(model){model.populate(model.getOffset());}};userSmarts.wt.action.OpenToolbarSelectorAction=Class.create(userSmarts.wt.action.StatefulAction);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{id:'openTBSelectorAction',text:"Show Menu",toolTipText:'Show Toolbar Items'});superClass.call(this,properties);var theme=userSmarts.runtime.Platform.getTheme();if(theme){this.image=theme.get("image.obj.selector");}else{this.image=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/selector.png');}
this.run=this.runMethod;};$prototype.runMethod=function(){if(!this.isChecked()){this.setChecked(false);if(this.dialog){this.dialog.close();}
return;}
if(this.site&&this.site instanceof userSmarts.ui.WorkbenchSite){var tbmgr=this.site.getActionBars().getToolbarManager();var count=tbmgr.getItems().length-1;var heightPerIcon=16;var totalHeight=count*16+(2*count);var dialog=new userSmarts.wt.dialogs.ToolbarMenu({toolbarManager:tbmgr,height:totalHeight});var position=elementPosition(this.node);var x=position.x-dialog.width;if(x<0)x=position.x+16;var y=position.y-dialog.height-50;if(y<0)y=position.y+16;dialog.setPosition(x,y);var deferred=dialog.open();deferred.addCallback(bind(function(){this.setChecked(false);},this));this.dialog=dialog;this.setChecked(true);}};userSmarts.wt.action.RefreshListAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{adapter:this,id:'refListAction',text:"Refresh List",toolTipText:'Refresh List'});userSmarts.wt.action.Action.call(this,properties);var theme=userSmarts.runtime.Platform.getTheme();if(theme){this.image=theme.get("image.refresh");}else{this.image=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/refresh.icon.gif');}
this.run=this.runMethod;};$prototype.runMethod=function(){var model=null;if(this.model){model=this.model;}else if(this.list){model=this.list.model;}
if(model){model.populate(model.getOffset());}};userSmarts.wt.action.ExpandListAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{adapter:this,id:'expListAction',text:"Expand List",toolTipText:'Expand List'});superClass.call(this,properties);var theme=userSmarts.runtime.Platform.getTheme();if(theme){this.image=theme.get("image.list.expand");}else{this.image=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/expand.gif');}
this.run=this.runMethod;};$prototype.runMethod=function(){var list=null;if(this.list){list=this.list;}
if(list&&list.model){var rows=list.model.getRows();for(var i=0;i<rows.length;++i){list.expand(rows[i]);}}};userSmarts.wt.action.CollapseListAction=Class.create(userSmarts.wt.action.Action);$prototype.initialize=function(superClass,properties){properties=properties||{};setdefault(properties,{adapter:this,id:'expListAction',text:"Collapse List",toolTipText:'Collapse List'});superClass.call(this,properties);var theme=userSmarts.runtime.Platform.getTheme();if(theme){this.image=theme.get("image.list.collapse");}else{this.image=userSmarts.runtime.Platform.find('com.usersmarts.rcp.rcp-wt-plugin','images/icons/collapse.gif');}
this.run=this.runMethod;};$prototype.runMethod=function(){var list=null;if(this.list){list=this.list;}
if(list&&list.model){var rows=list.model.getRows();for(var i=0;i<rows.length;++i){list.collapse(rows[i]);}}};namespace("userSmarts.wt.layout");$namespace.RowLayout=Class.create(userSmarts.wt.widgets.Layout);$prototype.initialize=function(superClass,properties){properties=setdefault(properties,{spacing:0,type:userSmarts.wt.widgets.Layout.VERTICAL});superClass.call(this,properties);};$namespace.RowLayout.prototype.NumberPattern=/(\d*)(.*)/;$prototype.getLayoutData=function(control){var rowData=control.getLayoutData();if(rowData&&!rowData.units){rowData.units={};this.parseRowData(rowData,"width");this.parseRowData(rowData,"height");}
return rowData;};$prototype.computeSize=function(control,maxWidth,maxHeight,flushCache){var wHint=5;var hHint=4;var data=this.getLayoutData(control);var margin=control.margin;var padding=control.padding;var border=control.border;var mpbx=margin.left+margin.right+padding.left+padding.right+border.left+border.right;var mpby=margin.top+margin.bottom+padding.top+padding.bottom+border.top+border.bottom;if(data){if(data.units.width=="%"){wHint=data.width/100.0*maxWidth;}else if(data.units.width=="*"){wHint="*";}else{wHint=data.width;}
if(data.units.height=="%"){hHint=data.height/100.0*maxHeight;}else if(data.units.height=="*"){hHint="*";}else{hHint=data.height;}}
return{x:wHint,y:hHint};};$prototype.parseRowData=function(rowData,fieldName){var value=rowData[fieldName];if(!value){return;}
if(typeof value=="number"){if(!rowData.units[fieldName]){rowData.units[fieldName]="px";}
return;}
var match=this.NumberPattern.exec(rowData[fieldName]);if(match){rowData[fieldName]=match[1]*1;rowData.units[fieldName]=match[2]||"px";}else if(value=="*"){rowData[fieldName]=100;rowData.units[fieldName]="*";}};$prototype.layout=function(composite,flushCache){var size=composite.getSize();if(this.type==userSmarts.wt.widgets.Layout.VERTICAL){this.layoutVertical(composite,size.height,flushCache);}else{this.layoutHorizontal(composite,size.width,flushCache);}};$prototype.layoutVertical=function(composite,height,flushCache){var children=composite.getChildren();var count=children.length;var childWidth=0;var childHeight=0;var maxHeight=0;var marginWidth=0;var offsetTop=0;var marginHeight=0;var spacing=this.spacing;var totalSpace=spacing*(count-1);var rect=composite.getClientArea();var clientX=rect.x;var clientY=rect.y;var clientWidth=rect.width;var clientHeight=rect.height-totalSpace;var totalHeight=0;var sizes=[];var nwild=0;for(var i=0;i<count;i++){var child=children[i];var size=this.computeSize(child,clientWidth,clientHeight,flushCache);sizes.push(size);if(size.y=="*"){nwild++;}else{totalHeight+=(spacing+size.y);}}
var wildHeight;if(clientHeight>totalHeight){wildHeight=(clientHeight-totalHeight)/nwild;}else{wildHeight=0;}
if(nwild>0){for(var i=0;i<count;++i){if(sizes[i].y=="*"){sizes[i].y=wildHeight;}}}
var maxX=0;var x=0;var y=0;for(var i=0;i<count;i++){var child=children[i];var childX=Math.floor(x);var childY=Math.floor(y);var size=sizes[i];childWidth=Math.floor(clientWidth);childHeight=(isNaN(size.y))?clientHeight:Math.floor(size.y);try{child.setBounds(childX,childY,childWidth,childHeight);}catch(e){}
y+=spacing+childHeight;maxX=Math.max(maxX,x);}};$prototype.layoutHorizontal=function(composite,width,flushCache){var children=composite.getChildren();var count=children.length;var childWidth=0;var childHeight=0;var maxHeight=0;var rect=composite.getClientArea();var clientX=rect.x;var clientY=rect.y;var offsetLeft=0;var marginWidth=0;var offsetTop=0;var marginHeight=0;var spacing=this.spacing;var totalSpace=spacing*(count-1);var clientWidth=rect.width-totalSpace;var clientHeight=rect.height;var totalWidth=0;var sizes=[];var nwild=0;for(var i=0;i<count;i++){var child=children[i];var size=this.computeSize(child,clientWidth,clientHeight,flushCache);sizes.push(size);if(size.x=="*"){nwild++;}else{totalWidth+=(spacing+size.x);}}
var wildWidth;if(clientWidth>totalWidth){wildWidth=(clientWidth-totalWidth)/nwild;}else{wildWidth=0;}
if(nwild>0){for(var i=0;i<count;++i){if(sizes[i].x=="*"){sizes[i].x=wildWidth;}}}
var maxX=0,x=offsetLeft+marginWidth,y=offsetTop+marginHeight;for(var i=0;i<count;i++){var child=children[i];var childX=x;var childY=y;var size=sizes[i];childWidth=size.x;childHeight=(isNaN(size.y))?clientHeight:Math.min(clientHeight,size.y);try{child.setBounds(childX,childY,childWidth,childHeight);}catch(e){}
x+=spacing+childWidth;maxX=Math.max(maxX,x);}
maxX=Math.max(clientX+offsetLeft+marginWidth,maxX-spacing);};userSmarts.wt.layout.StackLayout=function(properties){if(isPrototype(arguments)){return;}
userSmarts.wt.widgets.Layout.call(this,properties);this.marginWidth=0;this.marginHeight=0;this.topControl=null;};userSmarts.wt.layout.StackLayout.inheritsFrom(userSmarts.wt.widgets.Layout);userSmarts.wt.layout.StackLayout.prototype.layout=function(composite,flushCache){var children=composite.getChildren();var rect=composite.getClientArea();rect.x+=this.marginWidth;rect.y+=this.marginHeight;rect.width-=2*this.marginWidth;rect.height-=2*this.marginHeight;for(var i=0;i<children.length;++i){if(children[i]==this.topControl){children[i].setBounds(0,0,rect.width,rect.height);children[i].setVisibility(true);}else{children[i].setVisibility(false);}}};namespace("userSmarts.wt.forms");userSmarts.wt.forms.version=0.2;userSmarts.wt.forms.namespace="http://www.usersmarts.com/form#";userSmarts.wt.forms.Condition=function(properties){if(isPrototype(arguments)){return;}
Bean.call(this,properties);var listener=bind(function(event){this.setProperty('modified',true);},this);this.addChangeListener(listener,'field');this.addChangeListener(listener,'predicate');};userSmarts.wt.forms.Condition.inheritsFrom(Bean);$namespace.Field=function(properties){if(isPrototype(arguments)){return;}
Bean.call(this,properties);setdefault(this,{size:20,disabled:false,format:new StringFormat()});this.format=new StringFormat();};$namespace.Field.inheritsFrom(Bean);$prototype.paint=function(){this.input=INPUT();this.input.id=this.name;this.input.type="text";this.input.size=this.size;if(this.disabled){this.input.disabled=true;}
this.input.onchange=bind(this.onInputChange,this);if(this.binding){this.input.value=this.binding.getValue();}else{this.input.value=(this.value||"");}
this.layout=SPAN({'class':'form-input-field'});if(this.showLabel){this.layout.appendChild(LABEL({"for":this.name},this.title));}
this.layout.appendChild(this.input);if(this.binding&&this.binding.addChangeListener&&this.parent){this.binding.addChangeListener(bind(this.onBindingChange,this),this.parent.model);}
return this.layout;};$prototype.onInputChange=function(event){var value=this.format.parseObject(this.input.value);if(this.binding){this.binding.setValue(value);}
this.input.value=this.format.format(value);if(this.parent){this.parent.validate();}};$prototype.onBindingChange=function(event){var value=this.binding.getValue();this.input.value=this.format.format(value);};$prototype.focus=function(){if(this.input){this.input.focus();if(this.input.value){this.input.select();}}};userSmarts.wt.forms.SearchOption=function(properties){setdefault(this,properties);};userSmarts.wt.forms.SearchOption.getLabel=function(){return this.label;};userSmarts.wt.forms.SearchOption.getValue=function(){return this.value;};userSmarts.wt.forms.SearchObject=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{conditions:[]});Bean.call(this,properties);if(this.requireAll!==undefined){this.requireAll=(this.requireAll===true||this.requireAll=='true'||this.requireAll==1||this.requireAll=='1')?true:false;}else{this.requireAll=false;}
this.listener=bind(function(){this.setProperty('modified',true);},this);};userSmarts.wt.forms.SearchObject.inheritsFrom(Bean);userSmarts.wt.forms.SearchObject.prototype.addCondition=function(c){c.id='condition'+Math.random();c.search=this;c.addChangeListener(this.listener,'modified');this.conditions.push(c);this.setProperty('modified',true);};userSmarts.wt.forms.SearchObject.prototype.removeCondition=function(c){for(var i=0;i<this.conditions.length;i++){if(this.conditions[i].id==c.id){this.conditions[i].removeChangeListener(this.listener,'modified');this.conditions.splice(i,1);this.setProperty('modified',true);break;}}};userSmarts.wt.forms.SearchObject.prototype.getConditions=function(){return this.conditions;};userSmarts.wt.forms.DefaultOptionModel=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{options:[]});Bean.call(this,properties);if(this.datatype&&this.datatype.facets&&this.datatype.facets.enumeration){this.buildFromDatatype(this.datatype);}};userSmarts.wt.forms.DefaultOptionModel.inheritsFrom(Bean);userSmarts.wt.forms.DefaultOptionModel.prototype.getLabel=function(index){return this.options[index].label||"";};userSmarts.wt.forms.DefaultOptionModel.prototype.getValue=function(index){return this.options[index].value||"";};userSmarts.wt.forms.DefaultOptionModel.prototype.getDisabled=function(index){return this.options[index].disabled===true||this.options[index].disabled=="true";};userSmarts.wt.forms.DefaultOptionModel.prototype.isSelected=function(index){return this.options[index].selected===true||this.options[index].selected=="true";};userSmarts.wt.forms.DefaultOptionModel.prototype.setSelected=function(index,value){if(typeof(value)!="boolean"){value=true;}
return this.options[index].selected==value;};userSmarts.wt.forms.DefaultOptionModel.prototype.getOptionCount=function(){return this.options.length;};userSmarts.wt.forms.DefaultOptionModel.prototype.addOption=function(value,label,selected){var option={value:value,label:label,selected:(selected===true)};this.options.push(option);return option;};userSmarts.wt.forms.DefaultOptionModel.prototype.buildFromDatatype=function(datatype){var enumeration=datatype.facets.enumeration;for(var i=0;i<enumeration.length;++i){var item=enumeration[i];if(typeof(item)=='string'){this.addOption(item,item,false);}else if(typeof(item)=='object'){var value=item.value;var label=item.label;var selected=(this.selectedOption==value)||item.selected;this.addOption(value,label,selected);}}};userSmarts.wt.forms.SearchModel=function(){this.fields=[];this.datatypes=new userSmarts.wt.forms.SearchModelDatatypeRegistry();this.buildDatatypeRegistry();};userSmarts.wt.forms.SearchModel.prototype.addField=function(field){field.model=this;this.fields[field.name]=field;this.fields.push(field);};userSmarts.wt.forms.SearchModel.prototype.findField=function(field){try{return this.fields[field.toLowerCase()];}catch(e){return null;}};userSmarts.wt.forms.SearchModel.prototype.getOptionModel=function(field,selectedValue,useBaseType){var fieldObj;if(typeof(field)=='string'){fieldObj=this.findField(field);}else if(typeof(field)=='object'){fieldObj=field;}
var type=(useBaseType)?(fieldObj.datatype.base||fieldObj.datatype):fieldObj.datatype;if(fieldObj){var props={datatype:type,selectedOption:(selectedValue||fieldObj.firstValue)};return new userSmarts.wt.forms.DefaultOptionModel(props);}else{logError("No field");}};userSmarts.wt.forms.SearchModel.prototype.buildDatatypeRegistry=function(){this.datatypes.addType({uri:{prefix:'form',namespaceURI:userSmarts.wt.forms.namespace,localPart:'property'},facets:{enumeration:[]}});this.datatypes.addType({uri:{prefix:'xsd',namespaceURI:XSDNS,localPart:"integer"},facets:{enumeration:[{label:'equal to',value:'Equals'},{label:'not equal to',value:'NotEquals'},{label:'greater than',value:'GreaterThan'},{label:'less than',value:'LessThan'},{label:'greater than or equal to',value:'GreaterThanEquals'},{label:'less than or equal to',value:'LessThanEquals'},{label:'between',value:'Between'}]}});this.datatypes.addType({uri:{prefix:'xsd',namespaceURI:XSDNS,localPart:"float"},facets:{enumeration:[{label:'equal to',value:'Equals'},{label:'not equal to',value:'NotEquals'},{label:'greater than',value:'GreaterThan'},{label:'less than',value:'LessThan'},{label:'greater than or equal to',value:'GreaterThanEquals'},{label:'less than or equal to',value:'LessThanEquals'},{label:'between',value:'Between'}]}});this.datatypes.addType({uri:{prefix:'xsd',namespaceURI:XSDNS,localPart:"string"},facets:{enumeration:[{label:'is',value:'Equals'},{label:'is not',value:'NotEquals'},{label:'contains',value:'Contains'},{label:'does not contain',value:'DoesNotContain'},{label:'starts with',value:'StartsWith'},{label:'ends with',value:'EndsWith'}]}});this.datatypes.addType({uri:{prefix:'xsd',namespaceURI:XSDNS,localPart:"boolean"},facets:{enumeration:[{label:'true',value:'true'},{label:'false',value:'false'}]}});};userSmarts.wt.forms.SearchModelDatatypeRegistry=function(properties){DatatypeRegistry.apply(this,[properties]);};userSmarts.wt.forms.SearchModelDatatypeRegistry.inheritsFrom(DatatypeRegistry);userSmarts.wt.forms.SearchModelDatatypeRegistry.prototype.getType=function(uri){var type=this.types[uri];if(!type){type=datatypes.getType(uri);}
return type;};userSmarts.wt.forms.SearchModelParser=function(properties){if(isPrototype(arguments)){return;}
Bean.call(this,properties);var urlListener=new URLChangeListener(this,'url','xml');this.addChangeListener(bind(this.onXmlChange,this),"xml");};userSmarts.wt.forms.SearchModelParser.inheritsFrom(Bean);userSmarts.wt.forms.SearchModelParser.prototype.onXmlChange=function(event){var model=new userSmarts.wt.forms.SearchModel();var root=event.newValue.documentElement;var dataTypeElements=root.getElementsByTagName('datatype');forEach(dataTypeElements,partial(this.unMarshalDataType,model));var fieldElements=root.getElementsByTagName('field');forEach(fieldElements,partial(this.unMarshalField,model));event.source.setProperty("searchModel",model);};userSmarts.wt.forms.SearchModelParser.prototype.unMarshalField=function(model,el){var field={name:el.getAttribute('name')||'',value:el.getAttribute('name')||'',title:el.getAttribute('title')||'',label:el.getAttribute('label')||'',datatype:model.datatypes.getType(el.getAttribute('datatype')||'xsd:string'),rows:el.getAttribute('rows')||0,cols:el.getAttribute('cols')||0,multiplicity:(el.getAttribute('multiple')=="true"),defaultValue:el.getAttribute('value'),selected:false};model.addField(field);var dt=model.datatypes.getType(userSmarts.wt.forms.namespace+'property');if(dt){dt.facets.enumeration.push(field);}};userSmarts.wt.forms.SearchModelParser.prototype.unMarshalDataType=function(model,el){var name=el.getAttribute('name');var formType=el.getAttribute('form-type');var pattern=el.getAttribute('pattern');var size=el.getAttribute('size');var usePredicate=(el.getAttribute('usePredicate')=='false')||true;var datatype=model.datatypes.getType(name);if(!datatype){var basetype=model.datatypes.getType(el.getAttribute('base-type'));datatype={uri:name,base:basetype,facets:{length:(size*1)}};if(formType=='select'){datatype.isList=true;datatype.facets.enumeration=[];var options=el.getElementsByTagName('option');for(var i=0;i<options.length;i++){var optionE=options[i];var oLabel=scrapeText(optionE);var oValue=optionE.getAttribute('value');datatype.facets.enumeration.push({label:oLabel,value:oValue});}}
model.datatypes.addType(datatype);}};userSmarts.wt.forms.SearchParser=function(properties){if(isPrototype(arguments)){return;}
Bean.call(this,properties);var urlListener=new URLChangeListener(this,'url','xml');this.addChangeListener(bind(this.onXmlChange,this),"xml");};userSmarts.wt.forms.SearchParser.inheritsFrom(Bean);userSmarts.wt.forms.SearchParser.prototype.onXmlChange=function(event){var root=event.newValue.documentElement;var requireAll=root.getAttribute('requireAll');var search=new userSmarts.wt.forms.SearchObject({requireAll:requireAll});var conditionElements=root.getElementsByTagName('condition');forEach(conditionElements,bind(this.unMarshalCondition,this,search));this.setProperty("search",search);};userSmarts.wt.forms.SearchParser.prototype.unMarshalCondition=function(search,el){try{var field=el.getAttribute('field');var datatype=el.getAttribute('datatype');var predicate=el.getAttribute('predicate');var first=el.getAttribute('first');var second=el.getAttribute('second')||null;search.addCondition(new userSmarts.wt.forms.Condition({field:field,predicate:predicate,firstValue:first,secondValue:second,datatype:datatype}));}catch(e){logError("SearchParser::unMarshalCondition - error parsing condition : "+e.toString());}};userSmarts.wt.forms.FormWidget=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{atts:{}});Bean.call(this,properties);};userSmarts.wt.forms.FormWidget.inheritsFrom(Bean);userSmarts.wt.forms.FormWidget.prototype.paint=function(context){this.output=FORM(this.atts,this.layout);this.output.onsubmit=bind(this.handleSubmit,this);logDebug("FormWidget.paint: output: "+this.output);return this.output;};userSmarts.wt.forms.FormWidget.repaint=function(){};userSmarts.wt.forms.FormWidget.prototype.handleSubmit=function(event){if(typeof(this.onsubmit)=='function'){var type=event.explicitOriginalTarget.value;if(this.model&&typeof(this.model.onsubmit)=='function'){this.model.onsubmit(event,type);}
return false;}else{return false;}};userSmarts.wt.forms.FormWidget.prototype.onsubmit=function(event,type){return false;};userSmarts.wt.forms.FormWidget.prototype.validate=function(){if(this.model&&this.model.onvalidate){this.model.onvalidate();}};userSmarts.wt.forms.SearchWidget=function(properties){properties=setdefault(properties,{search:new SearchObject(),atts:{}});Bean.apply(this,[properties]);this.listener=bind(function(){this.repaint();},this);};userSmarts.wt.forms.SearchWidget.inheritsFrom(Bean);userSmarts.wt.forms.SearchWidget.prototype.onSearchChange=function(searchObj){if(this.search){this.search.removeChangeListener(this.listener,'modified');}
this.search=searchObj;this.search.addChangeListener(this.listener,'modified');};userSmarts.wt.forms.SearchWidget.prototype.paint=function(context){if(!this.layout){this.layout=DIV({'class':'search-widget'});}
this.form=context.findParent(userSmarts.wt.forms.FormWidget);this.repaint(context);return this.layout;};userSmarts.wt.forms.SearchWidget.prototype.repaint=function(context){if(!this.model){return;}
var conditions=this.search.getConditions();for(var i=this.layout.childNodes.length-1;i>=0;i--){this.layout.removeChild(this.layout.childNodes[i]);}
forEach(conditions,bind(function(condition){condition.removeChangeListener(this.conditionListener,'modified');},this));var newButton=INPUT({type:'button',value:'new',size:20});newButton.onclick=bind(function(){var availFields=this.model.datatypes.getType(userSmarts.wt.forms.namespace+'property');var firstField=this.model.findField(availFields.facets.enumeration[0].value);this.search.addCondition(new Condition(firstField.name,firstField.datatype.facets.enumeration[0].value,'','',firstField.datatype));},this);this.layout.appendChild(newButton);forEach(conditions,bind(function(condition){this.buildCondition(condition,context);},this));};userSmarts.wt.forms.SearchWidget.prototype.buildCondition=function(condition,context){var field=this.model.findField(condition.field);var datatype=field.datatype;if(typeof(datatype)=='string'){datatype=this.model.datatypes.getType(field.datatype);}
if(datatype.facets.enumeration){var predDatatype=datatype.base||datatype;var foundPredicate=false;for(var i=0;i<predDatatype.facets.enumeration.length;i++){if(predDatatype.facets.enumeration[i].value==condition.predicate){foundPredicate=true;}}
if(!foundPredicate){condition.predicate=predDatatype.facets.enumeration[0];}}
var div=DIV({'class':'form-search-condition'});var deleteButton=INPUT({'type':'submit','value':'-'});deleteButton.onclick=bind(function(c){this.removeCondition(c);},this.search,condition);div.appendChild(SPAN(null,deleteButton));var fieldsType=this.model.datatypes.getType(userSmarts.wt.forms.namespace+'property');var fieldProps={name:condition.id+"_FIELD",title:"Field",optionModel:new userSmarts.wt.forms.DefaultOptionModel({datatype:fieldsType,selectedOption:field.name}),parent:this.form,binding:new BeanPropertyBinding(condition,'field')};var fieldSelect=new userSmarts.wt.forms.SelectWidget(fieldProps);div.appendChild(fieldSelect.paint(context));var predProps={name:condition.id+"_PREDICATE",title:"Predicate",optionModel:this.model.getOptionModel(field,condition.predicate,true),parent:this.form,binding:new BeanPropertyBinding(condition,'predicate')};var predicateSelect=new userSmarts.wt.forms.SelectWidget(predProps);div.appendChild(predicateSelect.paint(context));if(datatype.isList){var props={title:"FirstValue",name:condition.id+"_FIRSTVALUE",description:'',size:datatype.facets.length||'',optionModel:this.model.getOptionModel(field,condition.firstValue,false),parent:this.form,binding:new BeanPropertyBinding(condition,'firstValue')};var firstValueSelect=new userSmarts.wt.forms.SelectWidget(props);if(this.form){this.form.append('fields',firstValueSelect);}
div.appendChild(firstValueSelect.paint(context));if(condition.predicate=='Between'){var secondprops={title:"SecondValue",name:condition.id+"_SECONDVALUE",description:'',size:datatype.facets.length||'',optionModel:this.model.getOptionModel(field,condition.secondValue,false),parent:this.form,binding:new BeanPropertyBinding(condition,'secondValue')};var secondValueSelect=new userSmarts.wt.forms.SelectWidget(secondprops);if(this.form){this.form.append('fields',secondValueSelect);}
div.appendChild(secondValueSelect.paint(context));}}else{var props={title:"Value",name:condition.id+"_VALUE",description:'',size:datatype.facets.length,parent:this.form,binding:new BeanPropertyBinding(condition,'firstValue')};var field=new userSmarts.wt.forms.Field(props);if(this.form){this.form.append("fields",field);}
div.appendChild(field.paint());}
this.layout.appendChild(div);};userSmarts.wt.forms.SelectWidget=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{atts:{},size:''});Bean.call(this,properties);if(!this.optionModel){this.optionModel=new userSmarts.wt.forms.DefaultOptionModel({datatype:this.datatype});}};userSmarts.wt.forms.SelectWidget.inheritsFrom(Bean);userSmarts.wt.forms.SelectWidget.prototype.paint=function(context){var options=[];var model=this.optionModel;var hasSelection=false;for(var i=0;i<model.getOptionCount();++i){var atts={value:model.getValue(i),'class':'form-option-'+model.getLabel(i).replace(/\s+/g,'_')};if(model.getDisabled(i)){atts.disabled="disabled";}
if(model.isSelected(i)||model.getValue(i)==this.value||(this.binding&&this.binding.getValue()==model.getValue(i))){hasSelection=true;atts.selected="selected";}
options.push(OPTION(atts,model.getLabel(i)));}
if(!hasSelection){if(options.length>0){options[0].selected="selected";if(this.binding){this.binding.setValue(options[0].value);}}}
this.select=SELECT();this.select.id=this.name;this.select.name=this.name;this.select.size=this.size;if(this.style){this.select.style=this.style;}
for(var i=0;i<options.length;++i){this.select.appendChild(options[i]);}
connect(this.select,'onchange',this,this.onInputChange);this.layout=SPAN({'class':'form-select-field'});if(this.showLabel){this.layout.appendChild(LABEL({"for":this.name},this.title));}
this.layout.appendChild(this.select);return this.layout;};userSmarts.wt.forms.SelectWidget.prototype.repaint=function(){};userSmarts.wt.forms.SelectWidget.prototype.onInputChange=function(event){var selectedIndex=this.select.selectedIndex;var value=this.optionModel.getValue(selectedIndex);if(this.binding){this.binding.setValue(value);}
if(this.parent){this.parent.validate();}};userSmarts.wt.forms.SelectWidget.prototype.focus=function(){if(this.select){this.select.focus();}};userSmarts.wt.forms.TextArea=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{rows:0,cols:0,wrap:'SOFT',multiplicity:false,format:new StringFormat()});Bean.call(this,properties);};userSmarts.wt.forms.TextArea.inheritsFrom(Bean);userSmarts.wt.forms.TextArea.prototype.paint=function(){var ta=document.createElement("TEXTAREA");ta.id=this.name;ta.name=this.name;ta.rows=this.rows;ta.cols=this.cols;ta['WRAP']=this.wrap;this.input=ta;connect(this.input,'onchange',this,this.onInputChange);if(this.value){this.input.value=this.value;}else if(this.binding){this.input.value=this.binding.getValue();}else{this.input.value="";}
this.layout=SPAN({'class':'form-input-field'});if(this.name&&this.title){this.layout.appendChild(LABEL({"for":this.name},this.title));}
this.layout.appendChild(this.input);if(this.binding&&this.binding.addChangeListener){this.binding.addChangeListener(bind(this.onBindingChange,this),this.parent.model);}
return this.layout;};userSmarts.wt.forms.TextArea.prototype.onInputChange=function(event){var value=this.format.parseObject(this.input.value);if(this.binding){this.binding.setValue(value);}
this.input.value=this.format.format(value);if(this.parent){this.parent.validate();}};userSmarts.wt.forms.TextArea.prototype.onBindingChange=function(event){var value=this.binding.getValue();this.input.value=this.format.format(value);};userSmarts.wt.forms.TextArea.prototype.focus=function(){this.input.focus();};userSmarts.wt.forms.RadioWidget=function(properties){if(isPrototype(arguments)){return;}
properties=setdefault(properties,{atts:{},size:''});Bean.call(this,properties);if(!this.optionModel&&this.datatype){this.optionModel=new userSmarts.wt.forms.DefaultOptionModel({datatype:this.datatype});}};userSmarts.wt.forms.RadioWidget.inheritsFrom(Bean);userSmarts.wt.forms.RadioWidget.prototype.paint=function(){this.layout=SPAN({'class':'form-select-field'});if(this.showLabel){this.layout.appendChild(LABEL({"for":this.name},this.title));}
var model=this.optionModel;var input;if(model){for(var i=0;i<model.getOptionCount();++i){input=INPUT({type:'radio',name:this.name});input.index=i;input.value=model.getValue(i);connect(input,"onclick",this,this.onInputChange);if(model.isSelected(i)||model.getValue(i)==this.value||(this.binding&&this.binding.getValue()==model.getValue(i))){input.checked=true;}
if(model.getDisabled(i)){input.disabled=true;}
this.layout.appendChild(input);this.layout.appendChild(document.createTextNode(" "+model.getLabel(i)));this.layout.appendChild(BR());}}
return this.layout;};userSmarts.wt.forms.RadioWidget.prototype.repaint=function(){};userSmarts.wt.forms.RadioWidget.prototype.onInputChange=function(event){var input=event.src();var index=input.index;this.optionModel.setSelected(index,input.checked);if(this.binding){var value=this.optionModel.getValue(index);if(input.checked){this.addValueToBinding(value);}else{this.removeValueFromBinding(value);}}
if(this.parent){this.parent.validate();}};userSmarts.wt.forms.RadioWidget.prototype.removeValueFromBinding=function(value){if(this.binding){var values=this.binding.getValue()||[];for(var i=0;i<values.length;++i){if(values[i]==value){values.splice(i,1);break;}}
this.binding.setValue(values);}};userSmarts.wt.forms.RadioWidget.prototype.addValueToBinding=function(value){if(this.binding){var values=this.binding.getValue()||[];var found=false;for(var i=0;i<values.length;++i){if(values[i]==value){found=true;break;}}
if(!found){values.push(value);}
this.binding.setValue(values);}};userSmarts.runtime.Platform.registerPluginJSON({"id":"com.usersmarts.rcp.rcp-wt-plugin","prerequisites":["com.usersmarts.rcp.rcp-runtime-plugin"],"pluginClass":"","providerName":"","extensionPoints":{},"name":"userSmarts WT","installURL":"${installURL}","label":"userSmarts WT","version":"0.1"});
