property.js
上传用户:yfdli66
上传日期:2010-02-20
资源大小:47k
文件大小:13k
- /*------------------------------------------------------------------------------
- + 属性的显示 +
- + +
- + +
- -------------------------------------------------------------------------------*/
- var pp_RightInputCss = "font:12;width:100%;"+
- "height:100%;"+
- "border:none;"+
- "background-color: Transparent;";
- //改变属性
- function changeProperty(aObj) {
- if (aObj.isChanged==true) {
- aObj.isChanged = false //设为false
- var obj;
- if (aObj.fieldName=="name") {
- var obj = new ChangeNameSty(fSelectedObj);
- obj.inputValue = aObj.value;
- } else if (aObj.fieldName=="left") {
- var obj = new ChangeLeftSty(fSelectedObj);
- obj.canvasObj = document.all.drawCanvas;
- obj.inputValue = aObj.value;
- } else if (aObj.fieldName=="top") {
- var obj = new ChangeTopSty(fSelectedObj);
- obj.canvasObj = document.all.drawCanvas;
- obj.inputValue = aObj.value;
- } else if (aObj.fieldName=="view") {
- var obj = new ChangeViewSty(fSelectedObj);
- obj.inputValue = aObj.value;
- } else if (aObj.fieldName=="auto") {
- var obj = new ChangeAutoSty(fSelectedObj);
- obj.inputValue = aObj.options[aObj.selectedIndex].value;
- } else if (aObj.fieldName=="conditionType") {
- var obj = new ChangeConditionTypeSty(fSelectedObj);
- obj.inputValue = aObj.options[aObj.selectedIndex].value;
- } else if (aObj.fieldName=="owner") {
- var obj = new ChangeOwnerSty(fSelectedObj);
- obj.inputValue = aObj.value;
- } else if (aObj.fieldName=="status") {
- var obj = new ChangeStatusSty(fSelectedObj);
- obj.inputValue = aObj.options[aObj.selectedIndex].value;
- } else if (aObj.fieldName=="oldStatus") {
- var obj = new ChangeOldStatusSty(fSelectedObj);
- obj.inputValue = aObj.options[aObj.selectedIndex].value;
- } else {
- alert(aObj.ctlType +" 没有定义,无法改变属性");
- return;
- }
- changePropertyContext.setStrategy(obj);
- changePropertyContext.changeProperty(); //改变属性
- controlSubject.notifyObservers(); //通知所有的观察者
- }
- }
- //重置所有的行
- function resetAllTR(aTR) {
- //先重置所有的行
- var obj;
- for (var i=0;i<aTR.parentElement.rows.length;i++) {
- obj = aTR.parentElement.rows[i];
- obj.firstChild.firstChild.firstChild.firstChild.firstChild.style.backgroundColor = "#FFFFFF";
- obj.firstChild.firstChild.firstChild.firstChild.firstChild.style.color = "#000000";
- }
- }
- //选择行
- function selectThisTR(aTR) {
- //重置所有行
- resetAllTR(aTR);
- //设置左边
- aTR.cells[0].firstChild.firstChild.firstChild.firstChild.style.backgroundColor = "#0A246A";
- aTR.cells[0].firstChild.firstChild.firstChild.firstChild.style.color = "#FFFFFF";
- }
- function moreEdit (aObj,aUrl) {
- var feature="dialogHeight:300px;dialogWidth:500px;edge:Raised;center: Yes;help: no;resizable:yes;status: no;";
- window.showModalDialog(aUrl,"编辑",feature);
- }
- /*--------属性状态-----------*/
- //属性状态接口
- function PropertyState (aTableObj,aSObj) {
- //property
- this.tableObj = aTableObj; //属性table对象
- this.sObj = aSObj; //当前所选控件
- //interface
- this.setProperty = setProperty; //设置属性
- //method
- this.clearRows = clearRows; //清空所有的行
- this.getRow = getRow; //获得一行
- this.getEditRow = getEditRow; //编辑的行
- this.getComboBoxRow = getComboBoxRow; //选择的行
- this.getMoreRow = getMoreRow; //弹出的行
- function setProperty () {
- }
- function clearRows () {
- while(this.tableObj.rows.length>0){
- this.tableObj.deleteRow(0);
- }
- }
- function getRow (aType,aLable,aFieldName,aFieldValue,aCanEdit) {
- var str = "";
- str = str+"<tr onmousedown = 'selectThisTR(this)' ><td><table bgcolor='#FFFFFF' width=100% border=0 cellspacing=0 cellpadding=0><tr>";
- str = str+"<td width=75 style='cursor:default'>"+aLable+"</td><td style='BORDER-LEFT: gray 1pt solid;cursor:default'>";
- //类别
- if (aType==1) { //edit
- if (aCanEdit) {
- str = str+"<input type='text' isChanged=false fieldName='"+aFieldName+"' value='"+aFieldValue+"' onblur='changeProperty(this)' style='"+pp_RightInputCss+"' onkeyup="this.isChanged=true" onkeydown='if(event.keyCode==13){this.blur()};event.cancelBubble=true' >";
- } else {
- str = str+"<font color=gray>"+aFieldValue+"</font>";
- }
- } else if (aType==2) { //comboBox
- var theValue = aFieldValue.split(":")[0];
- var opAry = ( aFieldValue.split(":") )[1].split(";");
- str = str+"<span style='position:relative;top:0px'><select isChanged=false fieldName='"+aFieldName+"' onchange='this.isChanged=true;changeProperty(this)' style='margin:-2px;width:100%'>";
- for (var i=0;i<opAry.length;i++) {
- if (opAry[i]==theValue) {
- str = str+"<option selected value='"+opAry[i]+"'>"+opAry[i]+"</option>";
- } else {
- str = str+"<option value='"+opAry[i]+"'>"+opAry[i]+"</option>";
- }
- }//end for
- str = str+"</select></span>";
- } else if (aType==3) { //more
- str = str+"<span><font color=gray>[more]</font> <img fieldName='"+aFieldName+"' onmousedown="this.src='images/workflow/more_hit.gif'" onmouseup="this.src='images/workflow/more.gif';moreEdit(this,'"+aFieldValue+"')" src='images/workflow/more.gif' width='16' height='16'></span>";
- }
- str = str+"</td></tr></table></td></tr>";
- return str;
- }
- //编辑的行
- function getEditRow (aLable,aFieldName,aFieldValue,aCanEdit) {
- return this.getRow (1,aLable,aFieldName,aFieldValue,aCanEdit);
- }
- //选择的行
- function getComboBoxRow (aLable,aFieldName,aFieldValue,aSelectList,aCanEdit) {
- return this.getRow (2,aLable,aFieldName,aFieldValue+":"+aSelectList,aCanEdit);
- }
- //弹出的行
- function getMoreRow (aLable,aFieldName,aUrl) {
- return this.getRow (3,aLable,aFieldName,aUrl,true);
- }
- function getFlowRow (aCaption,aUrl) {
- return getRow(1,aCaption,aUrl,true,true);
- }
- }
- //合并
- function JoinsPropertyState (aTableObj,aSObj) {
- //inhert
- this.base=PropertyState;
- this.base(aTableObj,aSObj);
- //override
- this.setProperty = setProperty;
- function setProperty () {
- this.clearRows(); //清空所有的行
- var str = this.tableObj.outerHTML.slice(0,-16);
- //id
- str += this.getEditRow("id","id",this.sObj.id,false);
- //type
- str += this.getEditRow("type","type",this.sObj.ctlType,false);
- //left
- str += this.getEditRow("left","left",this.sObj.style.posLeft,true);
- //top
- str += this.getEditRow("top","top",this.sObj.style.posTop,true);
- //名称
- str += this.getEditRow("名称","name",this.sObj.lastChild.innerText,false);
- //条件类型
- str += this.getComboBoxRow("条件类型","conditionType",this.sObj.conditionType,"or;and",true);
- //条件
- str += this.getMoreRow ("条件","aFieldName","workflow/flow_condition.jsp");
- str +="</tbody></table>";
- this.tableObj.outerHTML=str;
- }
- }
- //分支
- function SplitsPropertyState (aTableObj,aSObj) {
- //inhert
- this.base=PropertyState;
- this.base(aTableObj,aSObj);
- //override
- this.setProperty = setProperty;
- function setProperty () {
- this.clearRows(); //清空所有的行
- var str = this.tableObj.outerHTML.slice(0,-16);
- //id
- str += this.getEditRow("id","id",this.sObj.id,false);
- //type
- str += this.getEditRow("type","type",this.sObj.ctlType,false);
- //left
- str += this.getEditRow("left","left",this.sObj.style.posLeft,true);
- //top
- str += this.getEditRow("top","top",this.sObj.style.posTop,true);
- //name
- str += this.getEditRow("名称","name",this.sObj.lastChild.innerText,false);
- //结果
- str += this.getMoreRow ("结果","aFieldName","workflow/flow_result.jsp");
- str +="</tbody></table>";
- this.tableObj.outerHTML=str;
- }
- }
- //启动
- function InitialPropertyState (aTableObj,aSObj) {
- //inhert
- this.base=PropertyState;
- this.base(aTableObj,aSObj);
- //override
- this.setProperty = setProperty;
- function setProperty () {
- this.clearRows(); //清空所有的行
- var str = this.tableObj.outerHTML.slice(0,-16);
- //id
- str += this.getEditRow("id","id",this.sObj.id,false);
- //type
- str += this.getEditRow("type","type",this.sObj.ctlType,false);
- //left
- str += this.getEditRow("left","left",this.sObj.style.posLeft,true);
- //top
- str += this.getEditRow("top","top",this.sObj.style.posTop,true);
- //名称
- str += this.getEditRow("名称","name",this.sObj.lastChild.innerText,true);
- //试图
- str += this.getEditRow("视图","view",this.sObj.view,true);
- //权限
- str += this.getMoreRow ("权限","aFieldName","workflow/flow_role.jsp");
- //预处理
- str += this.getMoreRow ("预处理","aFieldName","workflow/flow_prv.jsp");
- //后处理
- str += this.getMoreRow ("后处理","aFieldName","workflow/flow_next.jsp");
- str +="</tbody></table>";
- this.tableObj.outerHTML=str;
- }
- }
- //步骤
- function StepsPropertyState (aTableObj,aSObj) {
- //inhert
- this.base=PropertyState;
- this.base(aTableObj,aSObj);
- //override
- this.setProperty = setProperty;
- function setProperty () {
- this.clearRows(); //清空所有的行
- var str = this.tableObj.outerHTML.slice(0,-16);
- //id
- str += this.getEditRow("id","id",this.sObj.id,false);
- //type
- str += this.getEditRow("type","type",this.sObj.ctlType,false);
- //left
- str += this.getEditRow("left","left",this.sObj.style.posLeft,true);
- //top
- str += this.getEditRow("top","top",this.sObj.style.posTop,true);
- //名称
- str += this.getEditRow("名称","name",this.sObj.lastChild.innerText,true);
- //试图
- str += this.getEditRow("视图","view",this.sObj.view,true);
- //自动
- str += this.getComboBoxRow("自动","auto",this.sObj.auto,"yes;no",true);
- //权限
- str += this.getMoreRow ("权限","aFieldName","workflow/flow_role.jsp");
- //预处理
- str += this.getMoreRow ("预处理","aFieldName","workflow/flow_prv.jsp");
- //后处理
- str += this.getMoreRow ("后处理","aFieldName","workflow/flow_next.jsp");
- str +="</tbody></table>";
- this.tableObj.outerHTML=str;
- }
- }
- //线条
- function LinesPropertyState (aTableObj,aSObj) {
- //inhert
- this.base=PropertyState;
- this.base(aTableObj,aSObj);
- //override
- this.setProperty = setProperty;
- function setProperty () {
- this.clearRows(); //清空所有的行
- var str = this.tableObj.outerHTML.slice(0,-16);
- //id
- str += this.getEditRow("id","id",this.sObj.id,false);
- //type
- str += this.getEditRow("type","type",this.sObj.ctlType,false);
- //owner
- str += this.getEditRow("所有者","owner",this.sObj.owner,true);
- //下步启动状态
- str += this.getComboBoxRow("下步启动状态","status",this.sObj.status,"Queued;Underway;Finished",true);
- //本步结束状态
- str += this.getComboBoxRow("本步结束状态","oldStatus",this.sObj.oldStatus,"Queued;Underway;Finished",true);
- //预处理
- str += this.getMoreRow ("预处理","aFieldName","workflow/flow_prv.jsp");
- //后处理
- str += this.getMoreRow ("后处理","aFieldName","workflow/flow_next.jsp");
- //条件
- str += this.getMoreRow ("条件","aFieldName","workflow/flow_condition.jsp");
- str +="</tbody></table>";
- this.tableObj.outerHTML=str;
- }
- }
- /*-----------end-属性状态--------*/
- /*-----------属性环境角色--------*/
- function PropertyContext () {
- //property
- this.propertyState = new StepsPropertyState(); //默认为开始状态
- //method
- this.setPropertyState = setPropertyState;
- this.setProperty = setProperty;
- function setPropertyState (aSelectedObj) {
- var obj = document.all.tbProperty;
- if (aSelectedObj.ctlType == CNST_CTLTYPE_JOINS) { //合并
- this.propertyState = new JoinsPropertyState(obj,aSelectedObj);
- } else if (aSelectedObj.ctlType == CNST_CTLTYPE_SPLITS ) { //分支
- this.propertyState = new SplitsPropertyState(obj,aSelectedObj);
- } else if (aSelectedObj.ctlType == CNST_CTLTYPE_STEPS) { //步骤
- this.propertyState = new StepsPropertyState(obj,aSelectedObj);
- } else if (aSelectedObj.ctlType == CNST_CTLTYPE_LINES) { //线条
- this.propertyState = new LinesPropertyState(obj,aSelectedObj);
- } else if (aSelectedObj.ctlType == CNST_CTLTYPE_INITIAL) { //启动
- this.propertyState = new InitialPropertyState(obj,aSelectedObj);
- }
- }
- function setProperty () {
- this.propertyState.setProperty();
- }
- }
- /*---end--属性环境角色--------*/