Revision | 4857 (tree) |
---|---|
Time | 2011-03-29 17:26:42 |
Author | nakajima_zeta |
gv_trap test
@@ -41,7 +41,11 @@ | ||
41 | 41 | co_GtGVItemContentsExchanger.prototype.addTransaction = function(transactionInfo){ |
42 | 42 | this.i_transactionInfoArray.push(transactionInfo); |
43 | 43 | } |
44 | +co_GtGVItemContentsExchanger.prototype.hasTransaction = function(){ | |
45 | + return this.i_transactionInfoArray && this.i_transactionInfoArray.length > 0; | |
46 | +} | |
44 | 47 | |
48 | + | |
45 | 49 | co_GtGVItemContentsExchanger.prototype.i_runTransaction = function(){ |
46 | 50 | var info = this.i_transactionInfoArray.shift(); |
47 | 51 | this.cmd = info.cmd; |
@@ -122,7 +126,9 @@ | ||
122 | 126 | var p = this.propCacheEntry; |
123 | 127 | d_p("ACT_GET_ITEM_CONTENTS property=" + p.property); |
124 | 128 | // p.gvthis.gvGet(p.property, this); |
125 | - p.gvobj.gvGet("", this); | |
129 | +// p.gvobj.gvGet("", this); | |
130 | +// p.gvobj.gvGet(".gv_trap", p, p.onGvTrap); | |
131 | + p.gvobj.gvGet(".gv_trap", this); | |
126 | 132 | return "ACT_WAIT_GET_GV_ITEM_CONTENTS"; |
127 | 133 | }, |
128 | 134 |
@@ -175,6 +181,7 @@ | ||
175 | 181 | ACT_START_DC : function(event) { |
176 | 182 | var p = this.propCacheEntry; |
177 | 183 | // p.gvthis.gvSet(p.property+"[0][0]", p.data[0][0], this); |
184 | + p.status = "OVERWRITE"; | |
178 | 185 | var gvSetRet = p.gvthis.gvSet(p.property, p.data, this); |
179 | 186 | d_p("gvSetRet = " + gvSetRet); |
180 | 187 |
@@ -186,7 +193,11 @@ | ||
186 | 193 | d_assert(event.type); |
187 | 194 | return null; |
188 | 195 | } |
189 | - d_p("ACT_WAIT_GVSET_COMPLETE called."); | |
196 | + | |
197 | + var p = this.propCacheEntry; | |
198 | + p.status = "COMPLETE"; | |
199 | + | |
200 | + d_p("ACT_WAIT_GVSET_COMPLETE called. return to ACT_START"); | |
190 | 201 | return "doACT_START"; |
191 | 202 | }, |
192 | 203 |
@@ -48,9 +48,7 @@ | ||
48 | 48 | GtGVItemContentsExchanger.prototype.i_gtPane = null; |
49 | 49 | |
50 | 50 | // dom node attributes. |
51 | -GtGVItemContentsExchanger.prototype.i_getGtAction = function(){ | |
52 | - return this.i_gtPane.getAttribute("gtAction"); | |
53 | -} | |
51 | + | |
54 | 52 | GtGVItemContentsExchanger.prototype.i_getGtOperation = function(){ |
55 | 53 | return this.i_gtPane.getAttribute("gtOperation"); |
56 | 54 | } |
@@ -149,6 +147,9 @@ | ||
149 | 147 | } |
150 | 148 | } |
151 | 149 | else{ |
150 | + debugger; | |
151 | + var gvObject = this.i_getGvObjectByName(gvObjName); | |
152 | + | |
152 | 153 | d_assert("gvObject was not found. gvObjName="+gvObjName+" gtFieldType="+gtFieldType+" pane="+this.i_gtPane); |
153 | 154 | } |
154 | 155 |
@@ -158,7 +159,6 @@ | ||
158 | 159 | cacheEntry.property = gvProperty; |
159 | 160 | cacheEntry.gvObjectName = gvObjName; |
160 | 161 | cacheEntry.i_coObject = new co_GtGVItemContentsExchanger(this, "getItemContents", absoluteProperty); |
161 | - | |
162 | 162 | this.i_propertyCache[absoluteProperty] = cacheEntry; |
163 | 163 | |
164 | 164 | return GtItem.singleToContents(new GtItem()); |
@@ -413,13 +413,32 @@ | ||
413 | 413 | var cacheEntry = this.i_propertyCache[absoluteProperty]; |
414 | 414 | |
415 | 415 | if(!cacheEntry){ |
416 | - d_assert("cachEntry was not found absoluteProperty="+absoluteProperty); | |
417 | - return "ERR_START"; | |
416 | + if( | |
417 | + ( | |
418 | + (gvProperty.lastIndexOf(".ACCEPT") == gvProperty.length - ".ACCEPT".length) || | |
419 | + (gvProperty.lastIndexOf(".CANCEL") == gvProperty.length - ".CANCEL".length) | |
420 | + ) | |
421 | + ){ | |
422 | + cacheEntry = new GtGVItemCacheEntry(); | |
423 | + cacheEntry.status = "OVERWRITE"; | |
424 | + cacheEntry.gvthis = gvObject; | |
425 | + cacheEntry.property = gvProperty; | |
426 | + cacheEntry.gvObjectName = gvObjName; | |
427 | + cacheEntry.i_coObject = new co_GtGVItemContentsExchanger(this, "dataChange", absoluteProperty); | |
428 | + var acceptGtItem = new GtItem(); | |
429 | + acceptGtItem.selected = true; | |
430 | + cacheEntry.data = [[acceptGtItem]]; | |
431 | + | |
432 | + this.i_propertyCache[absoluteProperty] = cacheEntry; | |
433 | + } | |
434 | + else{ | |
435 | + d_assert("cacheEntry was not found absoluteProperty="+absoluteProperty); | |
436 | + return; | |
437 | + } | |
418 | 438 | } |
419 | 439 | |
420 | 440 | var isStartNewTransaction = false; |
421 | 441 | |
422 | - | |
423 | 442 | if (cacheEntry.status == "LOADING") { |
424 | 443 | if( (tblIndex===0||tblIndex) && (fieldIndex===0||fieldIndex) ){ |
425 | 444 | cacheEntry.data[tblIndex][fieldIndex] = changedData; |
@@ -470,6 +489,14 @@ | ||
470 | 489 | } |
471 | 490 | } |
472 | 491 | |
492 | +GtGVItemContentsExchanger.prototype.i_initGtAction = function(){ | |
493 | + var gtActionString = this.i_gtPane.getAttribute("gtAction"); | |
494 | + if(gtActionString){ | |
495 | + this.i_gtAction = JSON.parse("{"+ gtActionString + "}"); | |
496 | + } | |
497 | +} | |
498 | + | |
499 | + | |
473 | 500 | GtGVItemContentsExchanger.prototype.transitionFunctions = { |
474 | 501 | INI_START: function(event) { |
475 | 502 | var initOpe = this.i_getGtInitOperation(); |
@@ -476,6 +503,9 @@ | ||
476 | 503 | if(!gtutils.isEmpty(initOpe)){ |
477 | 504 | this.i_evalInitOperation(initOpe); |
478 | 505 | } |
506 | + | |
507 | + this.i_initGtAction(); | |
508 | + | |
479 | 509 | if(this.i_isOperationCompleted()){ |
480 | 510 | return "doINI_EVAL_OPERATION"; |
481 | 511 | } |
@@ -503,13 +533,45 @@ | ||
503 | 533 | dataChange : function(event) { |
504 | 534 | var ft = event.source.getAttribute("gtFieldType"); |
505 | 535 | d_assert( (ft!="") || ("event source has not gtFieldType attribute " + event.source)); |
506 | - switch(ft){ | |
507 | - case "GT:ACCEPT": | |
508 | - return "doACT_ACCEPT"; | |
509 | - case "GT:CANCEL": | |
510 | - return "doACT_CANCEL"; | |
536 | + | |
537 | + if(this.i_gtAction){ | |
538 | + var through = ("through" in this.i_gtAction) && this.i_gtAction.through; | |
539 | + | |
540 | + if(ft in this.i_gtAction){ | |
541 | + var statement = this.i_gtAction[ft]; | |
542 | + var action = statement[0]; | |
543 | + this.i_destroyAfterAcceptFlag = statement[1]; | |
544 | + var gtFieldTypes = statement[2]; | |
545 | + if(typeof gtFieldTypes == "string"){ | |
546 | + gtFieldTypes = [gtFieldTypes]; | |
547 | + } | |
548 | + | |
549 | + switch(action){ | |
550 | + case "accept": | |
551 | + this.i_acceptTargetFieldTypes = gtFieldTypes; | |
552 | + return "doACT_ACCEPT"; | |
553 | + case "cancel": | |
554 | + this.i_acceptTargetFieldTypes = gtFieldTypes; | |
555 | + return "doACT_CANCEL"; | |
556 | + | |
557 | + /* | |
558 | + var cancelGtItem = new GtItem(); | |
559 | + cancelGtItem.selected = true; | |
560 | + for(var i=0; i<gtFieldTypes.length; ++i){ | |
561 | + this.i_tellDataChangeToGv(gtFieldTypes[i], cancelGtItem, 0, 0); | |
562 | + } | |
563 | + */ | |
564 | + } | |
565 | + | |
566 | + } | |
567 | + else if(through){ | |
568 | + this.i_tellDataChangeToGv(ft, event.param.target, event.param.tblIndex, event.param.fieldIndex); | |
569 | + } | |
511 | 570 | } |
512 | - this.i_tellDataChangeToGv(ft, event.param.target, event.param.tblIndex, event.param.fieldIndex); | |
571 | + else{ | |
572 | + this.i_tellDataChangeToGv(ft, event.param.target, event.param.tblIndex, event.param.fieldIndex); | |
573 | + } | |
574 | + | |
513 | 575 | return "ACT_START"; |
514 | 576 | }, |
515 | 577 | destroy: function(event) { |
@@ -544,18 +606,31 @@ | ||
544 | 606 | d_assert( (ftString!="") || ("gtFieldType is invalid attachedGtObj="+attachedGtObj) ); |
545 | 607 | if(ftString.indexOf("GV:") == 0){ |
546 | 608 | this.i_tellDataChangeToGv(ftString, items); |
609 | + attachedGtObj.setDirty(false); | |
547 | 610 | } |
548 | 611 | } |
549 | 612 | } |
613 | + | |
614 | + var acceptGtItem = new GtItem(); | |
615 | + acceptGtItem.selected = true; | |
616 | + for(var i=0; i<this.i_acceptTargetFieldTypes.length; ++i){ | |
617 | + this.i_tellDataChangeToGv(this.i_acceptTargetFieldTypes[i], acceptGtItem, 0, 0); | |
618 | + } | |
619 | + | |
550 | 620 | return "ACT_WAIT_ALL_DATA_CHANGE_COMPLETED"; |
551 | 621 | }, |
552 | 622 | |
553 | 623 | ACT_WAIT_ALL_DATA_CHANGE_COMPLETED : function(event){ |
624 | + d_p("enter ACT_WAIT_ALL_DATA_CHANGE_COMPLETED."); | |
554 | 625 | for(var it in this.i_propertyCache){ |
555 | 626 | var cacheEntry = this.i_propertyCache[it]; |
627 | + // d_p("i_propertyCache it="+it+" cacheEntry.status="+cacheEntry.status); | |
556 | 628 | if(cacheEntry.status == "OVERWRITE"){ |
557 | 629 | return null; |
558 | 630 | } |
631 | + if(cacheEntry.i_coObject && cacheEntry.i_coObject.hasTransaction()){ | |
632 | + return null; | |
633 | + } | |
559 | 634 | } |
560 | 635 | var param = { |
561 | 636 | subtype : "ok", |
@@ -562,17 +637,22 @@ | ||
562 | 637 | value : null |
563 | 638 | }; |
564 | 639 | this.i_gtPane.notice(GtEvent.create("acceptResult", this, param)); |
640 | + d_p("ALL_DATA_CHANGE_COMPLETED. return to ACT_START"); | |
641 | + if(("i_destroyAfterAcceptFlag" in this) && this.i_destroyAfterAcceptFlag){ | |
642 | + this.gtWindow.destroy(); | |
643 | + return "ACT_START"; | |
644 | + } | |
565 | 645 | return "ACT_START"; |
566 | 646 | }, |
567 | 647 | |
568 | 648 | ACT_CANCEL : function(event){ |
569 | 649 | d_p("GtGVItemContentsExchanger ACT_CANCEL called."); |
570 | - var param = { | |
571 | - subtype : "ok", | |
572 | - value : null | |
573 | - } | |
574 | - event.source.notice(GtEvent.create("acceptResult", this, param)); | |
575 | - return "ACT_START"; | |
650 | + var acceptGtItem = new GtItem(); | |
651 | + acceptGtItem.selected = true; | |
652 | + for(var i=0; i<this.i_acceptTargetFieldTypes.length; ++i){ | |
653 | + this.i_tellDataChangeToGv(this.i_acceptTargetFieldTypes[i], acceptGtItem, 0, 0); | |
654 | + } | |
655 | + return "ACT_WAIT_ALL_DATA_CHANGE_COMPLETED"; | |
576 | 656 | }, |
577 | 657 | |
578 | 658 | FIN_START: function(event) { |
@@ -22,3 +22,14 @@ | ||
22 | 22 | GtGVItemCacheEntry.prototype.gv_recl = false; |
23 | 23 | GtGVItemCacheEntry.prototype.data = null; // GtItem or 2DArray of GtItem |
24 | 24 | GtGVItemCacheEntry.prototype.co_dataChange = false; // flag of property changed by dataChange event. |
25 | +GtGVItemCacheEntry.prototype.i_coObject = null; | |
26 | + | |
27 | +/* | |
28 | +GtGVItemCacheEntry.prototype.onGvTrap = function(e){ | |
29 | + d_p("###### GtGVItemCacheEntry.prototype.onGvTrap called."); | |
30 | + | |
31 | + if(this.i_coObject){ | |
32 | + this.i_coObject.notice(e); | |
33 | + } | |
34 | +} | |
35 | +*/ | |
\ No newline at end of file |