property.js
上传用户:yfdli66
上传日期:2010-02-20
资源大小:47k
文件大小:13k
源码类别:

JavaScript

开发平台:

JavaScript

  1. /*------------------------------------------------------------------------------
  2. +                        属性的显示                             +
  3. +                                                        +
  4. +                           +
  5. -------------------------------------------------------------------------------*/
  6. var pp_RightInputCss   =    "font:12;width:100%;"+
  7.      "height:100%;"+
  8.                                 "border:none;"+
  9.                                 "background-color: Transparent;";
  10. //改变属性
  11. function changeProperty(aObj) {
  12. if (aObj.isChanged==true) {
  13. aObj.isChanged = false //设为false
  14. var obj;
  15. if (aObj.fieldName=="name") {
  16. var obj = new ChangeNameSty(fSelectedObj);
  17. obj.inputValue = aObj.value;
  18. } else if (aObj.fieldName=="left") {
  19. var obj = new ChangeLeftSty(fSelectedObj);
  20. obj.canvasObj = document.all.drawCanvas;
  21. obj.inputValue = aObj.value;
  22. } else if (aObj.fieldName=="top") {
  23. var obj = new ChangeTopSty(fSelectedObj);
  24. obj.canvasObj = document.all.drawCanvas;
  25. obj.inputValue = aObj.value;
  26. } else if (aObj.fieldName=="view") {
  27. var obj = new ChangeViewSty(fSelectedObj);
  28. obj.inputValue = aObj.value;
  29. } else if (aObj.fieldName=="auto") {
  30. var obj = new ChangeAutoSty(fSelectedObj);
  31. obj.inputValue = aObj.options[aObj.selectedIndex].value;
  32. } else if (aObj.fieldName=="conditionType") {
  33. var obj = new ChangeConditionTypeSty(fSelectedObj);
  34. obj.inputValue = aObj.options[aObj.selectedIndex].value;
  35. } else if (aObj.fieldName=="owner") {
  36. var obj = new ChangeOwnerSty(fSelectedObj);
  37. obj.inputValue = aObj.value;
  38. } else if (aObj.fieldName=="status") {
  39. var obj = new ChangeStatusSty(fSelectedObj);
  40. obj.inputValue = aObj.options[aObj.selectedIndex].value;
  41. } else if (aObj.fieldName=="oldStatus") {
  42. var obj = new ChangeOldStatusSty(fSelectedObj);
  43. obj.inputValue = aObj.options[aObj.selectedIndex].value;
  44. } else {
  45. alert(aObj.ctlType +" 没有定义,无法改变属性");
  46. return;
  47. }
  48. changePropertyContext.setStrategy(obj);
  49. changePropertyContext.changeProperty(); //改变属性
  50. controlSubject.notifyObservers(); //通知所有的观察者
  51. }
  52. }
  53. //重置所有的行
  54. function resetAllTR(aTR) {
  55. //先重置所有的行
  56. var obj;
  57. for (var i=0;i<aTR.parentElement.rows.length;i++) {
  58. obj = aTR.parentElement.rows[i];
  59. obj.firstChild.firstChild.firstChild.firstChild.firstChild.style.backgroundColor = "#FFFFFF";
  60. obj.firstChild.firstChild.firstChild.firstChild.firstChild.style.color = "#000000";
  61. }
  62. }
  63. //选择行
  64. function selectThisTR(aTR) {
  65. //重置所有行
  66. resetAllTR(aTR);
  67. //设置左边
  68. aTR.cells[0].firstChild.firstChild.firstChild.firstChild.style.backgroundColor = "#0A246A";
  69. aTR.cells[0].firstChild.firstChild.firstChild.firstChild.style.color = "#FFFFFF";
  70. }
  71. function moreEdit (aObj,aUrl) {
  72. var feature="dialogHeight:300px;dialogWidth:500px;edge:Raised;center: Yes;help: no;resizable:yes;status: no;";
  73. window.showModalDialog(aUrl,"编辑",feature);
  74. }
  75. /*--------属性状态-----------*/
  76. //属性状态接口
  77. function PropertyState (aTableObj,aSObj) {
  78. //property
  79. this.tableObj = aTableObj; //属性table对象
  80. this.sObj = aSObj;         //当前所选控件
  81. //interface
  82. this.setProperty = setProperty;  //设置属性
  83. //method
  84. this.clearRows = clearRows;      //清空所有的行
  85. this.getRow = getRow;  //获得一行
  86. this.getEditRow = getEditRow; //编辑的行
  87. this.getComboBoxRow = getComboBoxRow; //选择的行
  88. this.getMoreRow = getMoreRow; //弹出的行
  89. function setProperty () {
  90. }
  91. function clearRows () {
  92. while(this.tableObj.rows.length>0){
  93. this.tableObj.deleteRow(0);
  94. }
  95. }
  96. function getRow (aType,aLable,aFieldName,aFieldValue,aCanEdit) {
  97. var str = "";
  98. str  =  str+"<tr onmousedown = 'selectThisTR(this)' ><td><table bgcolor='#FFFFFF'  width=100% border=0 cellspacing=0 cellpadding=0><tr>";
  99. str  =  str+"<td width=75 style='cursor:default'>"+aLable+"</td><td style='BORDER-LEFT: gray 1pt solid;cursor:default'>";
  100. //类别
  101. if (aType==1) {  //edit
  102. if (aCanEdit) {
  103. 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' >";
  104. } else {
  105.                  str  =  str+"<font color=gray>"+aFieldValue+"</font>";
  106. }
  107. } else if (aType==2) { //comboBox
  108. var theValue = aFieldValue.split(":")[0];
  109. var opAry = ( aFieldValue.split(":") )[1].split(";");
  110. str  =  str+"<span style='position:relative;top:0px'><select isChanged=false fieldName='"+aFieldName+"' onchange='this.isChanged=true;changeProperty(this)' style='margin:-2px;width:100%'>";
  111. for (var i=0;i<opAry.length;i++) {
  112. if (opAry[i]==theValue) {
  113. str  =  str+"<option selected value='"+opAry[i]+"'>"+opAry[i]+"</option>";
  114. } else {
  115. str  =  str+"<option value='"+opAry[i]+"'>"+opAry[i]+"</option>";
  116. }
  117. }//end for
  118. str  =  str+"</select></span>";
  119. } else if (aType==3) { //more
  120. str  =  str+"<span><font color=gray>[more]</font>&nbsp;&nbsp;&nbsp;&nbsp;<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>";
  121. }
  122. str  =  str+"</td></tr></table></td></tr>";
  123. return str;
  124. }
  125. //编辑的行
  126.         function getEditRow (aLable,aFieldName,aFieldValue,aCanEdit) {
  127. return this.getRow (1,aLable,aFieldName,aFieldValue,aCanEdit);
  128.         }
  129. //选择的行
  130.         function getComboBoxRow (aLable,aFieldName,aFieldValue,aSelectList,aCanEdit) {
  131. return this.getRow (2,aLable,aFieldName,aFieldValue+":"+aSelectList,aCanEdit);
  132.         }
  133. //弹出的行
  134.         function getMoreRow (aLable,aFieldName,aUrl) {
  135. return this.getRow (3,aLable,aFieldName,aUrl,true);
  136.         }
  137.         function getFlowRow (aCaption,aUrl) {
  138. return getRow(1,aCaption,aUrl,true,true);
  139.         }
  140. }
  141. //合并
  142. function JoinsPropertyState (aTableObj,aSObj) {
  143. //inhert
  144.      this.base=PropertyState;
  145.         this.base(aTableObj,aSObj);
  146. //override
  147. this.setProperty = setProperty;
  148. function setProperty () {
  149. this.clearRows(); //清空所有的行
  150. var str = this.tableObj.outerHTML.slice(0,-16);
  151. //id
  152.    str +=  this.getEditRow("id","id",this.sObj.id,false);
  153. //type
  154. str +=  this.getEditRow("type","type",this.sObj.ctlType,false);
  155. //left
  156. str +=  this.getEditRow("left","left",this.sObj.style.posLeft,true);
  157. //top
  158. str +=  this.getEditRow("top","top",this.sObj.style.posTop,true);
  159. //名称
  160. str +=  this.getEditRow("名称","name",this.sObj.lastChild.innerText,false);
  161. //条件类型
  162. str +=  this.getComboBoxRow("条件类型","conditionType",this.sObj.conditionType,"or;and",true);
  163. //条件
  164.         str +=  this.getMoreRow ("条件","aFieldName","workflow/flow_condition.jsp");
  165. str +="</tbody></table>";
  166. this.tableObj.outerHTML=str;
  167. }
  168. }
  169. //分支
  170. function SplitsPropertyState (aTableObj,aSObj) {
  171. //inhert
  172.      this.base=PropertyState;
  173.         this.base(aTableObj,aSObj);
  174. //override
  175. this.setProperty = setProperty;
  176. function setProperty () {
  177. this.clearRows(); //清空所有的行
  178. var str = this.tableObj.outerHTML.slice(0,-16);
  179. //id
  180.    str +=  this.getEditRow("id","id",this.sObj.id,false);
  181. //type
  182. str +=  this.getEditRow("type","type",this.sObj.ctlType,false);
  183. //left
  184. str +=  this.getEditRow("left","left",this.sObj.style.posLeft,true);
  185. //top
  186. str +=  this.getEditRow("top","top",this.sObj.style.posTop,true);
  187. //name
  188. str +=  this.getEditRow("名称","name",this.sObj.lastChild.innerText,false);
  189. //结果
  190.         str +=  this.getMoreRow ("结果","aFieldName","workflow/flow_result.jsp");
  191. str +="</tbody></table>";
  192. this.tableObj.outerHTML=str;
  193. }
  194. }
  195. //启动
  196. function InitialPropertyState (aTableObj,aSObj) {
  197. //inhert
  198.      this.base=PropertyState;
  199.         this.base(aTableObj,aSObj);
  200. //override
  201. this.setProperty = setProperty;
  202. function setProperty () {
  203. this.clearRows(); //清空所有的行
  204. var str = this.tableObj.outerHTML.slice(0,-16);
  205. //id
  206.    str +=  this.getEditRow("id","id",this.sObj.id,false);
  207. //type
  208. str +=  this.getEditRow("type","type",this.sObj.ctlType,false);
  209. //left
  210. str +=  this.getEditRow("left","left",this.sObj.style.posLeft,true);
  211. //top
  212. str +=  this.getEditRow("top","top",this.sObj.style.posTop,true);
  213. //名称
  214. str +=  this.getEditRow("名称","name",this.sObj.lastChild.innerText,true);
  215. //试图
  216. str +=  this.getEditRow("视图","view",this.sObj.view,true);
  217. //权限
  218.         str +=  this.getMoreRow ("权限","aFieldName","workflow/flow_role.jsp");
  219. //预处理
  220.         str +=  this.getMoreRow ("预处理","aFieldName","workflow/flow_prv.jsp");
  221. //后处理
  222.         str +=  this.getMoreRow ("后处理","aFieldName","workflow/flow_next.jsp");
  223. str +="</tbody></table>";
  224. this.tableObj.outerHTML=str;
  225. }
  226. }
  227. //步骤
  228. function StepsPropertyState (aTableObj,aSObj) {
  229. //inhert
  230.      this.base=PropertyState;
  231.         this.base(aTableObj,aSObj);
  232. //override
  233. this.setProperty = setProperty;
  234. function setProperty () {
  235. this.clearRows(); //清空所有的行
  236. var str = this.tableObj.outerHTML.slice(0,-16);
  237. //id
  238.    str +=  this.getEditRow("id","id",this.sObj.id,false);
  239. //type
  240. str +=  this.getEditRow("type","type",this.sObj.ctlType,false);
  241. //left
  242. str +=  this.getEditRow("left","left",this.sObj.style.posLeft,true);
  243. //top
  244. str +=  this.getEditRow("top","top",this.sObj.style.posTop,true);
  245. //名称
  246. str +=  this.getEditRow("名称","name",this.sObj.lastChild.innerText,true);
  247. //试图
  248. str +=  this.getEditRow("视图","view",this.sObj.view,true);
  249. //自动
  250. str +=  this.getComboBoxRow("自动","auto",this.sObj.auto,"yes;no",true);
  251. //权限
  252.         str +=  this.getMoreRow ("权限","aFieldName","workflow/flow_role.jsp");
  253. //预处理
  254.         str +=  this.getMoreRow ("预处理","aFieldName","workflow/flow_prv.jsp");
  255. //后处理
  256.         str +=  this.getMoreRow ("后处理","aFieldName","workflow/flow_next.jsp");
  257. str +="</tbody></table>";
  258. this.tableObj.outerHTML=str;
  259. }
  260. }
  261. //线条
  262. function LinesPropertyState (aTableObj,aSObj) {
  263. //inhert
  264.      this.base=PropertyState;
  265.         this.base(aTableObj,aSObj);
  266. //override
  267. this.setProperty = setProperty;
  268. function setProperty () {
  269. this.clearRows(); //清空所有的行
  270. var str = this.tableObj.outerHTML.slice(0,-16);
  271. //id
  272.    str +=  this.getEditRow("id","id",this.sObj.id,false);
  273. //type
  274. str +=  this.getEditRow("type","type",this.sObj.ctlType,false);
  275. //owner
  276. str +=  this.getEditRow("所有者","owner",this.sObj.owner,true);
  277. //下步启动状态
  278. str +=  this.getComboBoxRow("下步启动状态","status",this.sObj.status,"Queued;Underway;Finished",true);
  279. //本步结束状态
  280. str +=  this.getComboBoxRow("本步结束状态","oldStatus",this.sObj.oldStatus,"Queued;Underway;Finished",true);
  281. //预处理
  282.         str +=  this.getMoreRow ("预处理","aFieldName","workflow/flow_prv.jsp");
  283. //后处理
  284.         str +=  this.getMoreRow ("后处理","aFieldName","workflow/flow_next.jsp");
  285. //条件
  286.         str +=  this.getMoreRow ("条件","aFieldName","workflow/flow_condition.jsp");
  287. str +="</tbody></table>";
  288. this.tableObj.outerHTML=str;
  289. }
  290. }
  291. /*-----------end-属性状态--------*/
  292. /*-----------属性环境角色--------*/
  293. function PropertyContext () {
  294. //property
  295. this.propertyState = new StepsPropertyState(); //默认为开始状态
  296. //method
  297. this.setPropertyState = setPropertyState;
  298. this.setProperty = setProperty;
  299. function setPropertyState (aSelectedObj) {
  300. var obj = document.all.tbProperty;
  301. if (aSelectedObj.ctlType == CNST_CTLTYPE_JOINS) {  //合并
  302. this.propertyState = new JoinsPropertyState(obj,aSelectedObj);
  303. } else if (aSelectedObj.ctlType == CNST_CTLTYPE_SPLITS ) { //分支
  304. this.propertyState = new SplitsPropertyState(obj,aSelectedObj);
  305. } else if (aSelectedObj.ctlType == CNST_CTLTYPE_STEPS) { //步骤
  306. this.propertyState = new StepsPropertyState(obj,aSelectedObj);
  307. } else if  (aSelectedObj.ctlType == CNST_CTLTYPE_LINES) {    //线条
  308. this.propertyState = new LinesPropertyState(obj,aSelectedObj);
  309. } else if  (aSelectedObj.ctlType == CNST_CTLTYPE_INITIAL) {    //启动
  310. this.propertyState = new InitialPropertyState(obj,aSelectedObj);
  311. }
  312. }
  313. function setProperty () {
  314.     this.propertyState.setProperty();
  315. }
  316. }
  317. /*---end--属性环境角色--------*/