/*
 * Copyright (c) 2009 The Olympos Development Team.
 *
 * http://sourceforge.net/projects/olympos/
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html. If redistributing this code,
 * this entire header must remain intact.
 */
Ext.namespace("uwm.property");uwm.property.ComboBoxBase=function(config){uwm.property.ComboBoxBase.superclass.constructor.call(this,Ext.apply(this,{},config));}
Ext.extend(uwm.property.ComboBoxBase,Ext.form.ComboBox);uwm.property.ComboBoxBase.prototype.findRecord=function(prop,value){if(this.store==null)
return null;var record;if(this.store.getCount()>0){this.store.each(function(r){if(r.data[prop]==value){record=r;return false;}});}
return record;}
Ext.override(Ext.form.ComboBox,{initEvents:function(){Ext.form.ComboBox.superclass.initEvents.call(this);this.keyNav=new Ext.KeyNav(this.el,{"up":function(e){this.inKeyMode=true;this.selectPrev();},"down":function(e){if(!this.isExpanded()){this.onTriggerClick();}else{this.inKeyMode=true;this.selectNext();}},"enter":function(e){if(this.forceSelection){this.onViewClick();}else{this.collapse();}
this.delayedCheck=true;this.unsetDelayCheck.defer(10,this);},"esc":function(e){this.collapse();},"tab":function(e){if(this.forceSelection){this.onViewClick(false);}else{this.collapse();}
return true;},scope:this,doRelay:function(foo,bar,hname){if(hname=='down'||this.scope.isExpanded()){return Ext.KeyNav.prototype.doRelay.apply(this,arguments);}
return true;},forceKeyDown:true});this.queryDelay=Math.max(this.queryDelay||10,this.mode=='local'?10:250);this.dqTask=new Ext.util.DelayedTask(this.initQuery,this);if(this.typeAhead){this.taTask=new Ext.util.DelayedTask(this.onTypeAhead,this);}
if(this.editable!==false&&!this.enableKeyEvents){this.mon(this.el,'keyup',this.onKeyUp,this);}
if(this.forceSelection){this.on('blur',this.doForce,this);}}})
Ext.namespace("uwm.i18n");uwm.i18n.Localization=function(){this.modelLanguages=new Array();this.curTranslationLanguage=null;this.curModelLanguage=null;}
uwm.i18n.Localization.prototype.getDefaultModelLanguage=function(){return uwm.Config.defaultLanguage;}
uwm.i18n.Localization.prototype.setModelLanguage=function(language){if(language!=this.curModelLanguage){this.curModelLanguage=language;uwm.event.EventBroker.getInstance().fireEvent("changeModelLanguage",language);}}
uwm.i18n.Localization.prototype.getModelLanguage=function(){if(this.curModelLanguage==null){this.curModelLanguage=this.getDefaultModelLanguage();}
return this.curModelLanguage;}
uwm.i18n.Localization.prototype.getAllModelLanguages=function(){return this.modelLanguages;}
uwm.i18n.Localization.prototype.getUserInterfaceLanguage=function(){return uwm.Session.getInstance().getLang();}
uwm.i18n.Localization.prototype.getAllUserInterfaceLanguages=function(){return uwm.Config.languages;}
uwm.i18n.Localization.prototype.setTranslationLanguage=function(language){if(language!=this.curTranslationLanguage){this.curTranslationLanguage=language;uwm.event.EventBroker.getInstance().fireEvent("changeTranslationLanguage",language);}}
uwm.i18n.Localization.prototype.getTranslationLanguage=function(){if(this.curTranslationLanguage==null){this.setTranslationLanguage(this.getDefaultTranslationLanguage());}
return this.curTranslationLanguage;}
uwm.i18n.Localization.prototype.getDefaultTranslationLanguage=function(){var curModelLanguage=this.getModelLanguage();var languages=this.getAllModelLanguages();for(var i=0;i<languages.length;i++){if(languages[i][0]!=curModelLanguage){return languages[i][0];}}
if(languages[0]){return languages[0][0];}
return'';}
uwm.i18n.Localization.prototype.getLanguageName=function(language,languages){for(var i=0;i<languages.length;i++){if(languages[i][0]==language){return languages[i][1];}}
return'';}
uwm.i18n.Localization.prototype.loadModelLanguages=function(callback){var self=this;uwm.persistency.Persistency.getInstance().list('Language',false,this.getModelLanguage(),function(options,data){for(var i=0;i<data.objects.length;i++){var currObj=data.objects[i];self.modelLanguages.push([currObj.values[1].code,currObj.values[1].Name]);}
if(callback instanceof Function){callback();}},function(options,data,errorMsg){uwm.Util.showMessage("Unable to load languages",data.errorMsg,uwm.Util.messageType.ERROR);})}
uwm.i18n.Localization.getInstance=function(){if(!uwm.i18n.Localization.instance){uwm.i18n.Localization.instance=new uwm.i18n.Localization();}
return uwm.i18n.Localization.instance;}
Ext.namespace("uwm.i18n");uwm.i18n.LanguageListBox=Ext.extend(uwm.property.ComboBoxBase,{languages:[],includeUserLanguage:true,initComponent:function(){var languages=this.languages;var data=new Array();for(var i=0;i<languages.length;i++){data[i]=new Array();data[i][0]=languages[i][0];data[i][1]=languages[i][1];if(data[i][0]==uwm.i18n.Localization.getInstance().getDefaultModelLanguage()){data[i][1]+=' [Default]';}}
var loc=uwm.i18n.Localization.getInstance();if(!this.includeUserLanguage){for(var i=0;i<data.length;i++){if(data[i][0]==loc.getModelLanguage()){data.splice(i,1);}}}
Ext.apply(this,{fieldLabel:uwm.Dict.translate('Language'),editable:'false',name:'Language',store:new Ext.data.ArrayStore({id:0,fields:['key','val'],data:data}),valueField:'key',displayField:'val',mode:'local',editable:false,triggerAction:'all'});uwm.i18n.LanguageListBox.superclass.initComponent.call(this);if(data[0]){this.setValue(data[0][0]);}}});uwm.i18n.LanguageListBox.prototype.getLanguageFromRecord=function(record){return record.get('key');}
Ext.namespace("uwm");uwm.Uwm=function(){}
uwm.Uwm.prototype.processConfig=function(){document.title=uwm.Config.appTitle;}
uwm.Uwm.prototype.startApplication=function(){this.installErrorHandler();this.installOverrides();var self=this;uwm.event.EventBroker.getInstance().addListener({"changeModelLanguage":function(language){self.restart();}});var params=location.search.split(/&/);var sid=null;for(var i=0;i<params.length;i++){var parts=params[i].split(/=/);if(parts[0]="sid"){sid=parts[1];break;}}
if(sid){this.startSession(sid,uwm.i18n.Localization.getInstance().getDefaultModelLanguage());}else{this.login=new uwm.ui.Login();}}
uwm.Uwm.prototype.startSession=function(sid,lang){uwm.Session.getInstance().init(sid,lang);if(this.login){this.login.destroy();}
var self=this;uwm.i18n.Localization.getInstance().loadModelLanguages(function(){self.createViewport();});}
uwm.Uwm.prototype.createViewport=function(){this.defaultWorkbench=new uwm.ui.Workbench();this.adminWorkbench=new uwm.tabadmin.Workbench();this.viewport=new Ext.Viewport({layout:"card",activeItem:0,items:[this.defaultWorkbench,this.adminWorkbench]})}
uwm.Uwm.prototype.switchWorkbench=function(newWorkbench){switch(newWorkbench){case"admin":if(!(uwm.diagram.DiagramContainer.getInstance().getTabPanel().getActiveTab().isHelpViewer)){uwm.diagram.DiagramContainer.getInstance().getTabPanel().getActiveTab().saveScrollPosition();}
this.viewport.getLayout().setActiveItem(1);break;case"default":default:this.viewport.getLayout().setActiveItem(0);if(!(uwm.diagram.DiagramContainer.getInstance().getTabPanel().getActiveTab().isHelpViewer)){uwm.diagram.DiagramContainer.getInstance().getTabPanel().getActiveTab().restoreScrollPosition();}
break;}}
uwm.Uwm.prototype.getActiveWorkbench=function(){return this.viewport.getLayout().activeItem;}
uwm.Uwm.prototype.reload=function(){this.viewport.destroy();uwm.persistency.Persistency.getInstance().logout(function(){window.location.reload();});}
uwm.Uwm.prototype.restart=function(){this.viewport.destroy();uwm.event.EventBroker.instance=null;uwm.hierarchytree.HierarchyTree.instance=null;uwm.modeltree.ModelTree.getInstance().destroy();uwm.objectgrid.ObjectGridContainer.instance=null;uwm.diagram.DiagramContainer.instance=null;uwm.model.ModelContainer.instance=null;uwm.property.PropertyContainer.instance=null;var self=this;uwm.event.EventBroker.getInstance().addListener({"changeModelLanguage":function(language){self.restart();}});this.createViewport();this.switchWorkbench("default");}
uwm.Uwm.prototype.installErrorHandler=function(){var self=this;var originalAddListener=Ext.EventManager.addListener;Ext.EventManager.addListener=function(element,eventName,fn,scope,options){scope=scope||this;return originalAddListener(element,eventName,function(){try{fn.apply(scope||this,arguments);}catch(e){if(e.message!="Permission denied to access property 'dom' from a non-chrome context"){self.handleError(e);}}},scope,options);}
Ext.EventManager.on=Ext.EventManager.addListener;window.onerror=function(message,uri,line){self.handleError(null,message,uri,line);}}
uwm.Uwm.prototype.handleError=function(e,message,uri,line){var data=new Object();data["file"]=uri?uri:e&&e.fileName?e.fileName:"unknown";data["line number"]=line?line:e&&e.lineNumber?e.lineNumber:"unknown";data["error name"]=e&&e.name?e.name:"unknown";data["error message"]=message?message:e&&e.message?e.message:"unknown";data["stack"]=e&&e.stack?e.stack:"unknown";var plainText="";for(var i in data){var val=data[i];if(!(val instanceof Function)){plainText+=i+": "+val+"\n";}}
uwm.persistency.Persistency.getInstance().log("error",plainText);var html="";for(var i in data){var val=data[i];if(!(val instanceof Function)){html+="<p><b>"+i+":</b> "+
(""+val).replace(/\n/g,"<br />")+"</p>";}}
if(uwm.Config.debug){uwm.Util.showMessage(uwm.Dict.translate("Error occured"),html,uwm.Util.messageType.ERROR);throw e;}else{var self=this;var window=new Ext.Window({id:uwm.Uwm.ERROR_WINDOW_ID,title:uwm.Dict.translate("Error occured"),layout:"fit",items:[new Ext.Panel({html:"<p class='uwm-errorDialogMessage'>"+
uwm.Dict.translate("An application error occured. You may continue your work, but this might lead to further errors.<br/>If you choose to restart, your data will be saved.")+"<br/><br/>"+
uwm.Dict.translate("To report the error click the following link to get to the ")+"<a href='http://sourceforge.net/tracker/?group_id=198381&atid=965248' target='_blank'>"+
uwm.Dict.translate("bug tracking system")+"</a>."+"</p>"}),new Ext.Panel({id:uwm.Uwm.ERROR_DETAILS_ID,title:uwm.Dict.translate("Error details"),collapsed:true,collapsible:true,animCollapse:false,collapseFirst:true,titleCollapse:true,html:"<div class='uwm-errorDialogDetails'>"+
html+"</div>",listeners:{"collapse":function(){window.center();},"expand":function(){window.center();}}})],buttons:[{text:uwm.Dict.translate("Continue"),handler:function(){window.destroy();}},{text:uwm.Dict.translate("Restart"),handler:function(){self.reload(true);}}]});window.show();}}
uwm.Uwm.prototype.installOverrides=function(){Ext.override(Ext.form.Field,{loadValue:function(value){this.setValue(value);this.originalValue=this.getValue();}});}
uwm.Uwm.getInstance=function(){if(!uwm.Uwm.instance){uwm.Uwm.instance=new uwm.Uwm();}
return uwm.Uwm.instance;}
uwm.Uwm.ERROR_WINDOW_ID="errorWindowId";uwm.Uwm.ERROR_DETAILS_ID="errorDetailsId";Ext.namespace("uwm.Constants");uwm.Constants.DD_GROUP="uwmDDGroup";uwm.Constants.SVN_REVISION="1320";uwm.Constants.AJAX_TIMEOUT=1800000;Ext.namespace("uwm.Util");uwm.Util.getUwmClassNameFromOid=function(oid){var result=oid.match(/^[^:]+/)[0];if(oid.charAt(0)=="{"){result=oid.match(/:([^}]+)/)[1];}
return result;}
uwm.Util.getNumericFromOid=function(oid){return oid.match(/:([0-9]+)/)[1];}
uwm.Util.showMessage=function(title,message,messageType){var messageContainer=Ext.get("messageContainer");if(!messageContainer){messageContainer=Ext.DomHelper.insertFirst(document.body,{id:"messageContainer",style:"position: absolute"},true);}
messageContainer.alignTo(document,'t-t');var messageBox=Ext.DomHelper.append(messageContainer,{html:'<div>'
+'<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>'
+'<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>'
+title
+'</h3>'
+message
+'</div></div></div>'
+'<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>'
+'</div>'},true);messageBox.slideIn('t').pause(6).ghost("t",{remove:true});}
uwm.Util.messageType={INFO:1,WARNING:2,ERROR:3}
uwm.Util.setElementUnselectable=function(elem){if(elem){elem.style.MozUserSelect="none";elem.style.KhtmlUserSelect="none";elem.unselectable="on";}}
Ext.namespace("uwm.Log");uwm.Log.DEBUG=0;uwm.Log.INFO=1;uwm.Log.WARN=2;uwm.Log.ERROR=3;uwm.Log.isEnabled=function(logLevel){return uwm.Config.logLevel<=logLevel;}
uwm.Log.log=function(message,logLevel){var consoleExists=false;try{consoleExists=console!=null;}
catch(e){}
if(consoleExists){if(uwm.Log.isEnabled(logLevel)){switch(logLevel){case uwm.Log.DEBUG:console.debug(message);break;case uwm.Log.INFO:console.info(message);break;case uwm.Log.WARN:console.warn(message);break;case uwm.Log.ERROR:console.error(message);break;default:console.log(message);}}}}
Ext.namespace("uwm");uwm.Session=function(){this.sid=null;this.jsonUrl=uwm.Config.jsonUrl;this.helpUrl="welcome/welcome.html";this.persistencyClass="uwm.persistency.Json";this.lang="en";}
uwm.Session.prototype.init=function(sid,lang){this.sid=sid;this.lang=lang;}
uwm.Session.prototype.getSid=function(){return this.sid;}
uwm.Session.prototype.getJsonUrl=function(){return this.jsonUrl;}
uwm.Session.prototype.getHelpUrl=function(){return this.helpUrl;}
uwm.Session.prototype.getPersistencyClass=function(){return this.persistencyClass;}
uwm.Session.prototype.getLang=function(){return this.lang;}
uwm.Session.getInstance=function(){if(!uwm.Session.instance){uwm.Session.instance=new uwm.Session();}
return uwm.Session.instance;}
Ext.namespace("uwm.Dict");uwm.Dict.voc={'Shows all':{'de':'Zeigt alle'},'within selected scope':{'de':'innerhalb des ausgewählten Bereiches'},'Shows all dependencies of a specific object. Use context menu on an object to show it here.':{'de':'Zeigt alle Abhängigkeiten eines Objekts an. Kontextmenü benutzen.'},'Shows all models, packages, and contained objects.':{'de':'Zeigt alle Modelle, Pakete und enthaltenen Objekte an.'},'This tree shows all dependencies of an object. Select an object, right-click and select &quot;Show in hierarchy&quot; to show it here.':{'de':'Dieser Baum zeigt alle Abhängigkeiten eines Objektes. Objekt auswählen, Rechtsklick und Auswahl &quot;In Hierarchie anzeigen&quot;, um es hier anzuzeigen.'},'Shows all objects within selected scope. To select a scope, select the <i>Model Tree</i>, right-click on a Model or Package and select &quot;Select as grid scope&quot;.':{'de':'Zeigt alle Objekte innerhalb des ausgewählten Bereiches. Um einen Bereich auszuwählen, <i>Model Tree</i> auswählen, Rechtsklick auf ein Modell or Paket und &quot;Als Gitterbereich wählen&quot;.'},'Please wait while your export is prepared ...':{'de':'Bitte warten, Export wird vorbereitet ...'},'Persistency layer error':{'de':'Fehler in Persistenzschicht'},'An unspecified error has occured in persistency layer.':{'de':'In der Persistenzschicht ist ein undefinierter Fehler aufgetreten.'},'Goals':{'de':'Ziele'},'Goal':{'de':'Ziel'},'Requirements':{'de':'Anforderungen'},'Requirement':{'de':'Anforderung'},'Features':{'de':'Fähigkeiten'},'Feature':{'de':'Fahigkeit'},'Issues':{'de':'Probleme'},'Issue':{'de':'Problem'},'Perspectives':{'de':'Perspektiven'},'Properties':{'de':'Eigenschaften'},'Available Content':{'de':'Verfügbarer Inhalt'},'New Objects':{'de':'Neue Objekte'},'Default':{'de':'Standard'},'Admin':{'de':'Administrator'},'Documentation Viewer':{'de':'Dokumentation'},'Hierarchy Tree':{'de':'Hierarchiebaum'},'Model Tree':{'de':'Modellbaum'},'Title':{'de':'Titel'},'Label':{'de':'Beschriftung'},'Priority':{'de':'Priorität'},'Help':{'de':'Hilfe'},'Open':{'de':'Öffnen'},'Name':{'de':'Name'},'Notes':{'de':'Notiz'},'created':{'de':'erstellt am'},'creator':{'de':'Ersteller'},'last_editor':{'de':'zuletzt geändert von'},'modified':{'de':'geändert am'},'Show in tree':{'de':'Im Baum anzeigen'},'Show in grid':{'de':'Im Gitter anzeigen'},'Show in hierarchy':{'de':'In Hierarchie anzeigen'},'Show in diagram':{'de':'Im Diagramm anzeigen'},'Show in model tree':{'de':'Im Modellbaum anzeigen'},'Delete from diagram':{'de':'Aus dem Diagramm löschen'},'Delete from model':{'de':'Aus dem Modell löschen'},'Add package':{'de':'Paket hinzufügen'},'Add diagram':{'de':'Diagramm hinzufügen'},'Add activity set':{'de':'Aktivitätsdiagramm hinzufügen'},'Select as grid scope':{'de':'Als Gitterbereich auswählen'},'Create model':{'de':'Modell erstellen'},'Add new entry':{'de':'Neuen Eintrag hinzufügen'},'Remove entry':{'de':'Eintrag entfernen'},'Name':{'de':'Name'},'Model Objects':{'de':'Modellobjekte'},'Existing Classes':{'de':'Existierende Klassen'},'Login':{'de':'Einloggen'},'Password':{'de':'Passwort'},'Language':{'de':'Sprache'},'This panel shows the properties of each object selected by a single click.':{'de':'Zeigt mit Click die Eigenschaften jedes Objekts an'},'Export as UML':{'de':'Als UML exportieren'},'Exporting UML ...':{'de':'Exportiere UML ...'},'Model Upload':{'de':'Modelle hochladen'},'Select UML model':{'de':'Wählen Sie ein UML-Modell aus'},'File to upload':{'de':'Hochzuladende Datei'},'Send model':{'de':'Sende Modell'},'Sending the model ...':{'de':'Sende das Modell ...'},'Import successful':{'de':'Import erfolgreich'},'Your import finished successfully. The application is going to restart.':{'de':'Der Import wurde erfolgreich beendet. Die Anwendung wird nun neu gestartet.'},'OK':{'de':'OK'},'Import failed':{'de':'Import fehlgeschlagen'},'Your import failed. See below for errors.':{'de':'Ihr Import ist fehlgeschlagen. Siehe unten für Fehlermeldungen (auf Englisch).'},'Export as Word Document':{'de':'Als Word-Dokument exportieren'},'Exporting Word Document ...':{'de':'Exportiere Word-Dokument ...'},'Error occured':{'de':'Ein Fehler ist aufgetreten'},'An application error occured. Your data will be saved and the application will be restarted.':{'de':'Ein Anwendungsfehler ist aufgetreten. Ihre Daten werden gespeichert und die Anwedung neu gestartet.'},'View':{'de':'Ansicht'},'Error details':{'de':'Fehlerdetails'},"Snap to objects":{'de':"An Objekten ausrichten"},"Auto-layout":{'de':"Auto-Layout"},"Reload":{'de':"Neu laden"},"Print":{'de':"Drucken"},"Please make sure that background printing is enabled in page setup.":{'de':"Bitte stellen Sie sicher, dass 'Hintergrund drucken' aktiviert ist."},"NOTE: This message will not be printed.":{'de':"ACHTUNG: Diese Nachricht wird nicht gedruckt."},"New":{'de':"Neue"},"Continue on your own risk":{'de':"Auf eigene Verantwortung fortfahren"},"Object History":{'de':"Objekt History"},"No changes have been made.":{'de':"Es wurden keine Veränderungen vorgenommen."},"Undo selected":{'de':"Änderungen rückgängig"},"Undo all changes since":{'de':"Zeitpunkt wiederherstellen"},"Cancel":{'de':"Abbrechen"},"Property":{'de':"Eigenschaft"},"Date":{'de':"Datum"},"Author":{'de':"Autor"},"Changed Items":{'de':"Änderungen"},"Show object history":{'de':"Objekt History zeigen"},"Old value":{'de':"Alter Wert"},"New value":{'de':"Neuer Wert"},"The selected properties have been successfully restored.":{'de':"Die ausgewählten Felder wurden erfolgreich wiederhergestellt."},"Error while exporting":{'de':"Fehler beim Exportieren"},"The export was unsuccessful. Please try again.":{'de':"Der Export war unerfolgreich. Bitte probieren Sie es erneut."},"Forbidden connection":{'de':"Verbotene Verbindung"},"This object already has a parent. Please disconnect it from its parent and redraw this connection to change its parent.":{'de':"Dieses Objekt hat bereits ein übergeordnetes Objekt. Um es einem anderen Objekt unterzuordnen, löschen Sie bitte die bestehende Verbindung."},"expand all":{'de':"alles erweitern"},"collapse all":{'de':"alles verkleinern"},"Export Documentation":{'de':"Dokumentation exportieren"},"Exporting Documentation ...":{'de':"Exportiere Dokumentation ..."}}
uwm.Dict.translate=function(){strword=arguments[0];try{strresult=uwm.Dict.voc[strword][uwm.i18n.Localization.getInstance().getUserInterfaceLanguage()];if(!strresult){strresult=strword;}}catch(e){strresult=strword;}
return strresult;}
Ext.namespace("uwm.persistency");uwm.persistency.Persistency=function(){}
uwm.persistency.Persistency.getInstance=function(){if(!uwm.persistency.Persistency.instance){uwm.persistency.Persistency.instance=eval("new "+uwm.Session.getInstance().getPersistencyClass()+"()");}
return uwm.persistency.Persistency.instance;}
uwm.persistency.Persistency.prototype.processSuccessHandler=function(successHandler,request,data){if(successHandler instanceof Function){successHandler(request,data);}}
uwm.persistency.Persistency.prototype.processErrorHandler=function(errorHandler,request,data,errorMessage){if(errorHandler instanceof Function){errorHandler(request,data,errorMessage);}
else if(errorHandler instanceof String){uwm.Util.showMessage(uwm.Dict.translate('Persistency layer error'),errorHandler+errorMessage,uwm.Util.messageType.ERROR);}
else if(errorMessage){uwm.Util.showMessage(uwm.Dict.translate('Persistency layer error'),errorMessage,uwm.Util.messageType.ERROR);}else{uwm.Util.showMessage(uwm.Dict.translate('Persistency layer error'),uwm.Dict.translate('An unspecified error has occured in persistency layer.'),uwm.Util.messageType.ERROR);}}
uwm.persistency.Persistency.prototype.doLogin=function(login,password,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.logout=function(successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.newObject=function(uwmClassName,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.deleteObject=function(oid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.associate=function(parentOid,childOid,invert,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.disassociate=function(parentOid,childOid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.save=function(oid,values,language,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.copy=function(oid,targetOid,recursive,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.sort=function(oid,direction,distance,poid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.display=function(oid,depth,language,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.batchdisplay=function(oid,language,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.list=function(uwmClassName,completeObjects,language,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.listbox=function(type,language,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.autocomplete=function(query,language,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.histlist=function(oid,start,limit,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.restorehistliststate=function(id,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.restorehistlistfields=function(ids,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.loadChildren=function(oid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.lock=function(oid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.unlock=function(oid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.log=function(logtype,msg,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.executeActionSet=function(actionSet){}
uwm.persistency.Persistency.prototype.createDiagramFromPackage=function(oid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.createControllerFromUseCase=function(oid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.putChildnodesToActivitySetDiagram=function(oid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.templatelist=function(successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.exportDoc=function(templateName,startOid,exportFormat,diagramFormat,language,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.exportUwm=function(startOid,language,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.exportImage=function(diagramOid,language,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.getCodeGeneratorList=function(successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.generateCode=function(codeId,modelOid,successHandler,errorHandler){}
uwm.persistency.Persistency.prototype.doContinue=function(controller,successHandler,errorHandler){}
Ext.namespace("uwm.persistency");uwm.persistency.Json=function(){this.sid=uwm.Session.getInstance().getSid();this.jsonUrl=uwm.Session.getInstance().getJsonUrl();}
uwm.persistency.Json.prototype=new uwm.persistency.Persistency;uwm.persistency.Json.prototype.jsonRequest=function(params,successHandler,errorHandler){params.sid=this.sid;params.response_format="JSON";if(params.language==undefined){params.language=uwm.i18n.Localization.getInstance().getModelLanguage();}
var self=this;Ext.Ajax.request({url:this.jsonUrl,method:"post",timeout:uwm.Constants.AJAX_TIMEOUT,params:params,callback:function(options,success,response){if(success){var data=Ext.util.JSON.decode(response.responseText);if(!data.errorMsg){self.processSuccessHandler(successHandler,options,data);}else{self.processErrorHandler(errorHandler,options,data,data.errorMsg);}}else{self.processErrorHandler(errorHandler,options,data);}}});}
uwm.persistency.Json.prototype.array2CommaList=function(array){var result=array;if(array instanceof Array){var first=true;result="";for(var i=0;i<array.length;i++){if(!first){result+=",";}else{first=false;}
result+=array[i];}}
return result;}
uwm.persistency.Json.prototype.doLogin=function(login,password,successHandler,errorHandler){this.jsonRequest({usr_action:"dologin",login:login,password:password},successHandler,errorHandler);}
uwm.persistency.Json.prototype.logout=function(successHandler,errorHandler){this.jsonRequest({usr_action:"logout"},successHandler,errorHandler);}
uwm.persistency.Json.prototype.newObject=function(uwmClassName,successHandler,errorHandler){this.jsonRequest({usr_action:"new",newtype:uwmClassName},successHandler,errorHandler);}
uwm.persistency.Json.prototype.deleteObject=function(oid,successHandler,errorHandler){this.jsonRequest({usr_action:"delete",deleteoids:this.array2CommaList(oid)},successHandler,errorHandler);}
uwm.persistency.Json.prototype.associate=function(parentOid,childOid,invert,successHandler,errorHandler){var direction="child";if(invert){direction="parent";}
this.jsonRequest({usr_action:"associate",oid:parentOid,associateoids:this.array2CommaList(childOid),associateAs:direction},successHandler,errorHandler);}
uwm.persistency.Json.prototype.disassociate=function(parentOid,childOid,successHandler,errorHandler){this.jsonRequest({usr_action:"disassociate",oid:parentOid,associateoids:this.array2CommaList(childOid)},successHandler,errorHandler);}
uwm.persistency.Json.prototype.save=function(oid,values,language,successHandler,errorHandler){var data={usr_action:"save",language:language};for(var i in values){if(!(values[i]instanceof Function)){data["value--"+i+"-"+oid]=values[i];}}
this.jsonRequest(data,successHandler,errorHandler);}
uwm.persistency.Json.prototype.copy=function(oid,targetOid,recursive,successHandler,errorHandler){this.jsonRequest({usr_action:"copy",oid:oid,targetoid:targetOid,recursive:recursive,},successHandler,errorHandler);}
uwm.persistency.Json.prototype.sort=function(oid,direction,distance,poid,successHandler,errorHandler){var action="sortdown";if(direction=="up"){action="sortup";}
this.jsonRequest({usr_action:action,sortoid:oid,dist:distance,poid:poid},successHandler,errorHandler);}
uwm.persistency.Json.prototype.display=function(oid,depth,language,successHandler,errorHandler){this.jsonRequest({usr_action:"display",oid:oid,depth:depth,language:language,omitMetaData:true,translateValues:true},successHandler,errorHandler);}
uwm.persistency.Json.prototype.batchdisplay=function(oid,language,successHandler,errorHandler){this.jsonRequest({usr_action:"batchdisplay",oid:oid,language:language,omitMetaData:true,translateValues:true},successHandler,errorHandler);}
uwm.persistency.Json.prototype.list=function(uwmClassName,completeObjects,language,successHandler,errorHandler){this.jsonRequest({usr_action:"list",type:uwmClassName,language:language,completeObjects:completeObjects},successHandler,errorHandler);}
uwm.persistency.Json.prototype.listbox=function(type,language,successHandler,errorHandler){this.jsonRequest({usr_action:"listbox",type:type,language:language},successHandler,errorHandler);}
uwm.persistency.Json.prototype.autocomplete=function(query,language,successHandler,errorHandler){this.jsonRequest({usr_action:'autocomplete',query:query,language:language},successHandler,errorHandler);}
uwm.persistency.Json.prototype.histlist=function(oid,start,limit,successHandler,errorHandler){this.jsonRequest({usr_action:'histlist',oid:oid,start:start,limit:limit},successHandler,errorHandler);}
uwm.persistency.Json.prototype.restorehistliststate=function(id,successHandler,errorHandler){this.jsonRequest({usr_action:'restorehistliststate',ids:id},successHandler,errorHandler);}
uwm.persistency.Json.prototype.restorehistlistfields=function(ids,successHandler,errorHandler){this.jsonRequest({usr_action:'restorehistlistfields',ids:ids},successHandler,errorHandler);}
uwm.persistency.Json.prototype.loadChildren=function(oid,successHandler,errorHandler){this.jsonRequest({controller:"TreeViewController",usr_action:"loadChildren",node:oid,sort:"sortkey"},successHandler,errorHandler);}
uwm.persistency.Json.prototype.lock=function(oid,successHandler,errorHandler){this.jsonRequest({usr_action:"lock",oid:oid},successHandler,errorHandler);}
uwm.persistency.Json.prototype.unlock=function(oid,successHandler,errorHandler){this.jsonRequest({usr_action:"unlock",oid:oid},successHandler,errorHandler);}
uwm.persistency.Json.prototype.createDiagramFromPackage=function(oid,successHandler,errorHandler){this.jsonRequest({usr_action:"packdiagr",oid:oid},successHandler,errorHandler);}
uwm.persistency.Json.prototype.createControllerFromUseCase=function(oid,successHandler,errorHandler){this.jsonRequest({usr_action:"usecasectrl",oid:oid},successHandler,errorHandler);}
uwm.persistency.Json.prototype.putChildnodesToActivitySetDiagram=function(oid,successHandler,errorHandler){this.jsonRequest({usr_action:"actsdiagr",oid:oid},successHandler,errorHandler);}
uwm.persistency.Json.prototype.log=function(logtype,msg,successHandler,errorHandler){var self=this;this.jsonRequest({usr_action:"log",logtype:logtype,msg:msg},successHandler,function(request,data,errorMessage){if(errorMessage){self.processSuccessHandler(successHandler);}else{self.processErrorHandler(errorHandler,request,data);}});}
uwm.persistency.Json.prototype.templatelist=function(successHandler,errorHandler){this.jsonRequest({usr_action:'templatelist'},successHandler,errorHandler);}
uwm.persistency.Json.prototype.exportDoc=function(templateName,startOid,exportFormat,diagramFormat,language,successHandler,errorHandler){this.jsonRequest({usr_action:'exportDoc',templateName:templateName,startOid:startOid,exportFormat:exportFormat,diagramFormat:diagramFormat,language:language},successHandler,errorHandler);}
uwm.persistency.Json.prototype.exportUwm=function(startOid,language,successHandler,errorHandler){this.jsonRequest({usr_action:'exportUWM',startOid:startOid,language:language},successHandler,errorHandler);}
uwm.persistency.Json.prototype.exportImage=function(diagramOid,language,successHandler,errorHandler){this.jsonRequest({usr_action:'exportImage',diagramOid:diagramOid,language:language},successHandler,errorHandler);}
uwm.persistency.Json.prototype.getCodeGeneratorList=function(successHandler,errorHandler){this.jsonRequest({usr_action:'generatorlist'},successHandler,errorHandler);}
uwm.persistency.Json.prototype.generateCode=function(codeId,modelOid,successHandler,errorHandler){this.jsonRequest({usr_action:'generateCode',codeId:codeId,modelOid:modelOid},successHandler,errorHandler);}
uwm.persistency.Json.prototype.doContinue=function(controller,successHandler,errorHandler){this.jsonRequest({controller:controller,usr_action:'continue'},successHandler,errorHandler);}
uwm.persistency.Json.prototype.executeActionSet=function(actionSet){var data={};var requests=actionSet.getRequests();for(var currActionName in requests){var currRequest=requests[currActionName];if(!(currRequest instanceof Function)){var jsonRequest={};jsonRequest.usr_action=currRequest.action;switch(currRequest.action){case"dologin":jsonRequest.login=currRequest.login;jsonRequest.password=currRequest.password;break;case"dologout":break;case"new":jsonRequest.newtype=currRequest.uwmClassName;break;case"delete":jsonRequest.deleteoids=this.array2CommaList(currRequest.oid);break;case"associate":var direction="child";if(currRequest.invert){direction="parent";}
jsonRequest.oid=currRequest.parentOid;jsonRequest.associateoids=this.array2CommaList(currRequest.childOid);jsonRequest.associateAs=direction;break;case"disassociate":jsonRequest.oid=currRequest.parentOid;jsonRequest.associateoids=this.array2CommaList(currRequest.childOid);break;case"save":var changeNode={};changeNode.oid=currRequest.oid;changeNode.type=uwm.Util.getUwmClassNameFromOid(currRequest.oid);changeNode.values={};changeNode.values[1]={};for(var i in currRequest.values){if(!(currRequest.values[i]instanceof Function)){changeNode.values[1][i]=currRequest.values[i];}}
jsonRequest[currRequest.oid]=changeNode;break;case"copy":jsonRequest.oid=currRequest.oid;jsonRequest.targetoid=currRequest.targetOid;jsonRequest.recursive=currRequest.recursive;break;case"sortup":case"sortdown":jsonRequest.sortoid=currRequest.sortoid;jsonRequest.dist=currRequest.dist;jsonRequest.poid=currRequest.poid;break;case"display":jsonRequest.oid=currRequest.oid;jsonRequest.depth=currRequest.depth;jsonRequest.language=currRequest.language;jsonRequest.omitMetaData=true;jsonRequest.translateValues=true;break;case"batchdisplay":jsonRequest.oid=currRequest.oid;jsonRequest.language=currRequest.language;jsonRequest.omitMetaData=true;jsonRequest.translateValues=true;break;case"list":jsonRequest.type=currRequest.uwmClassName;jsonRequest.language=currRequest.language;jsonRequest.completeObjects=currRequest.completeObjects;break;case"listbox":jsonRequest.type=currRequest.type;jsonRequest.language=currRequest.language;break;case"autocomplete":jsonRequest.query=currRequest.query;jsonRequest.language=currRequest.language;break;case"loadChildren":jsonRequest.controller="TreeViewController";jsonRequest.node=currRequest.oid;jsonRequest.sort=currRequest.sort;break;case"lock":jsonRequest.oid=currRequest.oid;break;case"unlock":jsonRequest.oid=currRequest.oid;break;case"log":jsonRequest.logtype=currRequest.logtype;jsonRequest.msg=currRequest.msg;break;case"packdiagr":jsonRequest.controller="PackageDiagramController";jsonRequest.oid=currRequest.oid;break;case"usecasectrl":jsonRequest.oid=currRequest.oid;break;case"actsdiagr":jsonRequest.controller="ActivitySetDiagramController";jsonRequest.oid=currRequest.oid;break;case"templatelist":jsonRequest.controller="TemplateListController";break;default:uwm.Util.showMessage("Programming Error","Unknown action in ActionSet: "+currRequest.action,uwm.Util.messageType.ERROR);}
data[currActionName]=jsonRequest;}}
this.jsonRequest({controller:"TerminateController",usr_action:"multipleAction",request_format:"JSON",data:Ext.encode(data),actionSet:actionSet},function(request,data){request.params.actionSet.successHandler(request,data);},function(request,data,errorMessage){request.params.actionSet.errorHandler(request,data,errorMessage);});}
Ext.namespace("uwm.persistency");uwm.persistency.ActionSet=function(){this.requests={};this.currentId=0;}
uwm.persistency.ActionSet.prototype.addLogin=function(login,password,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"dologin",login:login,password:password,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addLogout=function(successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"dologout",successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addNewObject=function(uwmClassName,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"new",uwmClassName:uwmClassName,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addDeleteObject=function(oid,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"delete",oid:oid,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addAssociate=function(parentOid,childOid,invert,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"associate",parentOid:parentOid,childOid:childOid,invert:invert,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addDisassociate=function(parentOid,childOid,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"disassociate",parentOid:parentOid,childOid:childOid,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addSave=function(oid,values,language,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"save",oid:oid,values:values,language:language,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addCopy=function(oid,targetOid,recursive,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"copy",oid:oid,targetoid:targetOid,recursive:recursive,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addSort=function(oid,direction,distance,poid,successHandler,errorHandler,errorLevel){var action="sortdown";if(direction=="up"){action="sortup";}
this.requests[this.getNextId()]={action:action,sortoid:oid,dist:distance,poid:poid,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addDisplay=function(oid,depth,language,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"display",oid:oid,depth:depth,language:language,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addBatchDisplay=function(oid,language,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"batchdisplay",oid:oid,language:language,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addList=function(uwmClassName,language,completeObjects,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"list",uwmClassName:uwmClassName,language:language,completeObjects:completeObjects,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addListbox=function(type,language,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"listbox",type:type,language:language,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addAutocomplete=function(query,language,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"autocomplete",query:query,language:language,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addLoadChildren=function(oid,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"loadChildren",oid:oid,sort:"sortkey",successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addLock=function(oid,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"lock",oid:oid,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addUnlock=function(oid,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"unlock",oid:oid,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.addLog=function(logtype,msg,successHandler,errorHandler,errorLevel){this.requests[this.getNextId()]={action:"log",logtype:logtype,msg:msg,successHandler:successHandler,errorHandler:errorHandler,errorLevel:errorLevel};}
uwm.persistency.ActionSet.prototype.commit=function(successHandler,errorHandler){for(var i in this.requests){var val=this.requests[i];if(!(val instanceof Function)){if(val.errorLevel){val.errorLevel=uwm.persistency.ActionSet.DEFAULT_ERROR_LEVEL;}}}
this.savedSuccessHandler=successHandler;this.savedErrorHandler=errorHandler;uwm.persistency.Persistency.getInstance().executeActionSet(this);}
uwm.persistency.ActionSet.prototype.getNextId=function(){var result=uwm.persistency.ActionSet.ACTION_PREFIX+this.currentId;this.currentId++;return result;}
uwm.persistency.ActionSet.prototype.getRequests=function(){return this.requests;}
uwm.persistency.ActionSet.prototype.successHandler=function(request,data){var errorLevel=null;var persistency=uwm.persistency.Persistency.getInstance();for(var currActionName in this.requests){var currRequest=this.requests[currActionName];if(!(currRequest instanceof Function)){var currResponse=data.data[currActionName];if(currResponse.success==1){persistency.processSuccessHandler(currRequest.successHandler,currRequest,currResponse);}else{if(currRequest.errorLevel>errorLevel){errorLevel=currRequest.errorLevel;}
persistency.processErrorHandler(currRequest.errorHandler,currRequest,currResponse,currResponse.errorMsg);if(currRequest.errorLevel==uwm.persistency.ActionSet.errorLevels.ERROR){throw new Error(uwm.Dict.translate("Critical Persistency Error")
+": "+currResponse.errorMsg);}}}}
persistency.processSuccessHandler(this.savedSuccessHandler,request,data);}
uwm.persistency.ActionSet.prototype.errorHandler=function(request,data,errorMessage){uwm.persistency.Persistency.getInstance().processErrorHandler(this.savedErrorHandler,request,data,errorMessage);}
uwm.persistency.ActionSet.errorLevels={IGNORE:1,WARN:2,ERROR:3}
uwm.persistency.ActionSet.DEFAULT_ERROR_LEVEL=uwm.persistency.ActionSet.errorLevels.WARN;uwm.persistency.ActionSet.ACTION_PREFIX="action";Ext.namespace("uwm.persistency");uwm.persistency.LongTask=function(call,iFrameId){this.call=call;this.iFrameId=iFrameId;this.processHandler=null;this.successHandler=null;this.errorHandler=null;}
uwm.persistency.LongTask.prototype.run=function(processHandler,successHandler,errorHandler){this.processHandler=processHandler;this.successHandler=successHandler;this.errorHandler=errorHandler;if(this.call instanceof Function){this.call(this.jsonSuccess.createDelegate(this),this.jsonError.createDelegate(this));}}
uwm.persistency.LongTask.prototype.jsonSuccess=function(options,data){var stepNumber=parseInt(data['stepNumber']);var numberOfSteps=parseInt(data['numberOfSteps']);var stepName=data['displayText'];var controller=data['controller'];if(stepNumber>numberOfSteps){if(this.successHandler instanceof Function){this.successHandler(data);}}
else if(stepNumber==numberOfSteps&&this.iFrameId!=null){if(this.processHandler instanceof Function){this.processHandler(stepName,stepNumber,numberOfSteps,data);}
var self=this;var iFrame=Ext.get(this.iFrameId);if(iFrame){iFrame.on("load",function(){self.onDownload.defer(10,self,[iFrame]);});iFrame.set({src:'../application/main.php?response_format=HTML&usr_action=continue&controller='+controller+'&sid='+uwm.Session.getInstance().getSid()});if(this.successHandler instanceof Function){this.successHandler(data);}}}
else{if(this.processHandler instanceof Function){this.processHandler(stepName,stepNumber,numberOfSteps,data);}
uwm.persistency.Persistency.getInstance().doContinue(controller,this.jsonSuccess.createDelegate(this),this.jsonError.createDelegate(this));}}
uwm.persistency.LongTask.prototype.jsonError=function(options,data){if(this.errorHandler instanceof Function){this.errorHandler(data);}}
uwm.persistency.LongTask.prototype.onDownload=function(iFrame){try{var result=Ext.util.JSON.decode(iFrame.dom.contentDocument.body.innerHTML);if(!result.success){if(this.errorHandler instanceof Function){this.errorHandler(data);}}}catch(e){}}
Ext.namespace("uwm.event");uwm.event.EventBroker=function(){uwm.event.EventBroker.superclass.constructor.call(this);this.addEvents({"create":true,"load":true,"delete":true,"changeLabel":true,"changeProperty":true,"associate":true,"disassociate":true});}
Ext.extend(uwm.event.EventBroker,Ext.util.Observable);uwm.event.EventBroker.getInstance=function(){if(!uwm.event.EventBroker.instance){uwm.event.EventBroker.instance=new uwm.event.EventBroker();}
return uwm.event.EventBroker.instance;}
Ext.namespace("uwm.ui");uwm.ui.Login=function(config){var self=this;this.form=new Ext.FormPanel({labelWidth:100,frame:true,title:'Login',bodyStyle:'padding:5px 5px 0',width:375,defaults:{width:230},keys:[{key:[10,13],handler:function(){self.initSession();}}],items:[new Ext.form.TextField({fieldLabel:uwm.Dict.translate('Login'),name:'login',allowBlank:false,value:uwm.Config.defaultLogin}),new Ext.form.TextField({fieldLabel:uwm.Dict.translate('Password'),name:'password',inputType:"password",allowBlank:false,value:uwm.Config.defaultPassword}),new uwm.i18n.LanguageListBox({languages:uwm.i18n.Localization.getInstance().getAllUserInterfaceLanguages(),}),new Ext.Panel({cls:"uwm-revisioninfo",html:"<p>"+uwm.Dict.translate("Revision")+": "+uwm.Constants.SVN_REVISION+"</p>"})],buttons:[{text:uwm.Dict.translate('Login'),type:'submit',handler:function(){self.initSession();}}]});if(!Ext.isGecko3){this.form.add(new Ext.Panel({cls:"uwm-browserWarning",html:"<div>"+"<p class='nonLast'><b>Attention:</b> You're using an unsupported browser. If you continue, the application may behave strangely or work not at all.</p>"+"<p>Currently, the supported browser is Firefox 3.</p>"+"</div>"}));}
uwm.ui.Login.superclass.constructor.call(this,Ext.apply(this,{id:"loginViewport",layout:"absolute",items:[this.form]},config));}
Ext.extend(uwm.ui.Login,Ext.Viewport);uwm.ui.Login.prototype.render=function(){uwm.ui.Login.superclass.render.apply(this,arguments);var viewportSize=this.getSize();var formSize=this.form.getSize();var x=viewportSize.width/2-formSize.width/2;var y=viewportSize.height/2-formSize.height/2;this.form.setPosition(x,y);this.form.getForm().findField("login").focus();}
uwm.ui.Login.prototype.initSession=function(){if(this.form.getForm().isValid()){var self=this;uwm.persistency.Persistency.getInstance().doLogin(this.form.getForm().findField("login").getValue(),this.form.getForm().findField("password").getValue(),function(options,data){self.handleLogin(options,data);},function(options,data,errorMsg){self.handleLoginFailure(options,data,errorMsg);});}}
uwm.ui.Login.prototype.handleLogin=function(options,data){var lang=uwm.i18n.Localization.getInstance().getDefaultModelLanguage();var languageField=this.form.getForm().findField("Language");if(languageField){lang=this.form.getForm().findField("Language").getValue();}
uwm.Uwm.getInstance().startSession(data.sid,lang);}
uwm.ui.Login.prototype.handleLoginFailure=function(options,data,errorMsg){uwm.Util.showMessage("Login Failed",data.errorMsg,uwm.Util.messageType.ERROR);var passwordField=this.form.getForm().findField("password");passwordField.setValue("");passwordField.focus();}
Ext.namespace("uwm.ui");uwm.ui.Perspective=function(){}
uwm.ui.Perspective=Ext.extend(Ext.Toolbar,{initComponent:function(){var self=this;this.defaultButton=new Ext.Toolbar.Button({text:uwm.Dict.translate('Default'),enableToggle:true,pressed:this.highlight=="default",highlight:this.highlight,highlightState:"default",handler:self.handleClick});this.adminButton=new Ext.Toolbar.Button({text:uwm.Dict.translate('Admin'),enableToggle:true,pressed:this.highlight=="admin",highlight:this.highlight,highlightState:"admin",handler:self.handleClick});Ext.apply(this,{region:"north",collapsible:false,split:false,items:[this.defaultButton,this.adminButton]});uwm.ui.Perspective.superclass.initComponent.apply(this,arguments);}});uwm.ui.Perspective.prototype.handleClick=function(button,e){button.toggle(this.highlight==button.highlightState);uwm.Uwm.getInstance().switchWorkbench(button.highlightState);}
Ext.namespace("uwm.ui");uwm.ui.AbstractWorkbench=function(config){uwm.ui.AbstractWorkbench.superclass.constructor.call(this,Ext.apply(this,{layout:"border"},config));}
Ext.extend(uwm.ui.AbstractWorkbench,Ext.Panel);uwm.ui.AbstractWorkbench.prototype.getEastPanel=function(){if(!this.eastPanel){this.eastPanel=new Ext.Panel({region:"east",layout:"border",collapsible:true,split:true,width:250,title:uwm.Dict.translate('Perspectives'),items:[new uwm.ui.Perspective({highlight:this.getHightLight()}),this.getPropertyContainer()]});}
return this.eastPanel;}
uwm.ui.AbstractWorkbench.prototype.getPropertyContainer=function(){if(!this.propertyContainer){this.propertyContainer=new uwm.property.PropertyContainer();}
return this.propertyContainer;}
uwm.ui.AbstractWorkbench.prototype.getHightLight=function(){return"";}
Ext.namespace("uwm.ui");uwm.ui.Workbench=function(config){uwm.ui.Workbench.superclass.constructor.call(this,Ext.apply(this,{items:[{region:"west",title:uwm.Dict.translate('Available Content'),collapsible:true,split:true,width:260,layout:"fit",id:"contentContainer",items:new Ext.Panel({layout:"border",items:[this.accordion=new uwm.newobjects.Accordion(),new uwm.ui.ExistingContentContainer({Accordion:this.accordion})]})},this.getEastPanel(),uwm.diagram.DiagramContainer.getInstance().getTabPanel()]},config));}
Ext.extend(uwm.ui.Workbench,uwm.ui.AbstractWorkbench);uwm.ui.Workbench.prototype.getHightLight=function(){return"default";}
Ext.namespace("uwm.ui");uwm.ui.InfoMask=function(el,config){uwm.ui.InfoMask.superclass.constructor.call(this,el,Ext.apply(this,{removeMask:true,msgCls:"uwm-infoMask"},config));}
Ext.extend(uwm.ui.InfoMask,Ext.LoadMask);Ext.namespace("uwm.ui");uwm.ui.HelpViewer=function(config){uwm.ui.HelpViewer.superclass.constructor.call(this,Ext.apply(this,{closable:true,title:uwm.Dict.translate('Documentation Viewer'),autoDestroy:false,autoShow:true,isHelpViewer:true,html:"<iframe id='"+uwm.ui.HelpViewer.IFRAME_ID+"' class='uwm-helpViewer-frame' src='"+uwm.Session.getInstance().getHelpUrl()+"'/>"},config));}
Ext.extend(uwm.ui.HelpViewer,Ext.Panel);uwm.ui.HelpViewer.prototype.loadUrl=function(url){var tabPanel=uwm.diagram.DiagramContainer.getInstance().getTabPanel();var tab=tabPanel.findById(this.getItemId());if(!tab){var tempTab=new Ext.Panel();tab=tabPanel.add(this);tabPanel.add(tempTab);tabPanel.activate(tempTab);}
tabPanel.activate(tab);if(tempTab){tabPanel.remove(tempTab);}
var iframe=Ext.get(uwm.ui.HelpViewer.IFRAME_ID);if(!iframe){iframe=this.body.insertHtml("afterBegin","<iframe id='"+uwm.ui.HelpViewer.IFRAME_ID+"' class='uwm-helpViewer-frame' />",true);}
iframe.dom.src=url;}
uwm.ui.HelpViewer.getInstance=function(){if(!uwm.ui.HelpViewer.instance){uwm.ui.HelpViewer.instance=new uwm.ui.HelpViewer();}
return uwm.ui.HelpViewer.instance;}
uwm.ui.HelpViewer.IFRAME_ID="uwm.ui.HelpViewer_iframe";Ext.namespace("uwm.ui");uwm.ui.Download=function(config){var self=this;this.okButton=new Ext.Button({text:uwm.Dict.translate("Close"),disabled:true,handler:function(){self.destroy();}});uwm.ui.Download.superclass.constructor.call(this,Ext.apply(this,{layout:"fit",items:[new Ext.Panel({html:"<div class='x-mask-loading'><div>"+uwm.Dict.translate('Please wait while your export is prepared ...')+"</div><iframe class='uwm-download-frame' id='"+uwm.ui.Download.IFRAME_ID+"' src='"+config.downloadURL+"'/></div>"})],buttons:[this.okButton],closable:false,resizable:false},config));this.on("render",function(){window.setTimeout(function(){var iframe=Ext.get(uwm.ui.Download.IFRAME_ID);iframe.on("load",function(){window.setTimeout(function(){try{var result=Ext.util.JSON.decode(iframe.dom.contentDocument.body.innerHTML);if(!result.success){uwm.Util.showMessage(uwm.Dict.translate("Error while exporting"),uwm.Dict.translate("The export was unsuccessful. Please try again."),uwm.Util.messageType.ERROR);}}catch(e){}
self.okButton.enable();},250);});},250);});}
Ext.extend(uwm.ui.Download,Ext.Window);uwm.ui.Download.IFRAME_ID="DownloadIFrameID";Ext.namespace("uwm.ui");uwm.ui.LongTaskRunner=function(config){var self=this;this.iFrameId=Ext.id();this.pbar=new Ext.ProgressBar({text:uwm.Dict.translate('Initializing ...'),id:'pbar',cls:'left-align',height:20,anchor:'100%'});this.okButton=new Ext.Button({text:uwm.Dict.translate("Cancel"),handler:function(){self.destroy();}});this.iFrame=new Ext.Panel({html:'<iframe id="'+this.iFrameId+'" src=""></iframe>',});this.iFrame.setVisible(false);uwm.ui.LongTaskRunner.superclass.constructor.call(this,Ext.apply(this,{layout:'anchor',width:320,height:87,items:[this.pbar,this.iFrame],buttons:[this.okButton],bodyBorder:false,border:false,closable:false,resizable:false,modal:true},config));this.on("render",function(){window.setTimeout(function(){self.pbar.reset();var iFrameId=null;if(self.isReturningDocument)
iFrameId=self.iFrameId;var task=new uwm.persistency.LongTask(self.call,iFrameId);task.run.defer(10,task,[function(text,i,total,data){self.pbar.updateProgress(i/total,text);if(self.progressHandler instanceof Function){self.progressHandler(data);}},function(data){self.pbar.updateText(uwm.Dict.translate("Finished"));self.okButton.setText(uwm.Dict.translate("Close"));if(data.summaryText&&data.summaryText!=""){self.add(new Ext.Panel({html:"<div class='uwm-errorDialogDetails'>"+
data.summaryText.replace(/\n/g,"<br>")+"</div>",autoScroll:true,height:100,anchor:'100%'}));self.setHeight(100+self.height);self.doLayout();}
if(self.successHandler instanceof Function){self.successHandler(data);}},function(data){self.okButton.setText(uwm.Dict.translate("Close"));if(self.errorHandler instanceof Function){self.errorHandler(data);}}]);},250);});}
uwm.ui.LongTaskRunner.prototype.close=function(){this.destroy();}
Ext.extend(uwm.ui.LongTaskRunner,Ext.Window);Ext.namespace("uwm.ui");uwm.ui.DropDown=function(){}
uwm.ui.DropDown=Ext.extend(Ext.Toolbar.SplitButton,{initComponent:function(){var menue=new Ext.menu.Menu({});var groupArray=this.Accordion.getGroupArray();var subMenus={};for(var i=0;i<groupArray.length;i++){subMenus[groupArray[i]]={text:groupArray[i],menu:[]};}
var self=this;for(var i=0;i<this.existingContent.length;i++){var belongsToGroup=false;var currContent=this.existingContent[i];if(currContent instanceof uwm.objectgrid.ObjectGrid){var uwmClass=modelClass=uwm.model.ModelNodeClassContainer.getInstance().getClass(currContent.getUwmClassName());var semanticGroup=uwmClass.getSemanticGroup();for(var j=0;j<groupArray.length;j++){if(!Ext.isArray(semanticGroup)){subMenus=this.addSemanticGroup(subMenus,currContent,semanticGroup,groupArray[j]);}else{for(var k=0;k<semanticGroup.length;k++){subMenus=this.addSemanticGroup(subMenus,currContent,semanticGroup[k],groupArray[j]);}}}}else{menue.add({text:uwm.Dict.translate(currContent.getName()),iconCls:currContent.getTreeIcon(),connectedPanel:currContent,handler:function(item){item.connectedPanel.show();if(item.connectedPanel==uwm.modeltree.ModelTree.getInstance()){self.expandAllButton.enable();self.collapseAllButton.enable();}
else{self.expandAllButton.disable();self.collapseAllButton.disable();}}})}}
var gridMenu=menue.add({text:uwm.Dict.translate("Grid Scope"),menu:[]});for(var i in subMenus){if(!(subMenus[i]instanceof Function)){gridMenu.menu.add(subMenus[i]);}}
var languageMenu=menue.add({text:uwm.Dict.translate("Language"),menu:[]});var loc=uwm.i18n.Localization.getInstance();var languages=loc.getAllModelLanguages();for(var i=languages.length-1;i>=0;i--){languageMenu.menu.add({text:languages[i][1],itemId:languages[i][0],checked:(languages[i][0]==loc.getModelLanguage()),group:'modelLanguage',checkHandler:function(item){uwm.i18n.Localization.getInstance().setModelLanguage(item.itemId);}});}
Ext.apply(this,{text:uwm.Dict.translate("View"),menu:menue});uwm.ui.DropDown.superclass.initComponent.apply(this,arguments);}});uwm.ui.DropDown.prototype.addSemanticGroup=function(subMenus,currContent,semanticGroup,referenceSemanticGroup){if(semanticGroup==referenceSemanticGroup){subMenus[semanticGroup].menu.push({text:currContent.getName(),iconCls:currContent.getTreeIcon(),connectedPanel:currContent,handler:function(item){item.connectedPanel.show();}});}
return subMenus;}
Ext.namespace("uwm.ui");uwm.ui.ExistingContentContainer=function(){}
uwm.ui.ExistingContentContainer=Ext.extend(Ext.Panel,{initComponent:function(){var self=this;this.existingContent=[new uwm.modeltree.ModelTree(),new uwm.ui.Glossary(),new uwm.hierarchytree.HierarchyTree()];this.getObjectGrids();this.expandAllButton=new Ext.Toolbar.Button({text:uwm.Dict.translate("expand all"),handler:function(){uwm.modeltree.ModelTree.getInstance().expandAll();}})
this.collapseAllButton=new Ext.Toolbar.Button({text:uwm.Dict.translate("collapse all"),handler:function(){uwm.modeltree.ModelTree.getInstance().collapseAll();}})
Ext.apply(this,{region:"center",title:uwm.Dict.translate('Existing Classes'),layout:'card',activeItem:0,items:this.existingContent,id:"existingFiguresContainer",tbar:[new uwm.ui.DropDown({Accordion:this.Accordion,existingContent:this.existingContent,expandAllButton:this.expandAllButton,collapseAllButton:this.collapseAllButton}),this.expandAllButton,this.collapseAllButton]});uwm.ui.ExistingContentContainer.superclass.initComponent.apply(this,arguments);uwm.ui.ExistingContentContainer.instance=this;}});uwm.ui.ExistingContentContainer.prototype.getObjectGrids=function(){var classes=uwm.model.ModelNodeClassContainer.getInstance().getAllClasses();var clsct=classes.getCount();for(var i=0;i<clsct;i++){var currClass=classes.itemAt(i);if(currClass instanceof uwm.model.ModelClass){this.existingContent.push(new uwm.objectgrid.ObjectGrid({uwmClassName:currClass.getUwmClassName()}));}}}
uwm.ui.ExistingContentContainer.prototype.showPanel=function(panel){var num=this.items.indexOf(panel);this.getLayout().setActiveItem(num);}
uwm.ui.ExistingContentContainer.getInstance=function(){return uwm.ui.ExistingContentContainer.instance;}
Ext.namespace("uwm.ui");uwm.ui.History=function(object){uwm.ui.History.superclass.constructor.call(this,Ext.apply(this,{layout:'border',height:350,width:550,title:uwm.Dict.translate('Object History'),selection:this.getSelectionModel()}));this.proxy=new uwm.ui.HistoryProxy(object);this.store=new Ext.data.Store({loadRecords:function(o,options,success){if(!o||success===false){if(success!==false){this.fireEvent("load",this,[],options);}
if(options.callback){options.callback.call(options.scope||this,[],options,false);}
return;}
var r=o.records,t=o.totalRecords||r.length;if(!options||options.add!==true){if(this.pruneModifiedRecords){this.modified=[];}
for(var i=0,len=r.length;i<len;i++){r[i].join(this);}
if(this.snapshot){this.data=this.snapshot;delete this.snapshot;}
this.data.clear();this.data.addAll(r);this.applySort();this.fireEvent("datachanged",this);}else{this.totalLength=Math.max(t,this.data.length+r.length);this.add(r);}
this.fireEvent("load",this,r,options);if(options.callback){options.callback.call(options.scope||this,r,options,true);}},proxy:this.proxy});this.store.proxy['store']=this.store;this.store.load({params:{start:0,limit:11}});this.window=this;this.setPosition(200,200);this.selection=this.getSelectionModel();this.toolbar=new Ext.PagingToolbar({pageSize:11,store:this.store,displayInfo:false,emptyMsg:uwm.Dict.translate("No changes have been made.")});this.grid=this.getGrid(object);this.add(this.grid);this.addButton(new Ext.Button({window:this.window,selection:this.selection,object:object,text:uwm.Dict.translate('Undo selected'),handler:this.undoSelected}));this.addButton(new Ext.Button({window:this.window,selection:this.selection,object:object,text:uwm.Dict.translate('Undo all changes since'),handler:this.undoAll}));this.addButton(new Ext.Button({window:this,text:uwm.Dict.translate('Cancel'),handler:function(){this.window.close();}}));this.grid.show();this.show();this.center();this.setVisible(true);}
Ext.extend(uwm.ui.History,Ext.Window);uwm.ui.History.prototype.getFields=function(){result=['id','timestamp','author','propertyString','changedProperty','oldValue','newValue'];return result;}
uwm.ui.History.prototype.getSelectionModel=function(){if(this.selection){var result=this.selection;}else{var result=new Ext.grid.CheckboxSelectionModel();}
return result;}
uwm.ui.History.prototype.getExpander=function(){var result=new Ext.grid.RowExpander({tpl:new Ext.Template(""),getBodyContent:function(record,index){var result='';result+='<TABLE class="uwm-historyGrid-tableWidth">';result+='<THEAD><TR><TH class="uwm-historyGrid-propertyWidth">'+uwm.Dict.translate('Property')+'</TH><TH class="uwm-historyGrid-valueWidth">'+uwm.Dict.translate('Old value')+'</TH><TH class="uwm-historyGrid-valueWidth">'+uwm.Dict.translate('New value')+'</TH></TR></THEAD><TBODY>';for(var i=0;i<record.data.changedProperty.length;i++){if(i%2==1){var color=' class="uwm-historyGrid-changes-second"';}else{var color=' class="uwm-historyGrid-changes-first"';}
result+="<TR"+color+">";result+="<TD>"+record.data.changedProperty[i]+"</TD>";result+="<TD>"+record.data.oldValue[i]+"</TD>";result+="<TD>"+record.data.newValue[i]+"</TD>";result+="</TR>";}
result+="</TBODY></TABLE>";return result;}});return result;}
uwm.ui.History.prototype.getGrid=function(object){var toolbar=this.toolbar;var expander=this.getExpander();var result=new Ext.grid.GridPanel({height:300,width:500,iconCls:object.getModelNodeClass().getTreeIcon(),title:object.getLabel(),region:'center',store:this.store,trackMouseOver:false,disableSelection:false,cls:"uwm-historyGrid",loadMask:true,plugins:expander,sm:this.getSelectionModel(),columns:[expander,{header:uwm.Dict.translate("Date"),dataIndex:'timestamp',displayField:'date',width:170,sortable:true},{header:uwm.Dict.translate("Author"),dataIndex:'author',width:150,hidden:false,sortable:true},{header:uwm.Dict.translate("Changed Items"),dataIndex:'propertyString',width:180,align:'right',sortable:true},this.getSelectionModel()],viewConfig:{forceFit:true},bbar:toolbar});result.show();return result;}
uwm.ui.History.prototype.undoAll=function(){var self=this;var sm=this.selection;if(sm.getSelections().length==0){Ext.MessageBox.alert("Error","No items selected.");}else{if((sm.getSelections().length>1)){Ext.MessageBox.alert("Error","Only one item may be selected.");}else{var selectedItem=sm.getSelections()[0];uwm.persistency.Persistency.getInstance().restorehistliststate(selectedItem.data.id,function(options,data){self.window.restoreSuccess(options,data,self.object)},function(options,data,errorMsg){self.window.restoreError(options,data,errorMsg);});}
this.window.close();}}
uwm.ui.History.prototype.undoSelected=function(){var self=this;if(this.selection.getSelections().length==0){Ext.MessageBox.alert("Error","No items selected.");}else{var selectedItems=this.selection.getSelections();var selectedIds=new Array();for(var i=0;i<selectedItems.length;i++){selectedIds.push(selectedItems[i].data.id);}
uwm.persistency.Persistency.getInstance().restorehistlistfields(selectedIds,function(options,data){self.window.restoreSuccess(options,data,self.object)},function(options,data,errorMsg){self.window.restoreError(options,data,errorMsg);});this.window.close();}}
uwm.ui.History.prototype.restoreError=function(options,data,errorMsg,callback,scope,arg){this.fireEvent("loadexception",this,options,data);callback.call(scope,null,arg,false);}
uwm.ui.History.prototype.restoreSuccess=function(options,data,object){Ext.MessageBox.alert('Success',uwm.Dict.translate('The selected properties have been successfully restored.'));var oldLabel=object.getLabel();if(oldLabel!=data.NewName){uwm.event.EventBroker.getInstance().fireEvent("changeLabel",object,null,data.NewName);}
uwm.property.PropertyContainer.getInstance().handleDeleteEvent(object);}
Ext.namespace("uwm.property");uwm.ui.HistoryProxy=function(object){this.totalProperty=0;uwm.ui.HistoryProxy.superclass.constructor.call(this,Ext.apply(this,{},object));this.oid=object.getOid();}
Ext.extend(uwm.ui.HistoryProxy,Ext.data.DataProxy);uwm.ui.HistoryProxy.prototype.load=function(params,reader,callback,scope,arg){if(this.fireEvent("beforeload",this,params)!==false){var self=this;uwm.persistency.Persistency.getInstance().histlist(this.oid,params.start,params.limit,function(options,data){self.loadResponse(options,data,callback,scope,arg);self.store.totalLength=self.totalProperty;},function(options,data,errorMsg){self.loadFailed(options,data,errorMsg,callback,scope,arg)});}else{callback.call(scope||this,null,arg,false);}}
uwm.ui.HistoryProxy.prototype.loadResponse=function(options,data,callback,scope,arg){var records=[];var data=data;var changelist=data.changelist;for(var i=0;i<changelist.length;i++){var propertyArray=[];var oldArray=[];var newArray=[];var propertyString="";for(var j=0;j<changelist[i].data.length;j++){for(k in changelist[i].data[j]){propertyArray.push(k);if(changelist[i].data[j][k].oldValueDisp){oldArray.push(changelist[i].data[j][k].oldValueDisp);}else{oldArray.push(changelist[i].data[j][k].oldValue);}
if(changelist[i].data[j][k].newValueDisp){newArray.push(changelist[i].data[j][k].newValueDisp);}else{newArray.push(changelist[i].data[j][k].newValue);}
if(propertyString==""){propertyString+=k;}else{propertyString+=(", "+k);}}}
records.push(new Ext.data.Record({id:changelist[i].id,timestamp:changelist[i].timestamp,author:changelist[i].user,propertyString:propertyString,changedProperty:propertyArray,oldValue:oldArray,newValue:newArray}));}
this.totalProperty=parseFloat(data.gescount);this.store.totalLength=this.totalProperty;var result={success:true,records:records};this.fireEvent("load",this,options,arg);callback.call(scope,result,arg,true);}
uwm.ui.HistoryProxy.prototype.loadFailed=function(options,data,errorMsg,callback,scope,arg){this.fireEvent("loadexception",this,options,data);callback.call(scope,null,arg,false);}
Ext.namespace("uwm.ui");uwm.ui.ExportAssistent=function(uwmClassName,oid){var self=this;this.uwmClassName=uwmClassName;this.oid=oid;this.exportButton=null;uwm.persistency.Persistency.getInstance().templatelist(function(options,data){self.JsonSuccess(options,data);},function(options,data,errorMessage){Ext.MessageBox.alert('Error',errorMessage);});}
Ext.extend(uwm.ui.ExportAssistent,Ext.Window);uwm.ui.ExportAssistent.prototype.JsonSuccess=function(options,data){var assistant=this;var docTypeFormItem=new Ext.FormPanel({name:'formPanel',title:uwm.Dict.translate('document format'),labelWidth:70,width:250,frame:true,items:[{xtype:'fieldset',name:'fieldsetDocFormat',id:'fieldsetDocFormat',title:' Export as : ',autoHeight:true,defaultType:'radio',items:[{labelSeparator:'',checked:true,boxLabel:'Microsoft Word',inputValue:'doc',name:'docformat'},{labelSeparator:'',boxLabel:'Open Office Writer',inputValue:'odt',name:'docformat'},{labelSeparator:'',boxLabel:'PDF',inputValue:'pdf',name:'docformat'}]},{xtype:'fieldset',name:'fieldsetDiagrams',id:'fieldsetDiagrams',title:' Content : ',autoHeight:true,defaultType:'radio',items:[{labelSeparator:'',checked:true,id:'diagramsNone',boxLabel:'Packages',inputValue:'none',name:'diagrams',listeners:{render:function(){new Ext.ToolTip({target:docTypeFormItem.findById('diagramsNone').container,html:'Export packages'});}}},{labelSeparator:'',id:'diagramsVirtual',boxLabel:'Diagrams',inputValue:'virtual',name:'diagrams',listeners:{render:function(){new Ext.ToolTip({target:docTypeFormItem.findById('diagramsVirtual').container,html:'Export diagrams as packages. Other package content will be ignored.'});}}}]}],});if(this.uwmClassName=='Diagram'){var diagramField=docTypeFormItem.findById('fieldsetDiagrams');diagramField.items.each(function(i){if(i.inputValue=='virtual'){i.setValue(true);}},this);}
var datapart=[];var fieldspart=[];var technicalNames=data.technicalNames;var titles=data.titles;var descriptions=data.descriptions;for(var i=0;i<technicalNames.length;i++){datapart.push({'technName':technicalNames[i],'templateName':titles[i],'description':descriptions[i]});}
fieldspart.push({name:'technName',mapping:'technName'},{name:'templateName',mapping:'templateName'},{name:'description',mapping:'description'});var eastore=new Ext.data.SimpleStore({data:datapart,fields:fieldspart});var grid=new Ext.grid.GridPanel({store:eastore,columns:[{header:uwm.Dict.translate('Template Name'),width:233,dataIndex:'templateName',sortable:true}],sm:new Ext.grid.RowSelectionModel({singleSelect:true}),listeners:{'cellclick':function(grid,rowIndex,columnIndex,e){var record=grid.getStore().getAt(rowIndex);if(record){if(assistant.exportButton.disabled){assistant.exportButton.setDisabled(false);}}}},title:uwm.Dict.translate('Please select to show Details.'),split:true,rowspan:2,height:426,width:250,frame:true});var detailPanel={id:'detailPanel',title:uwm.Dict.translate('detailed description'),html:'<i>'+uwm.Dict.translate('< detailed description >')+'</i>',split:true,height:170,width:250,frame:true,bodyStyle:{padding:'7px'}}
var template=new Ext.Template(['<b><u>Technical Name: </b></u><BR/><BR/><center>{technName}</center><BR/>','<b><u>Description: </b></u><BR/><BR/><center>{description}</center><BR/>'])
grid.getSelectionModel().on('rowselect',function(sm,rowIdx,r){var detailPanel=Ext.getCmp('detailPanel');template.overwrite(detailPanel.body,r.data);});var winLayout={title:uwm.Dict.translate('Export Assistant'),layout:'table',layoutConfig:{columns:2},region:'center',height:496,width:514,resizable:false,items:[grid,detailPanel,docTypeFormItem]};uwm.ui.ExportAssistent.superclass.constructor.call(this,Ext.apply(this,winLayout));this.exportButton=this.addButton({text:uwm.Dict.translate('Export'),disabled:true},function(){var doctypeSelected=docTypeFormItem.getForm().getValues().docformat;var diagramSelected=docTypeFormItem.getForm().getValues().diagrams;var gridSelectedIndex=grid.selModel.lastActive;if(gridSelectedIndex===null){return;}
var templateSelected=grid.getStore().getAt(gridSelectedIndex).get("technName");assistant.close();var startOid=assistant.oid;var localization=uwm.i18n.Localization.getInstance();var userLanguage=localization.getModelLanguage();new uwm.ui.LongTaskRunner({title:uwm.Dict.translate('Exporting Documentation ...'),call:function(successHandler,errorHandler){uwm.persistency.Persistency.getInstance().exportDoc(templateSelected,startOid,doctypeSelected,diagramSelected,userLanguage,successHandler,errorHandler);},successHandler:function(data){},errorHandler:function(data){uwm.Util.showMessage(uwm.Dict.translate("Error while exporting"),uwm.Dict.translate("The export was unsuccessful. Please try again."),uwm.Util.messageType.ERROR);},isReturningDocument:true}).show();},[grid,docTypeFormItem]);this.addButton(uwm.Dict.translate('Cancel'),function(){this.close();},this);this.setVisible(true);}
uwm.ui.ExportAssistent.prototype.restoreError=function(options,data,errorMsg,callback,scope,arg){this.fireEvent("loadexception",this,options,data);callback.call(scope,null,arg,false);}
uwm.ui.ExportAssistent.prototype.restoreSuccess=function(options,data,object){Ext.MessageBox.alert('Success',uwm.Dict.translate('Export successfully.'));}
Ext.namespace("uwm.ui");uwm.ui.GeneratorWizardProxy=function(config){uwm.ui.GeneratorWizardProxy.superclass.constructor.call(this,Ext.apply(this,{},config));}
Ext.extend(uwm.ui.GeneratorWizardProxy,Ext.data.DataProxy);uwm.ui.GeneratorWizardProxy.prototype.load=function(params,reader,callback,scope,arg){if(this.fireEvent("beforeload",this,params)!==false){var self=this;uwm.persistency.Persistency.getInstance().getCodeGeneratorList(function(options,data){self.loadResponse(options,data,callback,scope,arg);},function(options,data,errorMsg){self.loadFailed(options,data,errorMsg,callback,scope,arg)});}else{callback.call(scope||this,null,arg,false);}}
uwm.ui.GeneratorWizardProxy.prototype.loadResponse=function(options,data,callback,scope,arg){var records=new Array();var recordTemplate=new Ext.data.Record.create(["id","name","targetPlatform","description"]);for(var i=0;i<data.list.length;i++){var currObj=data.list[i];var currRecord=new recordTemplate(currObj);records.push(currRecord);}
var result={success:true,records:records,totalRecords:records.length};this.fireEvent("load",this,options,arg);callback.call(scope,result,arg,true);}
uwm.ui.GeneratorWizardProxy.prototype.loadFailed=function(options,data,errorMsg,callback,scope,arg){this.fireEvent("loadexception",this,options,data);callback.call(scope,null,arg,false);}
Ext.namespace("uwm.ui");uwm.ui.GeneratorWizard=function(config){var self=this;this.oid=config.oid;this.store=new Ext.data.Store({autoLoad:true,proxy:new uwm.ui.GeneratorWizardProxy()});this.generateButton=new Ext.Button({text:uwm.Dict.translate("Generate"),disabled:true,handler:function(){var record=self.grid.getSelectionModel().getSelected();var codeName=record.get("name");var codeId=record.get("id");var oid=self.oid;self.destroy();new uwm.ui.LongTaskRunner({title:uwm.Dict.translate("Generating")+" "+codeName+" ...",call:function(successHandler,errorHandler){uwm.persistency.Persistency.getInstance().generateCode(codeId,oid,successHandler,errorHandler);},successHandler:function(data){},errorHandler:function(data){uwm.Util.showMessage(uwm.Dict.translate("Error while generating"),uwm.Dict.translate("The generation was unsuccessful. Please try again."),uwm.Util.messageType.ERROR);},isReturningDocument:false}).show();}});this.cancelButton=new Ext.Button({text:uwm.Dict.translate("Cancel"),handler:function(){self.destroy();}});this.grid=new Ext.grid.GridPanel({autoHeight:true,store:this.store,colModel:new Ext.grid.ColumnModel({columns:[{width:100,dataIndex:"name"}]}),viewConfig:{forceFit:true,headersDisabled:true}});this.formPanel=new Ext.FormPanel({layout:"column",bodyStyle:"padding: 5px;",frame:true,defaults:{columnWidth:0.5,height:250,bodyStyle:"padding: 5px;"},items:[new Ext.form.FieldSet({title:uwm.Dict.translate("Available Generators"),defaults:{height:250,width:220},items:[this.grid]}),new Ext.form.FieldSet({title:uwm.Dict.translate("Information"),labelAlign:"top",defaults:{labelStyle:"font-weight: bold;",minHeight:50},items:[new Ext.form.DisplayField({fieldLabel:uwm.Dict.translate("Target Platform"),name:"targetPlatform"}),new Ext.form.DisplayField({fieldLabel:uwm.Dict.translate("Description"),name:"description"})]})],buttons:[this.generateButton,this.cancelButton]});this.grid.getSelectionModel().on("rowselect",function(sm,row,rec){self.formPanel.getForm().loadRecord(rec);self.formPanel.doLayout();self.generateButton.enable();})
uwm.ui.GeneratorWizard.superclass.constructor.call(this,Ext.apply(this,{title:uwm.Dict.translate("Generate Code"),items:[this.formPanel],width:500},config));this.show();this.doLayout();this.center();};Ext.extend(uwm.ui.GeneratorWizard,Ext.Window);Ext.namespace("uwm.ui");uwm.ui.GlossaryProxy=function(config){uwm.ui.GlossaryProxy.superclass.constructor.call(this,Ext.apply(this,{},config));}
Ext.extend(uwm.ui.GlossaryProxy,Ext.data.DataProxy);uwm.ui.GlossaryProxy.prototype.load=function(params,reader,callback,scope,arg){if(this.fireEvent("beforeload",this,params)!==false){var self=this;uwm.persistency.Persistency.getInstance().list("Glossary",true,uwm.i18n.Localization.getInstance().getModelLanguage(),function(options,data){self.loadResponse(options,data,callback,scope,arg);},function(options,data,errorMsg){self.loadFailed(options,data,errorMsg,callback,scope,arg)});}else{callback.call(scope||this,null,arg,false);}}
uwm.ui.GlossaryProxy.prototype.loadResponse=function(options,data,callback,scope,arg){var records=new Array();for(var i=0;i<data.objects.length;i++){var currObj=data.objects[i];var currRecord={oid:currObj.oid,uwmClassName:currObj.type};var values=currObj.values[1];if(values){currRecord.entrytype=values.entryType,currRecord.name=values.Name,currRecord.notes=values.Notes}
records.push(new Ext.data.Record(currRecord));}
var result={success:true,records:records,totalRecords:records.length};this.fireEvent("load",this,options,arg);callback.call(scope,result,arg,true);}
uwm.ui.GlossaryProxy.prototype.loadFailed=function(options,data,errorMsg,callback,scope,arg){this.fireEvent("loadexception",this,options,data);callback.call(scope,null,arg,false);}
Ext.namespace("uwm.ui");uwm.ui.Glossary=function(){}
uwm.ui.Glossary=Ext.extend(Ext.grid.GridPanel,{initComponent:function(){var self=this;Ext.apply(this,{layout:"fit",enableDragDrop:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),iconCls:self.getTreeIcon(),tabTip:uwm.Dict.translate("Lists all glossary terms."),columns:[{header:"Term",dataIndex:"name",width:100,sortable:false,hideable:false,renderer:function(value,p,record){return self.renderer(value,p,record);}}],hideHeaders:true,store:new Ext.data.Store({proxy:new uwm.ui.GlossaryProxy()}),viewConfig:{forceFit:true},loadMask:true});uwm.ui.Glossary.superclass.initComponent.apply(this,arguments);this.buildContextMenu();this.on("rowclick",function(grid,rowIndex,e){self.showProperties(grid,rowIndex,e);});this.on("rowcontextmenu",function(grid,rowIndex,e){self.showContextMenu(grid,rowIndex,e);});this.on("contextmenu",function(e){self.showContextMenu(undefined,null,e);});this.on("show",function(grid){this.getStore().load();},undefined,{single:true});this.on('show',function(){uwm.ui.ExistingContentContainer.getInstance().showPanel(self);});uwm.event.EventBroker.getInstance().addListener({"changeProperty":function(modelObject,oldLabel){self.handleChangePropertyEvent(modelObject,oldLabel);},"create":function(modelObject){self.handleCreateEvent(modelObject);},"delete":function(modelObject){self.handleDeleteEvent(modelObject);}});}})
uwm.ui.Glossary.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[new Ext.menu.Item({text:uwm.Dict.translate('Add entry'),handler:function(item,e){self.addEntry(item,e);}}),new Ext.menu.Item({itemId:uwm.ui.Glossary.CONTEXTMENU_DELETE_ID,text:uwm.Dict.translate('Delete entry'),handler:function(item,e){self.deleteEntry(item,e);}})]});}
uwm.ui.Glossary.prototype.showContextMenu=function(grid,rowIndex,e){this.contextMenu.rowIndex=rowIndex;var deleteEntry=this.contextMenu.items.get(uwm.ui.Glossary.CONTEXTMENU_DELETE_ID);deleteEntry.setDisabled(rowIndex===null);this.contextMenu.showAt([e.getXY()[0]+2,e.getXY()[1]+2]);e.preventDefault();}
uwm.ui.Glossary.prototype.getSelectedModelObject=function(callback){var oid=this.getStore().getAt(this.contextMenu.rowIndex).get("oid");uwm.model.ModelContainer.getInstance().loadByOid(oid,callback,0);}
uwm.ui.Glossary.prototype.showProperties=function(grid,rowIndex,e){var oid=this.getStore().getAt(rowIndex).get("oid");var modelObject=uwm.model.ModelContainer.getInstance().createByClassAndOid("Glossary",oid);uwm.property.PropertyContainer.getInstance().showProperty(modelObject);}
uwm.ui.Glossary.prototype.addEntry=function(item,e){uwm.model.ModelContainer.getInstance().createModelObject("Glossary");}
uwm.ui.Glossary.prototype.deleteEntry=function(item,e){this.getSelectedModelObject(function(modelObject){uwm.model.ModelContainer.getInstance().deleteByModelNode(modelObject);});}
uwm.ui.Glossary.prototype.getTreeIcon=function(){return"glossaryTabIcon";}
uwm.ui.Glossary.prototype.getName=function(){return"Glossary";}
uwm.ui.Glossary.prototype.renderer=function(value,p,record){return"<dl class='glossary'><dt>"+record.get("name")+"</dt><dd><p><i>"+record.get("entrytype")+"</i></p>"+record.get("notes")+"</dd></dl>";}
uwm.ui.Glossary.prototype.handleChangePropertyEvent=function(modelObject,oldLabel){if(modelObject.getLanguage()!=uwm.i18n.Localization.getInstance().getModelLanguage()){return;}
var record=this.getRecordByModelObject(modelObject);if(record){record.set("name",modelObject.getProperty("Name"));record.set("entrytype",modelObject.getProperty("entryType"));record.set("notes",modelObject.getProperty("Notes"));record.commit();}}
uwm.ui.Glossary.prototype.handleCreateEvent=function(modelObject){if(modelObject.getUwmClassName()=="Glossary"){this.getStore().add([new Ext.data.Record({oid:modelObject.getOid(),name:modelObject.getProperty("Name"),entrytype:modelObject.getProperty("entryType"),notes:modelObject.getProperty("Notes")})]);}}
uwm.ui.Glossary.prototype.handleDeleteEvent=function(modelObject){var record=this.getRecordByModelObject(modelObject);if(record){this.getStore().remove(record);}}
uwm.ui.Glossary.prototype.getRecordByModelObject=function(modelObject){return this.getStore().getAt(this.getStore().find('oid',modelObject.getOid()));}
uwm.ui.Glossary.CONTEXTMENU_DELETE_ID="deleteGlossaryTerm";Ext.namespace("uwm.tabadmin");uwm.tabadmin.GridProxy=function(config){uwm.tabadmin.GridProxy.superclass.constructor.call(this,Ext.apply(this,{},config));this.listType=config.listType;this.actionSet=config.actionSet;}
Ext.extend(uwm.tabadmin.GridProxy,Ext.data.DataProxy);uwm.tabadmin.GridProxy.prototype.load=function(params,reader,callback,scope,arg){if(this.fireEvent("beforeload",this,params)!==false){var self=this;this.actionSet.addList(this.listType,uwm.i18n.Localization.getInstance().getModelLanguage(),false,function(options,data){self.loadResponse(options,data,callback,scope,arg);},function(options,data,errorMsg){self.loadFailed(options,data,errorMsg,callback,scope,arg)});}else{callback.call(scope||this,null,arg,false);}}
uwm.tabadmin.GridProxy.prototype.loadResponse=function(options,data,callback,scope,arg){var records=new Array();for(var i=0;i<data.objects.length;i++){var currObj=data.objects[i];var currRecord={oid:currObj.oid,uwmClassName:currObj.type};for(var j in currObj.values){var currValue=currObj.values[j];if(!(currValue instanceof Function)){for(var k in currValue){var currElem=currValue[k];if(!(currElem instanceof Function)){currRecord.label=currElem;}}}}
records.push(new Ext.data.Record(currRecord));}
var result={success:true,records:records,totalRecords:records.length};this.fireEvent("load",this,options,arg);callback.call(scope,result,arg,true);}
uwm.tabadmin.GridProxy.prototype.loadFailed=function(options,data,errorMsg,callback,scope,arg){this.fireEvent("loadexception",this,options,data);callback.call(scope,null,arg,false);}
Ext.namespace("uwm.tabadmin");uwm.tabadmin.EnumTab=function(config){this.modelClass=uwm.model.ModelNodeClassContainer.getInstance().getClass(config.uwmClassName);var self=this;this.addEntryButton=new Ext.Toolbar.Button({id:"addEntry",text:uwm.Dict.translate('Add new entry'),handler:function(e,toolEl,panel){self.addEntry();}});this.removeEntryButton=new Ext.Toolbar.Button({id:"removeEntry",text:uwm.Dict.translate('Remove entry'),disabled:true,handler:function(e,toolEl,panel){self.removeEntry();}});uwm.tabadmin.EnumTab.superclass.constructor.call(this,Ext.apply(this,{layout:"fit",selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),title:this.modelClass.getUwmClassName(),columns:[{header:uwm.Dict.translate('Label'),dataIndex:"label",width:255,sortable:true}],store:new Ext.data.Store({autoLoad:true,proxy:new uwm.tabadmin.GridProxy({listType:config.uwmClassName,actionSet:config.actionSet})}),tbar:[this.addEntryButton,this.removeEntryButton]},config));this.on("rowclick",function(grid,rowIndex,e){self.handleRowClick(grid,rowIndex,e);});uwm.event.EventBroker.getInstance().addListener({"changeLabel":function(modelObject,oldLabel){self.handleChangeLabelEvent(modelObject,oldLabel);},"create":function(modelObject){self.handleCreateEvent(modelObject);},"delete":function(modelObject){self.handleDeleteEvent(modelObject);}});}
Ext.extend(uwm.tabadmin.EnumTab,Ext.grid.GridPanel);uwm.tabadmin.EnumTab.prototype.handleRowClick=function(grid,rowIndex,e){this.removeEntryButton.setDisabled(false);var record=this.getStore().getAt(rowIndex);var modelObject=this.getModelObjectByRecord(record);uwm.property.PropertyContainer.getInstance().showProperty(modelObject);}
uwm.tabadmin.EnumTab.prototype.handleChangeLabelEvent=function(modelObject,oldLabel){if(modelObject.getLanguage()!=uwm.i18n.Localization.getInstance().getModelLanguage()){return;}
var record=this.getRecordByModelObject(modelObject);if(record){record.set("label",modelObject.getLabel());record.commit();}}
uwm.tabadmin.EnumTab.prototype.handleCreateEvent=function(modelObject){if(modelObject.getUwmClassName()==this.modelClass.getUwmClassName()){this.getStore().add([new Ext.data.Record({oid:modelObject.getOid(),uwmClassName:modelObject.getUwmClassName(),Name:modelObject.getLabel()})]);}}
uwm.tabadmin.EnumTab.prototype.handleDeleteEvent=function(modelObject){var record=this.getRecordByModelObject(modelObject);if(record){this.getStore().remove(record);}}
uwm.tabadmin.EnumTab.prototype.addEntry=function(){uwm.model.ModelContainer.getInstance().createModelObject(this.modelClass.getUwmClassName());}
uwm.tabadmin.EnumTab.prototype.removeEntry=function(){var record=this.getSelectionModel().getSelected();if(record){var modelObject=this.getModelObjectByRecord(record);uwm.model.ModelContainer.getInstance().deleteByModelNode(modelObject);}
this.removeEntryButton.setDisabled(true);}
uwm.tabadmin.EnumTab.prototype.getModelObjectByRecord=function(record){return uwm.model.ModelContainer.getInstance().createByClassAndOid(record.get("uwmClassName"),record.get("oid"));}
uwm.tabadmin.EnumTab.prototype.getRecordByModelObject=function(modelObject){return this.getStore().getAt(this.getStore().find('oid',modelObject.getOid()));}
Ext.namespace("uwm.ui");uwm.tabadmin.ImportPanel=function(){}
uwm.tabadmin.ImportPanel=Ext.extend(Ext.form.FormPanel,{initComponent:function(){var self=this;Ext.apply(this,{title:uwm.Dict.translate('Model Upload'),frame:true,fileUpload:true,items:[new Ext.form.FileUploadField({emptyText:uwm.Dict.translate('Select UML model'),allowBlank:false,fieldLabel:uwm.Dict.translate('File to upload'),name:"modelFile",anchor:"50%"}),new Ext.Button({text:uwm.Dict.translate('Send model'),handler:function(){self.sendForm();}})]});uwm.tabadmin.ImportPanel.superclass.initComponent.apply(this,arguments);}});uwm.tabadmin.ImportPanel.prototype.sendForm=function(){var self=this;if(this.getForm().isValid()){this.getForm().submit({url:uwm.Session.getInstance().getJsonUrl(),params:{sid:uwm.Session.getInstance().getSid(),response_format:"JSON",usr_action:"importUWM"},waitMsg:uwm.Dict.translate('Sending the model ...'),success:function(form,action){self.successHandler(form,action);},failure:function(form,action){self.failureHandler(form,action);}});}}
uwm.tabadmin.ImportPanel.prototype.successHandler=function(form,action){var win=new Ext.Window({title:uwm.Dict.translate('Import successful'),layout:"fit",items:[new Ext.Panel({html:"<div class='uwm-dialogBox'><div>"+uwm.Dict.translate('Your import finished successfully. The application is going to restart.')+"</div></div>"})],buttons:[{text:uwm.Dict.translate('OK'),handler:function(){uwm.Uwm.getInstance().reload();}}]});win.show();}
uwm.tabadmin.ImportPanel.prototype.failureHandler=function(form,action){var win=new Ext.Window({title:uwm.Dict.translate('Import failed'),layout:"fit",items:[new Ext.Panel({html:"<div class='uwm-dialogBox'><div>"+uwm.Dict.translate('Your import failed. See below for errors.')+"</div><div>"+action.result.errorMsg+"</div></div>"})],buttons:[{text:uwm.Dict.translate('OK'),handler:function(){win.destroy();}}]});win.show();}
Ext.namespace("uwm.tabadmin");uwm.tabadmin.Workbench=function(config){this.tabPanel=new Ext.TabPanel({region:"center",activeTab:0,enableTabScroll:true,items:[new uwm.tabadmin.ImportPanel()]});uwm.tabadmin.Workbench.superclass.constructor.call(this,Ext.apply(this,{items:[this.tabPanel,this.getEastPanel()]},config));var classes=uwm.model.ModelNodeClassContainer.getInstance().getAllClasses();this.actionSet=new uwm.persistency.ActionSet();for(var i=0;i<classes.getCount();i++){var currClass=classes.itemAt(i);if(currClass instanceof uwm.model.TechnicalObjectClass){this.tabPanel.add(new uwm.tabadmin.EnumTab({uwmClassName:currClass.getUwmClassName(),actionSet:this.actionSet}));}}
var self=this;this.on("show",function(){self.actionSet.commit();},undefined,{single:true});}
Ext.extend(uwm.tabadmin.Workbench,uwm.ui.AbstractWorkbench);uwm.tabadmin.Workbench.prototype.getHightLight=function(){return"admin";}
Ext.namespace("uwm.property");uwm.property.PropertyContainer=function(){}
uwm.property.PropertyContainer=Ext.extend(Ext.Panel,{initComponent:function(){var self=this;var loc=uwm.i18n.Localization.getInstance();this.language=loc.getModelLanguage();this.mainPanel=new Ext.Panel({layout:"fit",region:"center",width:250,autoScroll:false,autoHeight:true,border:false,title:self.getTitleText(),tools:[{id:'gear',enableToggle:true,qtip:uwm.Dict.translate('Translate'),handler:function(event,toolEl,panel){if(!self.isTranslationPanelOpen()){self.openTranslationPanel();}
else{self.closeTranslationPanel();}}}]});this.translationPanel=new uwm.i18n.TranslationPanel({layout:"fit",region:"west",width:250,autoScroll:false,autoHeight:true,border:false,style:"border-right:1px solid #99BBE8;",hidden:true});Ext.apply(this,{region:"center",layout:"border",border:false,collapsible:false,split:true,width:250,autoScroll:true,header:false,items:[this.mainPanel,this.translationPanel]})
uwm.property.PropertyContainer.instance=this;uwm.property.PropertyContainer.superclass.initComponent.apply(this,arguments);this.currentOid=null;this.isLockedByOtherUser=null;this.form=null;this.on("afterlayout",this.showInfoMask);this.on("resize",this.doResize);uwm.event.EventBroker.getInstance().addListener({"changeLabel":function(modelObject,oldLabel){self.handleChangeLabelEvent(modelObject,oldLabel);},"create":function(modelObject){self.handleCreateEvent(modelObject);},"delete":function(modelObject){self.handleDeleteEvent(modelObject);}});}})
uwm.property.PropertyContainer.prototype.showInfoMask=function(){this.hideForm(this.mainPanel);this.hideForm(this.translationPanel);this.mask=new uwm.ui.InfoMask(this.body,{msg:uwm.Dict.translate('This panel shows the properties of each object selected by a single click.')});this.mask.show();this.un("afterlayout",this.showInfoMask);}
uwm.property.PropertyContainer.prototype.showLoadMask=function(){this.mask=new Ext.LoadMask(this.getEl());this.mask.show();}
uwm.property.PropertyContainer.prototype.hideMask=function(){if(this.mask){this.mask.hide();}}
uwm.property.PropertyContainer.prototype.doResize=function(){var width=this.ownerCt.getWidth();if(this.isTranslationPanelOpen()&&width>0){this.mainPanel.setWidth(width/2);this.translationPanel.setWidth(width/2);}
else{this.mainPanel.setWidth(width);}}
uwm.property.PropertyContainer.prototype.showProperty=function(modelNode){if(modelNode!=null){var eastPanel=this.findParentByType(uwm.property.EastPanel);if(!eastPanel.collapsed){var oid=modelNode.getOid();if(oid!=null&&this.currentOid!=oid){this.hideMask();var oldOid=this.currentOid;this.currentOid=modelNode.getOid();this.hideForm(this.mainPanel);this.hideForm(this.translationPanel);this.showLoadMask();var self=this;var actionSet=new uwm.persistency.ActionSet();if(oldOid){actionSet.addUnlock(oldOid);}
actionSet.addLock(this.currentOid,function(request,data){self.setLocked(false);},function(request,data){self.setLocked(true);});uwm.model.ModelContainer.getInstance().loadByOid(this.currentOid,actionSet);actionSet.commit(function(){self.handleLoadFinished();});}}}}
uwm.property.PropertyContainer.prototype.setLocked=function(isLocked){this.isLockedByOtherUser=isLocked;}
uwm.property.PropertyContainer.prototype.handleLoadFinished=function(){if(this.isTranslationPanelOpen()){this.translationPanel.showTranslation(this.currentOid,this.translationPanel.getLanguage(),this.isLockedByOtherUser,this.displayForm.createDelegate(this));}
else{this.displayForm();}}
uwm.property.PropertyContainer.prototype.displayForm=function(){var modelNode=uwm.model.ModelContainer.getInstance().getByOid(this.currentOid);this.form=modelNode.getModelNodeClass().getPropertyForm(modelNode,this.isLockedByOtherUser);this.form.localizeControls(uwm.i18n.Localization.getInstance().getModelLanguage());this.mainPanel.add(this.form);this.doLayout();modelNode.populatePropertyForm(this.form);if(this.isTranslationPanelOpen()){this.lockControls();}
this.hideMask();}
uwm.property.PropertyContainer.prototype.hideForm=function(panel){var items=panel.items;while(items&&items.getCount()>0){panel.remove(items.get(0),true);}}
uwm.property.PropertyContainer.prototype.getCurrentOid=function(){return this.currentOid;}
uwm.property.PropertyContainer.prototype.handleChangeLabelEvent=function(modelObject,oldLabel){this.purgeStore(modelObject);}
uwm.property.PropertyContainer.prototype.handleCreateEvent=function(modelObject){this.purgeStore(modelObject);}
uwm.property.PropertyContainer.prototype.handleDeleteEvent=function(modelObject){if(modelObject){if(this.currentOid==modelObject.getOid()){this.showInfoMask();}
this.purgeStore(modelObject);}}
uwm.property.PropertyContainer.prototype.lockControls=function(){if(this.form!=null){for(var i=0;i<this.form.items.getCount();i++){this.form.items.get(i).setDisabled(true);}}}
uwm.property.PropertyContainer.prototype.unlockControls=function(){if(this.form!=null){for(var i=0;i<this.form.items.getCount();i++){this.form.items.get(i).setDisabled(false);}}}
uwm.property.PropertyContainer.prototype.findControlByListType=function(name){if(this.form!=null){for(var i=0;i<this.form.items.getCount();i++){var curItem=this.form.items.get(i);if(curItem.listType==name){return curItem;}}}
return null;}
uwm.property.PropertyContainer.prototype.purgeStore=function(modelObject){if(modelObject){var control=this.findControlByListType(modelObject.getUwmClassName());if(control&&control instanceof uwm.property.ComboBox&&control.getStore()){control.getStore().reload();}}}
uwm.property.PropertyContainer.prototype.getTitleText=function(){var loc=uwm.i18n.Localization.getInstance();var languageName=loc.getLanguageName(this.language,loc.getAllModelLanguages());return uwm.Dict.translate('Properties')+" ["+languageName+"]";}
uwm.property.PropertyContainer.prototype.openTranslationPanel=function(){var targetWidth=500;this.lockControls();var eastPanel=uwm.Uwm.getInstance().getActiveWorkbench().getEastPanel();eastPanel.setWidth(targetWidth);eastPanel.ownerCt.doLayout();this.translationPanel.setVisible(true);this.showLoadMask();this.translationPanel.showTranslation(this.currentOid,this.translationPanel.getLanguage(),this.isLockedByOtherUser,this.hideMask.createDelegate(this));}
uwm.property.PropertyContainer.prototype.closeTranslationPanel=function(){var targetWidth=250;this.unlockControls();this.translationPanel.setVisible(false);this.hideForm(this.translationPanel);var eastPanel=uwm.Uwm.getInstance().getActiveWorkbench().getEastPanel();eastPanel.setWidth(targetWidth);eastPanel.ownerCt.doLayout();}
uwm.property.PropertyContainer.prototype.isTranslationPanelOpen=function(){return this.translationPanel.isVisible();}
uwm.property.PropertyContainer.getInstance=function(){return uwm.Uwm.getInstance().getActiveWorkbench().getPropertyContainer();}
Ext.namespace("uwm.property");uwm.property.TextField=function(config){var self=this;var cls=config.readOnly?"uwm-field-readOnly":null;uwm.property.TextField.superclass.constructor.call(this,Ext.apply(this,{listeners:{"change":function(field,newValue,oldValue){self.fieldChanged(field,newValue,oldValue);},"beforedestroy":function(field){self.handleDestroy(field);}},cls:cls},config));this.toolTipText=config.toolTip;this.modelNode=config.modelNode;}
Ext.extend(uwm.property.TextField,Ext.form.TextField);uwm.property.TextField.prototype.render=function(container,position){uwm.property.TextField.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.TextField.prototype.fieldChanged=function(field,newValue,oldValue){this.persistValue(newValue);}
uwm.property.TextField.prototype.handleDestroy=function(field){if(this.isDirty()){this.persistValue(this.getValue());}}
uwm.property.TextField.prototype.persistValue=function(newValue){if(this.validateValue(newValue)){this.originalValue=newValue;var tmp=new Object();tmp[this.getName()]=newValue;this.modelNode.changeProperties(tmp);}}
Ext.namespace("uwm.property");uwm.property.NumberField=function(config){var self=this;var cls=config.readOnly?"uwm-field-readOnly":null;uwm.property.NumberField.superclass.constructor.call(this,Ext.apply(this,{listeners:{"change":function(field,newValue,oldValue){self.fieldChanged(field,newValue,oldValue);},"beforedestroy":function(field){self.handleDestroy(field);}},cls:cls},config));this.toolTipText=config.toolTip;this.modelNode=config.modelNode;}
Ext.extend(uwm.property.NumberField,Ext.form.NumberField);uwm.property.NumberField.prototype.render=function(container,position){uwm.property.NumberField.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.NumberField.prototype.fieldChanged=function(field,newValue,oldValue){this.persistValue(newValue);}
uwm.property.NumberField.prototype.handleDestroy=function(field){if(this.isDirty()){this.persistValue(this.getValue());}}
uwm.property.NumberField.prototype.persistValue=function(newValue){if(this.validateValue(newValue)){this.originalValue=newValue;var tmp=new Object();tmp[this.getName()]=newValue;this.modelNode.changeProperties(tmp);}}
Ext.namespace("uwm.property");uwm.property.PasswordField=function(config){var self=this;uwm.property.PasswordField.superclass.constructor.call(this,Ext.apply(this,{listeners:{"change":function(field,newValue,oldValue){self.fieldChanged(field,newValue,oldValue);},"beforedestroy":function(field){self.handleDestroy(field);}},inputType:"password"},config));this.toolTipText=config.toolTip;this.modelNode=config.modelNode;}
Ext.extend(uwm.property.PasswordField,Ext.form.TextField);uwm.property.PasswordField.prototype.render=function(container,position){uwm.property.PasswordField.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.PasswordField.prototype.fieldChanged=function(field,newValue,oldValue){this.persistValue(newValue);}
uwm.property.PasswordField.prototype.handleDestroy=function(field){if(this.isDirty()){this.persistValue(this.getValue());}}
uwm.property.PasswordField.prototype.persistValue=function(newValue){if(this.validateValue(newValue)){this.originalValue=newValue;var tmp=new Object();tmp[this.getName()]=newValue;this.modelNode.changeProperties(tmp);}}
Ext.namespace("uwm.property");uwm.property.TextArea=function(config){var self=this;var cls=config.readOnly?"uwm-field-readOnly":null;uwm.property.TextArea.superclass.constructor.call(this,Ext.apply(this,{listeners:{"change":function(field,newValue,oldValue){self.fieldChanged(field,newValue,oldValue);},"beforedestroy":function(field){self.handleDestroy(field);}},cls:cls},config));this.toolTipText=config.toolTip;this.modelNode=config.modelNode;}
Ext.extend(uwm.property.TextArea,Ext.form.TextArea);uwm.property.TextArea.prototype.render=function(container,position){uwm.property.TextArea.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.TextArea.prototype.fieldChanged=function(field,newValue,oldValue){this.persistValue(newValue);}
uwm.property.TextArea.prototype.handleDestroy=function(field){if(this.isDirty()){this.persistValue(this.getValue());}}
uwm.property.TextArea.prototype.persistValue=function(newValue){if(this.validateValue(newValue)){this.originalValue=newValue;var tmp=new Object();tmp[this.getName()]=newValue;this.modelNode.changeProperties(tmp);}}
Ext.namespace("uwm.property");uwm.property.InlineComboBox=function(config){var self=this;uwm.property.InlineComboBox.superclass.constructor.call(this,Ext.apply(this,{store:new Ext.data.Store({proxy:new uwm.property.InlineComboBoxProxy({comboBox:this,value:this.getValue(),listeners:{"beforeload":function(proxy,params){params.language=self.language;}}})}),displayField:'val',valueField:'val',mode:"remote",triggerAction:'all',enableKeyEvents:true,typeAhead:true,minChars:1},config));var self=this;this.on({"keypress":function(field,e){self.handleKeyPress(field,e);}});this.doc=config.doc;this.htmledit=config.htmledit;this.language=null;}
Ext.extend(uwm.property.InlineComboBox,uwm.property.ComboBoxBase);uwm.property.InlineComboBox.prototype.setLanguage=function(language){this.language=language;}
uwm.property.InlineComboBox.prototype.handleKeyPress=function(field,e){var keycode=e.getKey();switch(keycode){case e.ENTER:case e.TAB:var record=this.findRecord(this.valueField,this.getValue());if(this.store&&record){this.htmledit.resolveInlineComboBox(record.data.val,record.data.type);}else{this.htmledit.revertInlineComboBox();}
break;case e.ESC:this.htmledit.revertInlineComboBox();break;default:break;}}
Ext.namespace("uwm.property");uwm.property.HtmlEditor=function(config){var self=this;uwm.property.HtmlEditor.superclass.constructor.call(this,Ext.apply(this,{emptyText:uwm.property.HtmlEditor.EMPTY_VALUE,enableAlignments:false,enableColors:false,enableFont:false,enableFontSize:false,enableLinks:false,enableSourceEdit:false,listeners:{"initialize":function(){self.handleInitialize();},"beforedestroy":function(field){self.handleDestroy(field);},"enable":function(field){if(this.rendered){this.wrap.unmask();}},"disable":function(field){if(this.rendered){this.wrap.mask();}}}},config));this.toolTipText=config.toolTip
this.modelNode=config.modelNode;if(config.readOnly){this.autoMonitorDesignMode=false;}}
Ext.extend(uwm.property.HtmlEditor,Ext.form.HtmlEditor);uwm.property.HtmlEditor.prototype.handleInitialize=function(){var link=this.doc.createElement("link");link.setAttribute("rel","stylesheet");link.setAttribute("type","text/css");link.setAttribute("href","css/htmledit.css");var head=this.doc.getElementsByTagName("head")[0];head.appendChild(link);if(this.readOnly){this.doc.body.setAttribute("class",'readOnly');try{Ext.EventManager.removeAll(this.doc);}catch(e){}
this.doc.designMode="off";}else{this.doc.body.setAttribute("class",'editable');Ext.EventManager.on(this.doc,'keypress',function(e){if(e.shiftKey&&e.getKey()==e.SPACE){this.insertAtCursor("<span id='"+uwm.property.HtmlEditor.INLINE_COMBO_BOX_SPAN_ID+"' />");this.span=this.doc.getElementById(uwm.property.HtmlEditor.INLINE_COMBO_BOX_SPAN_ID);var fullPreText="";if(this.span.previousSibling){fullPreText=this.span.previousSibling.textContent;}
else{fullPreText=this.span.textContent;}
this.preText="";if(fullPreText){var matchArray=fullPreText.match(/[^\t\n ]+$/);if(matchArray){this.preText=matchArray[0];this.span.previousSibling.textContent=fullPreText.substr(0,fullPreText.length-this.preText.length);}}
this.wrap=new Ext.Layer();this.comboBox=new uwm.property.InlineComboBox({htmledit:this,doc:this.doc,renderTo:this.wrap.dom,value:this.preText.trim()});var localpos=this.getPosition(true);var abspos=this.el.getXY();var combobox=this.comboBox.getBox();var spanbox=this.span.getBoundingClientRect();this.wrap.setBounds(abspos[0]-localpos[0]+spanbox.left,abspos[1]-localpos[1]+spanbox.top+combobox.height,combobox.width+20,combobox.height);this.wrap.show();this.comboBox.focus(undefined,true);}},this);var value=this.originalValue;if(value=="&nbsp;"||value.trim()==uwm.property.HtmlEditor.EMPTY_VALUE||value.trim()==""){this.execCmd('delete');if(Ext.isIE){e.updateToolbar();}}}}
uwm.property.HtmlEditor.prototype.resolveInlineComboBox=function(newValue,newValueType){this.comboBox.destroy();this.wrap.remove();this.span.parentNode.removeChild(this.span);if(newValue&&newValueType){this.insertAtCursor(" <span class='autocomplete-"+newValueType+"'>"+newValue+"</span> ");}
this.focus(undefined,100);}
uwm.property.HtmlEditor.prototype.revertInlineComboBox=function(){this.comboBox.destroy();this.wrap.remove();this.span.parentNode.removeChild(this.span);if(this.preText){this.insertAtCursor(this.preText);}
this.focus(undefined,100);}
uwm.property.HtmlEditor.prototype.render=function(container,position){uwm.property.HtmlEditor.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.HtmlEditor.prototype.handleDestroy=function(field){if(this.isDirty()){var tmp=new Object();tmp[this.getName()]=this.getValue();this.modelNode.changeProperties(tmp);}}
uwm.property.HtmlEditor.INLINE_COMBO_BOX_SPAN_ID="inlineComboBoxSpanId";uwm.property.HtmlEditor.EMPTY_VALUE="<br>";Ext.namespace("uwm.property");uwm.property.ComboBoxProxy=function(config){uwm.property.ComboBoxProxy.superclass.constructor.call(this,Ext.apply(this,{},config));this.listType=config.listType;}
Ext.extend(uwm.property.ComboBoxProxy,Ext.data.DataProxy);uwm.property.ComboBoxProxy.prototype.load=function(params,reader,callback,scope,arg){if(this.fireEvent("beforeload",this,params)!==false){var self=this;uwm.persistency.Persistency.getInstance().listbox(this.listType,params.language,function(options,data){self.loadResponse(options,data,callback,scope,arg);},function(options,data,errorMsg){self.loadFailed(options,data,errorMsg,callback,scope,arg)});}
else{callback.call(scope||this,null,arg,false);}}
uwm.property.ComboBoxProxy.prototype.loadResponse=function(options,data,callback,scope,arg){var records=new Array();for(var i=0;i<data.objects.length;i++){records.push(new Ext.data.Record({key:data.objects[i].key,val:data.objects[i].val}));}
var result={success:true,records:records,totalRecords:records.length};this.fireEvent("load",this,options,arg);callback.call(scope,result,arg,true);}
uwm.property.ComboBoxProxy.prototype.loadFailed=function(options,data,errorMsg,callback,scope,arg){this.fireEvent("loadexception",this,options,data);callback.call(scope,null,arg,false);}
Ext.namespace("uwm.property");uwm.property.ComboBox=function(config){var self=this;uwm.property.ComboBox.superclass.constructor.call(this,Ext.apply(this,{listeners:{"change":function(field,newValue,oldValue){self.fieldChanged(field,newValue,oldValue);},"beforedestroy":function(field){self.handleDestroy(field);}},store:new Ext.data.Store({proxy:new uwm.property.ComboBoxProxy({listType:config.listType,listeners:{"beforeload":function(proxy,params){params.language=self.language;}}})}),displayField:'val',valueField:'key',mode:"remote",triggerAction:'all',editable:false},config));this.toolTipText=config.toolTip;this.modelNode=config.modelNode;this.language=null;}
Ext.extend(uwm.property.ComboBox,uwm.property.ComboBoxBase);uwm.property.ComboBox.prototype.setLanguage=function(language){this.language=language;}
uwm.property.ComboBox.prototype.render=function(container,position){uwm.property.ComboBox.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.ComboBox.prototype.fieldChanged=function(field,newValue,oldValue){this.persistValue(newValue);}
uwm.property.ComboBox.prototype.handleDestroy=function(field){if(this.isDirty()){this.persistValue(this.getValue());}}
uwm.property.ComboBox.prototype.persistValue=function(newValue){if(this.validateValue(newValue)){this.originalValue=newValue;var tmp=new Object();tmp[this.getName()]=newValue;this.modelNode.changeProperties(tmp);}}
Ext.namespace("uwm.property");uwm.property.EditableComboBox=function(config){var self=this;uwm.property.EditableComboBox.superclass.constructor.call(this,Ext.apply(this,{},config));this.editable=true;this.forceSelection=false,this.typeAhead=false}
Ext.extend(uwm.property.EditableComboBox,uwm.property.ComboBox);uwm.property.EditableComboBox.prototype.persistValue=function(newValue){var records=this.getStore().query('key',newValue);if(records.getCount()>0){newValue=records.first().data['val'];}
uwm.property.EditableComboBox.superclass.persistValue.call(this,newValue);}
Ext.namespace("uwm.property");uwm.property.StaticComboBox=function(config){var self=this;uwm.property.StaticComboBox.superclass.constructor.call(this,Ext.apply(this,{listeners:{"change":function(field,newValue,oldValue){self.fieldChanged(field,newValue,oldValue);},"beforedestroy":function(field){self.handleDestroy(field);}},store:new Ext.data.SimpleStore({fields:[{name:"key",mapping:"key"},{name:"val",mapping:"val"}],data:config.data}),displayField:'val',valueField:'key',mode:"local",triggerAction:'all',editable:false,},config));this.toolTipText=config.toolTip;this.modelNode=config.modelNode;}
Ext.extend(uwm.property.StaticComboBox,uwm.property.ComboBoxBase);uwm.property.StaticComboBox.prototype.render=function(container,position){uwm.property.StaticComboBox.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.StaticComboBox.prototype.fieldChanged=function(field,newValue,oldValue){this.persistValue(newValue);}
uwm.property.StaticComboBox.prototype.handleDestroy=function(field){if(this.isDirty()){this.persistValue(this.getValue());}}
uwm.property.StaticComboBox.prototype.persistValue=function(newValue){if(this.validateValue(newValue)){this.originalValue=newValue;var tmp=new Object();tmp[this.getName()]=newValue;this.modelNode.changeProperties(tmp);}}
Ext.namespace("uwm.property");uwm.property.Checkbox=function(config){var self=this;uwm.property.Checkbox.superclass.constructor.call(this,Ext.apply(this,{listeners:{"check":function(field,checked){self.fieldChecked(field,checked);},"beforedestroy":function(field){self.handleDestroy(field);}}},config));this.toolTipText=config.toolTip;this.modelNode=config.modelNode;}
Ext.extend(uwm.property.Checkbox,Ext.form.Checkbox);uwm.property.Checkbox.prototype.render=function(container,position){uwm.property.Checkbox.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.Checkbox.prototype.fieldChecked=function(field,checked){this.persistValue(checked);}
uwm.property.Checkbox.prototype.handleDestroy=function(field){if(this.isDirty()){this.persistValue(this.getValue());}}
uwm.property.Checkbox.prototype.persistValue=function(checked){this.originalValue=checked;var tmp=new Object();tmp[this.getName()]=checked?"true":"false";this.modelNode.changeProperties(tmp);}
Ext.namespace("uwm.property");uwm.property.Radio=function(config){var self=this;uwm.property.Radio.superclass.constructor.call(this,Ext.apply(this,{listeners:{"check":function(field,checked){self.fieldChecked(field,checked);},"beforedestroy":function(field){self.handleDestroy(field);}}},config));this.toolTipText=config.toolTip;this.value=config.value;this.modelNode=config.modelNode;}
Ext.extend(uwm.property.Radio,Ext.form.Radio);uwm.property.Radio.prototype.render=function(container,position){uwm.property.Radio.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.Radio.prototype.fieldChecked=function(field,checked){if(checked){this.persistValue();}}
uwm.property.Radio.prototype.handleDestroy=function(field){if(this.isDirty()){this.persistValue(this.getValue());}}
uwm.property.Radio.prototype.persistValue=function(){this.originalValue=this.value;var tmp=new Object();tmp[this.getName()]=this.value;this.modelNode.changeProperties(tmp);}
Ext.namespace("uwm.property");uwm.property.DateField=function(config){var self=this;uwm.property.DateField.superclass.constructor.call(this,Ext.apply(this,{listeners:{"change":function(field,newValue,oldValue){self.fieldChanged(field,newValue,oldValue);},"beforedestroy":function(field){self.handleDestroy(field);}},format:"d.m.Y"},config));this.toolTipText=config.toolTip;this.modelNode=config.modelNode;}
Ext.extend(uwm.property.DateField,Ext.form.DateField);uwm.property.DateField.prototype.render=function(container,position){uwm.property.DateField.superclass.render.apply(this,arguments);if(this.toolTipText){this.toolTip=new Ext.ToolTip({target:container,html:this.toolTipText});}}
uwm.property.DateField.prototype.fieldChanged=function(field,newValue,oldValue){this.persistValue(newValue);}
uwm.property.DateField.prototype.handleDestroy=function(field){if(this.isDirty()){this.persistValue(this.getValue());}}
uwm.property.DateField.prototype.persistValue=function(newValue){if(this.validateValue(newValue)){this.originalValue=newValue;var tmp=new Object();tmp[this.getName()]=newValue.format("Y-m-d");this.modelNode.changeProperties(tmp);}}
Ext.namespace("uwm.property");uwm.property.PropertyForm=function(){}
uwm.property.PropertyForm=Ext.extend(Ext.form.FormPanel,{initComponent:function(){Ext.apply(this,{labelWidth:90,bodyStyle:"padding:5px;",bodyCssClass:"x-panel-mc",labelAlign:"top",autoScroll:false,autoHeight:true,border:false,defaults:{width:"auto"},msgTarget:"side",plugins:[new Ext.ux.form.FieldAutoExpand({labelOffsetFix:90})]})
uwm.property.PropertyForm.superclass.initComponent.apply(this,arguments);this.localizeControls(uwm.i18n.Localization.getInstance().getModelLanguage());}})
uwm.property.PropertyForm.prototype.localizeControls=function(language){for(var i=0;i<this.items.getCount();i++){var curItem=this.items.get(i);if(curItem.setLanguage instanceof Function){curItem.setLanguage(language);}}}
Ext.namespace("uwm.i18n");uwm.i18n.TranslationPanel=Ext.extend(Ext.Panel,{initComponent:function(){var self=this;this.language=uwm.i18n.Localization.getInstance().getTranslationLanguage();this.currentOid=null;this.isLocked=null;this.form=null;this.languageListBox=null;this.toolBar=new Ext.ux.GhostBar({threshold:5,position:'top',style:{overflow:'visible'}});this.createLanguageListbox();Ext.apply(this,{title:self.getTitleText(),tools:[{id:'right',qtip:uwm.Dict.translate('Close'),handler:function(event,toolEl,panel){uwm.property.PropertyContainer.getInstance().closeTranslationPanel();}}],plugins:[this.toolBar]})
uwm.i18n.TranslationPanel.superclass.initComponent.apply(this,arguments);uwm.event.EventBroker.getInstance().addListener({"changeProperty":function(modelObject,values){self.handleChangePropertyEvent.call(self,modelObject,values);},"changeTranslationLanguage":function(language){self.setLanguage(language);}});}})
uwm.i18n.TranslationPanel.prototype.createLanguageListbox=function(){if(this.languageListBox==null){var self=this;this.languageListBox=new uwm.i18n.LanguageListBox({includeUserLanguage:false,languages:uwm.i18n.Localization.getInstance().getAllModelLanguages(),hideLabel:true,width:200,listeners:{"select":function(field,record,index){var language=self.languageListBox.getLanguageFromRecord(record);uwm.i18n.Localization.getInstance().setTranslationLanguage(language);self.languageListBox.destroy();self.languageListBox=null;}}});this.languageListBox.setValue(this.language);this.toolBar.items.clear();this.toolBar.items.add(this.languageListBox);this.toolBar.doLayout();}}
uwm.i18n.TranslationPanel.prototype.showTranslation=function(oid,language,isLocked,callback){this.currentOid=oid;this.isLocked=isLocked;var uwmClassName=uwm.Util.getUwmClassNameFromOid(oid);var translatedNode=uwm.model.ModelContainer.getInstance().createNodeInstance(uwmClassName);translatedNode.oid=oid;translatedNode.language=language;translatedNode.reload(this.displayForm.createDelegate(this,[translatedNode,isLocked,callback]));}
uwm.i18n.TranslationPanel.prototype.displayForm=function(modelNode,isLocked,callback){this.form=modelNode.getModelNodeClass().getPropertyForm(modelNode,isLocked);this.form.localizeControls(this.getLanguage());this.add(this.form);this.lockUntranslatableControls();this.createLanguageListbox();this.doLayout();modelNode.populatePropertyForm(this.form);if(callback instanceof Function){callback();}}
uwm.i18n.TranslationPanel.prototype.getTitleText=function(){var loc=uwm.i18n.Localization.getInstance();var languageName=loc.getLanguageName(this.language,loc.getAllModelLanguages());return uwm.Dict.translate('Translation')+" ["+languageName+"]";}
uwm.i18n.TranslationPanel.prototype.lockUntranslatableControls=function(){if(this.form!=null){for(var i=0;i<this.form.items.getCount();i++){var curItem=this.form.items.get(i);if(curItem instanceof uwm.property.ComboBox||curItem instanceof uwm.property.NumberField||curItem instanceof uwm.property.StaticComboBox||curItem instanceof uwm.property.Radio||curItem instanceof uwm.property.PasswordField||curItem instanceof uwm.property.DateField||curItem.getName()=='Alias'){curItem.setDisabled(true);}}}}
uwm.i18n.TranslationPanel.prototype.handleChangePropertyEvent=function(modelObject,oldValues){if(this.form!=null){for(var curProp in oldValues){var newValue=modelObject.getProperty(curProp);for(var i=0;i<this.form.items.getCount();i++){var curItem=this.form.items.get(i);if(curItem.getName()==curProp&&curItem.disabled&&curItem.getValue()!=newValue){if(curItem instanceof uwm.property.ComboBox&&curItem.getStore()&&curItem.getStore().getCount()==0){curItem.getStore().load({callback:function(r,options,success){if(success&&curItem.findRecord(curItem.valueField,newValue)){curItem.setValue(newValue);}}});}
else{curItem.setValue(newValue);}
break;}}}}}
uwm.i18n.TranslationPanel.prototype.setLanguage=function(language){if(language!=this.language){this.language=language;this.setTitle(this.getTitleText());if(this.languageListBox!=null){this.languageListBox.setValue(this.language);}
if(this.currentOid&&this.isVisible()){var container=uwm.property.PropertyContainer.getInstance();container.hideForm(this);container.showLoadMask();this.showTranslation(this.currentOid,language,this.isLocked,container.hideMask.createDelegate(container));}}}
uwm.i18n.TranslationPanel.prototype.getLanguage=function(){return this.language;;}
Ext.namespace("uwm.property");uwm.property.InlineComboBoxProxy=function(config){uwm.property.InlineComboBoxProxy.superclass.constructor.call(this,Ext.apply(this,{},config));this.listType=config.listType;}
Ext.extend(uwm.property.InlineComboBoxProxy,Ext.data.DataProxy);uwm.property.InlineComboBoxProxy.prototype.load=function(params,reader,callback,scope,arg){if(this.fireEvent("beforeload",this,params)!==false){var self=this;uwm.persistency.Persistency.getInstance().autocomplete(this.comboBox.getValue(),params.language,function(options,data){self.loadResponse(options,data,callback,scope,arg);},function(options,data,errorMsg){self.loadFailed(options,data,errorMsg,callback,scope,arg)});}
else{callback.call(scope||this,null,arg,false);}}
uwm.property.InlineComboBoxProxy.prototype.loadResponse=function(options,data,callback,scope,arg){var records=new Array();for(var i in data.data){if(data.data[i].val){records.push(new Ext.data.Record({type:data.data[i].type,val:data.data[i].val}))};}
var result={success:true,records:records,totalRecords:records.length};this.fireEvent("load",this,options,arg);callback.call(scope,result,arg,true);}
uwm.property.InlineComboBoxProxy.prototype.loadFailed=function(options,data,errorMsg,callback,scope,arg){this.fireEvent("loadexception",this,options,data);callback.call(scope,null,arg,false);}
Ext.namespace("uwm.model");uwm.model.ModelNodeClassContainer=function(){this.items=new Ext.util.MixedCollection();this.semanticGroups=new Object();}
uwm.model.ModelNodeClassContainer.prototype.registerClass=function(modelNodeClass){this.items.add(modelNodeClass.getUwmClassName(),modelNodeClass);if(modelNodeClass instanceof uwm.model.ModelClass){var semanticGroup=modelNodeClass.getSemanticGroup();if(!Ext.isArray(semanticGroup)){this.addSemanticGroup(semanticGroup,modelNodeClass);}else{for(var i=0;i<semanticGroup.length;i++){this.addSemanticGroup(semanticGroup[i],modelNodeClass);}}}}
uwm.model.ModelNodeClassContainer.prototype.addSemanticGroup=function(semanticGroup,modelNodeClass){var entries=this.semanticGroups[semanticGroup];if(!entries){this.semanticGroups[semanticGroup]=new Array();entries=this.semanticGroups[semanticGroup];}
entries.push(modelNodeClass);}
uwm.model.ModelNodeClassContainer.prototype.getClass=function(uwmClassName){return this.items.get(uwmClassName);}
uwm.model.ModelNodeClassContainer.prototype.getAllClasses=function(){return this.items;}
uwm.model.ModelNodeClassContainer.prototype.getSemanticGroups=function(){return this.semanticGroups;}
uwm.model.ModelNodeClassContainer.getInstance=function(){if(!uwm.model.ModelNodeClassContainer.instance){uwm.model.ModelNodeClassContainer.instance=new uwm.model.ModelNodeClassContainer();}
return uwm.model.ModelNodeClassContainer.instance;}
Ext.namespace("uwm.model");uwm.model.ModelContainer=function(){this.items=new Ext.util.MixedCollection();}
uwm.model.ModelContainer.prototype.getByOid=function(oid){return this.items.get(oid);}
uwm.model.ModelContainer.prototype.createByDisplayResult=function(displayResult){var firstModelNode=null;var node=displayResult.node;var furtherElements=true;var outstandingNodes=new Ext.util.MixedCollection();while(furtherElements){var uwmClassName=node.type;var origOid=node.oid;var newModelNode=this.getNode(uwmClassName,origOid);var oid=newModelNode.oid;newModelNode.initByDisplayResult(node);newModelNode.oid=oid;this.items.add(oid,newModelNode);if(!firstModelNode){firstModelNode=newModelNode;}
for(var i in node){if(i!="values"&&i!="oid"&&i!="type"&&i!="properties"&&!(node[i]instanceof Function)){var container=node[i];for(var j=0;j<container.length;j++){outstandingNodes.add(container[j].oid,container[j]);}}}
outstandingNodes.removeKey(origOid);furtherElements=outstandingNodes.getCount()>0;node=outstandingNodes.first();}
return firstModelNode;}
uwm.model.ModelContainer.prototype.createByClassAndOid=function(uwmClassName,oid){var newModelNode=this.getNode(uwmClassName,oid);oid=newModelNode.oid;newModelNode.initByOid(oid);this.items.add(oid,newModelNode);return newModelNode;}
uwm.model.ModelContainer.prototype.createByClassAndNameAndOid=function(uwmClassName,name,oid){var newModelNode=this.getNode(uwmClassName,oid);oid=newModelNode.oid;newModelNode.initByNameAndOid(name,oid);this.items.add(oid,newModelNode);return newModelNode;}
uwm.model.ModelContainer.prototype.createModel=function(){var self=this;uwm.persistency.Persistency.getInstance().newObject("Model",function(request,data){self.handleCreatedModel(data.oid);});}
uwm.model.ModelContainer.prototype.handleCreatedModel=function(oid,callback){var newModelNode=this.getNode("Model",oid);oid=newModelNode.oid;this.items.add(oid,newModelNode);uwm.event.EventBroker.getInstance().fireEvent("create",newModelNode);var nodeLabel=newModelNode.getLabel();if(nodeLabel==oid){newModelNode.setDefaultLabel();}
else{uwm.event.EventBroker.getInstance().fireEvent("changeLabel",newModelNode,nodeLabel,nodeLabel);}
if(callback instanceof Function){callback(newModelNode);}}
uwm.model.ModelContainer.prototype.createPackage=function(parentModelNode){var self=this;uwm.persistency.Persistency.getInstance().newObject("Package",function(request,data){self.handleCreatedPackage(data.oid,parentModelNode);});}
uwm.model.ModelContainer.prototype.handleCreatedPackage=function(oid,parentModelNode){var newModelNode=this.getNode("Package",oid);oid=newModelNode.oid;this.items.add(oid,newModelNode);uwm.event.EventBroker.getInstance().fireEvent("create",newModelNode);newModelNode.setDefaultLabel();newModelNode.associate(parentModelNode);}
uwm.model.ModelContainer.prototype.createDiagram=function(parentModelNode){var self=this;uwm.persistency.Persistency.getInstance().newObject("Diagram",function(request,data){self.handleCreatedDiagram(data.oid,parentModelNode,"Diagram");});}
uwm.model.ModelContainer.prototype.createActivitySet=function(parentModelNode){var self=this;uwm.persistency.Persistency.getInstance().newObject("ActivitySet",function(request,data){self.handleCreatedDiagram(data.oid,parentModelNode,"ActivitySet");});}
uwm.model.ModelContainer.prototype.handleCreatedDiagram=function(oid,parentModelNode,type){var newModelNode;switch(type){case'ActivitySet':newModelNode=this.getNode("ActivitySet",oid);newModelNode.containedPackage=newModelNode;break;case'default':default:newModelNode=this.getNode("Diagram",oid);newModelNode.containedPackage=parentModelNode;break;}
oid=newModelNode.oid;this.items.add(oid,newModelNode);uwm.event.EventBroker.getInstance().fireEvent("create",newModelNode);newModelNode.setDefaultLabel();newModelNode.associate(parentModelNode);}
uwm.model.ModelContainer.prototype.createFigure=function(diagramModelNode,modelObject,actionSet,callback){var self=this;var figureOid=null;actionSet.addNewObject("Figure",function(request,data){figureOid=data.oid;self.handleCreatedFigure(data.oid,diagramModelNode,callback);});actionSet.addAssociate(diagramModelNode.getOid(),"{last_created_oid:Figure}",false,function(request,data){uwm.event.EventBroker.getInstance().fireEvent("associate",diagramModelNode,self.getByOid(figureOid),false);});if(modelObject){actionSet.addAssociate(modelObject.getOid(),"{last_created_oid:Figure}",false,function(request,data){uwm.event.EventBroker.getInstance().fireEvent("associate",modelObject,self.getByOid(figureOid));});}}
uwm.model.ModelContainer.prototype.handleCreatedFigure=function(oid,diagramModelNode,callback){var newFigure=this.getNode("Figure",oid);oid=newFigure.oid;this.items.add(oid,newFigure);newFigure.diagram=diagramModelNode;uwm.event.EventBroker.getInstance().fireEvent("create",newFigure);if(callback instanceof Function){callback(newFigure);}}
uwm.model.ModelContainer.prototype.createController=function(useCaseModelNode,parentModelNode){var self=this;uwm.persistency.Persistency.getInstance().createControllerFromUseCase(useCaseModelNode.getOid(),function(request,data){self.loadByOid(data.oid,self.handleCreatedController.createDelegate(self,[data.oid,parentModelNode]),1);});}
uwm.model.ModelContainer.prototype.handleCreatedController=function(oid,parentModelNode){var newModelNode=this.getNode("ChiController",oid);newModelNode.containedPackage=parentModelNode;oid=newModelNode.oid;this.items.add(oid,newModelNode);newModelNode.associate(parentModelNode);}
uwm.model.ModelContainer.prototype.createModelObject=function(uwmClassName,packageNode,actionSet,callback){var self=this;var newObjectOid=null;if(actionSet instanceof uwm.persistency.ActionSet){actionSet.addNewObject(uwmClassName,function(request,data){newObjectOid=data.oid;self.handleCreatedModelObject(data.oid,uwmClassName,undefined,callback);});actionSet.addAssociate(packageNode.getOid(),"{last_created_oid:"+
uwmClassName+"}",false,function(request,data){uwm.event.EventBroker.getInstance().fireEvent("associate",packageNode,self.getByOid(newObjectOid));});}else{uwm.persistency.Persistency.getInstance().newObject(uwmClassName,function(request,data){self.handleCreatedModelObject(data.oid,uwmClassName,packageNode,callback);});}}
uwm.model.ModelContainer.prototype.handleCreatedModelObject=function(oid,uwmClassName,packageNode,callback){var newObject=this.getNode(uwmClassName,oid);oid=newObject.oid;this.items.add(oid,newObject);uwm.event.EventBroker.getInstance().fireEvent("create",newObject);var nodeLabel=newObject.getLabel();if(nodeLabel==oid){newObject.setDefaultLabel();}
else{uwm.event.EventBroker.getInstance().fireEvent("changeLabel",newObject,nodeLabel,nodeLabel);}
if(packageNode){newObject.associate(packageNode);}
if(callback instanceof Function){callback(newObject);}}
uwm.model.ModelContainer.prototype.loadByOid=function(oid,callback,depth,secondCallback){var self=this;if(!depth){depth=0;}
if(callback instanceof uwm.persistency.ActionSet){callback.addDisplay(oid,depth,uwm.i18n.Localization.getInstance().getModelLanguage(),function(request,data){var node=self.createByDisplayResult(data);if(secondCallback){secondCallback(node);}});}else{uwm.persistency.Persistency.getInstance().display(oid,depth,uwm.i18n.Localization.getInstance().getModelLanguage(),function(request,data){var node=self.createByDisplayResult(data);if(callback){callback(node);}});}}
uwm.model.ModelContainer.prototype.deleteByModelNode=function(modelNode){if(modelNode.getUwmClassName()!="Figure"){Ext.MessageBox.confirm('Delete','Are you sure you want to delete '+modelNode.getLabel()+"?",function(btn){if(btn=="yes"){uwm.model.ModelContainer.getInstance().deleteObject(modelNode);}});}else{uwm.model.ModelContainer.getInstance().deleteObject(modelNode);}}
uwm.model.ModelContainer.prototype.deleteObject=function(modelNode){modelNode.markDeleted();uwm.persistency.Persistency.getInstance().deleteObject(modelNode.getOid(),function(request,data){uwm.event.EventBroker.getInstance().fireEvent("delete",modelNode);});}
uwm.model.ModelContainer.prototype.duplicateObject=function(modelNode,parentNode){var uwmClassName=modelNode.getModelNodeClass().getUwmClassName();var packageNode=this.getNode("Package",parentNode.getOid());var self=this;var longTaskRunner=new uwm.ui.LongTaskRunner({title:uwm.Dict.translate('Copying Object ...'),call:function(successHandler,errorHandler){uwm.persistency.Persistency.getInstance().copy(modelNode.getOid(),parentNode.getOid(),false,successHandler,errorHandler);},successHandler:function(data){uwm.persistency.Persistency.getInstance().display(data.oid,0,uwm.i18n.Localization.getInstance().getModelLanguage(),function(request,data){var node=self.createByDisplayResult(data);self.handleCreatedModelObject(node.oid,uwmClassName,packageNode,function(newObject){longTaskRunner.close();});})},errorHandler:function(data){uwm.Util.showMessage(uwm.Dict.translate("Error while copying"),uwm.Dict.translate("The process was unsuccessful. Please try again."),uwm.Util.messageType.ERROR);},isReturningDocument:false}).show();}
uwm.model.ModelContainer.prototype.duplicateModel=function(modelNode){var uwmClassName=modelNode.getModelNodeClass().getUwmClassName();var self=this;var longTaskRunner=new uwm.ui.LongTaskRunner({title:uwm.Dict.translate('Copying Project ...'),call:function(successHandler,errorHandler){uwm.persistency.Persistency.getInstance().copy(modelNode.getOid(),null,true,successHandler,errorHandler);},successHandler:function(data){uwm.persistency.Persistency.getInstance().display(data.oid,0,uwm.i18n.Localization.getInstance().getModelLanguage(),function(request,data){var node=self.createByDisplayResult(data);self.handleCreatedModel(node.oid,function(newObject){longTaskRunner.close();});})},errorHandler:function(data){uwm.Util.showMessage(uwm.Dict.translate("Error while copying"),uwm.Dict.translate("The process was unsuccessful. Please try again."),uwm.Util.messageType.ERROR);},isReturningDocument:false}).show();}
uwm.model.ModelContainer.prototype.getNode=function(uwmClassName,oid){var modelClass=uwm.model.ModelNodeClassContainer.getInstance().getClass(uwmClassName);if(!modelClass){uwm.Log.log("Model class: "+uwmClassName+" is not defined",uwm.Log.ERROR);}
oid=modelClass.demaskOid(oid);var newModelNode=this.items.get(oid);if(!newModelNode){var newModelNode=this.createNodeInstance(uwmClassName);}
newModelNode.oid=oid;return newModelNode;}
uwm.model.ModelContainer.prototype.createNodeInstance=function(uwmClassName){var modelClass=uwm.model.ModelNodeClassContainer.getInstance().getClass(uwmClassName);var realModelClass=modelClass.getRealModelClass();var newModelNode=eval("new "+modelClass.getInstanceClassName()+"(realModelClass)");return newModelNode;}
uwm.model.ModelContainer.getInstance=function(){if(!uwm.model.ModelContainer.instance){uwm.model.ModelContainer.instance=new uwm.model.ModelContainer();}
return uwm.model.ModelContainer.instance;}
Ext.namespace("uwm.model");uwm.model.ModelNodeClass=function(){}
uwm.model.ModelNodeClass.prototype.getUwmClassName=function(){return this.uwmClassName;}
uwm.model.ModelNodeClass.prototype.getInstanceClassName=function(){return this.instanceClassName;}
uwm.model.ModelNodeClass.prototype.getTreeIcon=function(){return this.treeIcon;}
uwm.model.ModelNodeClass.prototype.getPropertyForm=function(){}
uwm.model.ModelNodeClass.prototype.getDefaultLabel=function(){return this.defaultLabel;}
uwm.model.ModelNodeClass.prototype.isLabelProperty=function(propertyName){return this.labelProperties[propertyName]!=undefined;}
uwm.model.ModelNodeClass.prototype.getGridTabIconClass=function(){return this.gridTabIconClass;}
uwm.model.ModelNodeClass.prototype.demaskOid=function(orgOid){var result=orgOid;var uwmClassName=uwm.Util.getUwmClassNameFromOid(orgOid);if(this.realUwmClassName&&this.uwmClassName==uwmClassName){result=this.realUwmClassName+":"+uwm.Util.getNumericFromOid(orgOid);}else if(this.maskInfo){var demaskedUwmClassName=this.maskInfo[uwmClassName];if(demaskedUwmClassName){result=demaskedUwmClassName+":"+uwm.Util.getNumericFromOid(orgOid);}}
return result;}
uwm.model.ModelNodeClass.prototype.getRealModelClass=function(){var result=this;if(this.realUwmClassName){result=uwm.model.ModelNodeClassContainer.getInstance().getClass(this.realUwmClassName);}
return result;}
uwm.model.ModelNodeClass.prototype.getGraphics=function(label,figure){return eval("new "+this.getFigureClass()+"(label, figure)");}
uwm.model.ModelNodeClass.prototype.getSemanticGroup=function(){return this.semanticGroup;}
Ext.namespace("uwm.model");uwm.model.ModelClass=function(){this.initialWidth=150;this.initialHeight=50;}
uwm.model.ModelClass.prototype=new uwm.model.ModelNodeClass;uwm.model.ModelClass.prototype.getConstraints=function(){return this.constraints;}
uwm.model.ModelClass.prototype.getDescription=function(){return this.description;}
uwm.model.ModelClass.prototype.getHelpUrl=function(){return this.helpUrl;}
uwm.model.ModelClass.prototype.getFigureIcon=function(){return this.figureIcon;}
uwm.model.ModelNodeClass.prototype.getFigureClass=function(){return this.figureClass;}
uwm.model.ModelClass.prototype.getConnectionInfo=function(otherClass){return this.connectionInfo[otherClass.getUwmClassName()];}
uwm.model.ModelClass.prototype.getGridTabTip=function(){return this.gridTabTip;}
uwm.model.ModelClass.prototype.getGridFields=function(){return this.gridFields;}
uwm.model.ModelClass.prototype.getGridColumns=function(){return this.gridColumns;}
uwm.model.ModelClass.prototype.getSemanticGroup=function(){return this.semanticGroup;}
uwm.model.ModelClass.prototype.getAllConnectionInfo=function(){return this.connectionInfo;}
uwm.model.ModelClass.prototype.getInitialWidth=function(){return this.initialWidth;}
uwm.model.ModelClass.prototype.getInitialHeight=function(){return this.initialHeight;}
uwm.model.ModelClass.prototype.canCreateNewInDiagram=function(diagram){return true;}
Ext.namespace("uwm.model");uwm.model.RelationClass=function(){uwm.model.RelationClass.superclass.constructor.call(this);}
Ext.extend(uwm.model.RelationClass,uwm.model.ModelNodeClass);Ext.namespace("uwm.model");uwm.model.EditableRelationClass=function(){uwm.model.EditableRelationClass.superclass.constructor.call(this);}
Ext.extend(uwm.model.EditableRelationClass,uwm.model.RelationClass);uwm.model.EditableRelationClass.prototype.getPropertyForm=function(modelNode,isLockedByOtherUser){return new uwm.property.PropertyForm({items:[new uwm.property.TextField({fieldLabel:'Name',toolTip:"the name of this object",name:'Name',modelNode:modelNode,readOnly:isLockedByOtherUser}),new uwm.property.HtmlEditor({fieldLabel:'Notes',toolTip:"the actual description of the object.",name:'Notes',modelNode:modelNode,readOnly:isLockedByOtherUser}),new uwm.property.ComboBox({fieldLabel:'sourceMultiplicity',toolTip:"",name:'sourceMultiplicity',listType:"RelationMultiplicity",modelNode:modelNode,disabled:isLockedByOtherUser}),new uwm.property.StaticComboBox({fieldLabel:'sourceNavigability',toolTip:"",name:'sourceNavigability',data:[{key:"Navigable",val:"Navigable"},{key:"Non-Navigable",val:"Non-Navigable"}],modelNode:modelNode,disabled:isLockedByOtherUser}),new uwm.property.ComboBox({fieldLabel:'targetMultiplicity',toolTip:"",name:'targetMultiplicity',listType:"RelationMultiplicity",modelNode:modelNode,disabled:isLockedByOtherUser}),new uwm.property.StaticComboBox({fieldLabel:'targetNavigability',toolTip:"",name:'targetNavigability',data:[{key:"Navigable",val:"Navigable"},{key:"Non-Navigable",val:"Non-Navigable"}],modelNode:modelNode,disabled:isLockedByOtherUser}),new uwm.property.TextField({fieldLabel:'created',toolTip:"the creation date of this object",name:'created',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:'creator',toolTip:"the user that created this object",name:'creator',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:'last_editor',toolTip:"the last user that edited this object",name:'last_editor',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:'modified',toolTip:"the date when this object was modified",name:'modified',modelNode:modelNode,readOnly:true})]});}
Ext.namespace("uwm.model");uwm.model.ModelNode=function(modelNodeClass){if(modelNodeClass){this.modelNodeClass=modelNodeClass;this.uwmClassName=modelNodeClass.getUwmClassName();this.semanticGroup=modelNodeClass.getSemanticGroup();}
this.data=new Object();this.alreadyDeleted=false;this.maskedOids={};this.parentOids=[];this.childOids=[];this.language=null;}
uwm.model.ModelNode.prototype.initByDisplayResult=function(node){this.oid=node.oid;this.uwmClassName=node.type;this.maskedOids={};this.parentOids=this.deMaskOids(node.properties.parentoids);this.childOids=this.deMaskOids(node.properties.childoids);for(var i in node.values){if(!(node.values[i]instanceof Function)){for(var j in node.values[i]){if(!(node.values[i][j]instanceof Function)){this.data[j]=node.values[i][j];}}}}}
uwm.model.ModelNode.prototype.deMaskOids=function(oidList){var modelNodeClass=this.getModelNodeClass();var result=[];if(oidList){for(var i=0;i<oidList.length;i++){var currOid=oidList[i];var demaskedOid=modelNodeClass.demaskOid(currOid);if(!demaskedOid){result.push(currOid);}else{result.push(demaskedOid);this.maskedOids[demaskedOid]=currOid;}}}
return result;}
uwm.model.ModelNode.prototype.initByOid=function(oid){this.oid=oid;this.parentOids=null;this.childOids=null;this.maskedOids={};}
uwm.model.ModelNode.prototype.initByNameAndOid=function(name,oid){this.oid=oid;this.parentOids=null;this.childOids=null;this.maskedOids={};this.name=name;}
uwm.model.ModelNode.prototype.getUwmClassName=function(){return this.uwmClassName;}
uwm.model.ModelNode.prototype.getSemanticGroup=function(){return this.semanticGroup;}
uwm.model.ModelNode.prototype.getModelNodeClass=function(){var result=this.modelNodeClass;if(!result){this.modelNodeClass=uwm.model.ModelNodeClassContainer.getInstance().getClass(this.uwmClassName);result=this.modelNodeClass;}
return result;}
uwm.model.ModelNode.prototype.getParentOids=function(preventReload){return this.parentOids;}
uwm.model.ModelNode.prototype.getChildOids=function(preventReload){return this.childOids;}
uwm.model.ModelNode.prototype.getOid=function(){return this.oid;}
uwm.model.ModelNode.prototype.getName=function(){var result=this.data.Name;if(!result){result=this.name;}
return result;}
uwm.model.ModelNode.prototype.getLabel=function(){var result=this.getName();if(!result){result=this.getOid();}
return result;}
uwm.model.ModelNode.prototype.getLanguage=function(){if(this.language==null){this.language=uwm.i18n.Localization.getInstance().getModelLanguage();}
return this.language;}
uwm.model.ModelNode.prototype.setLanguage=function(language){this.language=language;}
uwm.model.ModelNode.prototype.reload=function(callback){var self=this;uwm.persistency.Persistency.getInstance().display(this.oid,0,this.getLanguage(),function(request,data){self.initByDisplayResult(data.node);if(callback instanceof Function){callback(self);}});}
uwm.model.ModelNode.prototype.populatePropertyForm=function(form){}
uwm.model.ModelNode.prototype.getProperty=function(propertyName){return this.data[propertyName];}
uwm.model.ModelNode.prototype.changeProperties=function(values){var oldValues=new Object();var oldLabels=new Object();var changedLabel=false;for(var i in values){if(!(values[i]instanceof Function)){oldValues[i]=this.data[i];this.data[i]=values[i];if(this.getModelNodeClass().isLabelProperty(i)){oldLabels[i]=oldValues[i];changedLabel=true;}}}
var self=this;uwm.persistency.Persistency.getInstance().save(this.getOid(),values,this.getLanguage(),function(request,data){uwm.event.EventBroker.getInstance().fireEvent("changeProperty",self,oldValues);if(changedLabel){uwm.event.EventBroker.getInstance().fireEvent("changeLabel",self,oldLabels);}});}
uwm.model.ModelNode.prototype.setDefaultLabel=function(){this.changeProperties({"Name":this.getModelNodeClass().getDefaultLabel()});}
uwm.model.ModelNode.prototype.markDeleted=function(){this.alreadyDeleted=true;}
uwm.model.ModelNode.prototype.isDeleted=function(){return this.alreadyDeleted;}
uwm.model.ModelNode.prototype.getMaskedRelatedOid=function(relatedOid){return this.maskedOids[relatedOid];}
uwm.model.ModelNode.prototype.associate=function(otherModelObject,connectionInfo,nmUwmClassName,connection){var self=this;var childOid=this.getOid();var parentOid=otherModelObject.getOid();if(connectionInfo&&connectionInfo.nmSelf&&!connectionInfo.invert){childOid=otherModelObject.getOid();parentOid=this.getOid();}
if(connectionInfo&&connectionInfo.nmSelf){if(connectionInfo.ownUwmClassName){childOid=connectionInfo.ownUwmClassName+":"+uwm.Util.getNumericFromOid(childOid);parentOid=connectionInfo.otherUwmClassName+":"+uwm.Util.getNumericFromOid(parentOid);}else{childOid=this.insertDirectionInOid(childOid,"Source");parentOid=this.insertDirectionInOid(parentOid,"Target");}}
if(!nmUwmClassName){uwm.persistency.Persistency.getInstance().associate(parentOid,childOid,false,function(request,data){self.fillInRelationObject(connection,data);uwm.event.EventBroker.getInstance().fireEvent("associate",otherModelObject,self);});if(this.parentOids){this.parentOids.push(otherModelObject.getOid());}
if(otherModelObject.childOids){otherModelObject.childOids.push(this.getOid());}}else{var actionSet=new uwm.persistency.ActionSet();actionSet.addAssociate(parentOid,childOid,false,function(request,data){self.fillInRelationObject(connection,data);var relationObject=connection.getRelationObject();relationObject.changeProperties({relationType:connectionInfo.connectionType,Name:connectionInfo.label});if(self.childOids){self.childOids.push(relationObject.getOid());var maskedOid=connectionInfo.ownUwmClassName+"End:"+uwm.Util.getNumericFromOid(relationObject.getOid());self.maskedOids[relationObject.getOid()]=maskedOid;}
if(otherModelObject.childOids){otherModelObject.childOids.push(relationObject.getOid());var maskedOid=connectionInfo.otherUwmClassName+"End:"+uwm.Util.getNumericFromOid(relationObject.getOid());otherModelObject.maskedOids[relationObject.getOid()]=maskedOid;}
uwm.event.EventBroker.getInstance().fireEvent("associate",otherModelObject,self);});actionSet.commit();}}
uwm.model.ModelNode.prototype.fillInRelationObject=function(connection,data){if(data.manyToMany){var temp={};for(var i in data.manyToMany){temp.node=data.manyToMany[i][0];break;}
var relationObject=uwm.model.ModelContainer.getInstance().createByDisplayResult(temp);connection.setRelationObject(relationObject);}}
uwm.model.ModelNode.prototype.insertDirectionInOid=function(oldOid,direction){var result=uwm.Util.getUwmClassNameFromOid(oldOid)+direction+":"+uwm.Util.getNumericFromOid(oldOid);return result;}
uwm.model.ModelNode.prototype.disassociate=function(otherModelObject,connectionInfo,relationObject){var self=this;this.updateOidLists(otherModelObject);otherModelObject.updateOidLists(this);var childOid=this.getOid();var parentOid=otherModelObject.getOid();if(this.getModelNodeClass()==otherModelObject.getModelNodeClass()||(connectionInfo.nmSelf&&connectionInfo.invertBackendRelation)){childOid=otherModelObject.getOid();parentOid=this.getOid();}
if(connectionInfo&&connectionInfo.nmSelf){if(connectionInfo.ownUwmClassName){childOid=connectionInfo.ownUwmClassName+":"+uwm.Util.getNumericFromOid(childOid);parentOid=connectionInfo.otherUwmClassName+":"+uwm.Util.getNumericFromOid(parentOid);}else{childOid=this.insertDirectionInOid(childOid,"Source");parentOid=this.insertDirectionInOid(parentOid,"Target");}}
uwm.persistency.Persistency.getInstance().disassociate(parentOid,childOid,function(request,data){if(connectionInfo&&connectionInfo.nmSelf&&relationObject){uwm.model.ModelContainer.getInstance().deleteObject(relationObject);}
uwm.event.EventBroker.getInstance().fireEvent("disassociate",otherModelObject,self);});}
uwm.model.ModelNode.prototype.updateOidLists=function(otherModelObject){if(this.childOids){var newList=[];for(var i=0;i<this.childOids.length;i++){if(this.childOids[i]!=otherModelObject.getOid()){newList.push(this.childOids[i]);}}
this.childOids=newList;}
if(otherModelObject.parentOids){var newList=[];for(var i=0;i<otherModelObject.parentOids.length;i++){if(otherModelObject.parentOids[i]!=this.getOid()){newList.push(otherModelObject.parentOids[i]);}}
otherModelObject.parentOids=newList;}}
Ext.namespace("uwm.model");uwm.model.ModelObject=function(modelNodeClass){uwm.model.ModelObject.superclass.constructor.call(this,modelNodeClass);}
Ext.extend(uwm.model.ModelObject,uwm.model.ModelNode);uwm.model.ModelObject.prototype.connectableWith=function(otherObject){var result=false;if(this.getModelNodeClass().getConnectionInfo(otherObject.getModelNodeClass())!=null){if(this.checkCardinality(otherObject)&&otherObject.checkCardinality(this)){result=true;}}
if(this.isConnected(otherObject)||otherObject.isConnected(this)){result=false;}
return result;}
uwm.model.ModelObject.prototype.checkCardinality=function(otherObject){var result=false;var connections=this.getNumberOfConnections(otherObject);var allowedConnections=this.getModelNodeClass().getConnectionInfo(otherObject.getModelNodeClass()).cardinality;if(connections<allowedConnections||allowedConnections==-1||!allowedConnections){result=true;}
return result;}
uwm.model.ModelObject.prototype.getNumberOfConnections=function(otherObject){var parentOids=this.getParentOids();var childOids=this.getChildOids();var result=0;result+=this.getConnections(parentOids,otherObject.getUwmClassName());result+=this.getConnections(childOids,otherObject.getUwmClassName());return result;}
uwm.model.ModelObject.prototype.getConnections=function(oidList,otherObjectClassName){var result=0;if(oidList){for(var i=0;i<oidList.length;i++){var childClassName=uwm.Util.getUwmClassNameFromOid(oidList[i]);if(childClassName==otherObjectClassName){result++;}}}
return result;}
uwm.model.ModelObject.prototype.isConnected=function(otherObject){var result=false;var otherOid=otherObject.getOid();if(this.parentOids){for(var i=0;i<this.parentOids.length;i++){if(this.parentOids[i]==otherOid){result=true;}}}
if(this.childOids){for(var i=0;i<this.childOids.length;i++){if(this.childOids[i]==otherOid){result=true;}}}
return result;}
uwm.model.ModelObject.prototype.hasParent=function(){var result=false;for(var i in this.parentOids){if(!(this.parentOids[i]instanceof Function)){if(uwm.Util.getUwmClassNameFromOid(this.parentOids[i])==this.getUwmClassName()){result=true;}}}
return result;}
Ext.namespace("uwm.model");uwm.model.Relation=function(modelNodeClass){uwm.model.Relation.superclass.constructor.call(this,modelNodeClass);}
Ext.extend(uwm.model.Relation,uwm.model.ModelNode);uwm.model.Relation.prototype.getMaskedModelNodeClass=function(){return uwm.model.ModelNodeClassContainer.getInstance().getClass(uwm.Util.getUwmClassNameFromOid(this.oid));}
Ext.namespace("uwm.model");uwm.model.EditableRelation=function(modelNodeClass){uwm.model.EditableRelation.superclass.constructor.call(this,modelNodeClass);}
Ext.extend(uwm.model.EditableRelation,uwm.model.Relation);uwm.model.EditableRelation.prototype.initByDisplayResult=function(node){uwm.model.EditableRelation.superclass.initByDisplayResult.call(this,node);this.data.sourceMultiplicity=node.values[1].sourceMultiplicity;this.data.sourceNavigability=node.values[1].sourceNavigability;this.data.targetMultiplicity=node.values[1].targetMultiplicity;this.data.targetNavigability=node.values[1].targetNavigability;this.data.Name=node.values[1].Name;this.data.Notes=node.values[1].Notes;this.data.created=node.values[1].created;this.data.creator=node.values[1].creator;this.data.last_editor=node.values[1].last_editor;this.data.modified=node.values[1].modified;}
uwm.model.EditableRelation.prototype.populatePropertyForm=function(form){var realForm=form.getForm();realForm.findField("sourceMultiplicity").loadValue(this.data.sourceMultiplicity);realForm.findField("sourceNavigability").loadValue(this.data.sourceNavigability);realForm.findField("targetMultiplicity").loadValue(this.data.targetMultiplicity);realForm.findField("targetNavigability").loadValue(this.data.targetNavigability);realForm.findField("Name").loadValue(this.data.Name);realForm.findField("Notes").loadValue(this.data.Notes);realForm.findField("created").loadValue(this.data.created);realForm.findField("creator").loadValue(this.data.creator);realForm.findField("last_editor").loadValue(this.data.last_editor);realForm.findField("modified").loadValue(this.data.modified);}
Ext.namespace("uwm.model");uwm.model.RelationEndClass=function(){uwm.model.RelationEndClass.superclass.constructor.call(this);}
Ext.extend(uwm.model.RelationEndClass,uwm.model.ModelNodeClass);uwm.model.RelationEndClass.prototype.getConnnectionEndRole=function(){return this.connectionEndRole;}
Ext.namespace("uwm.model");uwm.model.TechnicalObject=function(modelNodeClass){uwm.model.ModelNode.call(this,modelNodeClass);}
uwm.model.TechnicalObject.prototype=new uwm.model.ModelNode;Ext.namespace("uwm.model");uwm.model.TechnicalObjectClass=function(){uwm.model.ModelNodeClass.call(this);}
uwm.model.TechnicalObjectClass.prototype=new uwm.model.ModelNodeClass;Ext.namespace("uwm.model");uwm.model.ClassObjectClass=function(){uwm.model.ClassObjectClass.superclass.constructor.call(this);}
Ext.extend(uwm.model.ClassObjectClass,uwm.model.ModelClass);uwm.model.ClassObjectClass.prototype.isAttributeEnabled=function(){return true;}
uwm.model.ClassObjectClass.prototype.isOperationEnabled=function(){return true;}
Ext.namespace("uwm.model");uwm.model.ClassObject=function(modelNodeClass){uwm.model.ClassObject.superclass.constructor.call(this,modelNodeClass);}
Ext.extend(uwm.model.ClassObject,uwm.model.ModelObject);uwm.model.ClassObject.prototype.addAttribute=function(){throw new Error("uwm.model.ClassObject.addAttribute must be overwritten");}
uwm.model.ClassObject.prototype.addOperation=function(){throw new Error("uwm.model.ClassObject.addOperation must be overwritten");}
uwm.model.ClassObject.prototype.updateChildLabel=function(childModelNode,figure){var graphics=figure.getGraphics();var childGraphics=this.getChildGraphicsByOid(graphics,childModelNode.getOid());if(childGraphics){childGraphics.setLabel(childModelNode.getLabel());}}
uwm.model.ClassObject.prototype.removeChild=function(childModelNode,figure){var graphics=figure.getGraphics();var childGraphics=this.getChildGraphicsByOid(graphics,childModelNode.getOid());if(childGraphics){graphics.removeChildElement(childGraphics,true);}}
uwm.model.ClassObject.prototype.getChildGraphicsByOid=function(graphics,oid){var result=null;var childGraphics=graphics.getChildElements();for(var i=0;i<childGraphics.length;i++){var currChildGraphics=childGraphics[i];if(currChildGraphics.getModelObject().getOid()==oid){result=currChildGraphics;break;}}
return result;}
Ext.namespace("uwm.model");uwm.model.AttributeObject=function(modelNodeClass){uwm.model.AttributeObject.superclass.constructor.call(this,modelNodeClass);}
Ext.extend(uwm.model.AttributeObject,uwm.model.ModelNode);Ext.namespace("uwm.model");uwm.model.OperationObject=function(modelNodeClass){uwm.model.OperationObject.superclass.constructor.call(this,modelNodeClass);}
Ext.extend(uwm.model.OperationObject,uwm.model.ModelNode);Ext.namespace("uwm.model.builtin");uwm.model.builtin.ModelClass=function(){uwm.model.ModelNodeClass.call(this);this.uwmClassName="Model";this.instanceClassName="uwm.model.builtin.Model";this.treeIcon="FigureModel";this.defaultLabel="New Model";this.labelProperties={Name:true};}
uwm.model.builtin.ModelClass.prototype=new uwm.model.ModelNodeClass;uwm.model.builtin.ModelClass.prototype.getPropertyForm=function(modelNode){return new uwm.property.PropertyForm({items:[new uwm.property.TextField({fieldLabel:'Name',name:'Name',modelNode:modelNode}),new uwm.property.HtmlEditor({fieldLabel:'Notes',name:'Notes',modelNode:modelNode}),new uwm.property.TextField({fieldLabel:'created',name:'created',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:'creator',name:'creator',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:'last_editor',name:'last_editor',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:'modified',name:'modified',modelNode:modelNode,readOnly:true})]});}
uwm.model.ModelNodeClassContainer.getInstance().registerClass(new uwm.model.builtin.ModelClass());Ext.namespace("uwm.model.builtin");uwm.model.builtin.Model=function(modelNodeClass){uwm.model.ModelNode.call(this,modelNodeClass);}
uwm.model.builtin.Model.prototype=new uwm.model.ModelNode;uwm.model.builtin.Model.prototype.initByDisplayResult=function(node){uwm.model.ModelNode.prototype.initByDisplayResult.call(this,node);this.data.Name=node.values[1].Name;this.data.Notes=node.values[1].Notes;this.data.created=node.values[1].created;this.data.creator=node.values[1].creator;this.data.last_editor=node.values[1].last_editor;this.data.modified=node.values[1].modified;}
uwm.model.builtin.Model.prototype.populatePropertyForm=function(form){var realForm=form.getForm();realForm.findField("Name").loadValue(this.data.Name);realForm.findField("Notes").loadValue(this.data.Notes);realForm.findField("created").loadValue(this.data.created);realForm.findField("creator").loadValue(this.data.creator);realForm.findField("last_editor").loadValue(this.data.last_editor);realForm.findField("modified").loadValue(this.data.modified);}
Ext.namespace("uwm.model.builtin");uwm.model.builtin.PackageClass=function(){uwm.model.ModelNodeClass.call(this);this.uwmClassName="Package";this.instanceClassName="uwm.model.builtin.Package";this.treeIcon="FigurePackage";this.defaultLabel="New Package";this.labelProperties={Name:true};}
uwm.model.builtin.PackageClass.prototype=new uwm.model.ModelNodeClass;uwm.model.builtin.PackageClass.prototype.getPropertyForm=function(modelNode){return new uwm.property.PropertyForm({items:[new uwm.property.TextField({fieldLabel:uwm.Dict.translate('Name'),name:'Name',modelNode:modelNode}),new uwm.property.HtmlEditor({fieldLabel:uwm.Dict.translate('Notes'),name:'Notes',modelNode:modelNode}),new uwm.property.TextField({fieldLabel:uwm.Dict.translate('created'),name:'created',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:uwm.Dict.translate('creator'),name:'creator',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:uwm.Dict.translate('last_editor'),name:'last_editor',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:uwm.Dict.translate('modified'),name:'modified',modelNode:modelNode,readOnly:true})]});}
uwm.model.ModelNodeClassContainer.getInstance().registerClass(new uwm.model.builtin.PackageClass());Ext.namespace("uwm.model.builtin");uwm.model.builtin.Package=function(modelNodeClass){uwm.model.ModelNode.call(this,modelNodeClass);}
uwm.model.builtin.Package.prototype=new uwm.model.ModelNode;uwm.model.builtin.Package.prototype.initByDisplayResult=function(node){uwm.model.ModelNode.prototype.initByDisplayResult.call(this,node);this.data.Name=node.values[1].Name;this.data.Notes=node.values[1].Notes;this.data.created=node.values[1].created;this.data.creator=node.values[1].creator;this.data.last_editor=node.values[1].last_editor;this.data.modified=node.values[1].modified;}
uwm.model.builtin.Package.prototype.populatePropertyForm=function(form){var realForm=form.getForm();realForm.findField("Name").loadValue(this.data.Name);realForm.findField("Notes").loadValue(this.data.Notes);realForm.findField("created").loadValue(this.data.created);realForm.findField("creator").loadValue(this.data.creator);realForm.findField("last_editor").loadValue(this.data.last_editor);realForm.findField("modified").loadValue(this.data.modified);}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.BaseFigure=function(label,figure,minWidth,minHeight,startWidth,startHeight){this.minWidth=minWidth;this.minHeight=minHeight;this.figure=figure;draw2d.VectorFigure.call(this);if(startWidth&&startHeight){this.setDimension(startWidth,startHeight);}
if(label){this.setLabel(label);}
this.buildContextMenu();}
Ext.extend(uwm.graphics.figure.BaseFigure,draw2d.VectorFigure);uwm.graphics.figure.BaseFigure.prototype.setWorkflow=function(workflow){draw2d.VectorFigure.prototype.setWorkflow.call(this,workflow);if(workflow!=null&&this.port==null){this.port=new uwm.graphics.connection.UwmPort();this.port.setWorkflow(workflow);this.addPort(this.port,this.width+8,0);}}
uwm.graphics.figure.BaseFigure.prototype.buildContextMenu=function(){var figure=this.getFigure();this.uwmContextMenu=new Ext.menu.Menu({items:[new Ext.menu.Item({text:uwm.Dict.translate('Show in tree'),handler:function(item,e){figure.showInModelTree();}}),new Ext.menu.Item({itemId:uwm.graphics.figure.BaseFigure.CONTEXTMENU_SHOW_IN_GRID_ID,text:uwm.Dict.translate('Show in grid'),handler:function(item,e){figure.showInGrid();}}),new Ext.menu.Item({text:uwm.Dict.translate('Show in hierarchy'),handler:function(item,e){figure.showInHierarchy();}}),"-",new Ext.menu.Item({text:uwm.Dict.translate('Delete from diagram'),handler:function(item,e){figure.deleteFromDiagram();}}),new Ext.menu.Item({text:uwm.Dict.translate('Delete from model'),handler:function(tiem,e){figure.deleteFromModel();}}),new Ext.menu.Item({text:uwm.Dict.translate('Show object history'),handler:function(item,e){figure.showObjectHistory(item,e);}}),new Ext.menu.Item({text:"Help",handler:function(item,e){figure.showHelp(item,e);}})]});}
uwm.graphics.figure.BaseFigure.prototype.onContextMenu=function(x,y){var showInGrid=this.uwmContextMenu.items.get(uwm.graphics.figure.BaseFigure.CONTEXTMENU_SHOW_IN_GRID_ID);var isGridAvailable=this.figure.gridAvailable();showInGrid.setDisabled(!isGridAvailable);this.uwmContextMenu.showAt(this.figure.getDiagram().getContextMenuPosition(x,y));}
uwm.graphics.figure.BaseFigure.prototype.getFigure=function(){return this.figure;}
uwm.graphics.figure.BaseFigure.prototype.getMinWidth=function(){var result=draw2d.VectorFigure.prototype.getMinWidth.call(this);if(this.minWidth){result=this.minWidth;}
return result;}
uwm.graphics.figure.BaseFigure.prototype.getMinHeight=function(){var result=draw2d.VectorFigure.prototype.getMinHeight.call(this);if(this.minHeight){result=this.minHeight;}
return result;}
uwm.graphics.figure.BaseFigure.prototype.setDimension=function(width,height){draw2d.VectorFigure.prototype.setDimension.call(this,width,height);if(this.port!=null){this.port.setPosition(this.getWidth()+8,0);}}
uwm.graphics.figure.BaseFigure.prototype.createHTMLElement=function(){var item=draw2d.Figure.prototype.createHTMLElement.call(this);item.className="uwmFigure";uwm.Util.setElementUnselectable(item);return item;}
uwm.graphics.figure.BaseFigure.prototype.setLabel=function(newText){if(this.label){this.label.innerHTML=newText;}}
uwm.graphics.figure.BaseFigure.prototype.getLabel=function(){if(this.label){return this.label.innerHTML;}}
uwm.graphics.figure.BaseFigure.CONTEXTMENU_SHOW_IN_GRID_ID="showInGrid";Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.RectangleFigure=function(label,figure){uwm.graphics.figure.BaseFigure.call(this,label,figure,80,30,150,50);}
Ext.extend(uwm.graphics.figure.RectangleFigure,uwm.graphics.figure.BaseFigure);uwm.graphics.figure.RectangleFigure.prototype.setDimension=function(width,height){uwm.graphics.figure.BaseFigure.prototype.setDimension.call(this,width,height);if(this.label!=null){this.label.style.width=this.getWidth()-40+"px";this.label.style.height=this.getHeight()-3+"px";}}
uwm.graphics.figure.RectangleFigure.prototype.createHTMLElement=function(){var item=uwm.graphics.figure.BaseFigure.prototype.createHTMLElement.call(this);this.label=document.createElement("div");this.label.style.position="absolute";this.label.style.left="20px";this.label.style.top="5px";this.label.style.overflow="hidden";this.image=document.createElement("div");this.image.className=this.getFigure().getModelObject().getModelNodeClass().getFigureIcon();this.image.style.position="absolute";this.image.style.top="2px";this.image.style.right="2px";this.image.style.width="24px";this.image.style.height="24px";this.image.style.backgroundRepeat="no-repeat";return item;}
uwm.graphics.figure.RectangleFigure.prototype.paint=function(){uwm.graphics.figure.BaseFigure.prototype.paint.call(this);var width=this.getWidth()-1;var height=this.getHeight()-1;this.graphics.drawRect(0,0,width,height);this.graphics.drawLine(10,0,10,height);this.graphics.drawLine(15,0,15,height);this.graphics.paint();this.html.appendChild(this.label);this.html.appendChild(this.image);}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.StatusFigure=function(label,figure,initalWidth,initialHeight,minWidth,minHeight){uwm.graphics.figure.BaseFigure.call(this,label,figure,initalWidth,initialHeight,minWidth,minHeight);}
Ext.extend(uwm.graphics.figure.StatusFigure,uwm.graphics.figure.BaseFigure);uwm.graphics.figure.StatusFigure.prototype.setDimension=function(width,height){uwm.graphics.figure.BaseFigure.prototype.setDimension.call(this,width,height);if(this.label!=null){this.label.style.width=this.getWidth()-3+"px";this.label.style.height=(this.getHeight()-3)/2+"px";}
if(this.status!=null){this.status.style.top=(this.getHeight()-3)/2+5+"px";this.status.style.width=this.getWidth()-3+"px";this.status.style.height=(this.getHeight()-3)/2-5+"px";}}
uwm.graphics.figure.StatusFigure.prototype.createHTMLElement=function(){var item=uwm.graphics.figure.BaseFigure.prototype.createHTMLElement.call(this);this.label=document.createElement("div");this.label.style.position="absolute";this.label.style.left="5px";this.label.style.top="5px";this.label.style.overflow="hidden";this.status=document.createElement("div");this.status.style.position="absolute";this.status.style.left="5px";this.status.style.top="5px";this.status.style.overflow="hidden";this.status.style.textAlign="center";return item;}
uwm.graphics.figure.StatusFigure.prototype.paint=function(){uwm.graphics.figure.BaseFigure.prototype.paint.call(this);var width=this.getWidth()-1;var height=this.getHeight()-1;this.graphics.drawRect(0,0,width,height);this.graphics.paint();this.html.appendChild(this.label);this.html.appendChild(this.status);}
uwm.graphics.figure.StatusFigure.prototype.setLabel=function(newText){var result=uwm.graphics.figure.BaseFigure.prototype.setLabel.call(this,newText);if(this.getFigure()){this.setStatus(this.getFigure().getModelObject().getStatus());}}
uwm.graphics.figure.StatusFigure.prototype.setStatus=function(newStatus){this.status.innerHTML="["+newStatus+"]";}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.ComplexFigure=function(label,figure,minWidth,minHeight,startWidth,startHeight){uwm.graphics.figure.BaseFigure.call(this,label,figure,minWidth,minHeight,startWidth,startHeight);}
Ext.extend(uwm.graphics.figure.ComplexFigure,uwm.graphics.figure.BaseFigure);uwm.graphics.figure.ComplexFigure.prototype.setWorkflow=function(workflow){uwm.graphics.figure.BaseFigure.prototype.setWorkflow.call(this,workflow);this.setLabelDimension();}
uwm.graphics.figure.ComplexFigure.prototype.setDimension=function(width,height){uwm.graphics.figure.BaseFigure.prototype.setDimension.call(this,width,height);this.setLabelDimension();}
uwm.graphics.figure.ComplexFigure.prototype.setLabelDimension=function(){}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.LabelBelowFigure=function(label,figure,minWidth,minHeight,startWidth,startHeight){uwm.graphics.figure.ComplexFigure.call(this,label,figure,minWidth,minHeight,startWidth,startHeight);}
Ext.extend(uwm.graphics.figure.LabelBelowFigure,uwm.graphics.figure.ComplexFigure);uwm.graphics.figure.LabelBelowFigure.prototype.setLabelDimension=function(){if(this.label!=null){this.label.style.left=(-(this.label.clientWidth-this.width)/2)+"px";}}
uwm.graphics.figure.LabelBelowFigure.prototype.createHTMLElement=function(){var item=uwm.graphics.figure.ComplexFigure.prototype.createHTMLElement.call(this);this.label=document.createElement("div");this.label.style.position="absolute";this.label.style.width="auto";this.label.style.textAlign="center";this.label.style.bottom="-24px";this.label.style.height="20px";item.appendChild(this.label);return item;}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.ImageFigure=function(label,figure,imageUrl,minWidth,minHeight,startWidth,startHeight){this.url=imageUrl;uwm.graphics.figure.LabelBelowFigure.call(this,label,figure,minWidth,minHeight,startWidth,startHeight);}
Ext.extend(uwm.graphics.figure.ImageFigure,uwm.graphics.figure.LabelBelowFigure);uwm.graphics.figure.ImageFigure.prototype.createHTMLElement=function(){var item=uwm.graphics.figure.LabelBelowFigure.prototype.createHTMLElement.call(this);if(Ext.isIE6){this.d=document.createElement("div");this.d.style.position="absolute";this.d.style.left="0px";this.d.style.top="0px";this.d.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+this.url+"', sizingMethod='scale')";this.d=item.appendChild(this.d);}else{this.img=document.createElement("img");this.img.style.position="absolute";this.img.style.left="0px";this.img.style.top="0px";this.img.src=this.url;this.img=item.appendChild(this.img);this.d=document.createElement("div");this.d.style.position="absolute";this.d.style.left="0px";this.d.style.top="0px";this.d=item.appendChild(this.d);}
item.style.left=this.x+"px";item.style.top=this.y+"px";return item;}
uwm.graphics.figure.ImageFigure.prototype.paint=function(){uwm.graphics.figure.BaseFigure.prototype.paint.call(this);}
uwm.graphics.figure.ImageFigure.prototype.setDimension=function(w,h){uwm.graphics.figure.LabelBelowFigure.prototype.setDimension.call(this,w,h);if(this.d!=null){this.d.style.width=this.width+"px";this.d.style.height=this.height+"px";}
if(this.img!=null){this.img.setAttribute("width",this.width);this.img.setAttribute("height",this.height);}}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.LabelCenterFigure=function(label,figure,minWidth,minHeight,startWidth,startHeight){uwm.graphics.figure.ComplexFigure.call(this,label,figure,minWidth,minHeight,startWidth,startHeight);}
Ext.extend(uwm.graphics.figure.LabelCenterFigure,uwm.graphics.figure.ComplexFigure);uwm.graphics.figure.LabelCenterFigure.prototype.setLabelDimension=function(){if(this.label!=null){this.label.style.left=(-(this.label.clientWidth-this.width)/2)+"px";this.label.style.top=(-(this.label.clientHeight-this.height)/2)+"px";}}
uwm.graphics.figure.LabelCenterFigure.prototype.createHTMLElement=function(){var item=uwm.graphics.figure.ComplexFigure.prototype.createHTMLElement.call(this);this.label=document.createElement("div");this.label.style.position="absolute";this.label.style.width="100%";this.label.style.textAlign="center";this.label.style.left="5px";this.label.style.overflow="hidden";this.label.style.zIndex=1111;item.appendChild(this.label);return item;}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.ImageLabelCenterFigure=function(label,figure,imageUrl,minWidth,minHeight,startWidth,startHeight){this.url=imageUrl;uwm.graphics.figure.LabelCenterFigure.call(this,label,figure,minWidth,minHeight,startWidth,startHeight);}
Ext.extend(uwm.graphics.figure.ImageLabelCenterFigure,uwm.graphics.figure.LabelCenterFigure);uwm.graphics.figure.ImageLabelCenterFigure.prototype.createHTMLElement=function(){var item=uwm.graphics.figure.LabelCenterFigure.prototype.createHTMLElement.call(this);if(Ext.isIE6){this.d=document.createElement("div");this.d.style.position="absolute";this.d.style.left="0px";this.d.style.top="0px";this.d.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader (src='"+this.url+"', sizingMethod='scale')";this.d=item.appendChild(this.d);}else{this.img=document.createElement("img");this.img.style.position="absolute";this.img.style.left="0px";this.img.style.top="0px";this.img.src=this.url;this.img=item.appendChild(this.img);this.d=document.createElement("div");this.d.style.position="absolute";this.d.style.left="0px";this.d.style.top="0px";this.d=item.appendChild(this.d);}
item.style.left=this.x+"px";item.style.top=this.y+"px";return item;}
uwm.graphics.figure.ImageLabelCenterFigure.prototype.paint=function(){uwm.graphics.figure.LabelCenterFigure.prototype.paint.call(this);}
uwm.graphics.figure.ImageLabelCenterFigure.prototype.setDimension=function(w,h){uwm.graphics.figure.LabelCenterFigure.prototype.setDimension.call(this,w,h);if(this.d!=null){this.d.style.width=this.width+"px";this.d.style.height=this.height+"px";}
if(this.img!=null){this.img.setAttribute("width",this.width);this.img.setAttribute("height",this.height);}}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.ClassFigure=function(label,figure){this.minWidth=150;this.minHeight=65;this.figure=figure;this.childElements=[];draw2d.CompartmentFigure.call(this);this.setDimension(150,65);if(label){this.setLabel(label);}
this.buildContextMenu();}
Ext.extend(uwm.graphics.figure.ClassFigure,draw2d.CompartmentFigure);uwm.graphics.figure.ClassFigure.prototype.setWorkflow=function(workflow){return uwm.graphics.figure.BaseFigure.prototype.setWorkflow.call(this,workflow);}
uwm.graphics.figure.ClassFigure.prototype.buildContextMenu=function(){var figure=this.getFigure();var items=[];if(figure.getModelObject().getModelNodeClass().isAttributeEnabled()){items.push(new Ext.menu.Item({text:uwm.Dict.translate("Add Attribute"),handler:function(item,e){figure.getModelObject().addAttribute();}}));}
if(figure.getModelObject().getModelNodeClass().isOperationEnabled()){items.push(new Ext.menu.Item({text:uwm.Dict.translate("Add Operation"),handler:function(item,e){figure.getModelObject().addOperation();}}));}
items.push(new Ext.menu.Item({text:uwm.Dict.translate('Show in tree'),handler:function(item,e){figure.showInModelTree();}}));items.push(new Ext.menu.Item({itemId:uwm.graphics.figure.BaseFigure.CONTEXTMENU_SHOW_IN_GRID_ID,text:uwm.Dict.translate('Show in grid'),handler:function(item,e){figure.showInGrid();}}));items.push(new Ext.menu.Item({text:uwm.Dict.translate('Show in hierarchy'),handler:function(item,e){figure.showInHierarchy();}}));items.push("-");items.push(new Ext.menu.Item({text:uwm.Dict.translate('Delete from diagram'),handler:function(item,e){figure.deleteFromDiagram();}}));items.push(new Ext.menu.Item({text:uwm.Dict.translate('Delete from model'),handler:function(tiem,e){figure.deleteFromModel();}}));items.push(new Ext.menu.Item({text:uwm.Dict.translate('Show object history'),handler:function(item,e){figure.showObjectHistory(item,e);}}));items.push(new Ext.menu.Item({text:"Help",handler:function(item,e){figure.showHelp(item,e);}}));this.uwmContextMenu=new Ext.menu.Menu({items:items});}
uwm.graphics.figure.ClassFigure.prototype.onContextMenu=function(x,y){return uwm.graphics.figure.BaseFigure.prototype.onContextMenu.call(this,x,y);}
uwm.graphics.figure.ClassFigure.prototype.getFigure=function(){return uwm.graphics.figure.BaseFigure.prototype.getFigure.call(this);}
uwm.graphics.figure.ClassFigure.prototype.getMinWidth=function(){return uwm.graphics.figure.BaseFigure.prototype.getMinWidth.call(this);}
uwm.graphics.figure.ClassFigure.prototype.getMinHeight=function(){var result=this.minHeight;return result;}
uwm.graphics.figure.ClassFigure.prototype.setDimension=function(width,height){uwm.graphics.figure.BaseFigure.prototype.setDimension.call(this,width,height);var children=this.getChildren();if(children){var childWidth=this.getWidth()-4;for(var i=0;i<children.getSize();i++){var currChild=children.get(i);currChild.setDimension(childWidth,currChild.getHeight());}}}
uwm.graphics.figure.ClassFigure.prototype.createHTMLElement=function(){var item=uwm.graphics.figure.BaseFigure.prototype.createHTMLElement.call(this);this.label=document.createElement("div");this.label.style.position="absolute";this.label.style.left="5px";this.label.style.top="5px";this.label.style.overflow="hidden";this.label.style.height=(uwm.graphics.figure.ClassFigure.LABEL_HEIGHT-10)+"px";this.image=document.createElement("div");this.image.className=this.getFigure().getModelObject().getModelNodeClass().getFigureIcon();this.image.style.position="absolute";this.image.style.top="2px";this.image.style.right="2px";this.image.style.width="24px";this.image.style.height="24px";this.image.style.backgroundRepeat="no-repeat";return item;}
uwm.graphics.figure.ClassFigure.prototype.setLabel=function(newText){return uwm.graphics.figure.BaseFigure.prototype.setLabel.call(this,newText);}
uwm.graphics.figure.ClassFigure.prototype.getLabel=function(){return uwm.graphics.figure.BaseFigure.prototype.getLabel.call(this);}
uwm.graphics.figure.ClassFigure.prototype.addChildElement=function(newChild,expandFigure){var newPropertyPosition=uwm.graphics.figure.ClassFigure.LABEL_HEIGHT+uwm.graphics.figure.ClassFigure.SECTIONS_SPACING;var newOperationPosition=newPropertyPosition+uwm.graphics.figure.ClassFigure.SECTIONS_SPACING*3;var children=this.getChildren();for(var i=0;i<children.getSize();i++){var currChild=children.get(i);var height=currChild.getHeight();if(currChild instanceof uwm.graphics.figure.Attribute){newPropertyPosition+=height;newOperationPosition+=height;}else if(currChild instanceof uwm.graphics.figure.Operation){if(newChild instanceof uwm.graphics.figure.Attribute){var position=currChild.getPosition();currChild.setPosition(position.x,position.y+newChild.getHeight());}
newOperationPosition+=height;}}
this.childElements.push(newChild);var myPosition=this.getPosition();if(newChild instanceof uwm.graphics.figure.Attribute){this.workflow.getCommandStack().execute(new draw2d.CommandAdd(this.workflow,newChild,myPosition.x+2,myPosition.y+newPropertyPosition,this));}else if(newChild instanceof uwm.graphics.figure.Operation){this.workflow.getCommandStack().execute(new draw2d.CommandAdd(this.workflow,newChild,myPosition.x+2,myPosition.y+newOperationPosition,this));}
this.minHeight+=newChild.getHeight();if(expandFigure){var command=new draw2d.CommandResize(this);command.setDimension(this.getWidth(),this.getHeight()+newChild.getHeight());this.workflow.getCommandStack().execute(command);}else{this.paint();}}
uwm.graphics.figure.ClassFigure.prototype.removeChildElement=function(childToRemove,shrinkFigure){var childHeight=childToRemove.getHeight();try{this.removeChild(childToRemove);}catch(e){}
var existingFigure=this.workflow.getFigure(childToRemove.getId());if(existingFigure){this.workflow.removeFigure(childToRemove);}
var newPropertyPosition=uwm.graphics.figure.ClassFigure.LABEL_HEIGHT+uwm.graphics.figure.ClassFigure.SECTIONS_SPACING;var newOperationPosition=newPropertyPosition+uwm.graphics.figure.ClassFigure.SECTIONS_SPACING*3;var children=this.getChildren();var parentPosition=this.getPosition();for(var i=0;i<children.getSize();i++){var currChild=children.get(i);var height=currChild.getHeight();var childPosition=currChild.getPosition();if(currChild instanceof uwm.graphics.figure.Attribute){currChild.setPosition(childPosition.x,parentPosition.y+newPropertyPosition);newPropertyPosition+=height;newOperationPosition+=height;}}
for(var i=0;i<children.getSize();i++){var currChild=children.get(i);var height=currChild.getHeight();var childPosition=currChild.getPosition();if(currChild instanceof uwm.graphics.figure.Operation){currChild.setPosition(childPosition.x,parentPosition.y+newOperationPosition);newOperationPosition+=height;}}
this.minHeight-=childHeight;var index=this.childElements.indexOf(childToRemove);if(index!=-1){this.childElements.splice(index,1);}
if(shrinkFigure){var command=new draw2d.CommandResize(this);command.setDimension(this.getWidth(),this.getHeight()-childToRemove.getHeight());this.workflow.getCommandStack().execute(command);}else{this.paint();}}
uwm.graphics.figure.ClassFigure.prototype.getChildElements=function(){return this.childElements;}
uwm.graphics.figure.ClassFigure.prototype.paint=function(){uwm.graphics.figure.BaseFigure.prototype.paint.call(this);var width=this.getWidth()-1;var height=this.getHeight()-1;this.graphics.drawRect(0,0,width,height);this.graphics.drawLine(0,uwm.graphics.figure.ClassFigure.LABEL_HEIGHT,width,uwm.graphics.figure.ClassFigure.LABEL_HEIGHT);var children=this.getChildren();var propertySize=0;for(var i=0;i<children.getSize();i++){if(children.get(i)instanceof uwm.graphics.figure.Attribute){propertySize+=children.get(i).getHeight();}}
var linePos=uwm.graphics.figure.ClassFigure.LABEL_HEIGHT+propertySize+uwm.graphics.figure.ClassFigure.SECTIONS_SPACING*2;if(linePos<height){this.graphics.drawLine(0,linePos,width,linePos);}
this.graphics.paint();this.html.appendChild(this.label);this.html.appendChild(this.image);}
uwm.graphics.figure.ClassFigure.LABEL_HEIGHT=45;uwm.graphics.figure.ClassFigure.SECTIONS_SPACING=5;uwm.graphics.figure.ClassFigure.CONTEXTMENU_SHOW_IN_GRID_ID="showInGrid";Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.AbstractClassPart=function(label,modelObject){this.modelObject=modelObject;draw2d.Node.call(this);this.setDimension(150,16);if(label){this.setLabel(label);}
this.buildContextMenu();this.setCanDrag(false);this.setResizeable(false);}
Ext.extend(uwm.graphics.figure.AbstractClassPart,draw2d.Node);uwm.graphics.figure.AbstractClassPart.prototype.buildContextMenu=function(){var modelObject=this.getModelObject();var self=this;this.uwmContextMenu=new Ext.menu.Menu({items:[new Ext.menu.Item({text:uwm.Dict.translate('Delete from model'),handler:function(item,e){uwm.event.EventBroker.getInstance().addListener({"delete":function(modelObject){if(self.getParent()){self.getParent().removeChildElement(self,true);}}});uwm.model.ModelContainer.getInstance().deleteByModelNode(modelObject);}})]});}
uwm.graphics.figure.AbstractClassPart.prototype.onContextMenu=function(x,y){this.uwmContextMenu.showAt(this.getParent().getFigure().getDiagram().getContextMenuPosition(x,y));}
uwm.graphics.figure.AbstractClassPart.prototype.getModelObject=function(){return this.modelObject;}
uwm.graphics.figure.AbstractClassPart.prototype.createHTMLElement=function(){var item=draw2d.Node.prototype.createHTMLElement.call(this);item.style.border="none";this.label=document.createElement("div");this.label.style.position="absolute";this.label.style.left="0px";this.label.style.top="0px";this.label.style.overflow="hidden";return item;}
uwm.graphics.figure.AbstractClassPart.prototype.setLabel=function(newText){return uwm.graphics.figure.BaseFigure.prototype.setLabel.call(this,newText);}
uwm.graphics.figure.AbstractClassPart.prototype.getLabel=function(){return uwm.graphics.figure.BaseFigure.prototype.getLabel.call(this);}
uwm.graphics.figure.AbstractClassPart.prototype.paint=function(){uwm.graphics.figure.BaseFigure.prototype.paint.call(this);this.graphics.paint();this.html.appendChild(this.label);}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.Attribute=function(label,modelObject){uwm.graphics.figure.AbstractClassPart.call(this,label,modelObject);}
Ext.extend(uwm.graphics.figure.Attribute,uwm.graphics.figure.AbstractClassPart);uwm.graphics.figure.Attribute.prototype.createHTMLElement=function(){var item=uwm.graphics.figure.AbstractClassPart.prototype.createHTMLElement.call(this);this.label.className="FigureAttribute"
return item;}
Ext.namespace("uwm.graphics.figure");uwm.graphics.figure.Operation=function(label,modelObject){uwm.graphics.figure.AbstractClassPart.call(this,label,modelObject);}
Ext.extend(uwm.graphics.figure.Operation,uwm.graphics.figure.AbstractClassPart);uwm.graphics.figure.Operation.prototype.createHTMLElement=function(){var item=uwm.graphics.figure.AbstractClassPart.prototype.createHTMLElement.call(this);this.label.className="FigureOperation"
return item;}
uwm.graphics.figure.Operation.prototype.setLabel=function(newText){var result=uwm.graphics.figure.AbstractClassPart.prototype.setLabel.call(this,newText);this.addBracketsToDisplay();return result;}
uwm.graphics.figure.Operation.prototype.paint=function(){uwm.graphics.figure.AbstractClassPart.prototype.paint.call(this);this.addBracketsToDisplay();}
uwm.graphics.figure.Operation.prototype.addBracketsToDisplay=function(){var ops=Ext.query('.FigureOperation',this.html);if(ops){for(var i=0;i<ops.length;i++){ops[i].innerHTML+="()";}}}
Ext.namespace("uwm.graphics.connection");uwm.graphics.connection.UwmPortGraphics=function(){draw2d.VectorFigure.call(this);this.setDimension(10,10);}
Ext.extend(uwm.graphics.connection.UwmPortGraphics,draw2d.VectorFigure);uwm.graphics.connection.UwmPortGraphics.prototype.type="uwm.graphics.connection.UwmPortGraphics";uwm.graphics.connection.UwmPortGraphics.prototype.paint=function(){draw2d.VectorFigure.prototype.paint.call(this);var width=this.getWidth();var height=this.getHeight();this.graphics.drawLine(0,height/2,width,height/2);this.graphics.drawLine(width/2,0,width,height/2);this.graphics.drawLine(width/2,height,width,height/2);this.graphics.paint();}
Ext.namespace("uwm.graphics.connection");uwm.graphics.connection.UwmPort=function(){draw2d.Port.call(this,new uwm.graphics.connection.UwmPortGraphics());this.setDimension(10,10);}
Ext.extend(uwm.graphics.connection.UwmPort,draw2d.Port);uwm.graphics.connection.UwmPort.prototype.type="uwm.graphics.connection.UwmPort";uwm.graphics.connection.UwmPort.prototype.onDragEnter=function(port){if(port.parentNode.getFigure().getModelObject().connectableWith(this.parentNode.getFigure().getModelObject())){draw2d.Port.prototype.onDragEnter.call(this,port);}}
uwm.graphics.connection.UwmPort.prototype.onDrop=function(port){if(this.parentNode.id==port.parentNode.id){}
else{var portModelObject=port.parentNode.getFigure().getModelObject();var thisModelObject=this.parentNode.getFigure().getModelObject();this.parentNode.getFigure().getDiagram().createConnection(thisModelObject,portModelObject,this,port,port.parentNode.x,port.parentNode.y);}}
Ext.namespace("uwm.graphics.connection");uwm.graphics.connection.MidpointLocator=function(connection){draw2d.ConnectionLocator.call(this,connection);}
Ext.extend(uwm.graphics.connection.MidpointLocator,draw2d.ConnectionLocator);uwm.graphics.connection.MidpointLocator.prototype.type="uwm.graphics.connection.MidpointLocator";uwm.graphics.connection.MidpointLocator.prototype.relocate=function(target){var conn=this.getConnection();var p=new draw2d.Point();var points=conn.getPoints();var index=Math.floor((points.getSize()-2)/2);var p1=points.get(index);var p2=points.get(index+1);p.x=(p2.x-p1.x)/2+p1.x-this.getConnection().getLabel().getWidth()/2;p.y=(p2.y-p1.y)/2+p1.y-this.getConnection().getLabel().getHeight()/2;target.setPosition(p.x,p.y);}
Ext.namespace("uwm.graphics.connection");uwm.graphics.connection.ArrowDecorator=function(){draw2d.ConnectionDecorator.call(this);this.setBackgroundColor(new draw2d.Color(255,255,255));}
Ext.extend(uwm.graphics.connection.ArrowDecorator,draw2d.ConnectionDecorator);uwm.graphics.connection.ArrowDecorator.prototype.type="uwm.graphics.connection.ArrowDecorator";uwm.graphics.connection.ArrowDecorator.prototype.paint=function(g){g.setColor(this.color);g.setStroke(1);g.drawLine(12,8,0,0);g.drawLine(0,0,12,-8);}
Ext.namespace("uwm.graphics.connection");uwm.graphics.connection.ClosedArrowDecorator=function(){draw2d.ConnectionDecorator.call(this);this.setBackgroundColor(new draw2d.Color(255,255,255));}
Ext.extend(uwm.graphics.connection.ClosedArrowDecorator,draw2d.ConnectionDecorator);uwm.graphics.connection.ClosedArrowDecorator.prototype.type="uwm.graphics.connection.ClosedArrowDecorator";uwm.graphics.connection.ClosedArrowDecorator.prototype.paint=function(g){g.setColor(this.color);g.setStroke(1);g.drawLine(12,8,0,0);g.drawLine(0,0,12,-8);g.drawLine(12,8,12,-8);}
Ext.namespace("uwm.graphics.connection");uwm.graphics.connection.OpenDiamondDecorator=function(){draw2d.ConnectionDecorator.call(this);this.setBackgroundColor(new draw2d.Color(255,255,255));}
Ext.extend(uwm.graphics.connection.OpenDiamondDecorator,draw2d.ConnectionDecorator);uwm.graphics.connection.OpenDiamondDecorator.prototype.type="uwm.graphics.connection.OpenDiamondDecorator";uwm.graphics.connection.OpenDiamondDecorator.prototype.paint=function(g){g.setColor(this.backgroundColor);g.setStroke(1);g.fillPolygon([0,12,24,12],[0,8,0,-8]);g.setColor(this.color);g.drawPolygon([0,12,24,12],[0,8,0,-8]);}
Ext.namespace("uwm.graphics.connection");uwm.graphics.connection.FilledDiamondDecorator=function(){draw2d.ConnectionDecorator.call(this);this.setBackgroundColor(new draw2d.Color(0,0,0));}
Ext.extend(uwm.graphics.connection.FilledDiamondDecorator,draw2d.ConnectionDecorator);uwm.graphics.connection.FilledDiamondDecorator.prototype.type="uwm.graphics.connection.FilledDiamondDecorator";uwm.graphics.connection.FilledDiamondDecorator.prototype.paint=function(g){g.setColor(this.backgroundColor);g.setStroke(1);g.fillPolygon([0,12,24,12],[0,8,0,-8]);}
Ext.namespace("uwm.graphics.connection");uwm.graphics.connection.BaseConnection=function(label,decorators){draw2d.Connection.call(this);this.relationObject=null;if(decorators.source){this.setSourceDecorator(decorators.source);}
if(decorators.target){this.setTargetDecorator(decorators.target);}
this.setSourceAnchor(new draw2d.ChopboxConnectionAnchor(this));this.setTargetAnchor(new draw2d.ChopboxConnectionAnchor(this));this.setRouter(new draw2d.ManhattanConnectionRouter());this.stroke=jsgStroke.DOTTED;if(label){this.label=new draw2d.Label(label);this.label.setBackgroundColor(new draw2d.Color(255,255,255));this.label.setFontSize(8);this.createHTMLElement();this.html=this.getHTMLElement();this.addFigure(this.label,new uwm.graphics.connection.MidpointLocator(this));}
this.setDeleteable(true);this.buildContextMenu();}
Ext.extend(uwm.graphics.connection.BaseConnection,draw2d.Connection);uwm.graphics.connection.BaseConnection.prototype.type="uwm.graphics.connection.BaseConnection";uwm.graphics.connection.BaseConnection.prototype.setWorkflow=function(workflow){draw2d.Connection.prototype.setWorkflow.call(this,workflow);var htmlElement=this.getHTMLElement();if(htmlElement){var contextMenu=this.uwmContextMenu;var self=this;this.tmpContextMenu=function(e){var position=e.getXY();contextMenu.showAt(position);e.preventDefault();return false;}
var event="mousedown";if(Ext.isWindows){event="mouseup";}
Ext.fly(htmlElement).on(event,this.tmpContextMenu);}}
uwm.graphics.connection.BaseConnection.prototype.getLabel=function(){return this.label;}
uwm.graphics.connection.BaseConnection.prototype.buildContextMenu=function(){var self=this;this.uwmContextMenu=new Ext.menu.Menu({items:[new Ext.menu.Item({text:"Delete from model",handler:function(item,e){self.deleteFromModel(item,e);}})]});}
uwm.graphics.connection.BaseConnection.prototype.deleteFromDiagram=function(item,e){alert("TODO: Delete connection from diagram");}
uwm.graphics.connection.BaseConnection.prototype.deleteFromModel=function(item,e){this.getWorkflow().getCommandStack().execute(new draw2d.CommandDelete(this));}
uwm.graphics.connection.BaseConnection.prototype.setRelationObject=function(relationObject){this.relationObject=relationObject;}
uwm.graphics.connection.BaseConnection.prototype.getRelationObject=function(){return this.relationObject;}
Ext.namespace("uwm.diagram");uwm.diagram.DiagramTabPanel=function(){}
uwm.diagram.DiagramTabPanel=Ext.extend(Ext.TabPanel,{initComponent:function(){Ext.apply(this,{region:"center",xtype:"tabpanel",enableTabScroll:true,activeTab:0,id:uwm.diagram.DiagramTabPanel.COMPONENT_ID,items:uwm.ui.HelpViewer.getInstance()})
uwm.diagram.DiagramTabPanel.superclass.initComponent.apply(this,arguments);this.diagramContainer=this.initialConfig.diagramContainer;var self=this;this.on("tabchange",function(tabPanel,tab){self.tabChange(tabPanel,tab);});this.on("remove",function(tabPanel,tab){self.tabClose(tabPanel,tab);});}});uwm.diagram.DiagramTabPanel.prototype.tabChange=function(tabPanel,tab){var diagram=null;if(tab instanceof uwm.diagram.DiagramTab){diagram=tab.getDiagram();}
this.diagramContainer.setCurrentDiagram(diagram);}
uwm.diagram.DiagramTabPanel.prototype.tabClose=function(tabPanel,tab){if(tab instanceof uwm.diagram.DiagramTab){this.diagramContainer.unloadDiagram(tab.getDiagram());}}
uwm.diagram.DiagramTabPanel.COMPONENT_ID="uwm.diagram.DiagramTablPanel.ID";Ext.namespace("uwm.diagram");uwm.diagram.DiagramContainer=function(){this.items=new Ext.util.MixedCollection();this.tabPanel=new uwm.diagram.DiagramTabPanel({diagramContainer:this});this.currentDiagram=null;}
uwm.diagram.DiagramContainer.prototype.getByOid=function(oid){return this.items.get(oid);}
uwm.diagram.DiagramContainer.prototype.getTabPanel=function(){return this.tabPanel;}
uwm.diagram.DiagramContainer.prototype.createNewDiagram=function(){var result=new uwm.diagram.Diagram(this.getDiagramClass());result.init();this.items.add(result);this.tabPanel.activate(result.getTab());return result;}
uwm.diagram.DiagramContainer.prototype.getDiagramClass=function(){return uwm.model.ModelNodeClassContainer.getInstance().getClass("Diagram");}
uwm.diagram.DiagramContainer.prototype.loadDiagram=function(modelObject){var diagram=this.items.get(modelObject.getOid());if(!diagram){var self=this;diagram=modelObject;diagram.init();this.items.add(diagram.getOid(),diagram);this.tabPanel.activate(diagram.getTab());}else{diagram.getTab().show();}}
uwm.diagram.DiagramContainer.prototype.unloadDiagram=function(diagram){this.items.removeKey(diagram.getOid());}
uwm.diagram.DiagramContainer.prototype.setCurrentDiagram=function(diagram){this.currentDiagram=diagram;}
uwm.diagram.DiagramContainer.prototype.getCurrentDiagram=function(){return this.currentDiagram;}
uwm.diagram.DiagramContainer.prototype.isModelObjectContainedInCurrentDiagram=function(modelObject){var result=false;if(this.currentDiagram){result=this.currentDiagram.containsObject(modelObject);}
return result;}
uwm.diagram.DiagramContainer.getInstance=function(){if(!uwm.diagram.DiagramContainer.instance){uwm.diagram.DiagramContainer.instance=new uwm.diagram.DiagramContainer();}
return uwm.diagram.DiagramContainer.instance;}
Ext.namespace("uwm.diagram");uwm.diagram.DiagramTab=function(config){uwm.diagram.DiagramTab.superclass.constructor.call(this,Ext.apply(this,{elements:"body",closable:true,isHelpViewer:false},config));this.diagram=config.diagram;var self=this;this.on("activate",function(panel){self.restoreScrollPosition();});this.on("deactivate",function(panel){self.saveScrollPosition();});}
Ext.extend(uwm.diagram.DiagramTab,Ext.Panel);uwm.diagram.DiagramTab.prototype.render=function(){uwm.diagram.DiagramTab.superclass.render.apply(this,arguments);this.diagram.initWorkflow();this.diagram.initDropZone();this.diagram.loadFigures();}
uwm.diagram.DiagramTab.prototype.getDiagram=function(){return this.diagram;}
uwm.diagram.DiagramTab.prototype.saveScrollPosition=function(){this.scrollX=this.getDiagram().getWorkflow().getScrollLeft();this.scrollY=this.getDiagram().getWorkflow().getScrollTop();}
uwm.diagram.DiagramTab.prototype.restoreScrollPosition=function(){if(this.scrollX){this.getDiagram().getWorkflow().scrollTo(this.scrollX,this.scrollY,true);}}
Ext.namespace("uwm.diagram");uwm.diagram.DropZone=function(el,config){uwm.diagram.DropZone.superclass.constructor.call(this,el,Ext.apply(this,{ddGroup:uwm.Constants.DD_GROUP},config));this.diagram=config.diagram;}
Ext.extend(uwm.diagram.DropZone,Ext.dd.DropZone);uwm.diagram.DropZone.prototype.getTargetFromEvent=function(e){return e.getTarget();}
uwm.diagram.DropZone.prototype.onNodeOver=function(nodeData,source,e,data){return this.checkDropable(data.data);}
uwm.diagram.DropZone.prototype.onNodeDrop=function(nodeData,source,e,data){oid=null;var modelData=data.data;var result=this.checkDropable(modelData);if(result==this.dropAllowed){var dropWindowId=this.diagram.showDropWindow(e.xy[0],e.xy[1]);var xOffset=this.diagram.getWorkflow().getAbsoluteX();var yOffset=this.diagram.getWorkflow().getAbsoluteY();var scrollLeft=this.diagram.getWorkflow().getScrollLeft();var scrollTop=this.diagram.getWorkflow().getScrollTop();var x=e.xy[0]-xOffset+scrollLeft;var y=e.xy[1]-yOffset+scrollTop;if(modelData instanceof uwm.model.ModelObject){this.diagram.addExistingObject(modelData,x,y,dropWindowId);}else{this.diagram.createNewObject(modelData,x,y,dropWindowId);}}
return result;}
uwm.diagram.DropZone.prototype.checkDropable=function(modelData){var result=this.dropNotAllowed;if(modelData instanceof uwm.model.ModelObject){if(!this.diagram.containsObject(modelData)){result=this.dropAllowed;}}else if(modelData instanceof uwm.model.ModelClass){result=modelData.canCreateNewInDiagram(this.diagram)?this.dropAllowed:this.dropNotAllowed;}
if(!this.checkSemanticGroup(modelData)){result=this.dropNotAllowed;}
return result;}
uwm.diagram.DropZone.prototype.checkSemanticGroup=function(modelData){var result=false;for(var i=0;i<this.diagram.supportedGroups.length;i++){if(!Ext.isArray(modelData.semanticGroup)){if(this.diagram.supportedGroups[i]==modelData.semanticGroup){result=true;break;}}else{if(modelData.semanticGroup.indexOf(this.diagram.supportedGroups[i])!=-1){result=true;break;}}}
return result;}
Ext.namespace("uwm.diagram");uwm.diagram.SelectionListener=function(diagram){this.diagram=diagram;}
uwm.diagram.SelectionListener.prototype.onSelectionChanged=function(figure){if(figure){if(figure instanceof uwm.graphics.figure.BaseFigure||figure instanceof uwm.graphics.figure.ClassFigure){if(this.diagram.isPropertyDisplay()){uwm.property.PropertyContainer.getInstance().showProperty(figure.getFigure().getModelObject());}}else if(figure instanceof uwm.graphics.figure.AbstractClassPart){if(this.diagram.isPropertyDisplay()){uwm.property.PropertyContainer.getInstance().showProperty(figure.getModelObject());}}else if(figure instanceof uwm.graphics.connection.BaseConnection){var relationObject=figure.getRelationObject();if(relationObject instanceof uwm.model.EditableRelation){uwm.property.PropertyContainer.getInstance().showProperty(relationObject);}}}}
Ext.namespace("uwm.diagram");uwm.diagram.WorkflowEventListener=function(diagram){this.diagram=diagram;draw2d.CommandStackEventListener.call(this);}
Ext.extend(uwm.diagram.WorkflowEventListener,draw2d.CommandStackEventListener);uwm.diagram.WorkflowEventListener.prototype.stackChanged=function(stackEvent){if(this.diagram.isEventHandler()){if(stackEvent.isPostChangeEvent()){var command=stackEvent.getCommand();if(command instanceof draw2d.CommandConnect){var source=command.source.getParent().getFigure().getModelObject();var target=command.target.getParent().getFigure().getModelObject();var connectionInfo=command.connectionInfo;var nmUwmClassName=command.nmUwmClassName;var newSource=source;var newTarget=target;if(connectionInfo.invertBackendRelation){newSource=target;newTarget=source;}
newTarget.associate(newSource,connectionInfo,nmUwmClassName,command.connection);}else if(command instanceof draw2d.CommandMove){var figure=command.figure;if(figure instanceof uwm.graphics.figure.BaseFigure||figure instanceof uwm.graphics.figure.ClassFigure){var modelObject=command.figure.getFigure();modelObject.changeProperties({PositionX:command.newX,PositionY:command.newY});}}else if(command instanceof draw2d.CommandResize){var modelObject=command.figure.getFigure();modelObject.changeProperties({Width:command.newWidth,Height:command.newHeight});}else if(command instanceof draw2d.CommandDelete){var figure=command.figure;if(figure instanceof uwm.graphics.figure.BaseFigure||figure instanceof uwm.graphics.figure.ClassFigure){var persistencyFigure=figure.getFigure();if(!persistencyFigure.getModelObject().isDeleted()){uwm.model.ModelContainer.getInstance().deleteByModelNode(persistencyFigure);}
this.diagram.removeFromCache(figure.getFigure());}else if(figure instanceof uwm.graphics.connection.BaseConnection){var source=figure.getSource().getParent().getFigure().getModelObject();var target=figure.getTarget().getParent().getFigure().getModelObject();var connectionInfo=source.getModelNodeClass().getConnectionInfo(target.getModelNodeClass());var relationObject=null;if(connectionInfo.nmUwmClassName){relationObject=figure.getRelationObject();if(relationObject){if(connectionInfo.connection){connectionInfo=connectionInfo.connection;}else{var connectionType=relationObject.getProperty("relationType");for(var i in connectionInfo.connections){var currConnection=connectionInfo.connections[i];if(!(currConnection instanceof Function)){if(currConnection.connectionType==connectionType){connectionInfo=currConnection;break;}}}}}}
var newSource=source;var newTarget=target;if(connectionInfo.invertBackendRelation){newSource=target;newTarget=source;}
newSource.disassociate(newTarget,connectionInfo,relationObject);}else if(figure instanceof uwm.graphics.figure.AbstractClassPart){}}}}}
Ext.namespace("uwm.diagram.autolayout");uwm.diagram.autolayout.JiggleObject=function(){this.booleanField=false;this.intField=0;this.objectField=null;this.context=null;}
uwm.diagram.autolayout.JiggleObject.prototype.getContext=function(){return this.context;}
uwm.diagram.autolayout.JiggleObject.prototype.setContext=function(c){this.context=c;}
uwm.diagram.autolayout.JiggleObject.prototype.square=function(d){return d*d;}
uwm.diagram.autolayout.JiggleObject.prototype.cube=function(d){return d*d*d;}
uwm.diagram.autolayout.JiggleObject.prototype.intSquare=function(n){return n*n;}
uwm.diagram.autolayout.JiggleObject.prototype.power=function(base,d){if(d==0)
return 1;else if(d==1)
return base;else if(d%2==0)
return this.intSquare(this.power(base,d/2));else
return base*this.intSquare(this.power(base,d/2));}
uwm.diagram.autolayout.ForceLaw=function(graph){uwm.diagram.autolayout.JiggleObject.call(this);this.graph=graph;this.cap=Number.MAX_VALUE/1000}
uwm.diagram.autolayout.ForceLaw.prototype=new uwm.diagram.autolayout.JiggleObject;uwm.diagram.autolayout.ForceLaw.prototype.getCap=function(){return this.cap;}
uwm.diagram.autolayout.ForceLaw.prototype.setCap=function(cap){this.cap=cap;}
uwm.diagram.autolayout.SpringLaw=function(graph,preferredEdgeLength){uwm.diagram.autolayout.ForceLaw.call(this,graph);this.preferredEdgeLength=preferredEdgeLength;}
uwm.diagram.autolayout.SpringLaw.prototype=new uwm.diagram.autolayout.ForceLaw;uwm.diagram.autolayout.SpringLaw.prototype.apply=function(negativeGradient){var m=this.graph.numberOfEdges;var d=this.graph.getDimensions();for(var i=0;i<m;i++){var e=this.graph.edges.get(i);var from=e.getFrom();var to=e.getTo();var fromWeight=from.getWeight();var toWeight=to.getWeight();var f=from.intField;var t=to.intField;var w=Math.min(this.springAttraction(e),this.cap/e.getLength());var fromCoords=from.getCoords();var toCoords=to.getCoords();for(var j=0;j<d;j++){var force=(toCoords[j]-fromCoords[j])*w;negativeGradient[f][j]+=force*toWeight;negativeGradient[t][j]-=force*fromWeight;}}}
uwm.diagram.autolayout.QuadraticSpringLaw=function(graph,preferredEdgeLength){uwm.diagram.autolayout.SpringLaw.call(this,graph,preferredEdgeLength);}
uwm.diagram.autolayout.QuadraticSpringLaw.prototype=new uwm.diagram.autolayout.SpringLaw;uwm.diagram.autolayout.QuadraticSpringLaw.prototype.springAttraction=function(edge){var r=uwm.diagram.autolayout.Cell.prototype.sumOfRadii(edge.getFrom(),edge.getTo());var len=edge.getLength();return(len-r)/this.preferredEdgeLength;}
uwm.diagram.autolayout.VertexVertexRepulsionLaw=function(graph,preferredEdgeLength){uwm.diagram.autolayout.ForceLaw.call(this,graph);this.preferredEdgeLength=preferredEdgeLength;this.barnesHutTheta=0;}
uwm.diagram.autolayout.VertexVertexRepulsionLaw.prototype=new uwm.diagram.autolayout.ForceLaw;uwm.diagram.autolayout.VertexVertexRepulsionLaw.prototype.getBarnesHutTheta=function(){return this.barnesHutTheta;}
uwm.diagram.autolayout.VertexVertexRepulsionLaw.prototype.setBarnesHutTheta=function(t){this.barnesHutTheta=t;}
uwm.diagram.autolayout.VertexVertexRepulsionLaw.prototype.apply=function(negativeGradient){if(this.barnesHutTheta>0){this.applyUsingBarnesHut(negativeGradient);}
var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();for(var i=0;i<n-1;i++){var v1=this.graph.vertices.get(i);var v1Coords=v1.getCoords();var weight1=v1.getWeight();for(var j=i+1;j<n;j++){var v2=this.graph.vertices.get(j);var w=Math.min(this.pairwiseRepulsion(v1,v2),this.cap/uwm.diagram.autolayout.Vertex.prototype.getDistance(v1,v2));var v2Coords=v2.getCoords();var weight2=v2.getWeight();for(var k=0;k<d;k++){var force=(v1Coords[k]-v2Coords[k])*w;negativeGradient[i][k]+=force*weight2;negativeGradient[j][k]-=force*weight1;}}}}
uwm.diagram.autolayout.VertexVertexRepulsionLaw.prototype.applyUsingBarnesHut=function(negativeGradient){var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();if(n<=1)
return;this.graph.recomputeBoundaries();var root=new uwm.diagram.autolayout.QuadTree(this.graph);for(var i=0;i<n;i++){var v=this.graph.vertices.get(i);var qt=v.getContext();var cur=qt;while(cur.getContext()!=this.graph){var p=cur.getContext();var numberOfSubtrees=this.power(2,d);for(var j=0;j<numberOfSubtrees;j++){var st=p.subtrees[j];if(cur!=st){this.computeQTRepulsion(qt,st,negativeGradient);}}
cur=p;}}
this.pushForcesDownTree(root);for(var i=0;i<n;i++){var v=this.graph.vertices.get(i);var qt=v.getContext();for(var j=0;j<d;j++){negativeGradient[i][j]+=qt.force[j];}
v.setContext(this.graph);}}
uwm.diagram.autolayout.VertexVertexRepulsionLaw.prototype.computeQTRepulsion=function(leaf,cell,negativeGradient){if(cell==null)
return;var d=leaf.getDimensions();if((cell.objectField==null)&&(!this.wellSeparated(leaf,cell))){var numberOfSubtrees=this.power(2,d);for(var i=0;i<numberOfSubtrees;i++){this.computeQTRepulsion(leaf,cell.subtrees[i],negativeGradient);}}
else{var w=Math.min(this.pairwiseRepulsion(leaf,cell),this.cap/uwm.diagram.autolayout.Cell.prototype.getDistance(leaf,cell));var leafWeight=leaf.getWeight();var cellWeight=cell.getWeight();var leafCoords=leaf.getCoords();var cellCoords=cell.getCoords();var i=leaf.intField;for(var j=0;j<d;j++){var force=0.5*w*(leafCoords[j]-cellCoords[j]);negativeGradient[i][j]+=force*cellWeight;cell.force[j]-=force*leafWeight;}}}
uwm.diagram.autolayout.VertexVertexRepulsionLaw.prototype.wellSeparated=function(leaf,cell){if(cell==null)
throw new Error("cell == null");if(cell.objectField!=null)
return true;else{var d=cell.getDimensions();var len=Number.MAX_VALUE;var lo=cell.getMin();var hi=cell.getMax();for(var i=0;i<d;i++){len=Math.min(len,hi[i]-lo[i]);}
var dist=uwm.diagram.autolayout.Cell.prototype.getDistance(leaf,cell);return((len/dist)<this.barnesHutTheta);}}
uwm.diagram.autolayout.VertexVertexRepulsionLaw.prototype.pushForcesDownTree=function(qt){if((qt!=null)&&(qt.objectField==null)&&(qt.getWeight()>0)){var d=qt.getDimensions();var numberOfSubtrees=this.power(2,d);for(var i=0;i<numberOfSubtrees;i++){for(var j=0;j<d;j++){qt.subtrees[i].force[j]+=qt.force[j];}}
for(var i=0;i<numberOfSubtrees;i++){this.pushForcesDownTree(qt.subtrees[i]);}}}
uwm.diagram.autolayout.HybridVertexVertexRepulsionLaw=function(graph,preferredEdgeLength){uwm.diagram.autolayout.VertexVertexRepulsionLaw.call(this,graph,preferredEdgeLength);}
uwm.diagram.autolayout.HybridVertexVertexRepulsionLaw.prototype=new uwm.diagram.autolayout.VertexVertexRepulsionLaw;uwm.diagram.autolayout.HybridVertexVertexRepulsionLaw.prototype.pairwiseRepulsion=function(c1,c2){var r=uwm.diagram.autolayout.Cell.prototype.sumOfRadii(c1,c2);var k=this.preferredEdgeLength+r;var dSquared=uwm.diagram.autolayout.Cell.prototype.getDistanceSquared(c1,c2);if(dSquared<k*k){return k*k/dSquared;}
else{return this.cube(k/uwm.diagram.autolayout.Cell.prototype.getDistance(c1,c2));}}
uwm.diagram.autolayout.ForceModel=function(graph){this.graph=graph;this.preferredEdgeLength=0;this.forceLaws=new draw2d.ArrayList();this.constraints=new draw2d.ArrayList();}
uwm.diagram.autolayout.ForceModel.prototype.getPreferredEdgeLength=function(){return this.preferredEdgeLength;}
uwm.diagram.autolayout.ForceModel.prototype.setPreferredEdgeLength=function(k){this.preferredEdgeLength=k;}
uwm.diagram.autolayout.ForceModel.prototype.addForceLaw=function(fl){this.forceLaws.add(fl);}
uwm.diagram.autolayout.ForceModel.prototype.removeForceLaw=function(fl){this.forceLaws.remove(fl);}
uwm.diagram.autolayout.ForceModel.prototype.addConstraint=function(c){this.constraints.add(c);}
uwm.diagram.autolayout.ForceModel.prototype.removeConstraint=function(c){this.constraints.remove(c);}
uwm.diagram.autolayout.ForceModel.prototype.getNegativeGradient=function(negativeGradient){var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();for(var i=0;i<n;i++){for(var j=0;j<d;j++){negativeGradient[i][j]=0;}
this.graph.vertices.get(i).intField=i;}
for(var i=0;i<this.forceLaws.getSize();i++){var law=this.forceLaws.get(i);law.apply(negativeGradient);}}
uwm.diagram.autolayout.ForceModel.prototype.getPenaltyVector=function(penaltyVector){var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();for(var i=0;i<n;i++){for(var j=0;j<d;j++){penaltyVector[i][j]=0;}
this.graph.vertices.get(i).intField=i;}
for(var i=0;i<this.constraints.getSize();i++){var constraint=this.constraints.get(i);constraint.apply(penaltyVector);}}
uwm.diagram.autolayout.Constraint=function(graph){uwm.diagram.autolayout.JiggleObject.call(this);this.graph=graph;}
uwm.diagram.autolayout.Constraint.prototype=new uwm.diagram.autolayout.JiggleObject;uwm.diagram.autolayout.ProjectionConstraint=function(graph,dimensions){uwm.diagram.autolayout.Constraint.call(this,graph);this.dimensions=dimensions;}
uwm.diagram.autolayout.ProjectionConstraint.prototype=new uwm.diagram.autolayout.Constraint;uwm.diagram.autolayout.ProjectionConstraint.prototype.apply=function(penalty){var d=this.graph.getDimensions();var n=this.graph.numberOfVertices;for(var i=0;i<n;i++){var coords=this.graph.vertices.get(i).getCoords();for(var j=this.dimensions;j<d;j++){penalty[i][j]+=(-coords[j]);}}}
uwm.diagram.autolayout.ForceDirectedOptimizationProcedure=function(graph,fm){uwm.diagram.autolayout.JiggleObject.call(this);this.graph=graph;this.forceModel=fm;this.constrained=false;}
uwm.diagram.autolayout.ForceDirectedOptimizationProcedure.prototype=new uwm.diagram.autolayout.JiggleObject;uwm.diagram.autolayout.ForceDirectedOptimizationProcedure.prototype.getConstrained=function(){return this.constrained;}
uwm.diagram.autolayout.ForceDirectedOptimizationProcedure.prototype.setConstrained=function(c){this.constrained=c;}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure=function(graph,fm,accuracy){uwm.diagram.autolayout.ForceDirectedOptimizationProcedure.call(this,graph,fm);this.maxCos=accuracy;this.negativeGradient=null;this.descentDirection=null;this.penaltyVector=null;this.penaltyFactor=0;this.stepSize=0.1;this.previousStepSize=0;}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype=new uwm.diagram.autolayout.ForceDirectedOptimizationProcedure;uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.improveGraph=function(){var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();if((this.negativeGradient==null)||(this.negativeGradient.length!=n)){this.negativeGradient=new Array();this.penaltyVector=new Array();for(var i=0;i<n;i++){this.negativeGradient[i]=new Array();this.penaltyVector[i]=new Array();}
this.getNegativeGradient();}
this.computeDescentDirection();return this.lineSearch();}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.reset=function(){this.negativeGradient=null;this.penaltyFactor=0;}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.computePenaltyFactor=function(){var m1=this.l2Norm(this.negativeGradient);var m2=this.l2Norm(this.penaltyVector);if(m2==0){this.penaltyFactor=0;}
else if(m1==0){this.penaltyFactor=1;}
else{var cos=this.dotProduct(this.negativeGradient,this.penaltyVector)/(m1*m2);var penaltyFactor=Math.max(0.00000001,(0.00000001-cos))*Math.max(1,(m1/m2));}}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.getNegativeGradient=function(){this.forceModel.getNegativeGradient(this.negativeGradient);if(this.constrained){this.getPenaltyVector();this.computePenaltyFactor();var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();for(var i=0;i<n;i++){for(var j=0;j<d;j++){this.negativeGradient[i][j]+=this.penaltyFactor*this.penaltyVector[i][j];}}}}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.getPenaltyVector=function(){this.forceModel.getPenaltyVector(this.penaltyVector);}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.lineSearch=function(){this.previousStepSize=0;var n=this.graph.numberOfVertices;var magDescDir=this.l2Norm(this.descentDirection);if(magDescDir<0.0001){return 0;}
var magLo=this.l2Norm(this.negativeGradient);this.step();this.getNegativeGradient();var magHi=this.l2Norm(this.negativeGradient);var m=magDescDir*magHi;var cos=this.dotProduct(this.negativeGradient,this.descentDirection)/m;var lo=0;var hi=Number.MAX_VALUE;var i=0;while(((cos<0)||(cos>this.maxCos))&&(hi-lo>0.00000001)){if(cos<0){hi=this.stepSize;this.stepSize=(lo+hi)/2;}
else{if(hi<Number.MAX_VALUE){lo=this.stepSize;this.stepSize=(lo+hi)/2;}
else{lo=this.stepSize;this.stepSize*=2;}}
this.step();this.getNegativeGradient();m=magDescDir*this.l2Norm(this.negativeGradient);cos=this.dotProduct(this.negativeGradient,this.descentDirection)/m;}
return this.l2Norm(this.negativeGradient);}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.step=function(){var n=this.graph.numberOfVertices;var s=this.stepSize-this.previousStepSize;for(var i=0;i<n;i++){this.graph.vertices.get(i).translate(s,this.descentDirection[i]);}
this.previousStepSize=this.stepSize;}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.dotProduct=function(u,v){var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();var sum=0;for(var i=0;i<n;i++){for(var j=0;j<d;j++){sum+=u[i][j]*v[i][j];}}
return sum;}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.l2Norm=function(vect){return Math.sqrt(this.dotProduct(vect,vect));}
uwm.diagram.autolayout.FirstOrderOptimizationProcedure.prototype.lInfinityNorm=function(vect){var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();var max=0;for(var i=0;i<n;i++){for(var j=0;j<d;j++){max=Math.max(max,Math.abs(vect[i][j]));}}
return max;}
uwm.diagram.autolayout.ConjugateGradients=function(graph,fm,accuracy,restartThreshold){uwm.diagram.autolayout.FirstOrderOptimizationProcedure.call(this,graph,fm,accuracy);this.magnitudeOfPreviousGradientSquared=null;this.previousDescentDirection=null;this.restartThreshold=0;if(restartThreshold){this.restartThreshold=restartThreshold;}}
uwm.diagram.autolayout.ConjugateGradients.prototype=new uwm.diagram.autolayout.FirstOrderOptimizationProcedure;uwm.diagram.autolayout.ConjugateGradients.prototype.reset=function(){this.negativeGradient=null;this.descentDirection=null;}
uwm.diagram.autolayout.ConjugateGradients.prototype.computeDescentDirection=function(){var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();var magnitudeOfCurrentGradientSquared=0;if((this.descentDirection==null)||(this.descentDirection.length!=n)){this.descentDirection=new Array();this.previousDescentDirection=new Array();for(var i=0;i<n;i++){this.descentDirection[i]=new Array();this.previousDescentDirection[i]=new Array();for(var j=0;j<d;j++){var temp=this.negativeGradient[i][j];this.descentDirection[i][j]=temp;magnitudeOfCurrentGradientSquared+=this.square(temp);}}}
else{for(var i=0;i<n;i++){for(var j=0;j<d;j++){var temp=this.negativeGradient[i][j];magnitudeOfCurrentGradientSquared+=this.square(temp);}}
if(magnitudeOfCurrentGradientSquared<0.000001){for(var i=0;i<n;i++){for(var j=0;j<d;j++){this.previousDescentDirection[i][j]=0;this.descentDirection[i][j]=0;}}
return;}
var w=magnitudeOfCurrentGradientSquared/this.magnitudeOfPreviousGradientSquared;var dotProduct=0;var magnitudeOfDescentDirectionSquared=0;var m;for(var i=0;i<n;i++){for(var j=0;j<d;j++){this.descentDirection[i][j]=this.negativeGradient[i][j]+
w*this.previousDescentDirection[i][j];dotProduct+=this.descentDirection[i][j]*this.negativeGradient[i][j];magnitudeOfDescentDirectionSquared+=this.square(this.descentDirection[i][j]);}}
m=magnitudeOfCurrentGradientSquared*magnitudeOfDescentDirectionSquared;if(dotProduct/Math.sqrt(m)<this.restartThreshold){this.descentDirection=null;this.computeDescentDirection();return;}}
this.magnitudeOfPreviousGradientSquared=magnitudeOfCurrentGradientSquared;for(var i=0;i<n;i++){for(var j=0;j<d;j++){this.previousDescentDirection[i][j]=this.descentDirection[i][j];}}}
uwm.diagram.autolayout.Cell=function(){uwm.diagram.autolayout.JiggleObject.call(this);this.dimensions=2;this.weight=0;this.coords=null;this.min=null;this.max=null;this.size=null;this.setDimensions(2);}
uwm.diagram.autolayout.Cell.prototype=new uwm.diagram.autolayout.JiggleObject;uwm.diagram.autolayout.Cell.prototype.getWeight=function(){return this.weight;}
uwm.diagram.autolayout.Cell.prototype.setWeight=function(w){this.weight=w;}
uwm.diagram.autolayout.Cell.prototype.getDimensions=function(){return this.dimensions;}
uwm.diagram.autolayout.Cell.prototype.setDimensions=function(d){this.dimensions=d;this.coords=new Array();this.size=new Array();this.min=new Array();this.max=new Array();}
uwm.diagram.autolayout.Cell.prototype.getCoords=function(){return this.coords;}
uwm.diagram.autolayout.Cell.prototype.setCoords=function(c){for(var i=0;i<this.dimensions;i++){this.coords[i]=c[i];}}
uwm.diagram.autolayout.Cell.prototype.getMin=function(){return this.min;}
uwm.diagram.autolayout.Cell.prototype.setMin=function(c){for(var i=0;i<this.dimensions;i++){this.min[i]=c[i];}
this.recomputeSize();}
uwm.diagram.autolayout.Cell.prototype.getMax=function(){return this.max;}
uwm.diagram.autolayout.Cell.prototype.setMax=function(c){for(var i=0;i<this.dimensions;i++){this.max[i]=c[i];}
this.recomputeSize();}
uwm.diagram.autolayout.Cell.prototype.recomputeSize=function(){for(var i=0;i<this.dimensions;i++){this.size[i]=this.max[i]-this.min[i];}}
uwm.diagram.autolayout.Cell.prototype.getSize=function(){return this.size;}
uwm.diagram.autolayout.Cell.prototype.setSize=function(c){for(var i=0;i<this.dimensions;i++){this.size[i]=c[i];}
this.recomputeBoundaries();}
uwm.diagram.autolayout.Cell.prototype.recomputeBoundaries=function(){for(var i=0;i<this.dimensions;i++){this.min[i]=this.coords[i]-this.size[i]/2;this.max[i]=this.coords[i]+this.size[i]/2;}}
uwm.diagram.autolayout.Cell.prototype.translate=function(scalar,vector){if(!vector){scalar=vector;scalar=1;}
for(var i=0;i<this.dimensions;i++){var translation=scalar*vector[i];this.coords[i]+=translation;this.min[i]+=translation;this.max[i]+=translation;}}
uwm.diagram.autolayout.Cell.prototype.getDistanceSquared=function(c1,c2){var sum=0;var d=c1.getDimensions();for(var i=0;i<d;i++)
sum+=this.square(c1.coords[i]-c2.coords[i]);return sum;}
uwm.diagram.autolayout.Cell.prototype.getDistanceSquaredPoint=function(cell,point){var sum=0;var d=cell.getDimensions();for(var i=0;i<d;i++)
sum+=this.square(cell.coords[i]-point[i]);return sum;}
uwm.diagram.autolayout.Cell.prototype.getDistance=function(c1,c2){return Math.sqrt(this.getDistanceSquared(c1,c2));}
uwm.diagram.autolayout.Cell.prototype.getDistancePoint=function(cell,point){return Math.sqrt(this.getDistanceSquaredPoint(cell,point));}
uwm.diagram.autolayout.Cell.prototype.sumOfRadii=function(c1,c2){var d=c1.getDimensions();var coords1=c1.getCoords();var coords2=c2.getCoords();var seg=new Array();for(var i=0;i<d;i++){seg[i]=coords2[i]-coords1[i];}
return this.radiusSegment(d,c1.getSize(),seg)+this.radiusSegment(d,c2.getSize(),seg);}
uwm.diagram.autolayout.Cell.prototype.radius=function(cell,point){var d=cell.getDimensions();var coords=cell.getCoords();var seg=new Array();for(var i=0;i<d;i++){seg[i]=point[i]-coords[i];}
return this.radiusSegment(d,cell.getSize(),seg);}
uwm.diagram.autolayout.Cell.prototype.radiusSegment=function(d,cellSize,segment){var sum=0;for(var i=0;i<d;i++){sum+=cellSize[i];}
if(sum==0){return 0;}
var t=Number.MAX_VALUE;for(var i=0;i<d;i++){t=Math.min(t,Math.abs(cellSize[i]/segment[i]));}
var lengthSquared=0;for(var i=0;i<d;i++){lengthSquared+=this.square(t*segment[i]);}
return Math.sqrt(lengthSquared)/2;}
uwm.diagram.autolayout.QuadTree=function(graph,max,parent){uwm.diagram.autolayout.Cell.call(this);this.objectField=null;this.subtrees=new Array();var d;if(!max){this.setContext(graph);d=graph.getDimensions();this.setDimensions(d);var n=graph.numberOfVertices;this.setMin(graph.getMin());this.setMax(graph.getMax());for(var i=0;i<n;i++){graph.vertices.get(i).objectField=null;}
for(var i=0;i<n;i++){this.insert(graph.vertices.get(i));}}
else{this.setContext(parent);d=parent.getDimensions();this.setDimensions(d);this.setMin(graph);this.setMax(max);}
this.force=new Array();for(var i=0;i<d;i++){this.force[i]=0;}}
uwm.diagram.autolayout.QuadTree.prototype=new uwm.diagram.autolayout.Cell;uwm.diagram.autolayout.QuadTree.prototype.lookUp=function(v){if(this.objectField==v){return this;}
else if(this.objectField!=null){return null;}
else{return this.subtrees[this.getIndex(v)].lookUp(v);}}
uwm.diagram.autolayout.QuadTree.prototype.getIndex=function(v){var c=v.getCoords();var center=this.getCenter();var d=this.getDimensions();var index=0
var column=1;for(var i=0;i<d;i++){if(c[i]>center[i]){index+=column;}
column*=2;}
return index;}
uwm.diagram.autolayout.QuadTree.prototype.getCenter=function(){var d=this.getDimensions();var mp=new Array();var lo=this.getMin();var hi=this.getMax();for(var i=0;i<d;i++){mp[i]=(lo[i]+hi[i])/2;}
return mp;}
uwm.diagram.autolayout.QuadTree.prototype.recomputeSize=function(){}
uwm.diagram.autolayout.QuadTree.prototype.recomputeBoundaries=function(){}
uwm.diagram.autolayout.QuadTree.prototype.insert=function(v){var w=this.getWeight();var vw=v.getWeight();var d=this.getDimensions();var vCoords=v.getCoords();var vSize=v.getSize();if(w==0){v.setContext(this);this.setWeight(v.getWeight());this.setCoords(vCoords);this.setSize(v.getSize());this.objectField=v;return;}
if(this.objectField!=null){this.splitCell();}
var c=this.getCoords();var s=this.getSize();for(var i=0;i<d;i++){c[i]=(c[i]*w+vCoords[i]*vw)/(w+vw);s[i]=(s[i]*w+vSize[i]*vw)/(w+vw);}
this.setWeight(w+vw);this.subtrees[this.getIndex(v)].insert(v);}
uwm.diagram.autolayout.QuadTree.prototype.splitCell=function(){var v=this.objectField;this.objectField=null;var cellMin=this.getMin();var cellMax=this.getMax();var center=this.getCenter();var d=this.getDimensions();var n=this.power(2,d);var lo=new Array();var hi=new Array();for(var index=0;index<n;index++){var column=1;for(var i=0;i<d;i++){if((index&column)>0){lo[i]=center[i];hi[i]=cellMax[i];}
else{lo[i]=cellMin[i];hi[i]=center[i];}
column*=2;}
this.subtrees[index]=new uwm.diagram.autolayout.QuadTree(lo,hi,this);}
this.subtrees[this.getIndex(v)].insert(v);}
uwm.diagram.autolayout.Vertex=function(graph){uwm.diagram.autolayout.Cell.call(this);this.undirectedDegree=0;this.inDegree=0
this.outDegree=0;this.undirectedEdges=new draw2d.ArrayList();this.inEdges=new draw2d.ArrayList();this.outEdges=new draw2d.ArrayList();this.undirectedNeighbors=new draw2d.ArrayList();this.inNeighbors=new draw2d.ArrayList();this.outNeighbors=new draw2d.ArrayList();this.name="";this.fixed=false;this.setContext(graph);this.setWeight(1);this.setDimensions(graph.getDimensions());}
uwm.diagram.autolayout.Vertex.prototype=new uwm.diagram.autolayout.Cell;uwm.diagram.autolayout.Vertex.prototype.getName=function(){return this.name;}
uwm.diagram.autolayout.Vertex.prototype.setName=function(str){this.name=str;}
uwm.diagram.autolayout.Vertex.prototype.getFixed=function(){return this.fixed;}
uwm.diagram.autolayout.Vertex.prototype.setFixed=function(f){this.fixed=f;}
uwm.diagram.autolayout.Vertex.prototype.insertNeighbor=function(e){var from=e.getFrom();var to=e.getTo();var v=null;if(this==from){v=to;}
else if(this==to){v=from;}
else{throw new uwm.diagram.autolayout.Error(e+" not incident to "+this);}
if(!e.getDirected()){this.undirectedEdges.add(e);this.undirectedNeighbors.add(v);this.undirectedDegree++;}
else if(this==from){this.outEdges.add(e);this.outNeighbors.add(to);this.outDegree++;}
else{this.inEdges.add(e);this.inNeighbors.add(from);this.inDegree++;}}
uwm.diagram.autolayout.Vertex.prototype.deleteNeighbor=function(e){var from=e.getFrom();var to=e.getTo();var v=null;if(this==from){v=to;}
else if(this==to){v=from;}
else{throw new uwm.diagram.autolayout.Error(e+" not incident to "+this);}
try{if(!e.getDirected()){this.undirectedEdges.remove(e);this.undirectedNeighbors.remove(v);this.undirectedDegree--;}
else if(this==from){this.outEdges.remove(e);this.outNeighbors.remove(to);this.outDegree--;}
else{this.inEdges.remove(e);this.inNeighbors.remove(from);this.inDegree--;}}
catch(exc){throw new uwm.diagram.autolayout.Error(e+" not incident to "+this);}}
uwm.diagram.autolayout.Vertex.prototype.toString=function(){return"(Vertex: "+this.name+")";}
uwm.diagram.autolayout.Edge=function(graph,from,to,directed){uwm.diagram.autolayout.JiggleObject.call(this);this.from=from;this.to=to;this.label=null;this.directed=false;if(directed){this.directed=directed;}
this.preferredLength=0;this.setContext(graph);}
uwm.diagram.autolayout.Edge.prototype=new uwm.diagram.autolayout.JiggleObject;uwm.diagram.autolayout.Edge.prototype.getFrom=function(){return this.from;}
uwm.diagram.autolayout.Edge.prototype.getTo=function(){return this.to;}
uwm.diagram.autolayout.Edge.prototype.getLabel=function(){return this.label;}
uwm.diagram.autolayout.Edge.prototype.setLabel=function(lbl){this.label=lbl;}
uwm.diagram.autolayout.Edge.prototype.getDirected=function(){return this.directed;}
uwm.diagram.autolayout.Edge.prototype.setDirected=function(d){this.directed=d;}
uwm.diagram.autolayout.Edge.prototype.getPreferredLength=function(){return this.preferredLength;}
uwm.diagram.autolayout.Edge.prototype.setPreferredLength=function(len){this.preferredLength=len;}
uwm.diagram.autolayout.Edge.prototype.getLengthSquared=function(){return uwm.diagram.autolayout.Vertex.prototype.getDistanceSquared(this.from,this.to);}
uwm.diagram.autolayout.Edge.prototype.getLength=function(){return uwm.diagram.autolayout.Vertex.prototype.getDistance(this.from,this.to);}
uwm.diagram.autolayout.Edge.prototype.toString=function(){return"(Edge: "+this.from+", "+this.to+", "+
(this.directed?"directed":"undirected")+")";}
uwm.diagram.autolayout.EdgeLabel=function(edge,name){uwm.diagram.autolayout.Cell.call(this);this.name=name;this.setContext(e)}
uwm.diagram.autolayout.EdgeLabel.prototype=new uwm.diagram.autolayout.Cell;uwm.diagram.autolayout.EdgeLabel.prototype.getName=function(){return this.name;}
uwm.diagram.autolayout.EdgeLabel.prototype.setName=function(str){this.name=str;}
uwm.diagram.autolayout.EdgeLabel.prototype.toString=function(){return"(EdgeLabel: "+this.name+")";}
uwm.diagram.autolayout.Graph=function(dimensions){uwm.diagram.autolayout.Cell.call(this);this.numberOfVertices=0;this.numberOfMarkedVertices=0;this.numberOfEdges=0;this.vertices=new draw2d.ArrayList();this.edges=new draw2d.ArrayList();if(dimensions){this.setDimensions(dimensions);}}
uwm.diagram.autolayout.Graph.prototype=new uwm.diagram.autolayout.Cell;uwm.diagram.autolayout.Graph.prototype.insertVertex=function(){var v=new uwm.diagram.autolayout.Vertex(this);this.vertices.add(v);this.numberOfVertices++;return v;}
uwm.diagram.autolayout.Graph.prototype.insertEdge=function(from,to,dir){if(!dir){dir=false;}
var e=new uwm.diagram.autolayout.Edge(this,from,to,dir);from.insertNeighbor(e);to.insertNeighbor(e);this.edges.add(e);this.numberOfEdges++;return e;}
uwm.diagram.autolayout.Graph.prototype.deleteVertex=function(v){try{for(var i=0;i<v.inDegree;i++){var e=v.undirectedEdges.get(i);v.undirectedNeighbors.get(i).deleteNeighbor(e);this.edges.remove(e);this.numberOfEdges--;}
for(var i=0;i<v.inDegree;i++){var e=v.inEdges.get(i);v.inNeighbors.get(i).deleteNeighbor(e);this.edges.remove(e);this.numberOfEdges--;}
for(var i=0;i<v.outDegree;i++){var e=v.outEdges.get(i);v.outNeighbors.get(i).deleteNeighbor(e);this.edges.remove(e);this.numberOfEdges--;}
this.vertices.remove(v);this.numberOfVertices--;}
catch(exc){throw new uwm.diagram.autolayout.Error(v+" not found");}}
uwm.diagram.autolayout.Graph.prototype.deleteEdge=function(e){try{e.getFrom().deleteNeighbor(e);e.getTo().deleteNeighbor(e);this.edges.remove(e);this.numberOfEdges--;}
catch(exc){throw new uwm.diagram.autolayout.Error(e+" not found");}}
uwm.diagram.autolayout.Graph.prototype.recomputeBoundaries=function(){var d=this.getDimensions();var lo=this.getMin();var hi=this.getMax();for(var i=0;i<d;i++){lo[i]=Number.MAX_VALUE;hi[i]=-Number.MAX_VALUE;}
for(var i=0;i<this.numberOfVertices;i++){var v=this.vertices.get(i);var c=v.getCoords();for(var j=0;j<d;j++){lo[j]=Math.min(lo[j],c[j]);hi[j]=Math.max(hi[j],c[j]);}}
this.recomputeSize();}
uwm.diagram.autolayout.Graph.prototype.isConnected=function(){if(this.numberOfVertices==0){return false;}
for(var i=0;i<this.numberOfVertices;i++){this.vertices.get(i).booleanField=false;}
this.numberOfMarkedVertices=0;this.dft(vertices.get(0));return(this.numberOfMarkedVertices==this.numberOfVertices);}
uwm.diagram.autolayout.Graph.prototype.dft=function(v){v.booleanField=true;++this.numberOfMarkedVertices;for(var i=0;i<v.undirectedDegree;i++){var neighbor=v.undirectedNeighbors.get(i);if(!neighbor.booleanField){this.dft(neighbor);}}
for(var i=0;i<v.undirectedDegree;i++){var neighbor=v.inNeighbors.get(i);if(!neighbor.booleanField){this.dft(neighbor);}}
for(var i=0;i<v.undirectedDegree;i++){var neighbor=v.outNeighbors.get(i);if(!neighbor.booleanField){this.dft(neighbor);}}}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw=function(graph,preferredEdgeLength,strength){uwm.diagram.autolayout.ForceLaw.call(this,graph);this.preferredEdgeLength=preferredEdgeLength;this.strength=1;this.gridding=false;if(strength){this.strength=strength;}}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw.prototype=new uwm.diagram.autolayout.ForceLaw;uwm.diagram.autolayout.VertexEdgeRepulsionLaw.prototype.getGridding=function(){return gridding;}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw.prototype.setGridding=function(b){this.gridding=b;}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw.prototype.apply=function(negativeGradient){if(this.gridding){this.applyUsingGridding(negativeGradient);}
var n=this.graph.numberOfVertices;var m=this.graph.numberOfEdges;var d=this.graph.getDimensions();for(var i=0;i<n;i++){var v=this.graph.vertices.get(i);for(var j=0;j<m;j++){var e=this.graph.edges.get(j);var from=e.getFrom();var to=e.getTo();this.computeRepulsion(v,e,negativeGradient);}}}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw.prototype.applyUsingGridding=function(negativeGradient){this.graph.recomputeBoundaries();var n=this.graph.numberOfVertices;var m=this.graph.numberOfEdges;var d=this.graph.getDimensions();var gridSize=new Array();var drawingArea=this.graph.getSize();var k=this.preferredEdgeLength;for(var i=0;i<d;i++){gridSize[i]=parseInt(drawingArea[i]/k)+1;}
var grid=new draw2d.ArrayList();var gMin=this.graph.getMin();var index=new Array();var sign=new Array();for(var i=0;i<n;i++){var v=this.graph.vertices.get(i);var c=v.getCoords();for(var j=0;j<d;j++){index[j]=parseInt((c[j]-gMin[j])/k);}
var gridCell=grid.get(index);if(gridCell==null){grid.insertElementAt(new draw2d.ArrayList(),index);}
else{gridCell.add(v);}
v.objectField=index;}
for(var i=0;i<m;i++){var e=this.graph.edges.get(i);var from=e.getFrom();var to=e.getTo();var fCoords=from.getCoords();var tCoords=to.getCoords();for(var j=0;j<d;j++){if(fCoords[j]<tCoords[j]){sign[j]=1;}
else if(fCoords[j]>tCoords[j]){sign[j]=-1;}
else{sign[j]=0;}}
var current=from.objectField;var numberOfAdjs=this.power(3,d);var flag=true;while(flag||(!this.equal(current,to.objectField))){flag=false;for(var adj=0;adj<numberOfAdjs;adj++){var temp=adj;var doSecondPart=true;for(var j=0;j<d;j++){index[j]=current[j]+(temp%3)-1;if((index[j]<0)||(index[j]>=gridSize[j])){doSecondPart=false
temp/=3;}}
if(doSecondPart){var gridCell=grid.get(index);if((gridCell!=null)&&(!gridCell.booleanField)){for(var en=0;en<gridCell.length;en++){var v=gridCell[en];this.computeRepulsion(v,e,negativeGradient);}
gridCell.booleanField=true;}}}
var time;var minTime=Number.MAX_VALUE;var nextAxis=0;for(var axis=0;axis<d;axis++){if(sign[axis]==0){continue;}
if(sign[axis]==1){time=(current[axis]+1)*k/(tCoords[axis]-fCoords[axis]);}
else{time=current[axis]*k/(fCoords[axis]-tCoords[axis]);}
if(time<minTime){minTime=time;nextAxis=axis;}}
current[nextAxis]+=sign[nextAxis];}}}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw.prototype.equal=function(u,v){var d=u.length;for(var i=0;i<d;i++){if(u[i]!=v[i]){return false;}}
return true;}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw.prototype.computeRepulsion=function(v,e,negativeGradient){var from=e.getFrom();var to=e.getTo();if((from==v)||(to==v)){return;}
var d=v.getDimensions();var vCoords=v.getCoords();var fCoords=from.getCoords();var tCoords=to.getCoords();var dp=0;var lenSquared;for(var i=0;i<d;i++){dp+=(vCoords[i]-fCoords[i])*(tCoords[i]-fCoords[i]);}
if(dp<=0){this.computeRepulsionVertex(v,from,negativeGradient);}
else if(dp>=(lenSquared=e.getLengthSquared())){this.computeRepulsionVertex(v,to,negativeGradient);}
else{var len=Math.sqrt(lenSquared);var alpha=dp/len;var pCoords=new Array();for(var i=0;i<d;i++){pCoords[i]=(1-alpha)*fCoords[i]+alpha*tCoords[i];}
var w=Math.min(this.strength*this.pairwiseRepulsionCoords(v,pCoords),this.cap/uwm.diagram.autolayout.Vertex.prototype.getDistancePoint(v,pCoords));if(w==0){return;}
var vWeight=v.getWeight();var fWeight=from.getWeight();var tWeight=to.getWeight();for(var i=0;i<d;i++){var force1=(vCoords[i]-fCoords[i])*w*(1-alpha);var force2=(vCoords[i]-tCoords[i])*w*alpha;negativeGradient[v.intField][i]+=force1*fWeight;negativeGradient[from.intField][i]-=force1*vWeight;negativeGradient[v.intField][i]+=force2*tWeight;negativeGradient[to.intField][i]-=force2*vWeight;}}}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw.prototype.computeRepulsionVertex=function(v1,v2,negativeGradient){var d=v1.getDimensions();var w=Math.min(this.strength*this.pairwiseRepulsion(v1,v2),this.cap/uwm.diagram.autolayout.Vertex.prototype.getDistance(v1,v2));if(w==0){return;}
var v1Coords=v1.getCoords();var weight1=v1.getWeight();var v2Coords=v2.getCoords();var weight2=v2.getWeight();for(var i=0;i<d;i++){var force=(v1Coords[i]-v2Coords[i])*w;negativeGradient[v1.intField][i]+=force*weight2;negativeGradient[v2.intField][i]-=force*weight1;}}
uwm.diagram.autolayout.InverseSquareVertexEdgeRepulsionLaw=function(graph,preferredEdgeLength,strength){if(!strength){strength=1;}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw.call(this,graph,preferredEdgeLength,strength);}
uwm.diagram.autolayout.InverseSquareVertexEdgeRepulsionLaw.prototype=new uwm.diagram.autolayout.VertexEdgeRepulsionLaw;uwm.diagram.autolayout.InverseSquareVertexEdgeRepulsionLaw.prototype.pairwiseRepulsion=function(c1,c2){var k=this.preferredEdgeLength+uwm.diagram.autolayout.Cell.prototype.sumOfRadii(c1,c2);var d=uwm.diagram.autolayout.Cell.prototype.getDistance(c1,c2);if(d>=k){return 0;}
else{return this.cube(k/d)-k/d;}}
uwm.diagram.autolayout.InverseSquareVertexEdgeRepulsionLaw.prototype.pairwiseRepulsionCoords=function(cell,coords){var k=this.preferredEdgeLength+uwm.diagram.autolayout.Cell.prototype.radius(cell,coords);var d=uwm.diagram.autolayout.Cell.prototype.getDistancePoint(cell,coords);if(d>=k){return 0;}
else{return this.cube(k/d)-k/d;}}
uwm.diagram.autolayout.InverseSquareVertexVertexRepulsionLaw=function(graph,preferredEdgeLength){uwm.diagram.autolayout.VertexVertexRepulsionLaw.call(this,graph,preferredEdgeLength);}
uwm.diagram.autolayout.InverseSquareVertexVertexRepulsionLaw.prototype=new uwm.diagram.autolayout.VertexVertexRepulsionLaw;uwm.diagram.autolayout.InverseSquareVertexVertexRepulsionLaw.prototype.pairwiseRepulsion=function(c1,c2){var k=this.preferredEdgeLength+uwm.diagram.autolayout.Cell.prototype.sumOfRadii(c1,c2);return this.cube(k/uwm.diagram.autolayout.Cell.prototype.getDistance(c1,c2));}
uwm.diagram.autolayout.InverseVertexEdgeRepulsionLaw=function(graph,preferredEdgeLength,strength){if(!strength){strength=1;}
uwm.diagram.autolayout.VertexEdgeRepulsionLaw.call(this,graph,preferredEdgeLength,strength);}
uwm.diagram.autolayout.InverseVertexEdgeRepulsionLaw.prototype=new uwm.diagram.autolayout.VertexEdgeRepulsionLaw;uwm.diagram.autolayout.InverseVertexEdgeRepulsionLaw.prototype.pairwiseRepulsion=function(c1,c2){var k=this.preferredEdgeLength+uwm.diagram.autolayout.Cell.prototype.sumOfRadii(c1,c2);var dSquared=uwm.diagram.autolayout.Cell.prototype.getDistanceSquared(c1,c2);if(dSquared>=this.square(k)){return 0;}
else{return k*k/dSquared-k/Math.sqrt(dSquared);}}
uwm.diagram.autolayout.InverseVertexEdgeRepulsionLaw.prototype.pairwiseRepulsionCoords=function(cell,coords){var k=this.preferredEdgeLength+uwm.diagram.autolayout.Cell.prototype.radius(cell,coords);var dSquared=uwm.diagram.autolayout.Cell.prototype.getDistanceSquaredPoint(cell,coords);if(dSquared>=this.square(k)){return 0;}
else{return k*k/dSquared-k/Math.sqrt(dSquared);}}
uwm.diagram.autolayout.InverseVertexVertexRepulsionLaw=function(graph,preferredEdgeLength){uwm.diagram.autolayout.VertexVertexRepulsionLaw.call(this,graph,preferredEdgeLength);}
uwm.diagram.autolayout.InverseVertexVertexRepulsionLaw.prototype=new uwm.diagram.autolayout.VertexVertexRepulsionLaw;uwm.diagram.autolayout.InverseVertexVertexRepulsionLaw.prototype.pairwiseRepulsion=function(c1,c2){var k=this.preferredEdgeLength+uwm.diagram.autolayout.Cell.prototype.sumOfRadii(c1,c2);return k*k/uwm.diagram.autolayout.Cell.prototype.getDistanceSquared(c1,c2);}
uwm.diagram.autolayout.LinearSpringLaw=function(graph,preferredEdgeLength){uwm.diagram.autolayout.SpringLaw.call(this,graph,preferredEdgeLength);}
uwm.diagram.autolayout.LinearSpringLaw.prototype=new uwm.diagram.autolayout.SpringLaw;uwm.diagram.autolayout.LinearSpringLaw.prototype.springAttraction=function(e){var r=uwm.diagram.autolayout.Cell.prototype.sumOfRadii(e.getFrom(),e.getTo());if(r==0){return 1;}
else{return 1-r/e.getLength();}}
uwm.diagram.autolayout.StandardForceModel=function(graph,preferredEdgeLength,theta){uwm.diagram.autolayout.ForceModel.call(this,graph);this.preferredEdgeLength=preferredEdgeLength;var springLaw=new uwm.diagram.autolayout.QuadraticSpringLaw(graph,preferredEdgeLength);var vvRepulsionLaw=new uwm.diagram.autolayout.HybridVertexVertexRepulsionLaw(graph,preferredEdgeLength);this.addForceLaw(springLaw);this.addForceLaw(vvRepulsionLaw);this.addConstraint(new uwm.diagram.autolayout.ProjectionConstraint(graph,2));}
uwm.diagram.autolayout.SteepestDescent=function(graph,fm,accuracy){uwm.diagram.autolayout.FirstOrderOptimizationProcedure.call(this,graph,fm,accuracy);}
uwm.diagram.autolayout.SteepestDescent.prototype=new uwm.diagram.autolayout.FirstOrderOptimizationProcedure;uwm.diagram.autolayout.SteepestDescent.prototype.computeDescentDirection=function(){var n=this.graph.numberOfVertices;var d=this.graph.getDimensions();if((this.descentDirection==null)||(this.descentDirection.length!=n)){this.descentDirection=new Array();for(var i=0;i<n;i++){this.descentDirection[i]=new Array();}}
for(var i=0;i<n;i++){for(var j=0;j<d;j++){this.descentDirection[i][j]=this.negativeGradient[i][j];}}}
uwm.diagram.autolayout.Layouter=function(workflow){this.workflow=workflow;this.dimensions=2;this.preferredEdgeLength=100;this.optimizationProcedure=uwm.diagram.autolayout.Layouter.opt.CONJUGATE_GRADIENTS;this.lineSearchAccuracy=0.5;this.cgRestartThreshold=0.2;this.springs=uwm.diagram.autolayout.Layouter.spring.QUADRATIC;this.vertexVertexRepulsion=uwm.diagram.autolayout.Layouter.vvRepulsion.INVERSE_SQUARE;this.gridding=false;this.barnesHut=false;this.theta=0.9;this.iterations=25;}
uwm.diagram.autolayout.Layouter.opt={CONJUGATE_GRADIENTS:uwm.diagram.autolayout.ConjugateGradients,STEEPEST_DESCENT:uwm.diagram.autolayout.SteepestDescent};uwm.diagram.autolayout.Layouter.spring={QUADRATIC:uwm.diagram.autolayout.QuadraticSpringLaw,LINEAR:uwm.diagram.autolayout.LinearSpringLaw};uwm.diagram.autolayout.Layouter.vvRepulsion={INVERSE_SQUARE:uwm.diagram.autolayout.InverseSquareVertexVertexRepulsionLaw,INVERSE:uwm.diagram.autolayout.InverseVertexVertexRepulsionLaw,HYBRID:uwm.diagram.autolayout.HybridVertexVertexRepulsionLaw,INVERSE_SQUARE_EDGE:uwm.diagram.autolayout.InverseSquareVertexEdgeRepulsionLaw,INVERSE_EDGE:uwm.diagram.autolayout.InverseVertexEdgeRepulsionLaw}
uwm.diagram.autolayout.Layouter.prototype.getDimensions=function(){return this.dimensions;}
uwm.diagram.autolayout.Layouter.prototype.setDimenstion=function(d){this.dimensions=d;}
uwm.diagram.autolayout.Layouter.prototype.getPreferredEdgeLength=function(){return this.preferredEdgeLength;}
uwm.diagram.autolayout.Layouter.prototype.setPreferredEdgeLength=function(k){this.preferredEdgeLength=k;}
uwm.diagram.autolayout.Layouter.prototype.getOptimizationProcedure=function(){return this.optimizationProcedure;}
uwm.diagram.autolayout.Layouter.prototype.setOptimizationProcedure=function(o){this.optimizationProcedure=o;}
uwm.diagram.autolayout.Layouter.prototype.getLineSearchAccuracy=function(){return this.lineSearchAccuracy;}
uwm.diagram.autolayout.Layouter.prototype.setLineSearchAccuracy=function(l){this.lineSearchAccuracy=l;}
uwm.diagram.autolayout.Layouter.prototype.getCgRestartThreshold=function(){return this.cgRestartThreshold;}
uwm.diagram.autolayout.Layouter.prototype.setCgRestartThreshold=function(c){this.cgRestartThreshold=c;}
uwm.diagram.autolayout.Layouter.prototype.getSprings=function(){return this.springs;}
uwm.diagram.autolayout.Layouter.prototype.setSprings=function(s){this.springs=s;}
uwm.diagram.autolayout.Layouter.prototype.getVertexVertexRepulsion=function(){return this.vertexVertexRepulsion;}
uwm.diagram.autolayout.Layouter.prototype.setVertexVertexRepulsion=function(v){this.vertexVertexRepulsion=v;}
uwm.diagram.autolayout.Layouter.prototype.getGridding=function(){return this.gridding;}
uwm.diagram.autolayout.Layouter.prototype.setGridding=function(u){this.gridding=u;}
uwm.diagram.autolayout.Layouter.prototype.getBarnesHut=function(){return this.barnesHut;}
uwm.diagram.autolayout.Layouter.prototype.setBarnesHut=function(b){this.barnesHut=b;}
uwm.diagram.autolayout.Layouter.prototype.getTheta=function(){return this.theta;}
uwm.diagram.autolayout.Layouter.prototype.setTheta=function(t){this.theta=t;}
uwm.diagram.autolayout.Layouter.prototype.getIterations=function(){return this.iterations;}
uwm.diagram.autolayout.Layouter.prototype.setIterations=function(i){this.iterations=i;}
uwm.diagram.autolayout.Layouter.prototype.doLayout=function(){this.setupGraph();this.setupAndExecuteOptimization();this.moveFigures();}
uwm.diagram.autolayout.Layouter.prototype.setupGraph=function(){this.graph=new uwm.diagram.autolayout.Graph(this.dimensions);this.graph.setSize([this.workflow.getWidth(),this.workflow.getHeight()]);var workflowFigures=this.workflow.getFigures();this.figures=new draw2d.ArrayList();for(var i=0;i<workflowFigures.getSize();i++){var currFigure=workflowFigures.get(i);if(currFigure instanceof uwm.graphics.figure.BaseFigure||currFigure instanceof uwm.graphics.figure.ClassFigure){this.figures.add(currFigure);}}
this.vertexes=new draw2d.ArrayList();for(var i=0;i<this.figures.getSize();i++){var figure=this.figures.get(i);var vertex=this.graph.insertVertex();vertex.setName(figure.getId());vertex.setCoords([figure.getX(),figure.getY()]);vertex.setSize([figure.getWidth(),figure.getHeight()]);this.vertexes.add(vertex);}
var clusterIds=new Array();var nextClusterId=1;var clusters=new Array();for(var i=0;i<this.figures.getSize();i++){if(!clusterIds[i]){this.walkAndPopulateClusters(i,clusterIds,nextClusterId);nextClusterId++;}
var figure=this.figures.get(i);var ports=figure.getPorts();var numConnections=0;for(var j=0;j<ports.getSize();j++){var port=ports.get(j);var connections=port.getConnections();for(var k=0;k<connections.getSize();k++){numConnections++;var connection=connections.get(k);if(connection.getSource()==port){var from=this.vertexes.get(i);var targetPort=connection.getTarget();var targetFigure=targetPort.getParent();var targetIndex=this.figures.indexOf(targetFigure);var to=this.vertexes.get(targetIndex)
var edge=this.graph.insertEdge(from,to,true);}}}
var clustersEntry=clusters[clusterIds[i]];if(clustersEntry){if(clustersEntry.maxConnections<numConnections){clustersEntry.maxConnections=numConnections;clustersEntry.vertex=this.vertexes.get(i);}}
else{clusters[clusterIds[i]]={maxConnections:numConnections,vertex:this.vertexes.get(i)};}}
for(var i=1;i<clusters.length;i++){if(i!=1){var from=clusters[i-1].vertex;var to=clusters[i].vertex;var edge=this.graph.insertEdge(from,to,false);}
else{var from=clusters[clusters.length-1].vertex;var to=clusters[1].vertex;var edge=this.graph.insertEdge(from,to,false);}}}
uwm.diagram.autolayout.Layouter.prototype.setupAndExecuteOptimization=function(){var springLaw=new this.springs(this.graph,this.preferredEdgeLength);var vvRepulsionLaw=new this.vertexVertexRepulsion(this.graph,this.preferredEdgeLength);if(vvRepulsionLaw instanceof uwm.diagram.autolayout.VertexVertexRepulsionLaw&&this.barnesHut){vvRepulsionLaw.setBarnesHutTheta(this.theta);}
if(vvRepulsionLaw instanceof uwm.diagram.autolayout.VertexEdgeRepulsionLaw){vvRepulsionLaw.setGridding(this.gridding);}
var forceModel=new uwm.diagram.autolayout.ForceModel(this.graph);forceModel.addForceLaw(springLaw);forceModel.addForceLaw(vvRepulsionLaw);if(this.dimensions>0){forceModel.addConstraint(new uwm.diagram.autolayout.ProjectionConstraint(this.graph,this.dimensions));}
var opt=new this.optimizationProcedure(this.graph,forceModel,this.lineSearchAccuracy,this.cgRestartThreshold);for(var i=0;i<this.iterations;i++){opt.improveGraph();}}
uwm.diagram.autolayout.Layouter.prototype.moveFigures=function(){for(var i=0;i<this.vertexes.getSize();i++){var vertex=this.vertexes.get(i);var figure=this.figures.get(i);var coords=vertex.getCoords();var command=new draw2d.CommandMove(figure);command.setPosition(parseInt(coords[0]),parseInt(coords[1]));this.workflow.getCommandStack().execute(command);}}
uwm.diagram.autolayout.Layouter.prototype.walkAndPopulateClusters=function(index,clusterIds,thisClusterId){var figure=this.figures.get(index);if(!clusterIds[index]){clusterIds[index]=thisClusterId;var ports=figure.getPorts();for(var j=0;j<ports.getSize();j++){var port=ports.get(j);var connections=port.getConnections();for(var k=0;k<connections.getSize();k++){var connection=connections.get(k);if(connection.getSource()==port){var targetPort=connection.getTarget();var targetFigure=targetPort.getParent();var targetIndex=this.figures.indexOf(targetFigure);this.walkAndPopulateClusters(targetIndex,clusterIds,thisClusterId);}
else{var sourcePort=connection.getSource();var sourceFigure=sourcePort.getParent();var sourceIndex=this.figures.indexOf(sourceFigure);this.walkAndPopulateClusters(sourceIndex,clusterIds,thisClusterId);}}}}}
uwm.diagram.UwmWorkflow=function(id,diagram){draw2d.Workflow.call(this,id);this.diagram=diagram;this.buildContextMenu();}
Ext.extend(uwm.diagram.UwmWorkflow,draw2d.Workflow);uwm.diagram.UwmWorkflow.prototype.type="uwm.diagram.UwmWorkflow";uwm.diagram.UwmWorkflow.prototype.buildContextMenu=function(){var self=this;this.uwmContextMenu=new Ext.menu.Menu({items:[new Ext.menu.Item({text:uwm.Dict.translate("Show in model tree"),listeners:{click:function(){self.showInModelTree();}}}),new Ext.menu.CheckItem({itemId:uwm.diagram.UwmWorkflow.CONTEXT_MENU_SNAP_TO_OBJECTS,text:uwm.Dict.translate("Snap to objects"),listeners:{checkchange:function(item,checked){self.toggleSnapToObjects(item,checked);}}}),new Ext.menu.Item({text:uwm.Dict.translate("Auto-layout"),listeners:{click:function(){self.doLayout();}}}),new Ext.menu.Item({text:uwm.Dict.translate("Reload"),listeners:{click:function(){self.reloadDiagram();}}}),new Ext.menu.Item({text:uwm.Dict.translate("Print"),listeners:{click:function(){self.printDiagram();}}})]});}
uwm.diagram.UwmWorkflow.prototype.onContextMenu=function(x,y){var snapToObjects=this.uwmContextMenu.items.get(uwm.diagram.UwmWorkflow.CONTEXT_MENU_SNAP_TO_OBJECTS);snapToObjects.checked=this.diagram.isSnapToObjects();this.uwmContextMenu.showAt(this.diagram.getContextMenuPosition(x,y));this.oldX=null;this.html.style.cursor="default";}
uwm.diagram.UwmWorkflow.prototype.toggleSnapToObjects=function(item,checked){this.diagram.setSnapToObjects(checked);}
uwm.diagram.UwmWorkflow.prototype.doLayout=function(){this.diagram.doLayout();}
uwm.diagram.UwmWorkflow.prototype.showInModelTree=function(){this.diagram.showInModelTree();}
uwm.diagram.UwmWorkflow.prototype.reloadDiagram=function(){this.diagram.reloadDiagram();}
uwm.diagram.UwmWorkflow.prototype.printDiagram=function(){this.diagram.printDiagram();}
uwm.diagram.UwmWorkflow.prototype.showMenu=function(menu,xPos,yPos){}
uwm.diagram.UwmWorkflow.prototype.getDiagram=function(){return this.diagram;}
uwm.diagram.UwmWorkflow.prototype.onMouseDown=function(x,y){this.oldX=x;this.oldY=y;this.html.style.cursor="pointer";}
uwm.diagram.UwmWorkflow.prototype.onMouseUp=function(x,y){if(this.oldX){var deltaX=x-this.oldX;var deltaY=y-this.oldY;this.scrollTo(this.getScrollLeft()-deltaX,this.getScrollTop()-deltaY,true);this.oldX=null;this.oldY=null;}
this.html.style.cursor="default";}
uwm.diagram.UwmWorkflow.prototype.onMouseMove=function(x,y){if(this.oldX){var deltaX=x-this.oldX;var deltaY=y-this.oldY;this.scrollTo(this.getScrollLeft()-deltaX,this.getScrollTop()-deltaY,true);}}
uwm.diagram.UwmWorkflow.CONTEXT_MENU_SNAP_TO_OBJECTS="snapToObjects"
Ext.namespace("uwm.diagram");uwm.diagram.DiagramBase=function(modelNodeClass){uwm.diagram.DiagramBase.superclass.constructor.call(this,modelNodeClass);}
Ext.extend(uwm.diagram.DiagramBase,uwm.model.ModelNode);uwm.diagram.DiagramBase.prototype.initByDisplayResult=function(node){uwm.diagram.DiagramBase.superclass.initByDisplayResult.call(this,node);this.data.Alias=node.values[1].Alias;this.data.Version=node.values[1].Version;this.data.Name=node.values[1].Name;this.data.Notes=node.values[1].Notes;this.data.created=node.values[1].created;this.data.creator=node.values[1].creator;this.data.last_editor=node.values[1].last_editor;this.data.modified=node.values[1].modified;}
uwm.diagram.DiagramBase.prototype.populatePropertyForm=function(form){var realForm=form.getForm();realForm.findField("Alias").loadValue(this.data.Alias);realForm.findField("Version").loadValue(this.data.Version);realForm.findField("Name").loadValue(this.data.Name);realForm.findField("Notes").loadValue(this.data.Notes);realForm.findField("created").loadValue(this.data.created);realForm.findField("creator").loadValue(this.data.creator);realForm.findField("last_editor").loadValue(this.data.last_editor);realForm.findField("modified").loadValue(this.data.modified);}
Ext.namespace("uwm.diagram");uwm.diagram.AbstractDiagramClass=function(){uwm.diagram.AbstractDiagramClass.superclass.constructor.call(this);this.uwmClassName="AbstractDiagram";this.instanceClassName="uwm.diagram.AbstractDiagram";this.treeIcon="FigureDiagram";this.defaultLabel="New Diagram";this.labelProperties={Name:true};}
Ext.extend(uwm.diagram.AbstractDiagramClass,uwm.model.ModelNodeClass);uwm.diagram.AbstractDiagramClass.prototype.getPropertyForm=function(modelNode){return new uwm.property.PropertyForm({items:[new uwm.property.TextField({fieldLabel:'Name',name:'Name',modelNode:modelNode}),new uwm.property.HtmlEditor({fieldLabel:'Notes',name:'Notes',modelNode:modelNode}),new uwm.property.TextField({fieldLabel:'Alias',name:'Alias',modelNode:modelNode}),new uwm.property.TextField({fieldLabel:'Version',name:'Version',modelNode:modelNode}),new uwm.property.TextField({fieldLabel:'created',name:'created',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:'creator',name:'creator',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:'last_editor',name:'last_editor',modelNode:modelNode,readOnly:true}),new uwm.property.TextField({fieldLabel:'modified',name:'modified',modelNode:modelNode,readOnly:true})]});}
Ext.namespace("uwm.diagram");uwm.diagram.AbstractDiagram=function(modelNodeClass){uwm.diagram.AbstractDiagram.superclass.constructor.call(this,modelNodeClass);this.containedPackage=null;this.propertyDisplayEnabled=true;this.eventHandlerEnabled=true;this.semanticGroups=['Use Cases','requirements','domain',"activity","configuration"];this.figures=new Ext.util.MixedCollection();this.objects=new Ext.util.MixedCollection();this.dropWindows=new Ext.util.MixedCollection();this.canvas=null;var self=this;uwm.event.EventBroker.getInstance().addListener({"delete":function(modelObject){self.handleDeleteEvent(modelObject);},"changeLabel":function(modelObject,oldLabel,newLabel){self.handleChangeLabelEvent(modelObject,oldLabel,newLabel);},"associate":function(parentModelObject,childModelObject){self.handleAssociateEvent(parentModelObject,childModelObject);}});}
Ext.extend(uwm.diagram.AbstractDiagram,uwm.diagram.DiagramBase);uwm.diagram.AbstractDiagram.prototype.initByDisplayResult=function(node){uwm.diagram.AbstractDiagram.superclass.initByDisplayResult.call(this,node);}
uwm.diagram.AbstractDiagram.prototype.getOwnContainer=function(){var self=this;uwm.model.ModelContainer.getInstance().loadByOid(this.parentOids[0],self.actionSet,0,function(packageModel){self.setContainedPackage(packageModel);});}
uwm.diagram.AbstractDiagram.prototype.setContainedPackage=function(packageModel){this.containedPackage=packageModel;}
uwm.diagram.AbstractDiagram.prototype.init=function(){var container=uwm.diagram.DiagramContainer.getInstance();this.tab=new uwm.diagram.DiagramTab({title:this.getLabel(),diagram:this});this.snapToObjects=false;this.workspaceWidth=10000;this.workspaceHeight=10000;container.getTabPanel().add(this.tab);this.createdObjects=new Array();this.actionSet=new uwm.persistency.ActionSet();}
uwm.diagram.AbstractDiagram.prototype.initWorkflow=function(){this.viewPort=this.tab.body;this.viewPort.applyStyles({overflow:"auto",display:"block",position:"fixed"});this.canvas=Ext.DomHelper.append(this.viewPort,{tag:"div"},true);this.canvas.applyStyles({width:this.workspaceWidth+"px",height:this.workspaceHeight+"px"})
uwm.Util.setElementUnselectable(this.viewPort.dom);this.workflow=new uwm.diagram.UwmWorkflow(this.canvas.id,this);this.workflow.diagram=this;this.workflow.setViewPort(this.viewPort.id);this.scrollToCenter();this.selectionListener=new uwm.diagram.SelectionListener(this);this.workflow.addSelectionListener(this.selectionListener);this.workflowEventListener=new uwm.diagram.WorkflowEventListener(this);this.workflow.getCommandStack().addCommandStackEventListener(this.workflowEventListener);this.layouter=new uwm.diagram.autolayout.Layouter(this.workflow);}
uwm.diagram.AbstractDiagram.prototype.containsObject=function(modelObject){return this.objects.containsKey(modelObject.getOid());}
uwm.diagram.AbstractDiagram.prototype.getContainedFigure=function(oid){return this.figures.get(oid);}
uwm.diagram.AbstractDiagram.prototype.scrollToObject=function(modelObject){var figure=this.figures.get(modelObject.getOid());var graphics=figure.getGraphics();var canvas=this.viewPort.getSize();this.getWorkflow().scrollTo(graphics.x-canvas.width/2+graphics.getWidth()/2,graphics.y-canvas.height/2+graphics.getHeight()/2);}
uwm.diagram.AbstractDiagram.prototype.isPropertyDisplay=function(){return this.propertyDisplayEnabled;}
uwm.diagram.AbstractDiagram.prototype.isEventHandler=function(){return this.eventHandlerEnabled;}
uwm.diagram.AbstractDiagram.prototype.scrollToCenter=function(){var workflow=this.workflow;var height=this.workspaceHeight/2;var width=this.workspaceWidth/2;var self=this;setTimeout(function(){workflow.scrollTo(height,width,true);},500);}
uwm.diagram.AbstractDiagram.prototype.getTab=function(){return this.tab;}
uwm.diagram.AbstractDiagram.prototype.initDropZone=function(){var self=this;this.dropZone=new uwm.diagram.DropZone(this.viewPort,{diagram:this});}
uwm.diagram.AbstractDiagram.prototype.loadFigures=function(forceReload){this.propertyDisplayEnabled=false;this.eventHandlerEnabled=false;this.loadMask=new Ext.LoadMask(this.tab.container);this.loadMask.show();if(!this.childOids||this.childOids.length==0){forceReload=true;}else if(!this.containedPackage){forceReload=true;}else{var firstFigureOid=null;for(var i=0;i<this.childOids.length;i++){if(uwm.Util.getUwmClassNameFromOid(this.childOids[i])=="Figure"){firstFigureOid=this.childOids[i];break;}}
if(firstFigureOid){if(!uwm.model.ModelContainer.getInstance().getByOid(firstFigureOid)){forceReload=true;}}}
if(forceReload){var self=this;uwm.model.ModelContainer.getInstance().loadByOid(this.getOid(),function(modelNode){self.handleLoaded();},1);}else{this.handleLoaded();}}
uwm.diagram.AbstractDiagram.prototype.handleLoaded=function(){this.figuresToLoad=0;var self=this;var modelContainer=uwm.model.ModelContainer.getInstance();this.getOwnContainer();for(i in this.childOids){if(!(this.childOids[i]instanceof Function)){var figure=modelContainer.getByOid(this.childOids[i]);var parentOids=figure.getParentOids();for(var j in parentOids){var parentOid=parentOids[j];if(!(parentOid instanceof Function)&&parentOid!=this.getOid()&&figure instanceof uwm.diagram.Figure){this.figures.add(parentOid,figure);modelContainer.loadByOid(parentOid,this.actionSet,2);}}}}
this.figuresToLoad=this.figures.getCount();this.actionSet.commit(function(){self.handleLoadedObjects();});if(this.figuresToLoad==0){this.propertyDisplayEnabled=true;this.eventHandlerEnabled=true;this.loadMask.hide();this.scrollToCenter();}}
uwm.diagram.AbstractDiagram.prototype.handleLoadedObjects=function(){var self=this;var modelContainer=uwm.model.ModelContainer.getInstance();this.figures.eachKey(function(key,val){self.handleLoadedObject(modelContainer.getByOid(key));});}
uwm.diagram.AbstractDiagram.prototype.handleLoadedObject=function(modelObject){var figure=this.figures.get(modelObject.getOid());figure.load(modelObject,this);this.objects.add(modelObject.getOid(),modelObject);if(modelObject instanceof uwm.model.ClassObject){this.reestablishExistingClass(modelObject);}
this.figuresToLoad--;if(this.figuresToLoad==0){for(var i in this.objects.keys){var object=this.objects.items[i];if(!(object instanceof Function)){this.establishExistingConnections(object,object.getParentOids(),'parent');this.establishExistingConnections(object,object.getChildOids(),'child');}}
this.propertyDisplayEnabled=true;this.eventHandlerEnabled=true;this.loadMask.hide();this.scrollToCenter();}}
uwm.diagram.AbstractDiagram.prototype.reestablishConnections=function(newObject){this.establishExistingConnections(newObject,newObject.parentOids,'parent');this.establishExistingConnections(newObject,newObject.childOids,'child');var oid=newObject.getOid();for(var i in this.objects.items){var object=this.objects.items[i];if(!(object instanceof Function)){if(object.parentOids){for(var j=0;j<object.parentOids.length;j++){if(object.parentOids[j]==oid){var list=new Array();list.push(object.parentOids[j])
this.establishExistingConnections(object,list,'parent');}}}
if(object.childOids){for(var k=0;k<object.childOids.length;k++){if(object.childOids[k]==oid){var list=new Array();list.push(object.childOids[k]);this.establishExistingConnections(object,list,'child');}}}}}}
uwm.diagram.AbstractDiagram.prototype.getConnectedObject=function(oid){var result=this.objects.get(oid);if(!result){for(i in this.objects.items){if(this.objects.items[i].oid==oid){result=this.objects.items[i];}}}
return result;}
uwm.diagram.AbstractDiagram.prototype.establishExistingConnections=function(newObject,list,listtype){if(list){for(var i=0;i<list.length;i++){var connectedObject=this.getConnectedObject(list[i]);var relationObject=null;if(!connectedObject){var nmtype=false;var childObject=uwm.model.ModelContainer.getInstance().getByOid(list[i]);if(childObject instanceof uwm.model.Relation){relationObject=childObject;var parentOids=childObject.getParentOids();nmtype=true;for(var j=0;j<Math.min(2,parentOids.length);j++){var currParentOid=parentOids[j];if(currParentOid!=newObject.getOid()){connectedObject=this.getConnectedObject(currParentOid);break;}}}}
if(connectedObject){var forbiddenListtype;var connectionInfo=newObject.getModelNodeClass().getConnectionInfo(connectedObject.getModelNodeClass());var createConnection=true;var maskedClass;if(connectionInfo){if(connectionInfo.nmUwmClassName&&relationObject){var maskedRelatedOid=newObject.getMaskedRelatedOid(relationObject.getOid());maskedClass=uwm.model.ModelNodeClassContainer.getInstance().getClass(uwm.Util.getUwmClassNameFromOid(maskedRelatedOid));if(((maskedClass instanceof uwm.model.RelationEndClass)&&maskedClass.getConnnectionEndRole()=="target")||maskedClass instanceof uwm.model.RelationClass){if(connectionInfo.connection){connectionInfo=connectionInfo.connection;}else{var relationType=relationObject.getProperty("relationType");for(var j=0;j<connectionInfo.connections.length;j++){var currConnectionInfo=connectionInfo.connections[j];if(currConnectionInfo.connectionType==relationType){connectionInfo=currConnectionInfo;break;}}}}else{createConnection=false;}}}else{createConnection=false;}
if(createConnection){if(!connectionInfo.nmSelf){if(!(maskedClass instanceof uwm.model.RelationClass)&&((connectedObject.getUwmClassName()==newObject.getUwmClassName())||(nmtype==true))){if(connectionInfo.invert){forbiddenListtype="child";}else{forbiddenListtype="parent";}}else{forbiddenListtype="parent";}}
if(!(listtype==forbiddenListtype)){if(connectionInfo.nmSelf&&connectionInfo.invertBackendRelation){var newFigure=this.figures.get(connectedObject.getOid());var connectedFigure=this.figures.get(newObject.getOid());}
else{var newFigure=this.figures.get(newObject.getOid());var connectedFigure=this.figures.get(connectedObject.getOid());}
var newPort=newFigure.getGraphics().getPorts().get(0);var connectedPort=connectedFigure.getGraphics().getPorts().get(0);this.createSpecificConnection(newObject,connectedObject,newPort,connectedPort,connectionInfo,true,undefined,relationObject);}}}}}}
uwm.diagram.AbstractDiagram.prototype.reestablishExistingClass=function(newObject){var childOids=newObject.getChildOids();var modelContainer=uwm.model.ModelContainer.getInstance();var figure=this.figures.get(newObject.getOid());for(var i=0;i<childOids.length;i++){var currChild=modelContainer.getByOid(childOids[i]);if(currChild instanceof uwm.model.AttributeObject){var propertyGraphics=new uwm.graphics.figure.Attribute(currChild.getLabel(),currChild);figure.getGraphics().addChildElement(propertyGraphics,true);}else if(currChild instanceof uwm.model.OperationObject){var operationGraphics=new uwm.graphics.figure.Operation(currChild.getLabel(),currChild);figure.getGraphics().addChildElement(operationGraphics,true);}}}
uwm.diagram.AbstractDiagram.prototype.createConnection=function(sourceObject,targetObject,sourcePort,targetPort,x,y){if(sourceObject.connectableWith(targetObject)){var child;if(sourceObject.getUwmClassName()==targetObject.getUwmClassName()&&targetObject.hasParent()&&!(sourceObject.getUwmClassName()=='ChiNode')){Ext.Msg.alert(uwm.Dict.translate('Forbidden connection'),uwm.Dict.translate('This object already has a parent. Please disconnect it from its parent and redraw this connection to change its parent.'))}else{var connectionInfo=sourceObject.getModelNodeClass().getConnectionInfo(targetObject.getModelNodeClass());if(!connectionInfo.nmUwmClassName){this.createSpecificConnection(sourceObject,targetObject,sourcePort,targetPort,connectionInfo);}else if(connectionInfo.connections){var menu=new Ext.menu.Menu();var self=this;for(var i=0;i<connectionInfo.connections.length;i++){var currConnectionInfo=connectionInfo.connections[i];menu.add(new Ext.menu.Item({text:currConnectionInfo.label,connectionInfo:currConnectionInfo,nmUwmClassName:currConnectionInfo.nmUwmClassName||connectionInfo.nmUwmClassName,handler:function(){self.createSpecificConnection(sourceObject,targetObject,sourcePort,targetPort,this.connectionInfo,undefined,this.nmUwmClassName,undefined);}}));}
menu.showAt(this.getContextMenuPosition(x,y));}else{this.createSpecificConnection(sourceObject,targetObject,sourcePort,targetPort,connectionInfo.connection,undefined,connectionInfo.nmUwmClassName);}}}}
uwm.diagram.AbstractDiagram.prototype.createSpecificConnection=function(sourceObject,targetObject,sourcePort,targetPort,connectionInfo,noCommand,nmUwmClassName,relationObject){var decorators=this.getConnectionTypeDecorators(connectionInfo.connectionType);var startPort;var endPort;if(connectionInfo.invert){startPort=targetPort;endPort=sourcePort;}else{startPort=sourcePort;endPort=targetPort;}
if(connectionInfo.invertBackendRelation){var tmpPort=startPort;startPort=endPort;endPort=tmpPort;}
var connection=new uwm.graphics.connection.BaseConnection(connectionInfo.label,decorators);if(!noCommand){var command=new draw2d.CommandConnect(this.workflow,startPort,endPort);command.connectionInfo=connectionInfo;command.nmUwmClassName=nmUwmClassName;command.relationObject=relationObject;command.setConnection(connection);this.workflow.getCommandStack().execute(command);}else{connection.setSource(startPort);connection.setTarget(endPort);connection.setRelationObject(relationObject);this.workflow.addFigure(connection);}}
uwm.diagram.AbstractDiagram.prototype.getConnectionTypeDecorators=function(connectionType){var result=new Array();switch(connectionType){case"aggregation":result.source=new uwm.graphics.connection.OpenDiamondDecorator();result.target=new uwm.graphics.connection.ArrowDecorator();break;case"composition":result.source=new uwm.graphics.connection.FilledDiamondDecorator();result.target=new uwm.graphics.connection.ArrowDecorator();break;case"realization":result.target=new uwm.graphics.connection.ClosedArrowDecorator();break;case"generalization":result.target=new uwm.graphics.connection.ClosedArrowDecorator();break;case"association":result.target=new uwm.graphics.connection.ArrowDecorator();break;case"associationType":result.target=new uwm.graphics.connection.ArrowDecorator();break;default:result.target=new uwm.graphics.connection.ArrowDecorator();}
return result;}
uwm.diagram.AbstractDiagram.prototype.getWorkflow=function(){return this.workflow;}
uwm.diagram.AbstractDiagram.prototype.getCanvas=function(){return this.canvas;}
uwm.diagram.AbstractDiagram.prototype.isSnapToObjects=function(){return this.snapToObjects;}
uwm.diagram.AbstractDiagram.prototype.setSnapToObjects=function(snapToObjects){this.snapToObjects=snapToObjects;this.workflow.setSnapToGeometry(snapToObjects);}
uwm.diagram.AbstractDiagram.prototype.showInModelTree=function(){uwm.modeltree.ModelTree.getInstance().markNodeByOid(this.getOid());}
uwm.diagram.AbstractDiagram.prototype.reloadDiagram=function(){var container=uwm.diagram.DiagramContainer.getInstance();container.getTabPanel().remove(this.tab);uwm.diagram.DiagramContainer.getInstance().loadDiagram(this);}
uwm.diagram.AbstractDiagram.prototype.printDiagram=function(){var mask=new Ext.LoadMask(Ext.getBody(),{msg:uwm.Dict.translate("Loading...")});var printer=new uwm.diagram.print.Printer();mask.show();printer.print.defer(300,printer,[this,function(){mask.hide();}]);}
uwm.diagram.AbstractDiagram.prototype.doLayout=function(){this.layouter.doLayout();}
uwm.diagram.AbstractDiagram.prototype.getContextMenuPosition=function(x,y){var scroll=this.viewPort.getScroll();var xy=this.viewPort.getXY();return[x-scroll.left+xy[0]+2,y-scroll.top+xy[1]+2];}
uwm.diagram.AbstractDiagram.prototype.addExistingObject=function(modelObject,x,y,dropWindowId){var self=this;if(!this.objects.get(modelObject.getOid())){this.objects.add(modelObject.getOid(),modelObject);}
var actionSet=new uwm.persistency.ActionSet();uwm.model.ModelContainer.getInstance().loadByOid(modelObject.getOid(),actionSet,1);uwm.model.ModelContainer.getInstance().createFigure(this,modelObject,actionSet,function(newFigureNode){newFigureNode.init(modelObject,x,y);var modelClass=modelObject.getModelNodeClass();newFigureNode.changeProperties({PositionX:x,PositionY:y,Width:modelClass.getInitialWidth(),Height:modelClass.getInitialHeight()});self.figures.add(modelObject.getOid(),newFigureNode);self.reestablishConnections(modelObject);if(modelObject instanceof uwm.model.ClassObject){self.reestablishExistingClass(modelObject);}
if(dropWindowId){self.hideDropWindow(dropWindowId);}});actionSet.commit();}
uwm.diagram.AbstractDiagram.prototype.createNewObject=function(modelClass,x,y,dropWindowId){var self=this;var actionSet=new uwm.persistency.ActionSet();var newObjectOid=null;var newFigureOid=null;var savedObjectNode=null;var savedFigureNode=null;uwm.model.ModelContainer.getInstance().createModelObject(modelClass.getUwmClassName(),this.containedPackage,actionSet,function(newObjectNode){newObjectOid=newObjectNode.getOid();self.objects.add(newObjectNode.getOid(),newObjectNode);savedObjectNode=newObjectNode;});uwm.model.ModelContainer.getInstance().createFigure(this,undefined,actionSet,function(newFigureNode){newFigureOid=newFigureNode.getOid();newFigureNode.init(savedObjectNode,x,y);newFigureNode.changeProperties({PositionX:x,PositionY:y,Width:modelClass.getInitialWidth(),Height:modelClass.getInitialHeight()});self.figures.add(newObjectOid,newFigureNode);if(dropWindowId){self.hideDropWindow(dropWindowId);}
savedFigureNode=newFigureNode;});actionSet.addAssociate("{last_created_oid:Figure}","{last_created_oid:"+modelClass.getUwmClassName()+"}",function(request,data){uwm.event.EventBroker.getInstance().fireEvent("associate",savedFigureNode,savedObjectNode,false);});actionSet.commit();}
uwm.diagram.AbstractDiagram.prototype.getFigure=function(){return new uwm.diagram.Figure(uwm.model.ModelNodeClassContainer.getInstance().getClass("Figure"));}
uwm.diagram.AbstractDiagram.prototype.removeFromCache=function(figure){if(figure){var oid=figure.getModelObject().getOid();this.figures.removeKey(oid);this.objects.removeKey(oid);if(this.childOids){this.childOids.remove(figure.getOid());}}}
uwm.diagram.AbstractDiagram.prototype.handleDeleteEvent=function(modelNode){if(modelNode==this){uwm.diagram.DiagramContainer.getInstance().getTabPanel().remove(this.tab);}else if(modelNode instanceof uwm.model.AttributeObject||modelNode instanceof uwm.model.OperationObject){var parentModelNode=uwm.model.ModelContainer.getInstance().getByOid(modelNode.getParentOids()[0]);if(this.containsObject(parentModelNode)){parentModelNode.removeChild(modelNode,this.figures.get(parentModelNode.getOid()));}}else{var figure=this.figures.get(modelNode.getOid());if(figure){this.removeFromCache(figure);figure.remove();}}}
uwm.diagram.AbstractDiagram.prototype.handleChangeLabelEvent=function(modelNode,oldLabel,newLabel){if(modelNode.getLanguage()!=uwm.i18n.Localization.getInstance().getModelLanguage()){return;}
if(modelNode==this){if(this.tab){this.tab.setTitle(this.getLabel());}}else if(this.containsObject(modelNode)){var figure=this.figures.get(modelNode.getOid());if(figure){if(!newLabel){figure.getGraphics().setLabel(modelNode.getLabel());}else{figure.getGraphics().setLabel(newLabel);}}}else if(modelNode instanceof uwm.model.AttributeObject||modelNode instanceof uwm.model.OperationObject){var parentOids=modelNode.getParentOids();if(parentOids){var parentModelNode=uwm.model.ModelContainer.getInstance().getByOid(parentOids[0]);if(this.containsObject(parentModelNode)){parentModelNode.updateChildLabel(modelNode,this.figures.get(parentModelNode.getOid()));}}}}
uwm.diagram.AbstractDiagram.prototype.handleAssociateEvent=function(parentModelNode,childModelNode){if(parentModelNode instanceof uwm.model.builtin.Package&&childModelNode==this){uwm.diagram.DiagramContainer.getInstance().loadDiagram(this);}else if(childModelNode instanceof uwm.model.AttributeObject){var figure=this.figures.get(parentModelNode.getOid());if(figure){var graphics=figure.getGraphics();var propertyGraphics=new uwm.graphics.figure.Attribute(childModelNode.getLabel(),childModelNode);graphics.addChildElement(propertyGraphics,true);}}else if(childModelNode instanceof uwm.model.OperationObject){var figure=this.figures.get(parentModelNode.getOid());if(figure){var graphics=figure.getGraphics();var operationGraphics=new uwm.graphics.figure.Operation(childModelNode.getLabel(),childModelNode);graphics.addChildElement(operationGraphics,true);}}}
uwm.diagram.AbstractDiagram.prototype.showDropWindow=function(x,y,id){var dropWindow=new Ext.Window({x:x,y:y,plain:true,closable:false,draggable:false,resizable:false,items:[new Ext.Panel({html:"<div class='x-mask-loading'><div>"+uwm.Dict.translate('Loading ...')+"</div></div>"})]});dropWindow.show();if(!id){id=dropWindow.getId();}
this.dropWindows.add(id,dropWindow);return id;}
uwm.diagram.AbstractDiagram.prototype.hideDropWindow=function(id){if(this.dropWindows.containsKey(id)){this.dropWindows.get(id).destroy();this.dropWindows.removeKey(id);}}
Ext.namespace("uwm.diagram");uwm.diagram.DiagramClass=function(){uwm.diagram.DiagramClass.superclass.constructor.call(this);this.uwmClassName="Diagram";this.instanceClassName='uwm.diagram.Diagram';this.defaultLabel="New Diagram";}
Ext.extend(uwm.diagram.DiagramClass,uwm.diagram.AbstractDiagramClass);uwm.model.ModelNodeClassContainer.getInstance().registerClass(new uwm.diagram.DiagramClass());Ext.namespace("uwm.diagram");uwm.diagram.Diagram=function(modelNodeClass){this.supportedGroups=['UseCases','requirements','domain','configuration'];uwm.diagram.Diagram.superclass.constructor.call(this,modelNodeClass);}
Ext.extend(uwm.diagram.Diagram,uwm.diagram.AbstractDiagram);Ext.namespace("uwm.diagram");uwm.diagram.FigureClass=function(){uwm.model.ModelNodeClass.call(this);this.uwmClassName="Figure";this.instanceClassName="uwm.diagram.Figure";this.treeIcon="FigureFigure";this.labelProperties={};}
uwm.diagram.FigureClass.prototype=new uwm.model.ModelNodeClass;uwm.model.ModelNodeClassContainer.getInstance().registerClass(new uwm.diagram.FigureClass());Ext.namespace("uwm.diagram");uwm.diagram.Figure=function(modelNodeClass){uwm.model.ModelNode.call(this,modelNodeClass);}
Ext.extend(uwm.diagram.Figure,uwm.model.ModelNode);uwm.diagram.Figure.prototype.createNewObject=function(diagram,modelClass,x,y){this.diagram=diagram;this.modelObject=eval("new "+modelClass.getInstanceClassName()
+"(modelClass)");var workflow=diagram.getWorkflow();var compartment=null
this.graphics=this.getFigure(modelClass,modelClass.getDefaultLabel());workflow.getCommandStack().execute(new draw2d.CommandAdd(workflow,this.graphics,x,y,compartment));}
uwm.diagram.Figure.prototype.init=function(modelObject,x,y){this.modelObject=modelObject;var workflow=this.diagram.getWorkflow();var compartment=null
this.graphics=this.getFigure(modelObject.getModelNodeClass(),modelObject.getLabel());workflow.getCommandStack().execute(new draw2d.CommandAdd(workflow,this.graphics,x,y,compartment));}
uwm.diagram.Figure.prototype.load=function(modelObject,diagram){this.modelObject=modelObject;this.diagram=diagram;var x=this.getPositionX();var y=this.getPositionY();var workflow=diagram.getWorkflow();var compartment=null
this.graphics=this.getFigure(modelObject.getModelNodeClass(),modelObject.getLabel());this.graphics.setWorkflow(workflow);this.graphics.setDimension(this.getWidth(),this.getHeight());workflow.getCommandStack().execute(new draw2d.CommandAdd(workflow,this.graphics,x,y,compartment));}
uwm.diagram.Figure.prototype.getFigure=function(modelClass,label){return modelClass.getGraphics(label,this);}
uwm.diagram.Figure.prototype.getModelObject=function(){return this.modelObject;}
uwm.diagram.Figure.prototype.getDiagram=function(){return this.diagram;}
uwm.diagram.Figure.prototype.getGraphics=function(){return this.graphics;}
uwm.diagram.Figure.prototype.getPositionX=function(){return parseInt(this.data.PositionX);}
uwm.diagram.Figure.prototype.getPositionY=function(){return parseInt(this.data.PositionY);}
uwm.diagram.Figure.prototype.getWidth=function(){return parseInt(this.data.Width);}
uwm.diagram.Figure.prototype.getHeight=function(){return parseInt(this.data.Height);}
uwm.diagram.Figure.prototype.remove=function(){this.diagram.getWorkflow().getCommandStack().execute(new draw2d.CommandDelete(this.graphics));}
uwm.diagram.Figure.prototype.showInModelTree=function(){uwm.modeltree.ModelTree.getInstance().markNodeByOid(this.getModelObject().getOid());}
uwm.diagram.Figure.prototype.gridAvailable=function(){return uwm.objectgrid.ObjectGridContainer.getInstance().isGridAvailable(this.getModelObject());}
uwm.diagram.Figure.prototype.showInGrid=function(){uwm.objectgrid.ObjectGridContainer.getInstance().selectRow(this.getModelObject());}
uwm.diagram.Figure.prototype.showInHierarchy=function(){uwm.hierarchytree.HierarchyTree.getInstance().loadNode(this.getModelObject().getOid());}
uwm.diagram.Figure.prototype.deleteFromDiagram=function(){this.remove();}
uwm.diagram.Figure.prototype.deleteFromModel=function(){uwm.model.ModelContainer.getInstance().deleteByModelNode(this.getModelObject());}
uwm.diagram.Figure.prototype.showHelp=function(){uwm.ui.HelpViewer.getInstance().loadUrl(this.getModelObject().getModelNodeClass().getHelpUrl());}
uwm.diagram.Figure.prototype.showObjectHistory=function(self,e){new uwm.ui.History(this.modelObject);}
Ext.namespace("uwm.diagram");uwm.diagram.ActivitySet=function(modelNodeClass){this.supportedGroups=['activity'];uwm.diagram.ActivitySet.superclass.constructor.call(this,modelNodeClass);}
Ext.extend(uwm.diagram.ActivitySet,uwm.diagram.AbstractDiagram);uwm.diagram.ActivitySet.prototype.getOwnContainer=function(){this.containedPackage=this;}
Ext.namespace("uwm.diagram");uwm.diagram.ActivitySetClass=function(){uwm.diagram.ActivitySetClass.superclass.constructor.call(this);this.uwmClassName='ActivitySet';this.instanceClassName='uwm.diagram.ActivitySet';this.defaultLabel="New ActivitySet";this.treeIcon="FigureActivity";}
Ext.extend(uwm.diagram.ActivitySetClass,uwm.diagram.AbstractDiagramClass);uwm.model.ModelNodeClassContainer.getInstance().registerClass(new uwm.diagram.ActivitySetClass());Ext.namespace("uwm.diagram.print");uwm.diagram.print.Printer=function(){}
uwm.diagram.print.Printer.prototype.print=function(diagram,callback){var BORDER=50;var minX=Number.MAX_VALUE;var minY=Number.MAX_VALUE;var workflowFigures=diagram.getWorkflow().getFigures();for(var i=0;i<workflowFigures.getSize();i++){var currFigure=workflowFigures.get(i);minX=Math.min(minX,currFigure.getAbsoluteX());minY=Math.min(minY,currFigure.getAbsoluteY());}
var deltaX=minX;var deltaY=minY;for(var i=0;i<workflowFigures.getSize();i++){var currFigure=workflowFigures.get(i);if(currFigure.getParent()==null)
currFigure.setPosition(parseInt(currFigure.getAbsoluteX()-deltaX+BORDER),parseInt(currFigure.getAbsoluteY()-deltaY+BORDER));}
var currSelection=diagram.workflow.getCurrentSelection();diagram.workflow.setCurrentSelection(null);var diagramEl=Ext.get(Ext.get(diagram.getCanvas().id));var diagramStr=diagramEl.dom.innerHTML;var strTemplate='<html><head>';var strTemplate='<title>{0}</title>';strTemplate+='<link rel="stylesheet" type="text/css" href="css/common.css" />';strTemplate+='<link rel="stylesheet" type="text/css" href="css/figures.css" />';strTemplate+='<link rel="stylesheet" type="text/css" href="css/print.css" />';strTemplate+='</head><body onload="{1}"><div id="diagInfo">{0}</div>';strTemplate+='<div id="bgNote">'+uwm.Dict.translate('Please make sure that background printing is enabled in page setup.');strTemplate+='<br /><br />'+uwm.Dict.translate('NOTE: This message will not be printed.')+'</div>';strTemplate+='{2}';strTemplate+='</body></html>';var strHTML=String.format(strTemplate,diagram.getLabel(),Ext.isIE?'document.execCommand(\'print\');':'window.print();',diagramStr);var printWindow=window.open("","_blank");printWindow.document.open();printWindow.document.write(strHTML);printWindow.document.close();for(var i=0;i<workflowFigures.getSize();i++){var currFigure=workflowFigures.get(i);if(currFigure.getParent()==null)
currFigure.setPosition(parseInt(currFigure.getAbsoluteX()+deltaX-BORDER),parseInt(currFigure.getAbsoluteY()+deltaY-BORDER));}
diagram.workflow.setCurrentSelection(currSelection);if(callback instanceof Function){callback(this);}}
Ext.namespace("uwm.objecttree");uwm.objecttree.DragZone=function(el,config){uwm.objecttree.DragZone.superclass.constructor.call(this,el,Ext.apply(this,{ddGroup:uwm.Constants.DD_GROUP},config));this.el=el;}
Ext.extend(uwm.objecttree.DragZone,Ext.tree.TreeDragZone);uwm.objecttree.DragZone.prototype.getDragData=function(e){var result=uwm.objecttree.DragZone.superclass.getDragData.call(this,e);if(result){var node=result.node;if(node instanceof uwm.objecttree.Node){var sourceElement=e.getTarget();result.repairXY=Ext.fly(sourceElement).getXY();result.data=result.node.getModelNode();this.el.dragData=result;}}
return result;}
uwm.objecttree.DragZone.prototype.getRepairXY=function(){return this.dragData.repairXY;}
Ext.namespace("uwm.objecttree");uwm.objecttree.ObjectTree=function(config){uwm.objecttree.ObjectTree.superclass.constructor.call(this,Ext.apply(this,{autoScroll:true,animate:true,containerScroll:true,layout:"fit",enableDD:true,ddGroup:uwm.Constants.DD_GROUP},config));var self=this;this.on('show',function(){uwm.ui.ExistingContentContainer.getInstance().showPanel(self);});}
Ext.extend(uwm.objecttree.ObjectTree,Ext.tree.TreePanel);uwm.objecttree.ObjectTree.prototype.render=function(container,position){uwm.objecttree.ObjectTree.superclass.render.apply(this,arguments);new uwm.objecttree.DragZone(this,{});}
uwm.objecttree.ObjectTree.prototype.getTreeIcon=function(){return this.iconCls;}
uwm.objecttree.ObjectTree.prototype.getName=function(){return this.name;}
Ext.namespace("uwm.objecttree");uwm.objecttree.Node=function(config){uwm.objecttree.Node.superclass.constructor.call(this,Ext.apply(this,{},config));this.buildContextMenu();var self=this;this.on("contextmenu",function(node,e){self.showContextMenu(node,e);});this.on("click",function(node,e){self.showProperties(node,e);});}
Ext.extend(uwm.objecttree.Node,Ext.tree.AsyncTreeNode);uwm.objecttree.Node.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item,e);}}]});return this.contextMenu;}
uwm.objecttree.Node.prototype.showContextMenu=function(self,e){e.stopPropagation();self.contextMenu.showAt(e.getXY());}
uwm.objecttree.Node.prototype.deleteFromModel=function(self,e){uwm.model.ModelContainer.getInstance().deleteByModelNode(this.getModelNode());}
uwm.objecttree.Node.prototype.getModelNode=function(){return this.modelNode;}
uwm.objecttree.Node.prototype.showProperties=function(self,e){uwm.property.PropertyContainer.getInstance().showProperty(this.getModelNode());}
Ext.namespace("uwm.objecttree");uwm.objecttree.ObjectNode=function(config){uwm.objecttree.ObjectNode.superclass.constructor.call(this,Ext.apply(this,{},config));}
Ext.extend(uwm.objecttree.ObjectNode,uwm.objecttree.Node);uwm.objecttree.ObjectNode.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{itemId:uwm.objecttree.ObjectNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID,text:uwm.Dict.translate('Show in diagram'),handler:function(item,e){self.showInDiagram(item,e);}},{itemId:uwm.objecttree.ObjectNode.CONTEXTMENU_SHOW_IN_GRID_ID,text:uwm.Dict.translate('Show in grid'),handler:function(item,e){self.showInGrid(item.e);}},{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item,e);}},{text:uwm.Dict.translate('Duplicate'),handler:function(item,e){self.duplicate(item,e);}},{text:uwm.Dict.translate('Show object history'),handler:function(item,e){self.showObjectHistory(item,e);}},{text:uwm.Dict.translate('Help'),handler:function(item,e){self.showHelp(item,e);}}]});return this.contextMenu;}
uwm.objecttree.ObjectNode.prototype.showContextMenu=function(self,e){var showInDiagram=this.contextMenu.items.get(uwm.objecttree.ObjectNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID);var showInGrid=this.contextMenu.items.get(uwm.objecttree.ObjectNode.CONTEXTMENU_SHOW_IN_GRID_ID);var isInDiagram=this.containedInCurrentDiagram();showInDiagram.setDisabled(!isInDiagram);var isGridAvailable=this.gridAvailable();showInGrid.setDisabled(!isGridAvailable);uwm.objecttree.ObjectNode.superclass.showContextMenu(self,e);}
uwm.objecttree.ObjectNode.prototype.containedInCurrentDiagram=function(){return uwm.diagram.DiagramContainer.getInstance().isModelObjectContainedInCurrentDiagram(this.modelNode);}
uwm.objecttree.ObjectNode.prototype.gridAvailable=function(){return uwm.objectgrid.ObjectGridContainer.getInstance().isGridAvailable(this.modelNode);}
uwm.objecttree.ObjectNode.prototype.showInDiagram=function(self,e){uwm.diagram.DiagramContainer.getInstance().getCurrentDiagram().scrollToObject(this.modelNode);}
uwm.objecttree.ObjectNode.prototype.showInGrid=function(self,e){uwm.objectgrid.ObjectGridContainer.getInstance().selectRow(this.modelNode);}
uwm.objecttree.ObjectNode.prototype.showHelp=function(self,e){uwm.ui.HelpViewer.getInstance().loadUrl(this.modelNode.getModelNodeClass().getHelpUrl());}
uwm.objecttree.ObjectNode.prototype.showObjectHistory=function(self,e){new uwm.ui.History(this.modelNode);}
uwm.objecttree.Node.prototype.duplicate=function(self,e){uwm.model.ModelContainer.getInstance().duplicateObject(this.modelNode,this.parentNode.modelNode);}
uwm.objecttree.ObjectNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID="showInDiagram";uwm.objecttree.ObjectNode.CONTEXTMENU_SHOW_IN_GRID_ID="showInGrid";Ext.namespace("uwm.modeltree");uwm.modeltree.Loader=function(){}
uwm.modeltree.Loader=Ext.extend(Ext.tree.TreeLoader,{initComponent:function(){Ext.apply(this,{});uwm.modeltree.Loader.superclass.initComponent.apply(this,arguments);}})
uwm.modeltree.Loader.prototype.load=function(node,callback){var self=this;uwm.persistency.Persistency.getInstance().loadChildren(node.id,function(request,data){self.reformatData(self,node,callback,data);});}
uwm.modeltree.Loader.prototype.reformatData=function(self,node,callback,data){var changed=false;for(var i=0;i<data.objects.length;i++){changed=true;var responseNode=data['objects'][i];var uwmClassName=uwm.Util.getUwmClassNameFromOid(responseNode.oid);var newNode=null;switch(uwmClassName){case"Model":newNode=new uwm.modeltree.ModelNode({text:responseNode.text,oid:responseNode.oid});break;case"Package":newNode=new uwm.modeltree.PackageNode({text:responseNode.text,oid:responseNode.oid});break;case"Diagram":newNode=new uwm.modeltree.DiagramNode({text:responseNode.text,oid:responseNode.oid});break;case"ActivitySet":newNode=new uwm.modeltree.ActivitySetNode({text:responseNode.text,oid:responseNode.oid});break;case"ChiBusinessUseCase":newNode=new uwm.modeltree.UseCaseNode({text:responseNode.text,oid:responseNode.oid});break;case"ChiBusinessUseCaseCore":newNode=new uwm.modeltree.UseCaseCoreNode({text:responseNode.text,oid:responseNode.oid});break;case"ChiBusinessProcess":newNode=new uwm.modeltree.ProcessNode({text:responseNode.text,oid:responseNode.oid});break;case"Figure":case"NMUCActor":case"ChiUseCaseSourceEnd":case"ChiUseCaseTargetEnd":case"ChiUseCaseCoreSourceEnd":case"ChiUseCaseCoreTargetEnd":break;default:newNode=new uwm.modeltree.Node({text:responseNode.text,oid:responseNode.oid,uwmClassName:uwmClassName});break;}
if(newNode){node.appendChild(newNode);}}
if(callback instanceof Function){callback(this,node);}}
Ext.namespace("uwm.modeltree");uwm.modeltree.ModelTree=function(config){this.buildContextMenu();uwm.modeltree.ModelTree.superclass.constructor.call(this,Ext.apply(this,{id:uwm.modeltree.ModelTree.COMPONENT_ID,root:new Ext.tree.AsyncTreeNode({text:"root",draggable:false,id:'root'}),loader:new uwm.modeltree.Loader(),iconCls:"TreeTab",rootVisible:false,name:'Model Tree',enableDD:true,ddGroup:uwm.Constants.DD_GROUP,tabTip:"<b>"+uwm.Dict.translate('Model Tree')+"</b><p>"+uwm.Dict.translate('Shows all models, packages, and contained objects.')+"</p>"},config));uwm.modeltree.ModelTree.instance=this;var self=this;this.on("nodedragover",function(dragOverEvent){self.checkDroppable(dragOverEvent);});this.on("beforenodedrop",function(dropEvent){self.handleBeforeNodeDrop(dropEvent);});this.createdModels=new Ext.util.MixedCollection();this.createdPackages=new Ext.util.MixedCollection();this.createdDiagrams=new Ext.util.MixedCollection();this.disassociatedNodes=new Ext.util.MixedCollection();var self=this;uwm.event.EventBroker.getInstance().addListener({"create":function(modelObject){self.handleCreateEvent(modelObject);},"delete":function(modelObject){self.handleDeleteEvent(modelObject);},"changeLabel":function(modelObject,oldLabel,newLabel){self.handleChangeLabelEvent(modelObject,oldLabel,newLabel);},"associate":function(parentModelObject,childModelObject){self.handleAssociateEvent(parentModelObject,childModelObject);},"disassociate":function(parentModelObject,childModelObject){self.handleDisassociateEvent(parentModelObject,childModelObject);}});}
Ext.extend(uwm.modeltree.ModelTree,uwm.objecttree.ObjectTree);uwm.modeltree.ModelTree.prototype.render=function(container,position){uwm.modeltree.ModelTree.superclass.render.apply(this,arguments);var self=this;this.el.on("contextmenu",function(e,el){self.showContextMenu(self,e,el);});}
uwm.modeltree.ModelTree.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{text:uwm.Dict.translate('Create model'),handler:function(item,e){self.createModel();}}]});}
uwm.modeltree.ModelTree.prototype.showContextMenu=function(self,e,el){e.preventDefault();self.contextMenu.showAt(e.getXY());}
uwm.modeltree.ModelTree.prototype.checkDroppable=function(ddEvent){ddEvent.cancel=false;var insideTree=ddEvent.source.tree==this;var dropModelNode=null;if(ddEvent.dropNode){dropModelNode=ddEvent.dropNode.getModelNode();}
else{var uwmClassName=ddEvent.source.dragData.data.getUwmClassName();dropModelNode=uwm.model.ModelContainer.getInstance().createNodeInstance(uwmClassName);}
if(ddEvent.dropNode&&ddEvent.dropNode.parentNode==ddEvent.target){ddEvent.cancel=true;return;}
if(!insideTree&&ddEvent.point!="append"){ddEvent.cancel=true;return;}
var parentModelNode=this.getDropParentNode(ddEvent);var constraintsFulfilled=this.checkModelConstraints(parentModelNode,dropModelNode);ddEvent.cancel=!constraintsFulfilled;}
uwm.modeltree.ModelTree.prototype.getDropParentNode=function(dropEvent){var parentModelNode=null;if(dropEvent.point!="append"){var parentNode=dropEvent.target.parentNode;if(parentNode.id=='root'){parentModelNode=null;}
else{parentModelNode=parentNode.getModelNode();}}else{parentModelNode=dropEvent.target.getModelNode()}
return parentModelNode;}
uwm.modeltree.ModelTree.prototype.checkModelConstraints=function(parentModelNode,childModelNode){var result=true;if(parentModelNode==null&&!(childModelNode instanceof uwm.model.builtin.Model)){result=false;}
else if(parentModelNode instanceof uwm.model.builtin.Model){if(!(childModelNode instanceof uwm.model.builtin.Package)){result=false;}}
else if(parentModelNode instanceof cwm.ChiBusinessUseCase||parentModelNode instanceof cwm.ChiBusinessUseCaseCore){if(!(childModelNode instanceof uwm.diagram.ActivitySet)){result=false;}}
else if(parentModelNode instanceof cwm.ChiBusinessProcess){if(!(childModelNode instanceof cwm.ChiBusinessUseCase||childModelNode instanceof cwm.ChiBusinessUseCaseCore)){result=false;}}
else if(childModelNode instanceof uwm.model.builtin.Package){result=true;}
else if(childModelNode instanceof uwm.diagram.ActivitySet){result=false;}
else if(childModelNode.getSemanticGroup()=="activity"){if(!(parentModelNode instanceof uwm.diagram.ActivitySet)){result=false;}}
return result;}
uwm.modeltree.ModelTree.prototype.handleBeforeNodeDrop=function(dropEvent){this.checkDroppable(dropEvent);if(!dropEvent.cancel){if(!dropEvent.dropNode){var dropModelNode=dropEvent.source.dragData.data;var newType=dropModelNode.getUwmClassName();var parentNode=dropEvent.target.getModelNode();this.showCreateProgressNode(dropEvent.target,uwm.Dict.translate('Creating')+' '+newType+'...');if(uwm.Log.isEnabled(uwm.Log.DEBUG)){uwm.Log.log("insert: "+newType+" in "+parentNode.oid,uwm.Log.DEBUG);}
var actionSet=new uwm.persistency.ActionSet();uwm.model.ModelContainer.getInstance().createModelObject(newType,parentNode,actionSet);actionSet.commit();}
else{var actionSet=new uwm.persistency.ActionSet();var node=dropEvent.dropNode;var oldParent=node.parentNode;var newParentModelNode=this.getDropParentNode(dropEvent);if(oldParent instanceof uwm.objecttree.Node){var oldParentModelNode=oldParent.getModelNode();if(oldParentModelNode.getOid()!=newParentModelNode.getOid()){actionSet.addDisassociate(oldParentModelNode.getOid(),node.getModelNode().getOid());actionSet.addAssociate(newParentModelNode.getOid(),node.getModelNode().getOid(),false);}
if(dropEvent.point!="append"){var params=null;if(oldParentModelNode.getOid()==newParentModelNode.getOid()){var params=this.calculateSortParams(dropEvent);}
else{actionSet.addSort(node.getModelNode().getOid(),"up",9999,newParentModelNode.getOid());var params=this.calculateSortParams(dropEvent,0);}
actionSet.addSort(node.getModelNode().getOid(),params.direction,params.distance,newParentModelNode.getOid());}}
else{var params=this.calculateSortParams(dropEvent);actionSet.addSort(node.getModelNode().getOid(),params.direction,params.distance);}
actionSet.commit();}}}
uwm.modeltree.ModelTree.prototype.calculateSortParams=function(dropEvent,oldIndex){var parent=dropEvent.target.parentNode;if(oldIndex==undefined){oldIndex=parent.indexOf(dropEvent.dropNode);}
var newIndex=parent.indexOf(dropEvent.target);if(dropEvent.point=="below"){newIndex++;}
var distance=Math.abs(newIndex-oldIndex);var direction=newIndex-oldIndex>0?"down":"up";return{distance:distance,direction:direction};}
uwm.modeltree.ModelTree.prototype.handleDisassociateEvent=function(parentModelNode,childModelNode){if(uwm.Log.isEnabled(uwm.Log.DEBUG)){uwm.Log.log("handleDisassociate: "+childModelNode.getOid()+" from "+parentModelNode.getOid(),uwm.Log.DEBUG);}
var parentNode=this.getNodeById(parentModelNode.getOid());var childNode=this.getNodeById(childModelNode.getOid());if((parentNode instanceof uwm.modeltree.UseCaseNode||parentNode instanceof uwm.modeltree.UseCaseCoreNode)&&(childNode instanceof uwm.modeltree.PackageNode)){childNode.eachChild(function(node){if(node&&node.id==parentNode.id){if(uwm.Log.isEnabled(uwm.Log.DEBUG)){uwm.Log.log("remove node in disassociate: "+node.id+" from "+childNode.id,uwm.Log.DEBUG);}
node.remove();}});}
if((parentNode instanceof uwm.modeltree.UseCaseNode||parentNode instanceof uwm.modeltree.UseCaseCoreNode)&&(childNode instanceof uwm.modeltree.ProcessNode)){childNode.eachChild(function(node){if(node&&node.id==parentNode.id){if(uwm.Log.isEnabled(uwm.Log.DEBUG)){uwm.Log.log("remove node in disassociate: "+node.id+" from "+childNode.id,uwm.Log.DEBUG);}
node.remove();}});}}
uwm.modeltree.ModelTree.prototype.createModel=function(){uwm.model.ModelContainer.getInstance().createModel();}
uwm.modeltree.ModelTree.prototype.markNodeByOid=function(oid){var node=null;var currOid=oid;var parents=new Array();var container=uwm.model.ModelContainer.getInstance();do{parents.push(currOid);node=this.getNodeById(currOid);if(node==null){var modelObject=container.getByOid(currOid);if(modelObject==null){var self=this;container.loadByOid(currOid,function(){self.markNodeByOid(oid);});return;}
var parentOids=modelObject.getParentOids();var goodParent=null;for(var i=0;i<parentOids.length;i++){goodParent=parentOids[i];var parentUwmClassName=uwm.Util.getUwmClassNameFromOid(goodParent);if(parentUwmClassName=="Package"||parentUwmClassName=="Model"){break;}}
currOid=goodParent;}}while(node==null);this.show();if(parents.length==1){var parentNode=node.parentNode;parentNode.ensureVisible();parentNode.expand();node.select();}else{this.expandListAsync(parents);}}
uwm.modeltree.ModelTree.prototype.expandListAsync=function(parents,currNode){var oid=parents.pop();if(parents.length>0){if(currNode){currNode.expandChildNodes(false);}
var node=this.getNodeById(oid);node.ensureVisible();var self=this;node.expand(false,true,function(currNode){self.expandListAsync(parents,currNode);});}else{var node=this.getNodeById(oid);node.ensureVisible();node.select();}}
uwm.modeltree.ModelTree.prototype.handleCreateEvent=function(modelObject){if(modelObject instanceof uwm.model.builtin.Model){this.createdModels.add(modelObject.getOid(),modelObject);}else if(modelObject instanceof uwm.model.builtin.Package){this.createdPackages.add(modelObject.getOid(),modelObject);}else{if(modelObject instanceof uwm.diagram.Diagram||modelObject instanceof uwm.diagram.ActivitySet){this.createdDiagrams.add(modelObject.getOid(),modelObject);}}}
uwm.modeltree.ModelTree.prototype.handleDeleteEvent=function(modelObject){var node=this.getNodeById(modelObject.getOid());if(node){node.remove();}}
uwm.modeltree.ModelTree.prototype.handleChangeLabelEvent=function(modelObject,oldLabel,newLabel){if(modelObject.getLanguage()!=uwm.i18n.Localization.getInstance().getModelLanguage()){return;}
var oid=modelObject.getOid();var createdModel=this.createdModels.get(oid);if(!createdModel){var node=this.getNodeById(oid);if(!newLabel){if(node){node.setText(modelObject.getLabel());}}else{if(node){node.setText(newLabel);}}}else{this.createdModels.removeKey(oid);var node=new uwm.modeltree.ModelNode({oid:oid,text:modelObject.getLabel()});this.getRootNode().appendChild(node);this.removeCreateProgressNode();}}
uwm.modeltree.ModelTree.prototype.handleAssociateEvent=function(parentModelObject,childModelObject){if(uwm.Log.isEnabled(uwm.Log.DEBUG)){uwm.Log.log("handleAssociate: "+childModelObject.getOid()+" to "+parentModelObject.getOid(),uwm.Log.DEBUG);}
var parentOid=parentModelObject.getOid();var parentNode=this.getNodeById(parentOid);if(parentNode){if(parentNode instanceof uwm.modeltree.UseCaseNode||parentNode instanceof uwm.modeltree.UseCaseCoreNode){if(!(childModelObject instanceof uwm.diagram.ActivitySet)){if(parentModelObject.parentOids){for(var i=0;i<parentModelObject.parentOids.length;i++){var tempParentNode=this.getNodeById(parentModelObject.parentOids[i]);if(tempParentNode instanceof uwm.modeltree.PackageNode||tempParentNode instanceof uwm.modeltree.ProcessNode){parentNode=tempParentNode;parentModelObject=uwm.model.ModelContainer.getInstance().getByOid(parentNode.oid);break;}}}}}
var childNode=null;if(childModelObject instanceof uwm.model.builtin.Package&&this.createdPackages.get(childModelObject.getOid())){this.createdPackages.remove(childModelObject.getOid());childNode=new uwm.modeltree.PackageNode({oid:childModelObject.getOid(),text:childModelObject.getLabel()});}else if(childModelObject instanceof uwm.diagram.ActivitySet&&this.createdDiagrams.get(childModelObject.getOid())){this.createdPackages.remove(childModelObject.getOid());childNode=new uwm.modeltree.ActivitySetNode({oid:childModelObject.getOid(),text:childModelObject.getLabel()});}else if(childModelObject instanceof cwm.ChiBusinessUseCase){this.createdPackages.remove(childModelObject.getOid());childNode=new uwm.modeltree.UseCaseNode({oid:childModelObject.getOid(),text:childModelObject.getLabel()});}else if(childModelObject instanceof cwm.ChiBusinessUseCaseCore){this.createdPackages.remove(childModelObject.getOid());childNode=new uwm.modeltree.UseCaseCoreNode({oid:childModelObject.getOid(),text:childModelObject.getLabel()});}else if(childModelObject instanceof cwm.ChiBusinessProcess){this.createdPackages.remove(childModelObject.getOid());childNode=new uwm.modeltree.ProcessNode({oid:childModelObject.getOid(),text:childModelObject.getLabel()});}else if(childModelObject instanceof uwm.diagram.Diagram&&this.createdDiagrams.get(childModelObject.getOid())){this.createdPackages.remove(childModelObject.getOid());childNode=new uwm.modeltree.DiagramNode({oid:childModelObject.getOid(),text:childModelObject.getLabel()});}else if(childModelObject instanceof uwm.model.ModelObject){childNode=this.getNodeById(childModelObject.getOid());if(!childNode){childNode=new uwm.modeltree.Node({oid:childModelObject.getOid(),text:childModelObject.getLabel(),uwmClassName:childModelObject.getModelNodeClass().getUwmClassName()})};}
if(childNode){if(!parentNode.findChild("id",childNode.id)){if(uwm.Log.isEnabled(uwm.Log.DEBUG)){uwm.Log.log("append node in associate: "+childNode.id+" to "+parentNode.id,uwm.Log.DEBUG);}
if(parentNode.isExpanded()){this.removeCreateProgressNode();parentNode.appendChild(childNode);childNode.ensureVisible();}else{parentNode.expand();}}}}}
uwm.modeltree.ModelTree.prototype.showCreateProgressNode=function(parent,text){this.removeCreateProgressNode();this.createProgressNode=new Ext.tree.AsyncTreeNode({disabled:true,leaf:true,text:text,cls:"x-tree-node-loading"});parent.appendChild(this.createProgressNode);this.createProgressNode.ensureVisible();}
uwm.modeltree.ModelTree.prototype.removeCreateProgressNode=function(){if(this.createProgressNode&&this.createProgressNode.parentNode){this.createProgressNode.remove();}}
uwm.modeltree.ModelTree.getInstance=function(){return uwm.modeltree.ModelTree.instance;}
uwm.modeltree.ModelTree.COMPONENT_ID="uwm.modeltree.ModelTree.ID";Ext.namespace("uwm.modeltree");uwm.modeltree.ModelNode=function(config){this.modelNode=uwm.model.ModelContainer.getInstance().createByClassAndNameAndOid("Model",config.text,config.oid);uwm.modeltree.ModelNode.superclass.constructor.call(this,Ext.apply(this,{id:config.oid,iconCls:this.modelNode.getModelNodeClass().getTreeIcon(),allowDrag:true},config));}
Ext.extend(uwm.modeltree.ModelNode,uwm.objecttree.Node);uwm.modeltree.ModelNode.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{text:uwm.Dict.translate('Add package'),handler:function(item,e){self.addPackage(item,e);}},{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item,e);}},{text:uwm.Dict.translate('New model from this'),handler:function(item,e){self.duplicate(item,e);}},{text:uwm.Dict.translate('Select as grid scope'),handler:function(item,e){self.selectAsScope(item,e);}},{text:uwm.Dict.translate("Reload"),handler:function(item,e){self.reload();}},{text:uwm.Dict.translate('Export as UML'),handler:function(item,e){var localization=uwm.i18n.Localization.getInstance();var userLanguage=localization.getModelLanguage();new uwm.ui.LongTaskRunner({title:uwm.Dict.translate('Exporting UML ...'),call:function(successHandler,errorHandler){uwm.persistency.Persistency.getInstance().exportUwm(self.getModelNode().getOid(),userLanguage,successHandler,errorHandler);},successHandler:function(data){},errorHandler:function(data){uwm.Util.showMessage(uwm.Dict.translate("Error while exporting"),uwm.Dict.translate("The export was unsuccessful. Please try again."),uwm.Util.messageType.ERROR);},isReturningDocument:true}).show();}},{text:uwm.Dict.translate('Export Documentation'),handler:function(item,e){new uwm.ui.ExportAssistent("Model",self.getModelNode().getOid());}},{text:uwm.Dict.translate("Generate Code"),handler:function(item,e){new uwm.ui.GeneratorWizard({oid:self.getModelNode().getOid()});}}]});return this.contextMenu;}
uwm.modeltree.ModelNode.prototype.addPackage=function(self,e){uwm.model.ModelContainer.getInstance().createPackage(this.getModelNode());}
uwm.modeltree.ModelNode.prototype.duplicate=function(self,e){uwm.model.ModelContainer.getInstance().duplicateModel(this.modelNode);}
uwm.modeltree.ModelNode.prototype.selectAsScope=function(self,e){uwm.objectgrid.ObjectGridContainer.getInstance().loadScope(this.modelNode);}
Ext.namespace("uwm.modeltree");uwm.modeltree.PackageNode=function(config){this.modelNode=uwm.model.ModelContainer.getInstance().createByClassAndNameAndOid("Package",config.text,config.oid);uwm.modeltree.PackageNode.superclass.constructor.call(this,Ext.apply(this,{id:config.oid,iconCls:this.modelNode.getModelNodeClass().getTreeIcon()},config));}
Ext.extend(uwm.modeltree.PackageNode,uwm.objecttree.Node);uwm.modeltree.PackageNode.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{text:uwm.Dict.translate('Add package'),handler:function(item,e){self.addPackage(item,e);}},{text:uwm.Dict.translate('Add diagram'),handler:function(item,e){self.addDiagram(item,e);}},{text:uwm.Dict.translate('New diagram from package'),handler:function(item,e){self.addDiagramFromPackageAndReload(item,e,self,self.addDiagramFromPackage(item,e));}},{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item,e);}},{text:uwm.Dict.translate('Select as grid scope'),handler:function(item,e){self.selectAsScope(item,e);}},{text:uwm.Dict.translate("Reload"),handler:function(item,e){self.reload();}},{text:uwm.Dict.translate('Export as UML'),handler:function(item,e){var localization=uwm.i18n.Localization.getInstance();var userLanguage=localization.getModelLanguage();new uwm.ui.LongTaskRunner({title:uwm.Dict.translate('Exporting UML ...'),call:function(successHandler,errorHandler){uwm.persistency.Persistency.getInstance().exportUwm(self.getModelNode().getOid(),userLanguage,successHandler,errorHandler);},successHandler:function(data){},errorHandler:function(data){uwm.Util.showMessage(uwm.Dict.translate("Error while exporting"),uwm.Dict.translate("The export was unsuccessful. Please try again."),uwm.Util.messageType.ERROR);},isReturningDocument:true}).show();}},{text:uwm.Dict.translate('Export Documentation'),handler:function(item,e){new uwm.ui.ExportAssistent("Package",self.getModelNode().getOid());}}]});return this.contextMenu;}
uwm.modeltree.PackageNode.prototype.addPackage=function(self,e){uwm.model.ModelContainer.getInstance().createPackage(this.getModelNode());}
uwm.modeltree.PackageNode.prototype.addDiagram=function(self,e){uwm.model.ModelContainer.getInstance().createDiagram(this.getModelNode());}
uwm.modeltree.PackageNode.prototype.selectAsScope=function(self,e){uwm.objectgrid.ObjectGridContainer.getInstance().loadScope(this.modelNode);}
uwm.modeltree.PackageNode.prototype.addDiagramFromPackageAndReload=function(self,e,menuEntry,addDiagramFromPackage){menuEntry.reload();}
uwm.modeltree.PackageNode.prototype.addDiagramFromPackage=function(self,e){uwm.persistency.Persistency.getInstance().createDiagramFromPackage(this.oid,function(options,data){uwm.model.ModelContainer.getInstance().loadByOid(data['oid'],function(modelNodeDiagr){uwm.diagram.DiagramContainer.getInstance().loadDiagram(modelNodeDiagr);});});}
Ext.namespace("uwm.modeltree");uwm.modeltree.AbstractDiagramNode=function(config){uwm.modeltree.AbstractDiagramNode.superclass.constructor.call(this,Ext.apply(this,{},config));var self=this;this.on("dblclick",function(item,e){self.open(item,e);});}
Ext.extend(uwm.modeltree.AbstractDiagramNode,uwm.objecttree.Node);uwm.modeltree.AbstractDiagramNode.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{text:uwm.Dict.translate('Open'),handler:function(item,e){self.open(item,e);}},{text:uwm.Dict.translate('Export Documentation'),handler:function(item,e){new uwm.ui.ExportAssistent("Diagram",self.getModelNode().getOid());}},{text:uwm.Dict.translate('Export Image'),handler:function(item,e){var localization=uwm.i18n.Localization.getInstance();var userLanguage=localization.getModelLanguage();new uwm.ui.LongTaskRunner({title:uwm.Dict.translate('Exporting Image ...'),call:function(successHandler,errorHandler){uwm.persistency.Persistency.getInstance().exportImage(self.getModelNode().getOid(),userLanguage,successHandler,errorHandler);},successHandler:function(data){},errorHandler:function(data){uwm.Util.showMessage(uwm.Dict.translate("Error while exporting"),uwm.Dict.translate("The export was unsuccessful. Please try again."),uwm.Util.messageType.ERROR);},isReturningDocument:true}).show();}},{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item.e);}}]});return this.contextMenu;}
uwm.modeltree.AbstractDiagramNode.prototype.open=function(self,e){uwm.diagram.DiagramContainer.getInstance().loadDiagram(this.getModelNode());}
Ext.namespace("uwm.modeltree");uwm.modeltree.DiagramNode=function(config){this.modelNode=uwm.model.ModelContainer.getInstance().createByClassAndNameAndOid("Diagram",config.text,config.oid);uwm.modeltree.DiagramNode.superclass.constructor.call(this,Ext.apply(this,{id:config.oid,iconCls:this.modelNode.getModelNodeClass().getTreeIcon(),allowDrop:false,leaf:true},config));}
Ext.extend(uwm.modeltree.DiagramNode,uwm.modeltree.AbstractDiagramNode);Ext.namespace("uwm.modeltree");uwm.modeltree.Node=function(config){this.modelNode=uwm.model.ModelContainer.getInstance().createByClassAndNameAndOid(config.uwmClassName,config.text,config.oid);uwm.modeltree.Node.superclass.constructor.call(this,Ext.apply(this,{id:config.oid,iconCls:this.modelNode.getModelNodeClass().getTreeIcon(),leaf:true,allowDrop:false},config));}
Ext.extend(uwm.modeltree.Node,uwm.objecttree.ObjectNode);uwm.modeltree.Node.prototype.buildContextMenu=function(){var self=this;this.contextMenu=uwm.modeltree.Node.superclass.buildContextMenu.apply(this);this.contextMenu.add({text:uwm.Dict.translate('Show in hierarchy'),handler:function(item,e){self.showInHierarchy(item,e);}});return this.contextMenu;}
uwm.modeltree.Node.prototype.showInHierarchy=function(self,e){uwm.hierarchytree.HierarchyTree.getInstance().loadNode(this.getModelNode().getOid());}
uwm.modeltree.Node.prototype.gridAvailable=function(){return uwm.objectgrid.ObjectGridContainer.getInstance().isGridAvailable(this.modelNode,this.parentNode.getModelNode().getOid());}
uwm.modeltree.Node.prototype.expand=function(deep,anim,callback){if(callback instanceof Function){callback(this);}}
Ext.namespace("uwm.modeltree");uwm.modeltree.ActivitySetNode=function(config){this.modelNode=uwm.model.ModelContainer.getInstance().createByClassAndNameAndOid("ActivitySet",config.text,config.oid);uwm.modeltree.ActivitySetNode.superclass.constructor.call(this,Ext.apply(this,{id:config.oid,iconCls:this.modelNode.getModelNodeClass().getTreeIcon(),allowDrop:true},config));}
Ext.extend(uwm.modeltree.ActivitySetNode,uwm.modeltree.AbstractDiagramNode);uwm.modeltree.ActivitySetNode.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{text:uwm.Dict.translate('Open'),handler:function(item,e){self.open(item,e);}},{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item.e);}},{text:uwm.Dict.translate('Put ActivitySet childnodes on ActivitySet diagram'),handler:function(item,e){self.putChildnodesToActivitySetDiagramAndOpen(item,e);}}]});return this.contextMenu;}
uwm.modeltree.ActivitySetNode.prototype.putChildnodesToActivitySetDiagramAndOpen=function(self,e){uwm.persistency.Persistency.getInstance().putChildnodesToActivitySetDiagram(this.oid,function(options,data){uwm.model.ModelContainer.getInstance().loadByOid(data['oid'],function(modelNodeDiagr){uwm.diagram.DiagramContainer.getInstance().loadDiagram(modelNodeDiagr);});});}
Ext.namespace("uwm.modeltree");uwm.modeltree.UseCaseNode=function(config){this.modelNode=uwm.model.ModelContainer.getInstance().createByClassAndNameAndOid("ChiBusinessUseCase",config.text,config.oid);uwm.modeltree.UseCaseNode.superclass.constructor.call(this,Ext.apply(this,{id:config.oid,iconCls:this.modelNode.getModelNodeClass().getTreeIcon(),},config));}
Ext.extend(uwm.modeltree.UseCaseNode,uwm.objecttree.Node);uwm.modeltree.UseCaseNode.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{itemId:uwm.modeltree.UseCaseNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID,text:uwm.Dict.translate('Show in diagram'),handler:function(item,e){self.showInDiagram(item,e);}},{text:uwm.Dict.translate('Show in hierarchy'),handler:function(item,e){self.showInHierarchy(item,e);}},{itemId:uwm.modeltree.UseCaseNode.CONTEXTMENU_SHOW_IN_GRID_ID,text:uwm.Dict.translate('Show in grid'),handler:function(item,e){self.showInGrid(item.e);}},{text:uwm.Dict.translate('Add activity set'),handler:function(item,e){self.addActivitySet(item,e);}},{text:uwm.Dict.translate('Generate controller'),handler:function(item,e){self.createController(item,e);}},{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item,e);}},{text:uwm.Dict.translate("Reload"),handler:function(item,e){self.reload();}},{text:uwm.Dict.translate('Show object history'),handler:function(item,e){self.showObjectHistory(item,e);}},{text:uwm.Dict.translate('Help'),handler:function(item,e){self.showHelp(item,e);}}]});return this.contextMenu;}
uwm.modeltree.UseCaseNode.prototype.showContextMenu=function(self,e){var showInDiagram=this.contextMenu.items.get(uwm.modeltree.UseCaseNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID);var showInGrid=this.contextMenu.items.get(uwm.modeltree.UseCaseNode.CONTEXTMENU_SHOW_IN_GRID_ID);var isInDiagram=this.containedInCurrentDiagram();showInDiagram.setDisabled(!isInDiagram);var isGridAvailable=this.gridAvailable();showInGrid.setDisabled(!isGridAvailable);uwm.modeltree.UseCaseNode.superclass.showContextMenu(self,e);}
uwm.modeltree.UseCaseNode.prototype.containedInCurrentDiagram=function(){return uwm.diagram.DiagramContainer.getInstance().isModelObjectContainedInCurrentDiagram(this.modelNode);}
uwm.modeltree.UseCaseNode.prototype.showInHierarchy=function(self,e){uwm.hierarchytree.HierarchyTree.getInstance().loadNode(this.getModelNode().getOid());}
uwm.modeltree.UseCaseNode.prototype.gridAvailable=function(){return uwm.objectgrid.ObjectGridContainer.getInstance().isGridAvailable(this.modelNode,this.parentNode.getModelNode().getOid());}
uwm.modeltree.UseCaseNode.prototype.addActivitySet=function(self,e){uwm.model.ModelContainer.getInstance().createActivitySet(this.getModelNode());}
uwm.modeltree.UseCaseNode.prototype.createController=function(self,e){var controllerParentNode=this.parentNode;if(this.parentNode instanceof uwm.modeltree.ProcessNode){controllerParentNode=controllerParentNode.parentNode;}
uwm.modeltree.ModelTree.getInstance().showCreateProgressNode(this.parentNode,uwm.Dict.translate('Creating controller...'));uwm.model.ModelContainer.getInstance().createController(this.modelNode,controllerParentNode.getModelNode());}
uwm.modeltree.UseCaseNode.prototype.showInDiagram=function(self,e){uwm.diagram.DiagramContainer.getInstance().getCurrentDiagram().scrollToObject(this.modelNode);}
uwm.modeltree.UseCaseNode.prototype.showInGrid=function(self,e){uwm.objectgrid.ObjectGridContainer.getInstance().selectRow(this.modelNode);}
uwm.modeltree.UseCaseNode.prototype.showHelp=function(self,e){uwm.ui.HelpViewer.getInstance().loadUrl(this.modelNode.getModelNodeClass().getHelpUrl());}
uwm.modeltree.UseCaseNode.prototype.showObjectHistory=function(self,e){new uwm.ui.History(this.modelNode);}
uwm.modeltree.UseCaseNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID="showInDiagram";uwm.modeltree.UseCaseNode.CONTEXTMENU_SHOW_IN_GRID_ID="showInGrid";Ext.namespace("uwm.modeltree");uwm.modeltree.UseCaseCoreNode=function(config){this.modelNode=uwm.model.ModelContainer.getInstance().createByClassAndNameAndOid("ChiBusinessUseCaseCore",config.text,config.oid);uwm.modeltree.UseCaseCoreNode.superclass.constructor.call(this,Ext.apply(this,{id:config.oid,iconCls:this.modelNode.getModelNodeClass().getTreeIcon(),},config));}
Ext.extend(uwm.modeltree.UseCaseCoreNode,uwm.objecttree.Node);uwm.modeltree.UseCaseCoreNode.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{itemId:uwm.modeltree.UseCaseCoreNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID,text:uwm.Dict.translate('Show in diagram'),handler:function(item,e){self.showInDiagram(item,e);}},{text:uwm.Dict.translate('Show in hierarchy'),handler:function(item,e){self.showInHierarchy(item,e);}},{itemId:uwm.modeltree.UseCaseCoreNode.CONTEXTMENU_SHOW_IN_GRID_ID,text:uwm.Dict.translate('Show in grid'),handler:function(item,e){self.showInGrid(item.e);}},{text:uwm.Dict.translate('Add activity set'),handler:function(item,e){self.addActivitySet(item,e);}},{text:uwm.Dict.translate('Generate controller'),handler:function(item,e){self.createController(item,e);}},{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item,e);}},{text:uwm.Dict.translate("Reload"),handler:function(item,e){self.reload();}},{text:uwm.Dict.translate('Show object history'),handler:function(item,e){self.showObjectHistory(item,e);}},{text:uwm.Dict.translate('Help'),handler:function(item,e){self.showHelp(item,e);}}]});return this.contextMenu;}
uwm.modeltree.UseCaseCoreNode.prototype.showContextMenu=function(self,e){var showInDiagram=this.contextMenu.items.get(uwm.modeltree.UseCaseCoreNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID);var showInGrid=this.contextMenu.items.get(uwm.modeltree.UseCaseCoreNode.CONTEXTMENU_SHOW_IN_GRID_ID);var isInDiagram=this.containedInCurrentDiagram();showInDiagram.setDisabled(!isInDiagram);var isGridAvailable=this.gridAvailable();showInGrid.setDisabled(!isGridAvailable);uwm.modeltree.UseCaseCoreNode.superclass.showContextMenu(self,e);}
uwm.modeltree.UseCaseCoreNode.prototype.containedInCurrentDiagram=function(){return uwm.diagram.DiagramContainer.getInstance().isModelObjectContainedInCurrentDiagram(this.modelNode);}
uwm.modeltree.UseCaseCoreNode.prototype.showInHierarchy=function(self,e){uwm.hierarchytree.HierarchyTree.getInstance().loadNode(this.getModelNode().getOid());}
uwm.modeltree.UseCaseCoreNode.prototype.gridAvailable=function(){return uwm.objectgrid.ObjectGridContainer.getInstance().isGridAvailable(this.modelNode,this.parentNode.getModelNode().getOid());}
uwm.modeltree.UseCaseCoreNode.prototype.addActivitySet=function(self,e){uwm.model.ModelContainer.getInstance().createActivitySet(this.getModelNode());}
uwm.modeltree.UseCaseCoreNode.prototype.createController=function(self,e){var controllerParentNode=this.parentNode;if(this.parentNode instanceof uwm.modeltree.ProcessNode){controllerParentNode=controllerParentNode.parentNode;}
uwm.modeltree.ModelTree.getInstance().showCreateProgressNode(this.parentNode,uwm.Dict.translate('Creating controller...'));uwm.model.ModelContainer.getInstance().createController(this.modelNode,controllerParentNode.getModelNode());}
uwm.modeltree.UseCaseCoreNode.prototype.showInDiagram=function(self,e){uwm.diagram.DiagramContainer.getInstance().getCurrentDiagram().scrollToObject(this.modelNode);}
uwm.modeltree.UseCaseCoreNode.prototype.showInGrid=function(self,e){uwm.objectgrid.ObjectGridContainer.getInstance().selectRow(this.modelNode);}
uwm.modeltree.UseCaseCoreNode.prototype.showHelp=function(self,e){uwm.ui.HelpViewer.getInstance().loadUrl(this.modelNode.getModelNodeClass().getHelpUrl());}
uwm.modeltree.UseCaseCoreNode.prototype.showObjectHistory=function(self,e){new uwm.ui.History(this.modelNode);}
uwm.modeltree.UseCaseCoreNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID="showInDiagram";uwm.modeltree.UseCaseCoreNode.CONTEXTMENU_SHOW_IN_GRID_ID="showInGrid";Ext.namespace("uwm.modeltree");uwm.modeltree.ProcessNode=function(config){this.modelNode=uwm.model.ModelContainer.getInstance().createByClassAndNameAndOid("ChiBusinessProcess",config.text,config.oid);uwm.modeltree.ProcessNode.superclass.constructor.call(this,Ext.apply(this,{id:config.oid,iconCls:this.modelNode.getModelNodeClass().getTreeIcon(),},config));}
Ext.extend(uwm.modeltree.ProcessNode,uwm.objecttree.Node);uwm.modeltree.ProcessNode.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[{itemId:uwm.modeltree.ProcessNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID,text:uwm.Dict.translate('Show in diagram'),handler:function(item,e){self.showInDiagram(item,e);}},{text:uwm.Dict.translate('Show in hierarchy'),handler:function(item,e){self.showInHierarchy(item,e);}},{itemId:uwm.modeltree.ProcessNode.CONTEXTMENU_SHOW_IN_GRID_ID,text:uwm.Dict.translate('Show in grid'),handler:function(item,e){self.showInGrid(item.e);}},{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item,e);}},{text:uwm.Dict.translate("Reload"),handler:function(item,e){self.reload();}},{text:uwm.Dict.translate('Show object history'),handler:function(item,e){self.showObjectHistory(item,e);}},{text:uwm.Dict.translate('Help'),handler:function(item,e){self.showHelp(item,e);}}]});return this.contextMenu;}
uwm.modeltree.ProcessNode.prototype.showContextMenu=function(self,e){var showInDiagram=this.contextMenu.items.get(uwm.modeltree.ProcessNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID);var showInGrid=this.contextMenu.items.get(uwm.modeltree.ProcessNode.CONTEXTMENU_SHOW_IN_GRID_ID);var isInDiagram=this.containedInCurrentDiagram();showInDiagram.setDisabled(!isInDiagram);var isGridAvailable=this.gridAvailable();showInGrid.setDisabled(!isGridAvailable);uwm.modeltree.ProcessNode.superclass.showContextMenu(self,e);}
uwm.modeltree.ProcessNode.prototype.containedInCurrentDiagram=function(){return uwm.diagram.DiagramContainer.getInstance().isModelObjectContainedInCurrentDiagram(this.modelNode);}
uwm.modeltree.ProcessNode.prototype.showInHierarchy=function(self,e){uwm.hierarchytree.HierarchyTree.getInstance().loadNode(this.getModelNode().getOid());}
uwm.modeltree.ProcessNode.prototype.gridAvailable=function(){return uwm.objectgrid.ObjectGridContainer.getInstance().isGridAvailable(this.modelNode,this.parentNode.getModelNode().getOid());}
uwm.modeltree.ProcessNode.prototype.showInDiagram=function(self,e){uwm.diagram.DiagramContainer.getInstance().getCurrentDiagram().scrollToObject(this.modelNode);}
uwm.modeltree.ProcessNode.prototype.showInGrid=function(self,e){uwm.objectgrid.ObjectGridContainer.getInstance().selectRow(this.modelNode);}
uwm.modeltree.ProcessNode.prototype.showHelp=function(self,e){uwm.ui.HelpViewer.getInstance().loadUrl(this.modelNode.getModelNodeClass().getHelpUrl());}
uwm.modeltree.ProcessNode.prototype.showObjectHistory=function(self,e){new uwm.ui.History(this.modelNode);}
uwm.modeltree.ProcessNode.CONTEXTMENU_SHOW_IN_DIAGRAM_ID="showInDiagram";uwm.modeltree.ProcessNode.CONTEXTMENU_SHOW_IN_GRID_ID="showInGrid";Ext.namespace("uwm.hierarchytree");uwm.hierarchytree.Loader=function(){}
uwm.hierarchytree.Loader=Ext.extend(Ext.tree.TreeLoader,{initComponent:function(config){Ext.apply(this,{preloadChildren:false});uwm.hierarchytree.Loader.superclass.initComponent.apply(this,arguments);this.tree=config.tree;}})
uwm.hierarchytree.Loader.prototype.load=function(node,callback){var oid=node;if(node instanceof uwm.hierarchytree.Node){oid=node.getModelNode().getOid();}
var self=this;uwm.persistency.Persistency.getInstance().display(oid,uwm.hierarchytree.Loader.DEFAULT_LOAD_DEPTH,uwm.i18n.Localization.getInstance().getModelLanguage(),function(request,data){self.reformatData(self,node,callback,data);});}
uwm.hierarchytree.Loader.prototype.reformatData=function(self,node,callback,data){var modelNode=uwm.model.ModelContainer.getInstance().createByDisplayResult(data);var currNode=node;this.attachFollowers(currNode,modelNode);if(callback instanceof Function){callback(this,node);}}
uwm.hierarchytree.Loader.prototype.attachFollowers=function(currNode,modelNode,parentModel){var childOids=modelNode.getChildOids();var parentOids=modelNode.getParentOids();var parentNodeOid=null;if(parentModel){parentNodeOid=parentModel.getOid();}
var grandParentNodeOid=null;var parentNode=currNode.parentNode;if(parentNode){var grandParentNode=parentNode.parentNode;if(grandParentNode){grandParentNodeOid=grandParentNode.getModelNode().getOid();}}
var oidList=new Ext.util.MixedCollection();oidList=this.filterOidList(oidList,childOids,parentNodeOid,grandParentNodeOid);oidList=this.filterOidList(oidList,parentOids,parentNodeOid,grandParentNodeOid);this.attachFollowersList(currNode,modelNode,oidList.getRange(),parentNodeOid,grandParentNodeOid);}
uwm.hierarchytree.Loader.prototype.filterOidList=function(oidList,checkOidList,parentNodeOid,grandParentNodeOid){if(checkOidList){for(var i=0;i<checkOidList.length;i++){var currOid=checkOidList[i];if(currOid!=parentNodeOid&&currOid!=grandParentNodeOid&&!oidList.contains(currOid)){oidList.add(currOid);}}}
return oidList;}
uwm.hierarchytree.Loader.prototype.attachFollowersList=function(currNode,modelNode,oidList,parentNodeOid,grandParentNodeOid){var subClasses=new Array();var container=uwm.model.ModelContainer.getInstance();var self=this;for(var i=0;i<oidList.length;i++){var childModelNode=container.getByOid(oidList[i]);if(!childModelNode){container.loadByOid(oidList[i],function(){self.attachFollowersList(currNode,modelNode,oidList,parentNodeOid,grandParentNodeOid);});return;}
if(childModelNode instanceof uwm.model.Relation){var parentOids=childModelNode.getParentOids();for(var j=0;j<parentOids.length;j++){var currOid=parentOids[j];if(currOid!=modelNode.getOid()){oidList.splice(i,1);i--;if(currOid!=parentNodeOid&&currOid!=grandParentNodeOid){oidList.push(currOid);container.loadByOid(currOid,function(){self.attachFollowersList(currNode,modelNode,oidList,parentNodeOid,grandParentNodeOid);});return;}}}}
if(childModelNode instanceof uwm.model.ModelObject){var connectionType=modelNode.getModelNodeClass().getConnectionInfo(childModelNode.getModelNodeClass()).label;var subArray=subClasses[connectionType];if(!subArray){subArray=new Array();}
subArray.push(childModelNode)
subClasses[connectionType]=subArray;}}
for(var currClass in subClasses){if(!(subClasses[currClass]instanceof Function)){var currEntry=subClasses[currClass];var connectionNode=new uwm.hierarchytree.ConnectionNode({text:currClass});currNode.appendChild(connectionNode);for(var i=0;i<currEntry.length;i++){var childModelNode=currEntry[i];var subNode=new uwm.hierarchytree.Node({parent:modelNode,modelNode:childModelNode});connectionNode.appendChild(subNode);}}}}
uwm.hierarchytree.Loader.DEFAULT_LOAD_DEPTH=1;Ext.namespace("uwm.hierarchytree");uwm.hierarchytree.HierarchyTree=function(){}
uwm.hierarchytree.HierarchyTree=Ext.extend(uwm.objecttree.ObjectTree,{initComponent:function(){var self=this;Ext.apply(this,{id:uwm.hierarchytree.HierarchyTree.COMPONENT_ID,loader:new uwm.hierarchytree.Loader({tree:self}),iconCls:"HierarchyTab",name:"Hierarchy Tree",rootVisible:false,enableDrop:false,root:new Ext.tree.TreeNode(),tabTip:"<b>"+uwm.Dict.translate('Hierarchy Tree')+"</b><p>"+uwm.Dict.translate('Shows all dependencies of a specific object. Use context menu on an object to show it here.')+"</p>"});uwm.modeltree.ModelTree.superclass.initComponent.apply(this,arguments);uwm.hierarchytree.HierarchyTree.instance=this;var self=this;uwm.event.EventBroker.getInstance().addListener({"delete":function(modelObject){self.handleDeleteEvent(modelObject);},"changeLabel":function(modelObject,oldLabel,newLabel){self.handleChangeLabelEvent(modelObject,oldLabel,newLabel);},"associate":function(parentModelObject,childModelObject){self.handleAssociateEvent(parentModelObject,childModelObject);},"disassociate":function(parentModelObject,childModelObject){self.handleDisassociateEvent(parentModelObject,childModelObject);}});this.on("afterlayout",this.showInfoMask);this.wasActive=false;}})
uwm.hierarchytree.HierarchyTree.prototype.showInfoMask=function(){if(!this.wasActive){this.infoMask=new uwm.ui.InfoMask(this.body,{msg:uwm.Dict.translate('This tree shows all dependencies of an object. Select an object, right-click and select &quot;Show in hierarchy&quot; to show it here.')});this.infoMask.show();}
this.un("afterlayout",this.showInfoMask);}
uwm.hierarchytree.HierarchyTree.prototype.loadNode=function(oid){this.wasActive=true;if(this.infoMask){this.infoMask.hide();}
this.show();var modelNode=uwm.model.ModelContainer.getInstance().getByOid(oid);currNode=new uwm.hierarchytree.Node({parent:null,modelNode:modelNode,});if(this.root.firstChild){this.root.firstChild.remove();}
this.root.appendChild(currNode);currNode.expand();}
uwm.hierarchytree.HierarchyTree.prototype.handleDeleteEvent=function(modelObject){var instances=this.getInstances(modelObject.getOid());for(var i in instances){if(!(instances[i]instanceof Function)){var parent=instances[i].parentNode;instances[i].remove();if(!parent.hasChildNodes()){parent.remove();}}}}
uwm.hierarchytree.HierarchyTree.prototype.handleChangeLabelEvent=function(modelObject,oldLabel,newLabel){if(modelObject.getLanguage()!=uwm.i18n.Localization.getInstance().getModelLanguage()){return;}
var instances=this.getInstances(modelObject.getOid());if(!newLabel){var label=modelObject.getLabel();}else{var label=newLabel;}
for(var i in instances){if(!(instances[i]instanceof Function)){instances[i].setText(label);}}}
uwm.hierarchytree.HierarchyTree.prototype.handleAssociateEvent=function(parentModelObject,childModelObject){if(parentModelObject instanceof uwm.model.ModelObject&&childModelObject instanceof uwm.model.ModelObject){this.addPossibleNewChildren(parentModelObject,childModelObject);this.addPossibleNewChildren(childModelObject,parentModelObject);}}
uwm.hierarchytree.HierarchyTree.prototype.addPossibleNewChildren=function(parentModelObject,childModelObject){var instances=this.getInstances(parentModelObject.getOid());for(var i in instances){var currNode=instances[i];if(!(currNode instanceof Function)){var found=false;var searchNode=currNode;for(var j=0;j<4;j++){if(searchNode){if(searchNode instanceof uwm.hierarchytree.Node&&searchNode.getModelNode().getOid()==childModelObject.getOid()){found=true;break;}
searchNode=searchNode.parentNode;}else{break;}}
if(!found){var connectionType=parentModelObject.getModelNodeClass().getConnectionInfo(childModelObject.getModelNodeClass()).label;var connectionNode=currNode.findChild("text",connectionType);if(!connectionNode){connectionNode=new uwm.hierarchytree.ConnectionNode({text:connectionType});currNode.appendChild(connectionNode);}
var existingNodes=connectionNode.childNodes;var alreadyThere=false;for(var j in existingNodes){var existingNode=existingNodes[j];if(!(existingNode instanceof Function)){if(existingNode.getModelNode().getOid()==childModelObject.getOid()){alreadyThere=true;break;}}}
if(!alreadyThere){var subNode=new uwm.hierarchytree.Node({parent:parentModelObject,modelNode:childModelObject});connectionNode.appendChild(subNode);}}}}}
uwm.hierarchytree.HierarchyTree.prototype.handleDisassociateEvent=function(parentModelObject,childModelObject){if(parentModelObject instanceof uwm.model.ModelObject&&childModelObject instanceof uwm.model.ModelObject){this.deletePossibleChildren(parentModelObject,childModelObject);this.deletePossibleChildren(childModelObject,parentModelObject);}}
uwm.hierarchytree.HierarchyTree.prototype.deletePossibleChildren=function(parentModelObject,childModelObject){var instances=this.getInstances(parentModelObject.getOid());var self=this;var childOid=childModelObject.getOid();for(var i in instances){var currNode=instances[i];if(!(currNode instanceof Function)){var connectionNodes=currNode.childNodes;for(var j in connectionNodes){if(!(connectionNodes[j]instanceof Function)){var child=connectionNodes[j].findChildBy(function(node){return self.isNodeWithOid(node,childOid);});if(child){var parent=child.parentNode;child.remove();if(!parent.hasChildNodes()){parent.remove();}}}}}}}
uwm.hierarchytree.HierarchyTree.prototype.isNodeWithOid=function(node,childOid){var result=false;if(node instanceof uwm.hierarchytree.Node){result=node.getModelNode().getOid()==childOid;}
return result;}
uwm.hierarchytree.HierarchyTree.prototype.getInstances=function(oid){result=new Array();return this.walkTree(this.getRootNode(),oid,result);}
uwm.hierarchytree.HierarchyTree.prototype.walkTree=function(currNode,oid,result){for(var i in currNode.childNodes){if(!(currNode.childNodes[i]instanceof Function)){var currChild=currNode.childNodes[i];if(currChild instanceof uwm.hierarchytree.Node&&currChild.getModelNode().getOid()==oid){result.push(currChild);}
result=this.walkTree(currChild,oid,result);}}
return result;}
uwm.hierarchytree.HierarchyTree.getInstance=function(){return uwm.hierarchytree.HierarchyTree.instance;}
uwm.hierarchytree.HierarchyTree.COMPONENT_ID="uwm.hierarchytree.HierarchyTree.ID";Ext.namespace("uwm.hierarchytree");uwm.hierarchytree.Node=function(config){var childOids=config.modelNode.getChildOids(true);var parentOids=this.removeDirectParent(config.parent,config.modelNode.getParentOids(true));uwm.hierarchytree.Node.superclass.constructor.call(this,Ext.apply(this,{text:config.modelNode.getLabel(),iconCls:config.modelNode.getModelNodeClass().getTreeIcon(),leaf:childOids||parentOids,allowDrop:false},config));this.modelNode=config.modelNode;}
Ext.extend(uwm.hierarchytree.Node,uwm.objecttree.ObjectNode);uwm.hierarchytree.Node.prototype.buildContextMenu=function(){var self=this;this.contextMenu=uwm.hierarchytree.Node.superclass.buildContextMenu.apply(this);this.contextMenu.add({text:uwm.Dict.translate('Show in model tree'),handler:function(item,e){self.showInModelTree(item,e);}});return this.contextMenu;}
uwm.hierarchytree.Node.prototype.showInModelTree=function(self,e){uwm.modeltree.ModelTree.getInstance().markNodeByOid(this.getModelNode().getOid());}
uwm.hierarchytree.Node.prototype.removeDirectParent=function(parent,parentOids){var result=new Array();if(parentOid){var parentOid=parent.getOid();for(var i=0;i<parentOids;i++){if(parentOids[i]!=parentOid){result.push(parentOids[i]);}}}else{result=parentOids;}
return result;}
Ext.namespace("uwm.hierarchytree");uwm.hierarchytree.ConnectionNode=function(config){uwm.hierarchytree.ConnectionNode.superclass.constructor.call(this,Ext.apply(this,{leaf:false,allowDrag:false,allowDrop:false},config));}
Ext.extend(uwm.hierarchytree.ConnectionNode,Ext.tree.TreeNode);Ext.namespace("uwm.objectgrid");uwm.objectgrid.ObjectGridContainer=function(){this.items=new Object();this.containersInScope=new Array();this.dataContainers=new Array();var self=this;uwm.event.EventBroker.getInstance().addListener({"delete":function(modelObject){self.handleDeleteEvent(modelObject);},"changeLabel":function(modelObject,oldLabel){self.handleChangeLabelEvent(modelObject,oldLabel);},"associate":function(parentModelObject,childModelObject){self.handleAssociateEvent(parentModelObject,childModelObject);}});}
uwm.objectgrid.ObjectGridContainer.prototype.registerGrid=function(objectGrid){this.items[objectGrid.getUwmClassName()]=objectGrid;if(objectGrid instanceof uwm.objectgrid.ObjectGrid){this.dataContainers[objectGrid.getUwmClassName()]=new Array();}}
uwm.objectgrid.ObjectGridContainer.prototype.handleDeleteEvent=function(modelObject){var objectGrid=this.items[modelObject.getUwmClassName()];if(objectGrid){var record=objectGrid.getStore().query("oid",modelObject.getOid());if(record.getCount()>0){objectGrid.getStore().remove(record.get(0));}}}
uwm.objectgrid.ObjectGridContainer.prototype.handleChangeLabelEvent=function(modelObject,oldLabel){if(modelObject.getLanguage()!=uwm.i18n.Localization.getInstance().getModelLanguage()){return;}
var objectGrid=this.items[modelObject.getUwmClassName()];if(objectGrid){var record=objectGrid.getStore().query("oid",modelObject.getOid());if(record.getCount()>0){record.get(0).set("label",modelObject.getLabel());objectGrid.getStore().commitChanges();}}}
uwm.objectgrid.ObjectGridContainer.prototype.handleAssociateEvent=function(parentModelObject,childModelObject){var container=this.containersInScope[parentModelObject.getOid()];if(container){var objectGrid=this.items[childModelObject.getUwmClassName()];if(objectGrid){objectGrid.getStore().loadData([childModelObject.getGridData()],true);}
else if(childModelObject instanceof uwm.model.builtin.Package){this.containersInScope[childModelObject.getOid()]=childModelObject;}}}
uwm.objectgrid.ObjectGridContainer.prototype.loadScope=function(modelNode){this.rootModelNode=modelNode;var self=this;this.dataContainers=new Object();this.containersInScope=new Array();for(var i in this.items){var currGrid=this.items[i];if(currGrid instanceof uwm.objectgrid.ObjectGrid){this.dataContainers[i]=new Array();}}
var longTaskRunner=new uwm.ui.LongTaskRunner({title:uwm.Dict.translate('Loading Scope ...'),call:function(successHandler,errorHandler){uwm.persistency.Persistency.getInstance().batchdisplay(modelNode.getOid(),uwm.i18n.Localization.getInstance().getModelLanguage(),successHandler,errorHandler);},progressHandler:function(data){if(data.objects){self.handleLoadedScopePart(data.objects);}},successHandler:function(data){if(data.objects){self.handleLoadedScopePart(data.objects);}
self.handleLoadedScope();longTaskRunner.close();},errorHandler:function(data){uwm.Util.showMessage(uwm.Dict.translate("Error while loading scope"),uwm.Dict.translate("The process was unsuccessful. Please try again."),uwm.Util.messageType.ERROR);},isReturningDocument:false}).show();}
uwm.objectgrid.ObjectGridContainer.prototype.handleLoadedScopePart=function(objects){var modelContainer=uwm.model.ModelContainer.getInstance();for(var i=0;i<objects.length;i++){var modelNode=modelContainer.createByDisplayResult({node:objects[i]});this.collectData(modelNode);}}
uwm.objectgrid.ObjectGridContainer.prototype.handleLoadedScope=function(){for(var i in this.items){var currGrid=this.items[i];if(currGrid instanceof uwm.objectgrid.ObjectGrid){currGrid.getStore().loadData(this.dataContainers[i]);currGrid.hideInfoMask();}}}
uwm.objectgrid.ObjectGridContainer.prototype.collectData=function(modelNode){this.containersInScope[modelNode.getOid()]=modelNode;var modelNodeUwmClassName=modelNode.getUwmClassName();var container=this.dataContainers[modelNodeUwmClassName];if(container){container.push(modelNode.getGridData());}}
uwm.objectgrid.ObjectGridContainer.prototype.isGridAvailable=function(modelObject,parentOid){var result=false;var objectGrid=this.items[modelObject.getUwmClassName()];if(objectGrid){if(!parentOid){var parentOids=modelObject.getParentOids();if(parentOids){for(var i=0;i<parentOids.length;i++){var currOid=parentOids[i];if(uwm.Util.getUwmClassNameFromOid(currOid)=="Package"){parentOid=currOid;break;}}}}
if(parentOid){result=this.containersInScope[parentOid]?true:false;}}
return result;}
uwm.objectgrid.ObjectGridContainer.prototype.selectRow=function(modelObject){var objectGrid=this.items[modelObject.getUwmClassName()];if(objectGrid){objectGrid.show();var record=objectGrid.getStore().query("oid",modelObject.getOid());if(record.getCount()>0){objectGrid.getSelectionModel().selectRecords([record.get(0)],false);}}}
uwm.objectgrid.ObjectGridContainer.getInstance=function(){if(!uwm.objectgrid.ObjectGridContainer.instance){uwm.objectgrid.ObjectGridContainer.instance=new uwm.objectgrid.ObjectGridContainer();}
return uwm.objectgrid.ObjectGridContainer.instance;}
Ext.namespace("uwm.objectgrid");uwm.objectgrid.ObjectGrid=function(config){var modelClass=uwm.model.ModelNodeClassContainer.getInstance().getClass(config.uwmClassName);uwm.objectgrid.ObjectGrid.superclass.constructor.call(this,Ext.apply(this,{layout:"fit",enableDragDrop:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),iconCls:modelClass.getGridTabIconClass(),tabTip:modelClass.getGridTabTip(),columns:modelClass.getGridColumns(),store:new Ext.data.SimpleStore({id:"oid",fields:modelClass.getGridFields()}),viewConfig:{forceFit:true}},config));this.uwmClassName=config.uwmClassName;this.buildContextMenu();if(this.getStore().fields.containsKey("label")){this.getStore().setDefaultSort("label");}
var self=this;this.on("cellclick",function(grid,rowIndex,columnIndex,e){self.showProperties(grid,rowIndex,columnIndex,e);});this.on("rowcontextmenu",function(grid,rowIndex,e){self.showContextMenu(grid,rowIndex,e);});this.on("afterlayout",this.showInfoMask);this.on('show',function(){uwm.ui.ExistingContentContainer.getInstance().showPanel(self);});this.wasActive=false;uwm.objectgrid.ObjectGridContainer.getInstance().registerGrid(this);}
Ext.extend(uwm.objectgrid.ObjectGrid,Ext.grid.GridPanel);uwm.objectgrid.ObjectGrid.prototype.showInfoMask=function(){if(!this.wasActive){this.infoMask=new uwm.ui.InfoMask(this.body,{msg:uwm.Dict.translate('Shows all objects within selected scope. To select a scope, select the <i>Model Tree</i>, right-click on a Model or Package and select &quot;Select as grid scope&quot;.')});this.infoMask.show();}
this.un("afterlayout",this.showInfoMask);}
uwm.objectgrid.ObjectGrid.prototype.hideInfoMask=function(){if(this.infoMask){this.infoMask.hide();}
this.wasActive=true;}
uwm.objectgrid.ObjectGrid.prototype.buildContextMenu=function(){var self=this;this.contextMenu=new Ext.menu.Menu({items:[new Ext.menu.Item({itemId:uwm.objectgrid.ObjectGrid.CONTEXTMENU_SHOW_IN_DIAGRAM_ID,text:uwm.Dict.translate('Show in diagram'),handler:function(item,e){self.showInDiagram(item,e);},}),new Ext.menu.Item({text:uwm.Dict.translate('Show in model tree'),handler:function(item,e){self.showInModelTree(item,e);}}),new Ext.menu.Item({text:uwm.Dict.translate('Show in hierarchy'),handler:function(item,e){self.showInHierarchy(item,e);}}),"-",{text:uwm.Dict.translate('Delete from model'),handler:function(item,e){self.deleteFromModel(item,e);}}]});}
uwm.objectgrid.ObjectGrid.prototype.showContextMenu=function(grid,rowIndex,e){var showInDiagram=this.contextMenu.items.get(uwm.objectgrid.ObjectGrid.CONTEXTMENU_SHOW_IN_DIAGRAM_ID);this.contextMenu.rowIndex=rowIndex;showInDiagram.setDisabled(!this.containedInCurrentDiagram());this.contextMenu.showAt([e.getXY()[0]+2,e.getXY()[1]+2]);e.preventDefault();}
uwm.objectgrid.ObjectGrid.prototype.getUwmClassName=function(){return this.uwmClassName;}
uwm.objectgrid.ObjectGrid.prototype.getSelectedModelObject=function(){var oid=this.getStore().getAt(this.contextMenu.rowIndex).get("oid");return uwm.model.ModelContainer.getInstance().getByOid(oid);}
uwm.objectgrid.ObjectGrid.prototype.showProperties=function(grid,rowIndex,columnIndex,e){var oid=this.getStore().getAt(rowIndex).get("oid");var modelObject=uwm.model.ModelContainer.getInstance().getByOid(oid);uwm.property.PropertyContainer.getInstance().showProperty(modelObject);}
uwm.objectgrid.ObjectGrid.prototype.containedInCurrentDiagram=function(){return uwm.diagram.DiagramContainer.getInstance().isModelObjectContainedInCurrentDiagram(this.getSelectedModelObject());}
uwm.objectgrid.ObjectGrid.prototype.showInDiagram=function(item,e){uwm.diagram.DiagramContainer.getInstance().getCurrentDiagram().scrollToObject(this.getSelectedModelObject());}
uwm.objectgrid.ObjectGrid.prototype.showInModelTree=function(item,e){uwm.modeltree.ModelTree.getInstance().markNodeByOid(this.getSelectedModelObject().getOid());}
uwm.objectgrid.ObjectGrid.prototype.showInHierarchy=function(item,e){uwm.hierarchytree.HierarchyTree.getInstance().loadNode(this.getSelectedModelObject().getOid());}
uwm.objectgrid.ObjectGrid.prototype.deleteFromModel=function(item,e){uwm.model.ModelContainer.getInstance().deleteByModelNode(this.getSelectedModelObject());}
uwm.objectgrid.ObjectGrid.prototype.getTreeIcon=function(){return('Figure'+this.getUwmClassName());}
uwm.objectgrid.ObjectGrid.prototype.getName=function(){return this.uwmClassName;}
uwm.objectgrid.ObjectGrid.CONTEXTMENU_SHOW_IN_DIAGRAM_ID="showInDiagram";Ext.namespace("uwm.newobjects");uwm.newobjects.DragZone=function(el,config){uwm.newobjects.DragZone.superclass.constructor.call(this,el,Ext.apply(this,{ddGroup:uwm.Constants.DD_GROUP},config));this.el=el;}
Ext.extend(uwm.newobjects.DragZone,Ext.grid.GridDragZone);uwm.newobjects.DragZone.prototype.getDragData=function(e){var result=uwm.newobjects.DragZone.superclass.getDragData.call(this,e);var sourceElement=e.getTarget();result.repairXY=Ext.fly(sourceElement).getXY();result.data=this.grid.getSelectionModel().getSelected().get("modelClass");this.el.dragData=result;return result;}
uwm.newobjects.DragZone.prototype.getRepairXY=function(){return this.dragData.repairXY;}
Ext.namespace("uwm.newobjects");uwm.newobjects.NewObjectsGrid=function(){}
uwm.newobjects.NewObjectsGrid=Ext.extend(Ext.grid.GridPanel,{initComponent:function(){var self=this;this.cellActions=new Ext.ux.grid.CellActions({listeners:{action:function(grid,record,action,value){self.helpClick(grid,record,action,value);}},align:"left"});Ext.apply(this,{region:"north",collapsible:true,split:true,autoScroll:true,height:250,title:uwm.Dict.translate("New")+" "+this.semanticGroup,layout:"fit",enableDragDrop:true,ddGroup:uwm.Constants.DD_GROUP,selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),store:this.getStore(),plugins:[this.cellActions],columns:[{header:"",width:24,dataIndex:"iconClass",sortable:false,fixed:true,hideable:false,menuDisabled:true,resizable:false,renderer:this.showImage},{header:uwm.Dict.translate('Title'),width:174,dataIndex:"title",sortable:true},{header:"",dataIndex:"none",width:24,fixed:true,hideable:false,menuDisabled:true,resizable:false,cellActions:{iconCls:"uwm-help-icon",qtipIndex:"description"}},{header:"modelClass",dataIndex:"modelClass",hidden:true,hideable:false}]});uwm.newobjects.NewObjectsGrid.superclass.initComponent.apply(this,arguments);}})
uwm.newobjects.NewObjectsGrid.prototype.getStore=function(){var data=new Array();var classes=uwm.model.ModelNodeClassContainer.getInstance().getAllClasses();for(var i=0;i<classes.getCount();i++){var currClass=classes.itemAt(i);if(currClass instanceof uwm.model.ModelClass){var semanticGroup=currClass.semanticGroup;if(!Ext.isArray(semanticGroup)){data=this.addSemanticGroup(data,currClass,semanticGroup);}else{for(var j=0;j<semanticGroup.length;j++){data=this.addSemanticGroup(data,currClass,semanticGroup[j]);}}}}
return new Ext.data.SimpleStore({data:data,fields:[{name:"iconClass",mapping:"iconClass",},{name:"title",mapping:"title"},{name:"description",mapping:"description"},{name:"modelClass",mapping:"modelClass"},{name:"helpUrl",mapping:"helpUrl"}]});}
uwm.newobjects.NewObjectsGrid.prototype.addSemanticGroup=function(data,currClass,semanticGroup){if(semanticGroup==this.semanticGroup){data.push({iconClass:currClass.getTreeIcon(),title:currClass.getUwmClassName(),description:currClass.getDescription(),helpUrl:currClass.getHelpUrl(),modelClass:currClass});}
return data;}
uwm.newobjects.NewObjectsGrid.prototype.render=function(container,position){uwm.newobjects.NewObjectsGrid.superclass.render.call(this,container,position);this.initDragZone();}
uwm.newobjects.NewObjectsGrid.prototype.initDragZone=function(){new uwm.newobjects.DragZone(this,{});}
uwm.newobjects.NewObjectsGrid.prototype.showImage=function(value){return"<div class='uwm-grid-icon "+value+"'>&nbsp;</div>";}
uwm.newobjects.NewObjectsGrid.prototype.helpClick=function(grid,record,action,value){uwm.ui.HelpViewer.getInstance().loadUrl(record.get("helpUrl"));}
Ext.namespace("uwm.newobjects");uwm.newobjects.Accordion=function(){}
uwm.newobjects.Accordion=Ext.extend(Ext.Panel,{initComponent:function(){Ext.apply(this,{region:'north',layout:"accordion",height:280,split:true,layoutConfig:{animate:true}});uwm.newobjects.Accordion.superclass.initComponent.apply(this,arguments);this.data=new Array(0);var classes=uwm.model.ModelNodeClassContainer.getInstance().getAllClasses();for(var i=0;i<classes.getCount();i++){var currClass=classes.itemAt(i);if(currClass instanceof uwm.model.ModelClass){var semanticGroup=currClass.getSemanticGroup();if(!Ext.isArray(semanticGroup)){this.addSemanticGroup(semanticGroup);}else{for(var j=0;j<semanticGroup.length;j++){this.addSemanticGroup(semanticGroup[j]);}}}}
for(var i=0;i<this.data.length;i++){this.add(new uwm.newobjects.NewObjectsGrid({semanticGroup:this.data[i]}));}}});uwm.newobjects.Accordion.prototype.addSemanticGroup=function(semanticGroup){var newGroup=true;for(var j=0;j<this.data.length;j++){if(semanticGroup==this.data[j]){newGroup=false;}}
if(newGroup){this.data.push(semanticGroup);}}
uwm.newobjects.Accordion.prototype.getGroupArray=function(){return this.data;}